MATLAB: I want to convert the image to desired format?

image processingImage Processing Toolbox

A=imread(' ');
r=A(:,:,1);
g=A(:,:,2);
b=A(:,:,3);
BW = edge(r,'sobel');
BW = bwareaopen(BW,50);
figure, imshow(BW);
result = imfill(BW,'holes')&~BW;
figure, imshow(result);
I used this program to convert the file attached edge.jpg to area.jpg but i am unable to convert the edge1.jpg. Can anyone please explain why it is not working and any ways to convert it to desired format as in area

Best Answer

If it's not filling, then you don't have a solid unbroken outline.