Image Processing Toolbox User's Guide |
Finding the Area of the Foreground of a Binary Image
The bwarea
function returns the area of a binary image. The area is a measure of the size of the foreground of the image. Roughly speaking, the area is the number of on
pixels in the image.
bwarea
does not simply count the number of pixels set to on
, however. Rather, bwarea
weights different pixel patterns unequally when computing the area. This weighting compensates for the distortion that is inherent in representing a continuous image with discrete pixels. For example, a diagonal line of 50 pixels is longer than a horizontal line of 50 pixels. As a result of the weighting bwarea
uses, the horizontal line has area of 50, but the diagonal line has area of 62.5.
This example uses bwarea
to determine the percentage area increase in circbw.tif
that results from a dilation operation.
BW = imread('circbw.tif'); SE = ones(5); BW2 = imdilate(BW,SE); increase = (bwarea(BW2) - bwarea(BW))/bwarea(BW); increase = 0.3456
See the reference page for bwarea
for more information about the weighting pattern.
Selecting Objects in a Binary Image | Finding the Euler Number of a Binary Image |
© 1994-2005 The MathWorks, Inc.