91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 11.03MB
    文件類型: .zip
    金幣: 1
    下載: 0 次
    發布日期: 2023-07-09
  • 語言: Matlab
  • 標簽: Meanshift??matlab??

資源簡介

基于meanshift的單目標跟蹤算法實現 說明: 1. RGB顏色空間刨分,采用16*16*16的直方圖 2. 目標模型和候選模型的概率密度計算公式參照上文 3. opencv版本運行:按P停止,截取目標,再按P,進行單目標跟蹤 4. Matlab版本,將視頻改為圖片序列,第一幀停止,手工標定目標,雙擊目標區域,進行單目標跟蹤。 博客地址:http://blog.csdn.net/jinshen

資源截圖

代碼片段和文件信息

%配套論文《基于MeanShift算法的目標跟蹤算法研究》?P28-29
function?[]?=?select()
close?all;
clear?all;
%%%%%%%%%%%%%%%%%%根據一幅目標全可見的圖像圈定跟蹤目標%%%%%%%%%%%%%%%%%%%%%%%
I=imread(‘result72.jpg‘);
figure(1);
imshow(I);


[temprect]=imcrop(I);
[abc]=size(temp);? %a:rowb:col


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%計算目標圖像的權值矩陣%%%%%%%%%%%%%%%%%%%%%%%
y(1)=a/2;
y(2)=b/2;
tic_x=rect(1)+rect(3)/2;
tic_y=rect(2)+rect(4)/2;
m_wei=zeros(ab);%權值矩陣
h=y(1)^2+y(2)^2?;%帶寬


for?i=1:a
????for?j=1:b
????????dist=(i-y(1))^2+(j-y(2))^2;
????????m_wei(ij)=1-dist/h;?%epanechnikov?profile
????end
end
C=1/sum(sum(m_wei));%歸一化系數


%計算目標權值直方圖qu
%hist1=C*wei_hist(tempm_weiab);%target?model
hist1=zeros(14096);
for?i=1:a
????for?j=1:b
????????%rgb顏色空間量化為16*16*16?bins
????????q_r=fix(double(temp(ij1))/16);??%fix為趨近0取整函數
????????q_g=fix(double(temp(ij2))/16);
????????q_b=fix(double(temp(ij3))/16);
????????q_temp=q_r*256+q_g*16+q_b;????????????%設置每個像素點紅色、綠色、藍色分量所占比重
????????hist1(q_temp+1)=?hist1(q_temp+1)+m_wei(ij);????%計算直方圖統計中每個像素點占的權重
????end
end
hist1=hist1*C;
rect(3)=ceil(rect(3));
rect(4)=ceil(rect(4));




%%%%%%%%%%%%%%%%%%%%%%%%%讀取序列圖像
myfile=dir(‘D:\matlab7\work\mean?shift\image\*.jpg‘);
lengthfile=length(myfile);


