Products & Services Solutions Academia Support User Community Company

Learn more about Video and Image Processing Blockset   

Blob Analysis - 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 quantities such as the Centroid, label matrix, and blob count.

The Blob Analysis block supports variable size signals at the input and output.

For information on pixel and spatial coordinate system definitions, 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

Dialog Box

Use the check boxes to specify the statistics values you want the block to output. The following table summarizes the Blob Analysis block 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.

Main tab

The following table describes parameters that appear in the Main tab of Blob Analysis.

Parameter

Value

Area

Select this check box to output a vector that represents the number of pixels in labeled regions

Centroid

Select this check box to output a 2-by-N matrix. The columns represent the coordinates of the centroid of each region, where N is the number of blobs.

Example: Suppose there are two blobs, where the row and column coordinates of their centroids are r1, c1 and r2, c2, respectively. The block outputs

at the Centroid port.

Bounding box

Select this check box to output a 4-by-N matrix. The columns represent the coordinates of each bounding box, where N is the number of blobs.

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. Wherew and h define the width and height of the bounding box. The block outputs

at the BBox port.

Major axis length

Select this check box to output a vector with the following characteristics:

  • Represents the lengths of the major axes of ellipses

  • Has the same normalized second central moments as the labeled regions

Minor axis length

Select this check box to output a vector with the following characteristics:

  • Represents the lengths of the minor axes of ellipses

  • Has the same normalized second central moments as the labeled regions

Orientation

Select this check box to output a 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

Select this check box to output a vector that represents the eccentricities of ellipses that have the same second moments as the region

Equivalent diameter squared

Select this check box to output a vector that represents the equivalent diameters squared

Extent

Select this check box to output a vector that represents the results of dividing the areas of the blobs by the area of their bounding boxes

Perimeter

Select this check box to output an N-by-1 vector of the perimeter lengths, in pixels, of each blob, where N is the number of blobs.

Statistics output data typeUse this parameter to specify the data type of the outputs at the Centroid, MajorAxis, MinorAxis, Orientation, Eccentricity, Equivalent diameter squared, and Extent ports. If you select Fixed-point, the block cannot calculate the major axis, minor axis, orientation, or eccentricity and the associated check boxes become unavailable.
ConnectivityUse this parameter to define which pixels connect to each other. If you want to connect pixels located on the top, bottom, left, and right, select 4. If you want to connect pixels 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. For example:

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 .

Output label matrixSelect this check box, to output the label matrix at the Label port. The pixels equal to 0 represent the background. The pixels equal to 1 represent the first object. The pixels equal to 2 represent the second object, and so on.

Blob Properties tab

The following table describes the parameters of the Blob Properties tab.

Parameter

Value

Maximum number of blobs

Specify the maximum number of labeled regions in each input image. The block uses this value to preallocate vectors and matrices to ensure that they are long enough to hold the statistical values.

Warn if maximum number of blobs is exceeded

Select this check box to output a warning when the number of blobs in an image is greater than the value of Maximum number of blobs parameter.

Output number of blobs found

Select this check box to output a scalar value that represents the actual number of connected regions in each image at the Count port.

Specify maximum blob area in pixels

Select this check box to enter the minimum blob area in the edit box that appears beside the check box. The blob gets a label if the number of pixels meets the minimum size specified. The maximum allowable value is the maximum of unit32 data type. This parameter is tunable.

Exclude blobs touching image border

Select this check box to exclude a labeled blob that contains at least one border pixel.

Output blob statistics as a variable-size signal

Select this check box to output blob statistics as a variable-size signal. Selecting this check box means that you do not need to specify fill values.

Fill empty spaces in outputs outputs

Select this check box to fill empty spaces in the statistical vectors with the values you specify in the Fill values parameter.

The Fill empty spaces in outputs check box does not appear when you select the Output blob statistics as a variable-size signal check box.

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. If the empty spaces do not affect your computation, you can deselect the Fill empty spaces in outputs check box. As a best practice, leave this check box selected.

The Fill values parameter is not visible when you select the Output blob statistics as a variable-size signal check box.

Fixed-Point Data Types

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

The parameters on the Fixed-point tab apply only when you set the Statistics output data type parameter to Specify via Fixed-point tab.

Parameter

Value

Rounding mode

Select the rounding mode Floor, Ceiling, Nearest or Zero for fixed-point operations.

Overflow mode

Select the overflow mode, Wrap or Saturate for fixed-point operations.

Product output

When you select Binary point scaling, you can enter the Word length and the Fraction length of the product output, in bits.

When you select Slope and bias scaling, you can enter the Word length in bits, and the Slope of the product output. All signals in the Video and Image Processing Blockset software have a bias of 0.

The block places the output of the multiplier into the Product output data type and scaling. The computation of the equivalent diameter squared uses the product output data type. During this computation, the block multiplies the blob area (stored in the accumulator) by the 4/pi factor. This factor has a word length that equals the value of Equivalent diameter squared output data type Word length. The value of the Fraction length equals its word length minus two. Use this parameter to specify how to designate this product output word and fraction lengths.

Accumulator

When you select Same as product output the characteristics match the characteristics of the product output.

When you select Binary point scaling, you can enter the Word length and the Fraction length of the accumulator, in bits.

When you select Slope and bias scaling, you can enter the Word length, in bits, and the Slope of the Accumulator. All signals in the Video and Image Processing Blockset software have a bias of 0.

Inputs to the Accumulator get cast to the accumulator data type. Each element of the input gets added to the output of the adder, which remains in the accumulator data type. 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:

  • When you select Same as accumulator, these characteristics match the characteristics of the accumulator.

  • When you select Binary point scaling, you can enter the Word length and Fraction length of the output, in bits.

  • When you select Slope and bias scaling, you can enter the Word length, in bits, and the Slope of the output. All signals in the Video and Image Processing Blockset software have a bias of 0.

Equiv Diam^2 output

Choose how to specify the Word length and Fraction length of the output at the Diameter ^2 port:

  • When you select Same as accumulator, these characteristics match the characteristics of the Accumulator.

  • When you select Same as product output, these characteristics match the characteristics of the Product output.

  • When you select Binary point scaling, you can enter the Word length and Fraction length of the output, in bits.

  • When you select Slope and bias scaling, you can enter the Word length, in bits, and the Slope of the output. All signals in the Video and Image Processing Blockset software have a bias of 0.

Extent output

Choose how to specify the Word length and Fraction length of the output at the Extent port:

  • When you select Same as accumulator, these characteristics match the characteristics of the accumulator.

  • When you select Binary point scaling, you can enter the Word length and Fraction length of the output, in bits.

  • When you select Slope and bias scaling, you can enter the Word length, in bits, and the Slope of the output. All signals in the Video and Image Processing Blockset software have a bias of 0.

Fill in empty spaces outputs

Select this check box to fill empty spaces in the statistical vectors with the value you specify in the Fill values parameter.

The Fill empty spaces in outputs check box is not visible when you select the Output blob statistics as a variable-size signal check box.

Perimeter output

Choose how to specify the Word length and Fraction length of the output at the Perimeter port:

  • When you select Same as accumulator, these characteristics match the characteristics of the accumulator.

  • When you select Binary point scaling, you can enter the Word length and Fraction length of the output, in bits.

  • When you select Slope and bias scaling, you can enter the word length, in bits, and the Slope of the output. All signals in the Video and Image Processing Blockset software have a bias of 0.

Lock scaling against changes by the autoscaling tool

Select this parameter to prevent the autoscaling tool in the Fixed-Point Tool overriding any fixed-point scaling you specify in this block mask. 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

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

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