Blob Analysis - Compute statistical values for labeled regions

Library

Statistics

Description

Use the Blob Analysis block to calculate statistics for labeled regions in a binary image. The block returns some quantities, such as the Centroid, as values that represent spatial coordinate locations. For information about how pixel and spatial coordinate systems are defined in the Video and Image Processing Blockset™, see Coordinate Systems in the Video and Image Processing Blockset User's Guide.

Use the Variable Selector block to select certain blobs based on their statistics. For more information about this block, see the Variable Selector block reference page in the Signal Processing Blockset™ documentation.

PortInput/OutputSupported Data TypesComplex Values Supported

BW

Vector or matrix that represents a binary image

Boolean

No

Area

Vector that represents the number of pixels in labeled regions

  • 32-bit signed integer

No

Centroid

2-by-N matrix of centroid coordinates, where N is the number of blobs

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point

No

BBox

4-by-N matrix of bounding box coordinates, where N is the number of blobs

  • 32-bit signed integer

No

MajorAxis

Vector that represents the lengths of major axes of ellipses

  • Double-precision floating point

  • Single-precision floating point

No

MinorAxis

Vector that represents the lengths of minor axes of ellipses

Same as MajorAxis port

No

Orientation

Vector that represents the angles between the major axes of the ellipses and the x-axis.

Same as MajorAxis port

No

Eccentricity

Vector that represents the eccentricities of the ellipses

Same as MajorAxis port

No

Diameter^2

Vector that represents the equivalent diameters squared

Same as Centroid port

No

Extent

Vector that represents the results of dividing the areas of the blobs by the area of their bounding boxes

Same as Centroid port

No

Perimeter

Vector containing an estimate of the perimeter length, in pixels, for each blob

Same as Centroid port

No

Label

Label matrix

  • 8-, 16-, or 32-bit unsigned integer

No

Count

Scalar value that represents the actual number of labeled regions in each image

Same as Label port

No

Main Pane

Use the check boxes to specify the statistics values you want the block to output. The following table summarizes the block's behavior based on which check box you select. For a full description of each of these statistics, see the regionprops function reference page in the Image Processing Toolbox™ documentation.

Check Box

Block Output

Area

Vector that represents the number of pixels in labeled regions

Centroid

2-by-N matrix whose columns represent the coordinates of the centroid of each region, where N is the number of blobs. For example, if there are two blobs and the row and column coordinates of their centroids are r1, c1 and r2, c2, respectively, the block outputs

at the Centroid port.

Bounding box

4-by-N matrix whose columns represent the coordinates of each bounding box, where N is the number of blobs. For example, suppose there are two blobs, where r and c define the row and column location of the upper-left corner of the bounding box and w and h define the width and height of the bounding box, the block outputs

at the BBox port.

Major axis length

Vector that represents the lengths of the major axes of ellipses that have the same normalized second central moments as the labeled regions

Minor axis length

Vector that represents the lengths of the minor axes of ellipses that have the same normalized second central moments as the labeled regions

Orientation

Vector that represents the angles between the major axes of the ellipses and the x-axis. The angle values are in radians and range between and

Eccentricity

Vector that represents the eccentricities of ellipses that have the same second moments as the origin

Equivalent diameter squared

Vector that represents the equivalent diameters squared

Extent

Vector that represents the results of dividing the areas of the blobs by the area of their bounding boxes

Perimeter

N-by-1 vector containing estimates of the perimeter lengths, in pixels, of each blob, where N is the number of blobs

Use the Statistics output data type parameter to specify the data type of the outputs at the Centroid, MajorAxis, MinorAxis, Orientation, Eccentricity, Diameter^2, and Extent ports. If you select Fixed-point, the block cannot calculate the major axis, minor axis, orientation, or eccentricity and these check boxes become unavailable.

Use the Connectivity parameter to define which pixels are connected to each other. If you want a pixel to be connected to the other pixels located on the top, bottom, left, and right, select 4. If you want a pixel to be connected to the other pixels on the top, bottom, left, right, and diagonally, select 8. For more information about this parameter, see the Label block reference page.

The Connectivity parameter also affects how the block calculates the perimeter of a blob. The following figure illustrates how the block calculates the perimeter when you set the Connectivity parameter to 4.

The block calculates the distance between the center of each pixel (marked by the black dots) and estimates the perimeter to be 22. The next figure illustrates how the block calculates the perimeter of a blob when you set the Connectivity parameter to 8.

The block takes a different path around the blob and estimates the perimeter to be .

If you select the Output label matrix check box, the block outputs the label matrix, where pixels equal to 0 represent the background, pixels equal to 1 represent the first object, pixels equal to 2 represent the second object, and so on, at the Label port.

Blob Properties Pane

Use the Maximum number of blobs parameter to specify the maximum number of labeled regions in each input image. The block uses this value to preallocate vectors and matrices so that they are long enough to hold all of the statistical values. If you select the Warn if maximum number of blobs is exceeded check box, the block produces a warning if the number of blobs in an image is greater than the value you entered for the Maximum number of blobs parameter. If you select the Output number of blobs found check box, the block outputs a scalar value that represents the actual number of connected regions in each image at the Count port.

If you select the Specify minimum blob area in pixels and/or Specify maximum blob area in pixels check boxes, you can enter the minimum and maximum pixel area for the blobs. Blobs that do not meet this area criteria are not labeled. Select the Exclude blobs touching image border check box if you do not want to label blobs that contain at least one border pixel.

