MATLAB: Small objects not being removed using bwareaopen()

bwareaopenimage analysisimage processingimage segmentation

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

I figured I would post the answer since I figured it out. If I add the line
binaryImage = imcomplement(binaryImage)
in it inverts what is black and white and that works for this. It apparently wanted to have the objects be white and not black (?) which is a bit confusing to me, but it works now.
Full code:
image = imread('Gaussian.jpg'); % load in your image
binaryImage = im2bw(image, 0.5); % converts image to binary file
binaryImage = imcomplement(binaryImage) % inverts black and white
BW2 = bwareaopen(binaryImage, 150); % removes objects comprised of < 150 pixels
imshowpair(binaryImage, BW2, 'montage') % display both images to see if spots are removed