removal the outer boundary of bw image?
Show older comments
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
Walter Roberson
on 29 Jan 2012
Just don't plot the green ??
mmm ssss
on 29 Jan 2012
mmm ssss
on 29 Jan 2012
Image Analyst
on 29 Jan 2012
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.
Answers (1)
Image Analyst
on 29 Jan 2012
Use morphological erosion
bw = imerode(bw, true(3));
12 Comments
mmm ssss
on 29 Jan 2012
Image Analyst
on 29 Jan 2012
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.
mmm ssss
on 29 Jan 2012
mmm ssss
on 29 Jan 2012
Image Analyst
on 29 Jan 2012
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.
mmm ssss
on 29 Jan 2012
mmm ssss
on 29 Jan 2012
Image Analyst
on 30 Jan 2012
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.
mmm ssss
on 30 Jan 2012
mmm ssss
on 30 Jan 2012
mmm ssss
on 30 Jan 2012
mmm ssss
on 30 Jan 2012
Categories
Find more on Morphological Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!