change the output representation

In this code for convex hull.... the output image has a white border around the image.... as i have shown in the link....
what should i do to the code so that i dont want the border.... i want the output as
The code i used is...
function convexhull
a=imread('impcon.bmp');
a=a(:,:,3);
o=a;
subplot(2,2,1)
imshow(o)
title('original image');
[r,c]=size(a);
c=[1 0 0;1 0 0;1 0 0 ]
c1=[1 1 1;0 0 0;0 0 0 ];
c2=[0 0 1; 0 0 1;0 0 1];
c3=[0 0 0;0 0 0;1 1 1];
b=a;
for u=1:10
d=(imerode(b,c))|a;
if(b==d)
break;
end
b=d;
end
%-------------
m=a;
for u=1:10
n=(imerode(m,c1))|a;
if(m==n)
break;
end
m=n;
end
%-------------
p=a;
for u=1:10
l=(imerode(p,c2))|a;
if(p==l)
break;
end
p=l;
end
%-------------
z=a;
for u=1:10
v=(imerode(z,c3))|a;
if(z==v)
break;
end
z=v;
end
%-------------
H=z|p|m|b;
subplot(2,2,2)
imshow(H)
title('convex Hull of image');
Please show me where to change the code.... so that i get the output as shown in the second link.....please do reply....

 채택된 답변

Image Analyst
Image Analyst 2013년 3월 21일

1 개 추천

Why aren't you using bwconvhull()? If you don't have a new enough version, then you can use imclearborder() to get rid of foreground touching the border.

댓글 수: 2

Elysi Cochin
Elysi Cochin 2013년 3월 21일
thank u sir.... i used imclearborder()
Image Analyst
Image Analyst 2013년 3월 21일
You're welcome, though it's not the preferred solution - bwconvhull() is.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Geometric Transformation and Image Registration에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by