| Image Processing Toolbox | Search  Help Desk |
| bwarea | Examples See Also |
Compute the area of the objects in a binary image
Syntax
total = bwarea(BW)
Description
total = bwarea(BW) estimates the area of the objects in binary image BW. total is a scalar whose value corresponds roughly to the total number of on pixels in the image, but may not be exactly the same because different patterns of pixels are weighted differently.
Class Support
BW can be of class uint8 or double. total is of class double.
Algorithm
bwarea estimates the area of all of the on pixels in an image by summing the areas of each pixel in the image. The area of an individual pixel is determined by looking at its 2-by-2 neighborhood. There are six different patterns distinguished, each representing a different area:
on pixels (area = 0)
on pixel (area = 1/4)
on pixels (area = 1/2)
on pixels (area = 3/4)
on pixels (area = 7/8)
on pixels (area = 1)
on pixel surrounded by off pixels has a total area of 1.
Example
This example computes the area in the objects of a 256-by-256 binary image.BW = imread('circles.tif');
imshow(BW);

bwarea(BW)
ans =
15799
See Also
bweuler, bwperim
References
Pratt, William K. Digital Image Processing. New York: John Wiley & Sons, Inc., 1991. p. 634.