This How-to applies to Image Analysis. It shows a method of using Matlab to count objects and find the subsequent area of those objects.
The following image will serve as an example:
The image simply has 4 geometric shapes on a black background. The goal is to count the number of objects and to find the area of each of those objects.
For documenting purposes (and so that we can see what the numerical arrays look like), the test image is cropped and scaled down to a small size of 37×22 pixels:
Here are what the actual values look like:
Counting and Indexing the Objects with the Function: bwlabel
The Matlab function “bwlabel” is used to both separate, and count the objects. (More info of the “bwlabel” function can be found on the Matworks web site:
http://www.mathworks.com/help/images/ref/bwlabel.html). If the binary image has been assigned to the variable “bmask”, the function is called as follows: