-
大小: 248KB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2021-06-12
- 語言: Matlab
- 標(biāo)簽: matlab??運(yùn)動(dòng)??源碼??論文??
資源簡(jiǎn)介
matlab運(yùn)動(dòng)估計(jì)代碼.里面有源圖像和運(yùn)行結(jié)果.對(duì)寫論文應(yīng)該有幫助

代碼片段和文件信息
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%??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?%%
img1?=?im2double?(imread?(file1));
%%?Take?alternating?rows?and?columns?%%
[odd1?even1]?=?split?(img1);
img2?=?im2double?(imread?(file2));
[odd2?even2]?=?split?(img2);
%%?Run?Lucas?Kanade?%%
[Dx?Dy]?=?Estimate?(odd1?odd2);
%%?Plot?%%
figure;?
[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);
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?Kanade?on?the?image?sequence?at?pyramid?step?%%
function?[Vx?Vy]?=?EstimateMotion?(W?G1?half_window_size)
[m?n]?=?size?(W);
Vx?=?zeros?(size?(W));?Vy?=?zeros?(size?(W));
N?=?zeros?(2*half_window_size+1?5);
for?i?=?1:m
????l?=?0;
????for?j?=?1-half_window_size:1+half_window_size
????????l?=?l?+?1;
????????N?(l:)?=?getSlice?(W?G1?i?j?half_window_size);
????end
?
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄??????????0??2006-10-05?17:57??lk
?????文件??????64078??2003-04-08?18:03??lk\1.bmp
?????文件??????64078??2003-04-08?18:03??lk\2.bmp
?????文件??????21958??2003-04-07?14:03??lk\3.bmp
?????文件??????21958??2003-04-07?14:03??lk\4.bmp
?????文件?????169984??2004-04-18?03:57??lk\Lucas.doc
?????文件???????6932??2004-04-18?03:07??lk\Lucas_Kanade.m
?????文件????????298??2004-04-18?04:01??lk\tests.m
????..A.SH.?????20480??2006-10-05?18:07??lk\Thumbs.db
-----------?---------??----------?-----??----
???????????????369984????????????????????10
評(píng)論
共有 條評(píng)論