If the number of blobs found in an image is less than the scalar value entered for the Maximum number of blobs parameter, the block has empty spaces in the statistics output arrays. If you select the Fill empty spaces in outputs check box, the block fills the empty spaces with the scalar value you specify in the Fill values parameter. If you enter a vector for the Fill values parameter, it must have the same length as the number of selected statistics. The block uses each vector element to fill a different statistics vector. If the empty spaces do not affect your computation, you can deselect the Fill empty spaces in outputs check box. Otherwise, we recommend leaving it selected.

Fixed-Point Data Types

The following diagram shows the data types used in the Blob Analysis block for fixed-point signals.

You can set the product output, accumulator, centroid output, equivalent diameter squared output, and extent output data types in the block mask as discussed in the next section.

Dialog Box

The Main pane of the Blob Analysis dialog box appears as shown in the following figure.

Area

Select this check box to output the area of the blobs.

Centroid

Select this check box to output the 2-by-N matrix whose columns represent the coordinates of the centroid of each labeled region.

Bounding box

Select this check box to output the coordinates of the bounding boxes.

Major axis length

Select this check box to output a vector whose values represent the lengths of the major axes of the ellipses that have the same normalized second central moments as the labeled regions.

Minor axis length

Select this check box to output a vector whose values represent the lengths of the minor axes of the ellipses that have the same normalized second central moments as the labeled regions.

Orientation

Select this check box to output a vector whose values represent the angles between the major axes of the ellipses and the x-axis. The angle values are in radians and range between -pi/2 and pi/2.

Eccentricity

Select this check box to output a vector whose values represent the eccentricities of the ellipses that have the same second moments as the origin.

Equivalent diameter squared

Select this check box to output a vector whose values represent the equivalent diameters squared.

Extent

Select this check box to output a vector whose values represent the results of dividing the areas of the blobs by the area of their bounding boxes.

Perimeter

Select this check box to output a vector whose values represent estimates of the perimeter lengths, in pixels, of each blob.

Statistics output data type

Specify the data type of the outputs at the Centroid, MajorAxis, MinorAxis, Orientation, Eccentricity, Diameter^2, and Extent ports.

Connectivity

Specify which pixels are connected to each other. If you want a pixel to be connected to the pixels on the top, bottom, left, and right, select 4. If you want a pixel to be connected to the pixels on the top, bottom, left, right, and diagonally, select 8.

Output label matrix

If you select this check box, the block outputs the label matrix at the Label port.

The Blob Properties pane of the Blob Analysis dialog box appears as shown in the following figure.

Maximum number of blobs

Specify the maximum number of labeled regions in each input image.

Warn if maximum number of blobs is exceeded

If you select this check box, the block produces a warning if the number of blobs in an image is greater than the value you entered for the Maximum number of blobs parameter.

Output number of blobs found

If you select this check box, the block outputs a scalar value that represents the actual number of labeled regions in each image at the Count port.

Specify minimum blob area in pixels

If you select this check box, you can enter the minimum blob area in the edit box that appears beside the check box. Blobs that do not meet this criteria are not labeled. This parameter is tunable.

Specify maximum blob area in pixels

If you select this check box, you can enter the maximum blob area in the edit box that appears beside the check box. Blobs that do not meet this criteria are not labeled. The maximum allowable value is maximum of unit32 data type.

Exclude blobs touching image border

Select this check box if you do not want to label blobs that contain at least one border pixel.

Fill empty spaces in outputs

If you select this check box, the block fills the empty spaces in the statistical vectors with the value(s) you specify in the Fill values parameter.

Fill values

If you enter a scalar value, the block fills all the empty spaces in the statistical vectors with this value. If you enter a vector, it must have the same length as the number of selected statistics. The block uses each vector element to fill a different statistics vector.

The Fixed-point pane of the Blob Analysis dialog box appears as follows. These parameters are applicable only when the Statistics output data type parameter is set to Specify via Fixed-point tab.

Rounding mode

Select the rounding mode for fixed-point operations.

Overflow mode

Select the overflow mode for fixed-point operations.

Product output

As depicted previously, the output of the multiplier is placed into the product output data type and scaling. The product output data type is used during the computation of the equivalent diameter squared. During this computation, the blob area, which is stored in the accumulator, is multiplied by the 4/pi factor. This factor has a word length that is equal to the equivalent diameter squared output data type's word length and a fraction length that is equal to its word length minus two. Use this parameter to specify how to designate this product output word and fraction lengths.

Accumulator

As depicted previously, inputs to the accumulator are cast to the accumulator data type. The output of the adder remains in the accumulator data type as each element of the input is added to it. Use this parameter to specify how to designate this accumulator word and fraction lengths:

Centroid output

Choose how to specify the word length and fraction length of the output at the Centroid port:

Equiv Diam^2 output

Choose how to specify the word length and fraction length of the output at the Diameter^2 port:

Extent output

Choose how to specify the word length and fraction length of the output at the Extent port:

Perimeter output

Choose how to specify the word length and fraction length of the output at the Perimeter port:

Lock scaling against changes by the autoscaling tool

Select this parameter to prevent any fixed-point scaling you specify in this block mask from being overridden by the autoscaling tool in the Fixed-Point Tool. For more information, see fxptdlg, a reference page on the Fixed-Point Tool in the Simulink® documentation.

See Also

Label

Video and Image Processing Blockset

Variable Selector

Signal Processing Blockset

regionprops

Image Processing Toolbox

  


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