资源简介
L-K金字塔光流法matlab代码实现,参考1981年An iterative image registration technique with an application to stereo vision文章
代码片段和文件信息
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Name: Musawir Ali Shah
%%% Assignment #3
%%% Project title: Lucas Kanade Motion Estimation Using Pyramids (Level 4)
%%% Note: The project specification says use density of 10 in plotting
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Usage: Lucas_Kanade(‘1.bmp‘‘2.bmp‘10)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Lucas_Kanade(file1file2density);
%% Read Images %%
im11=imread (file1);
if size(size(im11)2)==3
im1=rgb2gray(im11);
end
img1 = im2double (im1);
%% Take alternating rows and columns %%
%[odd1 even1] = split (img1);
im22=imread (file2);
if size(size(im22)2)==3
im2=rgb2gray(im22);
end
img2 = im2double(im2);
%[odd2 even2] = split (img2);
%% Run Lucas Kanade %%
%[Dx Dy] = Estimate (odd1 odd2);
[Dx Dy] = Estimate (img1 img2);
%% Plot %%
figure;
imshow(imread(file1));
hold on;
[maxImaxJ]=size(Dx);
Dx=Dx(1:density:maxI1:density:maxJ);
Dy=Dy(1:density:maxI1:density:maxJ);
quiver(1:density:maxJ(maxI):(-density):1Dx-Dy1);
hold on;
[maxImaxJ]=size(Dx1);
Dx1=Dx1(1:density:maxI1:density:maxJ);
Dy1=Dy1(1:density:maxI1:density:maxJ);
quiver(1:density:maxJ(maxI):(-density):1Dx1-Dy11);
axis square;
%% Run Lucas Kanade on all levels and interpolate %%
function [Dx Dy] = Estimate (img1 img2)
level = 4;
half_window_size=2;
[m n] = size (img1);
G00 = img1; G10 = img2;
if (level>0)
G01 = reduce (G00); G11 = reduce (G10);
end
if (level>1)
G02 = reduce (G01); G12 = reduce (G11);
end
if (level>2)
G03 = reduce (G02); G13 = reduce (G12);
end
if (level>3)
G04 = reduce (G03); G14 = reduce (G13);
end
l = level;
for i=level:-1:0
if (l == level)
switch (l)
case 4 Dx = zeros (size (G04)); Dy = zeros (size (G04));
case 3 Dx = zeros (size (G03)); Dy = zeros (size (G03));
case 2 Dx = zeros (size (G02)); Dy = zeros (size (G02));
case 1 Dx = zeros (size (G01)); Dy = zeros (size (G01));
case 0 Dx = zeros (size (G00)); Dy = zeros (size (G00));
end
else
Dx = expand (Dx); Dy = expand (Dy);
Dx = Dx .* 2; Dy = Dy .* 2;
end
switch (l)
case 4
W = warp (G04 Dx Dy);
[Vx Vy] = EstimateMotion (W G14 half_window_size);
case 3
W = warp (G03 Dx Dy);
[Vx Vy] = EstimateMotion (W G13 half_window_size);
case 2
W = warp (G02 Dx Dy);
[Vx Vy] = EstimateMotion (W G12 half_window_size);
case 1
W = warp (G01 Dx Dy);
[Vx Vy] = EstimateMotion (W G11 half_window_size);
case 0
W = warp (G00 Dx Dy);
[Vx Vy] = EstimateMotion (W G10 half_window_size);
end
[m n] = size (W);
Dx(1:m 1:n) = Dx(1:m1:n) + Vx; Dy(1:m 1:n) = Dy(1:m 1:n) + Vy;
smooth (Dx); smooth (Dy);
l = l - 1;
end
%% Lucas Kanad
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-02-25 22:14 Lucas_Kanade\
文件 64078 2003-04-08 18:03 Lucas_Kanade\1.bmp
文件 81110 2009-04-09 13:04 Lucas_Kanade\11.bmp
文件 64078 2003-04-08 18:03 Lucas_Kanade\2.bmp
文件 82302 2009-04-09 13:04 Lucas_Kanade\22.bmp
文件 21958 2003-04-07 14:03 Lucas_Kanade\3.bmp
文件 21958 2003-04-07 14:03 Lucas_Kanade\4.bmp
文件 82302 2009-04-09 14:07 Lucas_Kanade\a.bmp
文件 82302 2009-04-09 14:08 Lucas_Kanade\b.bmp
文件 132186 2019-02-25 20:46 Lucas_Kanade\fr
文件 403108 2007-07-28 03:16 Lucas_Kanade\fr
文件 128038 2019-02-25 20:46 Lucas_Kanade\fr
文件 402536 2007-07-28 03:16 Lucas_Kanade\fr
文件 169984 2004-04-18 03:57 Lucas_Kanade\Lucas.doc
文件 7312 2019-02-25 22:35 Lucas_Kanade\Lucas_Kanade.m
文件 310 2019-02-25 22:06 Lucas_Kanade\tests.m
文件 31 2012-03-15 16:52 Lucas_Kanade\Unti
相关资源
- MATLAB s函数最详细指南编写教程24998
- 几乎包含IEEE所有节点的牛拉潮流计算
- 目标检测的DPM模型在windows下的实现
- 发动机万有特性曲线matlab源程序
- matlab实现VQ说话人识别系统.zip
- pbm/pgm/ppm图片的读写Matlab
- 基于MATLAB数字图像处理的实现和仿真
-
matlab simuli
nk simevent 建模入门 - 数字图像处理实验报告北科大 matlab
- Matlab帧内/帧间预测
- 基于Matlab和FPGA的FIR数字滤波器设计及
- Matlab_R2009a_V7.8.0汉化包
- 基于HMM的姿势识别 matlab代码
- matlab r2013b crack
- matlab学习手册
- 西交大模式识别编程大作业报告+MAT
- 基于MATLAB的波场模拟
- 遥感数字图像处理内含Matlab)代码
- 超像素分割matlab代码
- Matlab有限元分析与应用(电子书以及
- 最优化方法及其Matlab程序设计(可复
- Bursa_Wolf,布尔莎坐标转换matlab
- g.726 源代码 matlab
- MATLAB与机器学习
- 波束赋形——matlab程序
- 随机信号处理功率谱估计MATLAB程序及
- 支持向量机的matlab实现及相应Demo
- RGB 、YUV、YIQ 和 YCrCb颜色空间转换的
- 离散点云三维重建matlab程序
- 纹理图像分割Matlab源代码 PDF PPT
评论
共有 条评论