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 Answer from Rebecca Napolitano on mathworks.com
🌐
MathWorks
mathworks.com › image processing toolbox › image segmentation and analysis › region and image properties
bwareaopen - Remove small objects from binary image - MATLAB
BW2 = bwareaopen(BW,P) removes all connected components (objects) that have fewer than P pixels from the binary image BW, producing another binary image, BW2.
Discussions

what does bwareaopen do?
I understand, bwareaopen(BW, P) means, the function removes pixels from BW matrix less than 'P' pixels and the default conn is 4 which means conn=4 means - X - X 0 X - X - con... More on mathworks.com
🌐 mathworks.com
1
2
April 17, 2014
Remove unwanted small and connected regions in the image
Hi everybody, I need to extract small connected regions in the image . Is there a solution to this problem? More on mathworks.com
🌐 mathworks.com
2
1
November 21, 2023
matlab - How does "bwareaopen" work? - Stack Overflow
I saw the documentation of bwareaopen, but what was confusing me is the number of pixels. When we say 8-neighbourhood, doesn't that mean 9-pixels? In this function, we specify the number of pixels,... More on stackoverflow.com
🌐 stackoverflow.com
count - Matlab Bwareaopen equivalent function in OpenCV - Stack Overflow
I'm trying to find similar or equivalent function of Matlabs "Bwareaopen" function in OpenCV? In MatLab Bwareaopen(image,P) removes from a binary image all connected components (objects) that have... More on stackoverflow.com
🌐 stackoverflow.com
🌐
MathWorks
blogs.mathworks.com › steve › 2016 › 08 › 22 › binary-image-area-filtering
Binary image area filtering » Steve on Image Processing with MATLAB - MATLAB & Simulink
August 22, 2016 - Among the mathematical morphology folk, removing connected components that have an area smaller than some threshold is called area opening, and there's an Image Processing Toolbox function called bwareaopen that does it.
🌐
GitHub
gist.github.com › SeanCho1996 › 264d1b2cb65b205d5b33fbd5cec6acbd
Implementation of Matlab bwareaopen in cv2 · GitHub
Implementation of Matlab bwareaopen in cv2 . GitHub Gist: instantly share code, notes, and snippets.
🌐
MathWorks
mathworks.com › image processing toolbox › image segmentation and analysis › region and image properties
bwareafilt - Extract objects from binary image by size - MATLAB
This MATLAB function extracts all connected components (objects) from the binary image BW, where the area of the objects is in the specified range, producing another binary image BW2.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 2050207-remove-unwanted-small-and-connected-regions-in-the-image
Remove unwanted small and connected regions in the image - MATLAB Answers - MATLAB Central
November 21, 2023 - mask = bwareaopen(mask, 10); % Keep only blobs with an area of 10 pixels or more. mask = bwareafilt(mask, [10, 500]); % Keep only blobs with an area of 10 pixels to 500 pixels. mask = bwareafilt(mask, 3); % Keep the 3 largest blobs ONLY.
Find elsewhere
🌐
Northwestern University
ece.northwestern.edu › local-apps › matlabhelp › toolbox › images › bwareaopen.html
bwareaopen (Image Processing Toolbox)
BW2 = bwareaopen(BW,P) removes from a binary image all connected components (objects) that have fewer than P pixels, producing another binary image BW2.
🌐
MathWorks
in.mathworks.com › matlabcentral › answers › 326280-how-to-remove-noise-in-binary-image
How to remove noise in binary image - MATLAB Answers - MATLAB Central
February 22, 2017 - https://in.mathworks.com/matlabcentral/answers/326280-how-to-remove-noise-in-binary-image#answer_255806 · Cancel Copy to Clipboard · There are functions bwareaopen() and bwareafilt() that could help filter based on size. If you have other characteristics that define noise, like shape or whatever, then use bwpropfilt().
🌐
MathWorks
mathworks.com › matlabcentral › answers › 116818-removal-of-objects-from-binary-image
Removal Of objects from binary image. - MATLAB Answers - MATLAB Central
February 19, 2014 - https://www.mathworks.com/matlabcentral/answers/116818-removal-of-objects-from-binary-image#answer_124965 ... I just did that in the past month or two for someone - extracting the main vasculature of the retina in a fundus photograph. Look up the tag eye and look for my name. Or look in my File Exchange or at bwareaopen as Dishant suggests.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 304273-a-function-similar-to-bwareaopen-and-imdilate
A function similar to bwareaopen and imdilate? - MATLAB Answers - MATLAB Central
September 23, 2016 - I have a picture with several particles in it. I have made the intensity in particles 255 and the background 0 so the particles are very detectable. But each particle has a different size of pixels. By using bwareaopen, I can eliminate particles bigger/smaller than a certain limit.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 222135-what-function-do-i-use-to-remove-large-object
what function do i use to remove large object ? - MATLAB Answers - MATLAB Central
June 2, 2015 - In matlab we use bwareaopen(I,n) function to remove object smaller than n pixel from image I. Is there any function to remove object greater than m pixel from image I ? what should i do to re...
🌐
MathWorks
in.mathworks.com › matlabcentral › answers › 391282-shape-recognition-in-a-complex-image
shape recognition in a complex image - MATLAB Answers - MATLAB Central
March 28, 2018 - https://in.mathworks.com/matlabcentral/answers/391282-shape-recognition-in-a-complex-image#answer_312506 ... I don't think that's a good way. What I'd do is to use stdfilt() to find regions with low standard deviation. Threshold to find areas with low stddev, then regionprops to find the areas. Then determine what area is the smallest allowable and call bwareafilt() or bwareaopen() to throw out small, noise blobs.