I have a binary image, how can I count the balck pixels as a group??
Show older comments
I process a rgb image to gray to binary and use filters to remove noise and get some specific black areas. Now I want to count the areas. How many are there? How can I do that? can anyone help me?

Accepted Answer
More Answers (1)
Image Analyst
on 30 Oct 2016
You can get it by inverting your image and calling bwlabel:
[labeledImage, numRegions] = bwlabel(~binaryImage);
No need to call regionprops() just to get the count, though you might want to if you want to measure other things like areas.
Categories
Find more on Image Filtering in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!