图像相关
2015-06-30 14:51
183 查看
pic = imread('A.jpg');
pic_g = rgb2gray(pic);
pic_edge = edge(pic_g,'roberts',0.15,'both');
figure,imshow(pic_edge);title('提取图像的边缘');
%%
se1 = strel('rectangle',[25,25]);
pic_c = imclose(pic_edge,se1);
figure,imshow(pic_c);title('对图像进行闭运算');
%%
pic_d = bwareaopen(pic_c,200);
figure,imshow(pic_d);title('移除小对象');
%%
[m,n] = size(pic_d);
top = 1;buttom = m;left = 1;right = n;
while sum(pic_d(top,:))==0 && top<m
top = top + 1;
end
while sum(pic_d(buttom,:))==0 && buttom > 1
buttom = buttom - 1;
end
while sum(pic_d(:,left))==0 && left<n
left = left + 1;
end
while sum(pic_d(:,right))==0 && right>1
right = right - 1;
end
wid = right - left;
hig = buttom - top;
pic_qie = imcrop(pic,[left top abs(wid) abs(hig)]);
figure,imshow(pic_qie);
原来图像
切割后的图像
pic_g = rgb2gray(pic);
pic_edge = edge(pic_g,'roberts',0.15,'both');
figure,imshow(pic_edge);title('提取图像的边缘');
%%
se1 = strel('rectangle',[25,25]);
pic_c = imclose(pic_edge,se1);
figure,imshow(pic_c);title('对图像进行闭运算');
%%
pic_d = bwareaopen(pic_c,200);
figure,imshow(pic_d);title('移除小对象');
%%
[m,n] = size(pic_d);
top = 1;buttom = m;left = 1;right = n;
while sum(pic_d(top,:))==0 && top<m
top = top + 1;
end
while sum(pic_d(buttom,:))==0 && buttom > 1
buttom = buttom - 1;
end
while sum(pic_d(:,left))==0 && left<n
left = left + 1;
end
while sum(pic_d(:,right))==0 && right>1
right = right - 1;
end
wid = right - left;
hig = buttom - top;
pic_qie = imcrop(pic,[left top abs(wid) abs(hig)]);
figure,imshow(pic_qie);
原来图像
切割后的图像
相关文章推荐
- 北大ACM3684——Physics Experiment
- 【转】关系映射文件***.hbm.xml详解
- centos7 修改主机名的方法(在centos7有效)
- informatica 修改tomcat 连接池
- 3A服务器tacacs+的配置
- String+String和StringBuilder.append(String)的效率和区别
- 如何安装独立版的CHM(Oracle Cluster Health Monitor)
- 认识自己——从别人的身上看自己
- 欢迎使用CSDN-markdown编辑器
- Tiny模板引擎之工具介绍
- MDX Order排序
- Could not reserve enough space for object heap 问题解决
- REDIS 高可用性部署架构图
- WWDC 2015 之 watchOS 2 初印象
- Linux下安装PHP环境
- System-value semantics for the rasterizer stage.
- Android tcpdump抓包方法与步骤
- Ceph官网中文文档翻译小组OSChina入住
- Tiny VS 其它开源产品
- ios --- 调用系统"设置"里的功能