Tutorial: Generate BBox or Rectangle to locate the target obejct

 

Tutorial: Generate BBox or Rectangle to locate the target obejct  

  

 1 clc;close all;clear all;
 2 Img=imread('/home/wangxiao/Documents/files/Visual_Tracking/MDNet-CVPR2016/MDNet-master/attentionMap/Basketball/0001.png');
 3 if ndims(Img)==3
 4     I=rgb2gray(Img);
 5 else
 6     I=Img;
 7 end
 8 I=im2bw(I,graythresh(I));
 9 [m,n]=size(I);
10 imshow(I);title('binary image');
11 txt=get(gca,'Title');
12 set(txt,'fontsize',16);
13 L=bwlabel(I);
14 stats=regionprops(L,'all');
15 set(gcf,'color','w');
16 set(gca,'units','pixels','Visible','off');
17 q=get(gca,'position');
18 q(1)=0;%设置左边距离值为零
19 q(2)=0;%设置右边距离值为零
20 set(gca,'position',q);
21 for i=1:length(stats)
22     hold on;
23     rectangle('position',stats(i).BoundingBox,'edgecolor','y','linewidth',2);
24     temp = stats(i).Centroid;
25     plot(temp(1),temp(2),'r.');
26     drawnow;
27 end
28 frame=getframe(gcf,[0,0,n,m]);
29 im=frame2im(frame);
30 imwrite(im,'a.jpg','jpg');%可以修改保存的格式

 

  

 

 

  Reference: 

  1. http://blog.sina.com.cn/s/blog_4d633dc70100o0r0.html

 

转载于:https://www.cnblogs.com/wangxiaocvpr/p/6935438.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值