Clear Filters
Clear Filters

How to Fill a 'hole' with leakage?

2 views (last 30 days)
Subhajit Chatterjee
Subhajit Chatterjee on 25 Sep 2015
Commented: Jeff E on 25 Sep 2015
I want to fill this holes in this image. I have tried strel() and then imclose() and then imfill() holes. But it is failed to detect these holes with leakage? Please put some light on how to fill those image and make this a whole black one. Thanks
  1 Comment
Jeff E
Jeff E on 25 Sep 2015
Try imclose, which will make a bridge between the two "leakages" and then find the holes. imclose affects other parts of the image, so adding back those holes you found and then filling in holes again will get you a more accurate result. You may need to play a bit with the size of the imclose filter as well, depending upon the size of the "leaks".
imgin = imread('breast_image_segmented_38.jpg');
imgbw = im2bw(imgin);
%take complement to adhere to convention
imgbw = imcomplement(imgbw) ;
%make bridges across small "leaks"
img_close = imclose(imgbw , strel('disk', 7));
%find holes in resulting image
holes = ~img_close & imfill(img_close, 'holes');
%add back holes to original image
img_filled = imfill((imgbw | holes) , 'holes');
%optional additional filling
img_filled_closed = imclose(img_filled, strel('disk', 3)) ;

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!