Skip to Main Content Skip to Search
Product Documentation

bwarea - Area of objects in 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 might not be exactly the same because different patterns of pixels are weighted differently.

Class Support

BW can be numeric or logical. For numeric input, any nonzero pixels are considered to be on. The return value total is of class double.

Algorithms

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, each representing a different area:

Keep in mind that each pixel is part of four different 2-by-2 neighborhoods. This means, for example, that a single on pixel surrounded by off pixels has a total area of 1.

Examples

Compute the area in the objects of a 256-by-256 binary image.

BW = imread('circles.png');
imshow(BW);

bwarea(BW)

ans =

  1.4187e+004

References

[1] Pratt, William K., Digital Image Processing, New York, John Wiley & Sons, Inc., 1991, p. 634.

See Also

bweuler | bwperim

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS