-
大小: 32KB文件類型: .zip金幣: 2下載: 0 次發(fā)布日期: 2021-06-05
- 語(yǔ)言: Matlab
- 標(biāo)簽: matlab??紅外目標(biāo)??目標(biāo)跟蹤??
資源簡(jiǎn)介
matlab版本的紅外目標(biāo)跟蹤的代碼,供大家參考查閱,有一定的價(jià)值

代碼片段和文件信息
%Meanshift?Function:
%Created?a?simple?convergence?algorithm?which?looks?in?windows?of?varying
%sizes.?This?function?is?called?by?wrapper?programs?such?as?single
%track.This?algorithm?identifies?the?first?window?that?is?stable.
function?[s_win?x_c?y_c]?=?camshift(I_curr?s_win)
%Constant?Parameters:
T?=?.5;???????????????%?Threshold?of?convergence?(in?pixels)
del?=?T;?????????????%Pixel?delta?defaults?at?T
max_iterations?=?200;
%Input?the?initial?search?window?(location?and?size)
ix?=?s_win(1);??????%Initial?x?location
iy?=?s_win(2);??????%Initial?y?location
sx?=?s_win(3);??????%Search?window?size?in?x
sy?=?s_win(4);??????%Search?window?size?in?y
for?x_f?=?.5:.1:1.5
for?y_f?=?.5:.1:1.5
????x_c?=?round(ix?+?sx/2);?
????y_c?=?round(iy?+?sy/2);
????iterations?=?0;
????%While?the?solution?is?still?converging?as?long?as?we?haven‘t?been
????%searching?for?too?many?iterations
????while?(iterations?=?T)
????????
????????%Save?the?previous?ix?and?iy:
x_p?=?x_c;
????????y_p?=?y_c;
????????
????????%?Compute?centroid?of?search?window
????????x_min?=?round(x_c?-?x_f?*?sx);?
????????x_max?=?round(x_c?+?x_f?*?sx);
????????y_min?=?round(y_c?-?y_f?*?sy);
????????y_max?=?round(y_c?+?y_f?*?sy);
????????
TS?=?double(0);
for?i?=?x_min:x_max
????????????for?j?=?y_min:y_max
????????????????if?i??1&&?j?>??1
????????????????????%Calculate?the?sum?over?the?area:
????????????????????TS?=?TS?+?double(I_curr(ji));
????????????????end
????????????end
end
I_x?=?double(0);
for?i?=?x_min:x_max
????????????for?j?=?y_min:y_max
????????????????if?i??1&&?j?>??1
????????????????????%Calculate?the?weighted?value:
????????????????????I_x?=?I_x?+?i?*?double(I_curr(ji));
????????????????end
????????????end
end
????????I_y?=?double(0);
????????for?i?=?x_min:x_max
????????????for?j?=?y_min:y_max
????????????????if?i??1&&?j?>??1
????????????????????%Calculate?the?weighted?value:
????????????????????I_y?=?I_y?+?j?*?double(I_curr(ji));
????????????????end
????????????end
????????end
????????%Find?the?centroid:
x_c?=?round(I_x/TS);
y_c?=?round(I_y/TS);
????????
???????
????????%Calculate?Current?Error
????????del?=?abs(x_p-x_c)?+?abs(y_p-y_c);
????????iterations?=?iterations?+?1;
????end
????
????if?del?<=?T
????????break;
????end
????????
end
????if?del?<=?T
????????break;
????end
end
sx?=?min(max(round(x_f?*?sx)1)size(I_curr2));
sy?=?min(max(round(y_f?*?sy)1)size(I_curr1));
ix?=?min(max(round(x_c?-?x_f?*?sx/2)1)size(I_curr2));
iy?=?min(max(round(y_c?-?y_f?*?sy/2)1)size(I_curr1));
%Set?return?varaibles?for?new?window?location
s_win(1)?=?ix;??????%Initial?x?location
s_win(2)?=?iy;??????%Initial?y?location
s_win(3)?=?sx;??????%Search?window?size?in?x
s_win(4)?=?sy;??????%Search?window?size?in?y
end
????
????
???????
????
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-03-02?18:43??ob
?????文件????????2098??2015-03-02?18:43??ob
?????文件????????2002??2015-03-02?18:43??ob
?????文件????????1465??2015-03-02?18:43??ob
?????文件???????21980??2015-03-02?18:43??ob
?????文件???????19518??2015-03-02?18:43??ob
?????文件?????????832??2015-03-02?18:43??ob
?????文件????????4049??2015-03-02?18:43??ob
?????文件????????4078??2015-03-02?18:43??ob
?????文件???????18485??2015-03-02?18:43??ob
?????文件???????18541??2015-03-02?18:43??ob
?????文件????????3738??2015-03-02?18:43??ob
?????文件????????2932??2015-03-02?18:43??ob
?????文件????????3113??2015-03-02?18:43??ob
?????文件?????????810??2015-03-02?18:43??ob
- 上一篇:matlab的copula相關(guān)程序
- 下一篇:prony算法的具體步驟
評(píng)論
共有 條評(píng)論