您的位置:首页 > 其它

图像相关

2015-06-30 14:51 141 查看
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);

原来图像






切割后的图像




内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: