MATLAB: How to count number of white cirlces in a bw image

bw imagesimage processisngporosity

Hello
I have the following image. How do I count the Number of white regions (region fully enclosed by black pixels)? There are about 22 in this picture (counted manually). How to code it? Any help is much appreciated!!
Best Regards, Omar

Best Answer

Use bwlabel():
[labeledImage, numRegions] = bwlabel(binaryImage);