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/Vis...

 

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

相关文章
|
7月前
|
网络安全 Python Windows
pyspark--完美解决 Could not find a version that satisfies the requirement 安装包名字 (from versions: )
pyspark--完美解决 Could not find a version that satisfies the requirement 安装包名字 (from versions: )
439 9
“Could not find suitable distribution for Requirement.parse(‘XXXX‘)”的问题
“Could not find suitable distribution for Requirement.parse(‘XXXX‘)”的问题
390 0
|
4月前
|
iOS开发 Perl
解决Xcode15报错:DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS
解决Xcode15报错:DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS
227 1
|
7月前
target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target S
target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target S
107 0
|
TensorFlow 算法框架/工具 Python
成功解决File "frozen importlib._bootstrap", line 219, in _call_with_frames_removed ImportError: DLL lo
成功解决File "frozen importlib._bootstrap", line 219, in _call_with_frames_removed ImportError: DLL lo
成功解决File "frozen importlib._bootstrap", line 219, in _call_with_frames_removed ImportError: DLL lo
|
Linux
编译OpenJDK8:specified bound depends on the length of the source argument
编译OpenJDK8:specified bound depends on the length of the source argument
185 0
成功解决问题"h5py\h5r.pyx", line 145, in init h5py.h5r AttributeError: type object 'h5py.h5r.Reference' ha
成功解决问题"h5py\h5r.pyx", line 145, in init h5py.h5r AttributeError: type object 'h5py.h5r.Reference' ha
|
前端开发 iOS开发 移动开发
Xcode 10: Build input file double-conversion cannot be found
升级到xcode10之后 ReactNative项目启动报错如下: error: Build input file cannot be found: '/Users/rod/dev/react/testing/awesome/node_modules/react-native/third-party/double-conversion-1.
3293 0
|
Shell Python
安装 AWS Command Line Interface 失败 Could not find a version that satisfies the requirement awscli
版权声明:本文为 testcs_dn(微wx笑) 原创文章,非商用自由转载-保持署名-注明出处,谢谢。 https://blog.csdn.net/testcs_dn/article/details/79739281 ...
2018 0

热门文章

最新文章