Measure properties of image regions

returns measurements for the set of properties specified by `stats`

= regionprops(`BW`

,`properties`

)`properties`

for each 8-connected component (object) in the binary image, `BW`

.
`stats`

is struct array containing a struct for each object in the
image. You can use `regionprops`

on contiguous regions and discontiguous
regions (see Algorithms).

To return measurements of a 3-D volumetric image, consider using `regionprops3`

. While `regionprops`

can accept 3-D images,
`regionprops3`

calculates more statistics for 3-D images than
`regionprops`

.

For all syntaxes, if you do not specify the `properties`

argument, then
`regionprops`

returns the `'Area'`

,
`'Centroid'`

, and `'BoundingBox'`

measurements.

You optionally can measure properties of image regions `'ConvexArea'`

, `'ConvexHull'`

,
`'ConvexImage'`

, `'Circularity'`

,
`'EulerNumber'`

, `'FilledArea'`

,
`'FilledImage'`

, `'MaxFeretProperties'`

,
`'MinFeretProperties'`

and `'Solidity'`

properties are
not supported on a GPU.

measures a set of properties for each connected component (object) in
`stats`

= regionprops(`CC`

,`properties`

)`CC`

, which is a structure returned by `bwconncomp`

.

This syntax is not supported on a GPU.

measures a set of properties for each labeled region in label matrix
`stats`

= regionprops(`L`

,`properties`

)`L`

.

returns measurements for the set of properties specified by `stats`

= regionprops(___,`I`

,`properties`

)`properties`

for each labeled region in the image `I`

. The first input to
`regionprops`

(`BW`

, `CC`

, or
`L`

) identifies the regions in `I`

.

The function

`ismember`

is useful with`regionprops`

,`bwconncomp`

, and`labelmatrix`

for creating a binary image containing only objects or regions that meet certain criteria. For example, these commands create a binary image containing only the regions whose area is greater than 80 and whose eccentricity is less than 0.8.cc = bwconncomp(BW); stats = regionprops(cc, 'Area','Eccentricity'); idx = find([stats.Area] > 80 & [stats.Eccentricity] < 0.8); BW2 = ismember(labelmatrix(cc), idx);

The comma-separated list syntax for structure arrays is useful when you work with the output of

`regionprops`

. For a field that contains a scalar, you can use this syntax to create a vector containing the value of this field for each region in the image. For instance, if`stats`

is a structure array with field`Area`

, then the following expression:stats(1).Area, stats(2).Area, ..., stats(end).Area

is equivalent to:

stats.Area

Therefore, you can use these calls to create a vector containing the area of each region in the image.

`allArea`

is a vector of the same length as the structure array`stats`

.stats = regionprops(L, 'Area'); allArea = [stats.Area];

The functions

`bwlabel`

,`bwlabeln`

, and`bwconncomp`

all compute connected components for binary images.`bwconncomp`

replaces the use of`bwlabel`

and`bwlabeln`

. It uses less memory and is sometimes faster than the other functions.Function Input Dimension Output Form Memory Use Connectivity `bwlabel`

2-D Label matrix with double-precision High 4 or 8 `bwlabeln`

N-D Double-precision label matrix High Any `bwconncomp`

N-D `CC`

structLow Any The output of

`bwlabel`

and`bwlabeln`

is a double-precision label matrix. To compute a label matrix using a more memory-efficient data type, use the`labelmatrix`

function on the output of`bwconncomp`

:CC = bwconncomp(BW); L = labelmatrix(CC);

If you are measuring components in a binary image with default connectivity, it is no longer necessary to call

`bwlabel`

or`bwlabeln`

first. You can pass the binary image directly to`regionprops`

, which then uses the memory-efficient`bwconncomp`

function to compute the connected components automatically. To specify nondefault connectivity, call`bwconncomp`

and pass the result to`regionprops`

.CC = bwconncomp(BW, CONN); S = regionprops(CC);

Most of the measurements take little time to compute. However, the following measurements can take longer, depending on the number of regions in

`L`

:`'ConvexHull'`

`'ConvexImage'`

`'ConvexArea'`

`'FilledImage'`

Computing certain groups of measurements takes about the same amount of time as computing just one of them.

`regionprops`

takes advantage of intermediate computations useful to each computation. Therefore, it is fastest to compute all the desired measurements in a single call to`regionprops`

.

Contiguous regions are also called *objects*, *connected
components*, or *blobs*. A label matrix containing
contiguous regions might look like this:

1 1 0 2 2 0 3 3 1 1 0 2 2 0 3 3

`L`

equal
to 1 belong to the first contiguous region or connected component;
elements of `L`

equal to 2 belong to the second connected
component; and so on.Discontiguous regions are regions that might contain multiple connected components. A label matrix containing discontiguous regions might look like this:

1 1 0 1 1 0 2 2 1 1 0 1 1 0 2 2

`L`

equal
to 1 belong to the first region, which is discontiguous and contains
two connected components. Elements of `L`

equal to
2 belong to the second region, which is a single connected component. `bwconncomp`

| `bwferet`

| `bwlabel`

| `bwlabeln`

| `bwpropfilt`

| `ismember`

| `labelmatrix`

| `regionprops3`

| `watershed`