I am using the function:
bwareaopen(Image, minPixels)
on the following image:
It should remove all of the objects in my binary image which are less than a specified number of pixels (minPixels). However, it seems to be consistently missing some that are smaller than that range. The following figure shows the original image and the one after bwareaopen() is applied.
The issues are the same for minPixel < 100000. It turns the image completely black expectedly at higher orders of magnitude.
Below is the code I am using. Thanks for any help!
image = imread('Gaussian.jpg'); % load in your image
binaryImage = im2bw(image, 0.5); % converts image to binary file
BW2 = bwareaopen(binaryImage, 150); % removes objects comprised of < 150 pixels
imshowpair(binaryImage, BW2, 'montage') % display both images to see if spots are removed
(Documentation for bwareaopen can be found at: https://www.mathworks.com/help/images/ref/bwareaopen.html)
Best Answer