How to isolate the circle from the shaded area?
Show older comments
I would like to have only a shaded area from the picture. I want to remove the circle from the binary image. Any idea?

Answers (1)
Matt J
on 1 Feb 2015
How about
A=imread('http://www.mathworks.com/matlabcentral/answers/uploaded_files/24735/D1.png');
A=rgb2gray(A);
outer=~imfill(A,'holes');
outerd=imdilate(outer,ones(5));
newImage = A&~outerd;
2 Comments
Mahmoud
on 1 Feb 2015
B=imerode(~A,ones(3));
S=regionprops(B,'PixelIdxList','Area');
[ar,idx]=sort([S.Area],'descend');
tofill=vertcat(S(idx(1:2)).PixelIdxList);
C=false(size(A));
C(tofill)=1;
result=~imdilate(C,ones(5));
Categories
Find more on Color Segmentation 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!