for?l=1:lengthfile
????Im=imread(myfile(l).name);
????num=0;
????Y=[22];
????
????
????%%%%%%%mean?shift迭代
????while((Y(1)^2+Y(2)^2>0.5)&num<20)???%迭代條件
????????num=num+1;
????????temp1=imcrop(Imrect);
????????%計算侯選區域直方圖
????????%hist2=C*wei_hist(temp1m_weiab);%target?candidates?pu
????????hist2=zeros(14096);
????????for?i=1:a
????????????for?j=1:b
????????????????q_r=fix(double(temp1(ij1))/16);
????????????????q_g=fix(double(temp1(ij2))/16);
????????????????q_b=fix(double(temp1(ij3))/16);
????????????????q_temp1(ij)=q_r*256+q_g*16+q_b;
????????????????hist2(q_temp1(ij)+1)=?hist2(q_temp1(ij)+1)+m_wei(ij);
????????????end
????????end
????????hist2=hist2*C;
????????figure(2);
????????subplot(121);
????????plot(hist2);
????????hold?on;
????????
????????w=zeros(14096);
????????for?i=1:4096
????????????if(hist2(i)~=0)?%不等于
????????????????w(i)=sqrt(hist1(i)/hist2(i));
????????????else
????????????????w(i)=0;
????????????end
????????end
????????
????????
????????
????????%變量初始化
????????sum_w=0;
????????xw=[00];
????????for?i=1:a;
????????????for?j=1:b
????????????????sum_w=sum_w+w(uint32(q_temp1(ij))+1);
????????????????xw=xw+w(uint32(q_temp1(ij))+1)*[i-y(1)-0.5j-y(2)-0.5];
????????????end
????????end
????????Y=xw/sum_w;
????????%中心點位置更新
????????rect(1)=rect(1)+Y(2);
????????rect(2)=rect(2)+Y(1);
????end
????
????
????%%%跟蹤軌跡矩陣%%%
????tic_x=[tic_x;rect(1)+rect(3)/2];
????tic_y=[tic_y;rect(2)+rect(4)/2];
????
????v1=rect(1);
????v2=rect(2);
????v3=rect(3);
????v4=rect(4);
????%%%顯示跟蹤結果%%%
????subplot(122);
????imshow(uint8(Im));
????title(‘目標跟蹤結果及其運動軌跡‘);
????hold?on;
????plot([v1v1+v3][v2v2][v1v1][v2v2+v4][v1v1+v3][v2+v

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-06-12?16:42??Meanshift\
?????目錄???????????0??2014-06-12?16:42??Meanshift\matlab\
?????目錄???????????0??2014-06-12?16:42??Meanshift\matlab\image\
?????文件???????53586??2014-06-11?23:14??Meanshift\matlab\image\result100.jpg
?????文件???????53682??2014-06-11?23:14??Meanshift\matlab\image\result101.jpg
?????文件???????51480??2014-06-11?23:19??Meanshift\matlab\image\result73.jpg
?????文件???????52668??2014-06-11?23:19??Meanshift\matlab\image\result74.jpg
?????文件???????53206??2014-06-11?23:19??Meanshift\matlab\image\result75.jpg
?????文件???????53078??2014-06-11?23:19??Meanshift\matlab\image\result76.jpg
?????文件???????53577??2014-06-11?23:19??Meanshift\matlab\image\result77.jpg
?????文件???????54160??2014-06-11?23:19??Meanshift\matlab\image\result78.jpg
?????文件???????53735??2014-06-11?23:19??Meanshift\matlab\image\result79.jpg
?????文件???????53948??2014-06-11?23:19??Meanshift\matlab\image\result80.jpg
?????文件???????54540??2014-06-11?23:19??Meanshift\matlab\image\result81.jpg
?????文件???????54054??2014-06-11?23:19??Meanshift\matlab\image\result82.jpg
?????文件???????52994??2014-06-11?23:19??Meanshift\matlab\image\result83.jpg
?????文件???????49604??2014-06-11?23:19??Meanshift\matlab\image\result84.jpg
?????文件???????50696??2014-06-11?23:19??Meanshift\matlab\image\result85.jpg
?????文件???????51384??2014-06-11?23:19??Meanshift\matlab\image\result86.jpg
?????文件???????52733??2014-06-11?23:19??Meanshift\matlab\image\result87.jpg
?????文件???????52758??2014-06-11?23:19??Meanshift\matlab\image\result88.jpg
?????文件???????53308??2014-06-11?23:19??Meanshift\matlab\image\result89.jpg
?????文件???????53722??2014-06-11?23:14??Meanshift\matlab\image\result90.jpg
?????文件???????53366??2014-06-11?23:14??Meanshift\matlab\image\result91.jpg
?????文件???????53468??2014-06-11?23:14??Meanshift\matlab\image\result92.jpg
?????文件???????54035??2014-06-11?23:14??Meanshift\matlab\image\result93.jpg
?????文件???????52586??2014-06-11?23:14??Meanshift\matlab\image\result94.jpg
?????文件???????52189??2014-06-11?23:14??Meanshift\matlab\image\result95.jpg
?????文件???????49294??2014-06-11?23:14??Meanshift\matlab\image\result96.jpg
?????文件???????51386??2014-06-11?23:14??Meanshift\matlab\image\result97.jpg
?????文件???????52663??2014-06-11?23:14??Meanshift\matlab\image\result98.jpg
............此處省略34個文件信息

評論

共有 條評論