MATLAB: Black task processing in an image

image analysisimage processingImage Processing Toolboximage segmentationMATLAB

Hello
I have a problem with the image display level, the problem is that I have black spots in the white part and I want to eliminate them
attaching the resulting image and the .mat file
thank you in advanceask.jpg

Best Answer

Threshold the image and then call imfill()
binaryImage = grayImage > someValue;
binaryImage = imfill(binaryImage, 'holes');
If you want only holes of a certain diameter filled, then it's a little trickier, so write back.