removal the outer boundary of bw image?

Hi all
i wrote this code
y=imread('..........bmp');
bw=im2bw(y);
b=bwboundaries(bw);
boundry=b{1};
imshow(bw);
hold on;
plot(boundry(:,2),boundry(:,1),'g');
now i need to remove the outer boundary in green color without any effect on the details inside this boundary , is this possible in matlab ? if it is possible how can this be done?
regards

4 Comments

Just don't plot the green ??
no , is it what you understood from my question?
i want to remove this green boundary from also original image not from only the plotted figure , i means how to get rid of this green figure , eithout any affect on the details inside it.
thanks
*without any affect on the details inside it
Walter, I tried but I have no idea what he wants. Apparently it's not what you or I suggested even though both suggestions were valid possible approaches according to how he unclearly worded his question.

Sign in to comment.

Answers (1)

Use morphological erosion
bw = imerode(bw, true(3));

12 Comments

no , it is uncorrect because after morphological operation (skeletonization) , the outer boundary of the hand still exists.
i want to remove this green boundary from the original image also , not from the plotted one only.
I did not say to do skeletonization. I said to do erosion. Erosion eats away at the outermost layer of white objects in a binary image. You could do the same thing by calling bwperim and subtracting that result from the original binary image- they're equivalent. I don't even know what you did because if you did either skeletonization or erosion, you would not have the outer layer of image remain.
yes , but my target is to remove the green boundary now in order not to appear when i find the image skeleton , i means this green boundary must be removed without any effect on the inside detials , this will help in get good skeleton for the inside details without the green outer boundary
http://www.2shared.com/photo/PZSrQfCA/analyat1.html
http://www.2shared.com/photo/qA7LujXu/Analyst1.html
http://www.2shared.com/photo/01vj7dQ-/analyst2.html
you can see the above images as an illustration to my question
I guess I'm not sure what you want then. I told you how to find the outer layer of regions in a binary image (which is where you plotted the green pixels), but you say you don't want that. Therefore I fall back to what Walter says: Just don't plot the boundaries and you will have no green boundaries plotted in the overlay above your image.
thanks , but this is not what i want
regards
as we now that the hand has boundary and this must be removed not from only the plotted figure , but from original image also, for example if we said that we have a square and inside it there is 3 circle and one star , we want to remove only the square boundaries , without any affecting the boundaries of the star and boundaries of 3 circles.
Yes, you can get the boundary coordinates from bwboundaries, from erosion, or from bwperim. Then just set those coordinates to zero in your original image and your binary image.
how can i set them to zero , can you give me sample code please?
mg=imread('E:\master_matlab\HandVein_DataSet\0010hv3.bmp');
level=graythresh(mg);
x=im2bw(mg,level);
figure,imshow(x);
BW2 = bwperim(~x);
figure,imshow(BW2);
now how can i remove the white border in BW2 image?
and the obtain image mg without these border?
*and the obtain image mg without these border?

Sign in to comment.

Asked:

on 29 Jan 2012

Community Treasure Hunt

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

Start Hunting!