clear;
clc;
%数据的初始化
%在HSV空间中,将三个颜色分量合成为一维特征向量时,一维向量的大小
v_count=193;
N=500;
%采样粒子的个数
n=52;%179;%400;%52;
%视频序列中的图像帧数
first=1;
%第一帧图像的名称序号
new_sita=0.20;
%(new_sita)^2表示颜色信息的高斯分布方差。
vx=[0,0,0];
vy=[0,0,0];
%得出目标的移动速度
runtime=0;%求取目标速度的时候用
struct_index=0;%存储结构体的指数
%产生随机粒子的方差
sigma_x=3.5;
sigma_y=3.5;
%求前10帧图像与目标模板的相似度
pre_probability=zeros(1,10);
%判断是否进行了重采样
resample_judge=0;
%得到目标模板的初始数据
I=imread('rice.png');
imshow(I);
rect = getrect();
x1 = rect(1);
x2 = rect(1) + rect(3);
y1 = rect(2);
y2 = rect(2) + rect(4);
%得到初始跟踪目标的中心坐标点
x=round((x1+x2)/2);
y=round((y1+y2)/2);
%得到描述目标轮廓的椭圆的长短半轴的平方
hx=((x2-x1)/3)^2;
hy=((y2-y1)/3)^2;
sizeimage=size(I);
image_boundary_x=int16(sizeimage(2));
image_boundary_y=int16(sizeimage(1));
%将第一帧用来选择被跟踪目标的图片存入指定的文件夹中
F = getframe;
mkdir('.\result');
image_source=strcat('.\result\','1.jpg');
imwrite(F.cdata,image_source);
%在第一帧中手动选定的目标进行初始化操作
[H S V]=rgb_to_rank(I);
[Sample_Set,Sample_probability,Estimate,target_histgram]=initialize(x,y,hx,hy,H,S,V,N,image_boundary_x,image_boundary_y,v_count,new_sita);
pre_probability(1)=Estimate(1).probability;
%从第二帧往后循环迭代的进行下去
for loop=2:n
struct_index=struct_index+1;
a=num2str(loop+first-1);
b=[a,'.bmp'];
b=['.\仿真图片1\',b];
I=imread(b);
[H,S,V]=rgb_to_rank(I);
%产生随机粒子
[Sample_Set,after_prop]=reproduce(Sample_Set,vx,vy,image_boundary_x,image_boundary_y,I,N,sigma_x,sigma_y,runtime);
%得出被跟踪目标的在当前帧的预测位置
[Sample_probability,Estimate,vx,vy,TargetPic,Sample_histgram]=evaluate(Sample_Set,Estimate,target_histgram,new_sita,loop,after_prop,H,S,V,N,image_boundary_x,image_boundary_y,v_count,vx,vy,hx,hy,Sample_probability);
%模板更新时和重采用判断时,都要用到归一化的权值Sample_probability
%模板跟新
if(loop<=10)%前10帧属于特殊情况,需要额外进行处理
sum_probability=0;
for p=1:loop-1
sum_probability=sum_probability+pre_probability(p);
end
mean_probability=sum_probability/(loop-1);
else%直接求取均值
mean_probability=mean(pre_probability);
end
mean_probability;
Estimate(loop).probability;
if(Estimate(loop).probability>mean_probability)
[target_histgram,pre_probability]=update_target(target_histgram,Sample_histgram,Sample_probability,pre_probability,Estimate,N,v_count,loop,resample_judge);
%不进行模板更新,但是要对pre_probability进行更新操作
else if(loop>10)
for k=1:9
pre_probability(k)=pre_probability(k+1);
end
pre_probability(10)=Estimate(loop).probability;
else
pre_probability(loop)=Estimate(loop).probability;
end
end
resample_judge=0;
%判断是否需要重采样
back_sum_weight=0;
for judge=1:N
back_sum_weight=back_sum_weight+(Sample_probability(judge))^2;
end
sum_weight=1/back_sum_weight;
if(sum_weight<N/2)
%重采样过程
usetimes=reselect(Sample_Set,Sample_probability,N);
[Sample_Set,Sample_probability]=assemble(Sample_Set,usetimes,Sample_probability,N);%进行线性组合
resample_judge=1;
end
%得到目标运动的轨迹
if(struct_index==1)
routine.x=round(Estimate(loop).x);
routine.y=round(Estimate(loop).y);
else
routine(struct_index).x=round(Estimate(loop).x);
routine(struct_index).y=round(Estimate(loop).y);
end
i=1;
j=1;
while(j<=struct_index)
for new_x=routine(j).x-i:routine(j).x+i
for new_y=routine(j).y:routine(j).y+i
TargetPic(new_y,new_x,1)=0;
TargetPic(new_y,new_x,2)=0;
TargetPic(new_y,new_x,3)=255;
end
end
j=j+1;
end
%画出每一帧图像中跟踪目标的预测中心点
i=1;
for new_x=round(Estimate(loop).x)-i:round(Estimate(loop).x+i)
for new_y=round(Estimate(loop).y)-i:round(Estimate(loop).y+i)
TargetPic(new_y,new_x,1)=255;
TargetPic(new_y,new_x,2)=255;
TargetPic(new_y,new_x,3)=255;
end
end
imshow(TargetPic);
F = getframe;
image_source=strcat('C:\Users\lenovo\Desktop\仿真程序\result\',num2str(loop),'.bmp');
imwrite(F.cdata,image_source);
end
%在灰度图中绘制出被跟踪目标的轨迹
im_routine=redraw_routine(image_boundary_x,image_boundary_y,routine,struct_index);
figure;
title('被跟踪目标的运动轨迹图');
hold on;
imshow(im_routine);
没有合适的资源?快使用搜索试试~ 我知道了~
滤波跟踪基于粒子滤波实现视频目标跟踪算法附matlab代码.zip
共190个文件
bmp:179个
m:11个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 2 下载量 24 浏览量
2022-06-25
14:22:36
上传
评论 6
收藏 2.34MB ZIP 举报
温馨提示
1.版本:matlab2019a,不会运行可私信 2.领域:【滤波跟踪】 3.内容:基于粒子滤波实现视频目标跟踪算法附matlab代码.zip 4.适合人群:本科,硕士等教研学习使用
资源推荐
资源详情
资源评论
收起资源包目录
滤波跟踪基于粒子滤波实现视频目标跟踪算法附matlab代码.zip (190个子文件)
19.bmp 14KB
162.bmp 14KB
20.bmp 14KB
165.bmp 14KB
158.bmp 14KB
168.bmp 14KB
21.bmp 14KB
159.bmp 14KB
164.bmp 14KB
163.bmp 14KB
161.bmp 14KB
22.bmp 14KB
5.bmp 14KB
23.bmp 14KB
160.bmp 14KB
3.bmp 14KB
18.bmp 14KB
167.bmp 14KB
166.bmp 14KB
6.bmp 14KB
169.bmp 14KB
157.bmp 14KB
4.bmp 14KB
17.bmp 14KB
1.bmp 14KB
2.bmp 14KB
7.bmp 14KB
154.bmp 14KB
176.bmp 14KB
26.bmp 14KB
155.bmp 14KB
24.bmp 14KB
25.bmp 14KB
16.bmp 14KB
149.bmp 14KB
146.bmp 14KB
152.bmp 14KB
148.bmp 14KB
175.bmp 14KB
147.bmp 14KB
153.bmp 14KB
27.bmp 14KB
178.bmp 14KB
174.bmp 14KB
177.bmp 14KB
173.bmp 14KB
156.bmp 14KB
170.bmp 14KB
150.bmp 14KB
8.bmp 14KB
151.bmp 14KB
171.bmp 14KB
28.bmp 14KB
15.bmp 14KB
29.bmp 14KB
145.bmp 13KB
172.bmp 13KB
9.bmp 13KB
179.bmp 13KB
14.bmp 13KB
144.bmp 13KB
47.bmp 13KB
50.bmp 13KB
55.bmp 13KB
61.bmp 13KB
48.bmp 13KB
49.bmp 13KB
51.bmp 13KB
59.bmp 13KB
10.bmp 13KB
79.bmp 13KB
78.bmp 13KB
53.bmp 13KB
52.bmp 13KB
54.bmp 13KB
142.bmp 13KB
62.bmp 13KB
81.bmp 13KB
57.bmp 13KB
80.bmp 13KB
30.bmp 13KB
13.bmp 13KB
141.bmp 13KB
60.bmp 13KB
143.bmp 13KB
73.bmp 13KB
75.bmp 13KB
77.bmp 13KB
63.bmp 13KB
58.bmp 13KB
72.bmp 13KB
11.bmp 13KB
46.bmp 13KB
71.bmp 13KB
74.bmp 13KB
31.bmp 13KB
12.bmp 13KB
56.bmp 13KB
82.bmp 13KB
76.bmp 13KB
共 190 条
- 1
- 2
资源评论
- kefu3hao2023-04-18资源质量不错,和资源描述一致,内容详细,对我很有用。
- 怎么不下雨2023-10-10资源和描述一致,质量不错,解决了我的问题,感谢资源主。
天天Matlab科研工作室
- 粉丝: 2w+
- 资源: 7251
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 农村信用社联合社计算机信息系统投产与变更管理办.docx
- 农村信用社联合社计算机信息系统数据管理办法.docx
- 利用SPSS作临床效度分析线上计算网站介绍-医学研究部统计谘.(医学PPT课件).ppt
- 利用Zabbix监控mysqldump定时备份数据库状态.docx
- 利用计算机解决问题的基本过程.doc
- 化工铁路通信工程总结.doc
- 北京大学网络教育软件工程作业.docx
- 医药公司(连锁店)计算机操作规程未新系统的自行按照旧制修改-新系统过制的编号加修模版.doc
- 医药公司(连锁店)计算机系统操作规程模版.doc
- 医药连锁门店计算机系统的操作和管理程序未新系统的自行按照旧制修改-新系统过制的编号加修模版.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功