I = imread('coins.png');
figure
imshow(I)
title('Original Image')
Convert image to binary image.
转化成二值图
BW = imbinarize(I);
figure
imshow(BW)
title('Original Image Converted to Binary Image')
Fill holes in the binary image and display the result.
BW2 = imfill(BW,'holes');
figure
imshow(BW2)
title('Filled Image')