Filling holes for objects in a binary image
imout = imfill(imin)
A binary image
The output with the holes filled.
This function used to fill the holes in a binary image for better object detection purpose.
S = imread(fullpath(getIPCVpath() + "/images/" + 'coins_gray.jpg')); subplot(131);imshow(S); Sbin = im2bw(~S,0.5); subplot(132);imshow(Sbin); Sfill = imfill(Sbin); subplot(133);imshow(Sfill);