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

相关文章
|
3月前
|
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
157 1
|
6月前
|
PyTorch 算法框架/工具
The “freeze_support()“ line can be omitted if the program is not going to be frozen
The “freeze_support()“ line can be omitted if the program is not going to be frozen
103 1
Pingdom Website Speed Test
在Pingdom输入 URL 地址,即可测试页面加载速度,分析并找出性能瓶颈。帮助用户找出影响网站速度的原因,并给出改善网页性能的可行性方案,很适合做网站的用户。
69 0
Anaconda Navigator:could not find or load the QT platform plugin "window in"
Anaconda Navigator:could not find or load the QT platform plugin "window in"
240 0
Anaconda Navigator:could not find or load the QT platform plugin "window in"
Cannot find source code based button in SE24
When you are logging on to customer system for incident handling, you want to switch to source code to perform some keyword search. However, you could not find button “Source code based builder” in toolbar, with following warning message: ———————————————— 版权声明:本文为CSDN博主「汪子熙」的原创文章,遵循CC 4.0 BY-SA版权协
Cannot find source code based button in SE24
vuepress build提示YAMLException: end of the stream or a document separator is expected at line 7, colu
vuepress build提示YAMLException: end of the stream or a document separator is expected at line 7, colu
855 0
成功解决model_selection\_search.py:761: DeprecationWarning: The grid_scores_ attribute was deprecated in
成功解决model_selection\_search.py:761: DeprecationWarning: The grid_scores_ attribute was deprecated in
|
前端开发 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.
3274 0
|
新零售 测试技术 Python
Robot Framework - Variable file
RF导入变量文件 在Setting中导入 Setting中导入变量文件时,和导入外部资源文件类似。变量文件的路径可以包含参数,如果一个变量文件接受参数,那么它们也可以是变量。
1364 0