Main Content

vision.BlobAnalysis

Properties of connected regions

Description

To compute statistics for connected regions in a binary image

To track a set of points:

  1. Create the vision.BlobAnalysis object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

Creation

Description

Hblob = vision.BlobAnalysis returns a blob analysis object, H, used to compute statistics for connected regions in a binary image.

example

Hblob = vision.BlobAnalysis(Name,Value) sets properties using one or more name-value pairs. Enclose each property name in quotes. For example, Hblob = vision.BlobAnalysis('AreaOutputPort',true)

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Return blob area, specified as true or false.

Return coordinates of blob centroids, specified as true or false.

Return coordinates of bounding boxes, specified as true or false.

Return vector whose values represent lengths of ellipses' major axes, specified as true or false. Set this property to true 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. This property applies when you set the OutputDataType property to double or single.

Return vector whose values represent lengths of ellipses' minor axes, specified as true or false. Set this property to true 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. This property is available when the OutputDataType property is double or single.

Return vector whose values represent angles between ellipses' major axes and x-axis, specified as true or false. Set this property to true to output a vector whose values represent the angles between the major axes of the ellipses and the x-axis. This property applies when you set the OutputDataType property to double or single.

Return vector whose values represent ellipses' eccentricities, specified as true or false. Set this property to true to output a vector whose values represent the eccentricities of the ellipses that have the same second moments as the region. This property applies when you set the OutputDataType property to double or single.

Return vector whose values represent equivalent diameters squared, specified as true or false. Set this property to true to output a vector whose values represent the equivalent diameters squared.

Return vector whose values represent results of dividing blob areas by bounding box areas, specified as true or false.

Return vector whose values represent estimates of blob perimeter lengths, specified as true or false.

Output data type of statistics, specified as double,single, or Fixed point. Area and bounding box outputs are always an int32 data type. Major axis length, Minor axis length, Orientation and Eccentricity do not apply when you set this property to Fixed point.

Connected pixels, specified as 4 or 8.

Maximum number of labeled regions in each input image, specified as a positive scalar integer. The maximum number of blobs the object outputs depends on both the value of this property, and on the size of the input image. The number of blobs the object outputs may be limited by the input image size.

Minimum blob area in pixels, specified as positive scalar integer.

Tunable: Yes

Maximum blob area in pixels, specified as an integer.

Tunable: Yes

Exclude blobs that contain at least one image border pixel, specified as true or false.

Maximum number of labeled regions in each input image, specified as a positive scalar integer. The maximum number of blobs the object outputs depends on both the value of this property, and on the size of the input image. The number of blobs the object outputs may be limited by the input image size

Fixed-Point Properties

Rounding method for fixed-point operations, specified as 'Floor', 'Ceiling', 'Convergent', 'Nearest' , 'Round' , 'Simplest' , or 'Zero'.

Action to take when integer input is out-of-range, specified as 'Wrap' or 'Saturate'.

Product data type, specified as 'Same as input' or 'Custom'.

Product word and fraction lengths, specified as a scaled numerictype (Fixed-Point Designer) object. This property applies only when you set the AccumulatorDataType property to 'Custom'.

Data type of accumulator, specified as 'Same as product', 'Same as input', or 'Custom'.

Accumulator word and fraction lengths, specified as a scaled numerictype (Fixed-Point Designer) object. This property applies only when you set the AccumulatorDataType property to 'Custom'.

Usage

Description

[area,centroid,bbox] = Hblob(bw)returns the area, centroid, and the bounding box of the blobs when the AreaOutputPort, CentroidOutputPort and BoundingBoxOutputPort properties are set to true. These are the only properties that are set to true by default. If you set any additional properties to true, the corresponding outputs follow the area,centroid, and bbox outputs.

example

[___,majoraxis] = Hblob(bw) computes the major axis length majoraxis of the blobs found in input binary image bw when you set the MajorAxisLengthOutputPort property to true.

[___,minoraxis] = Hblob(bw) computes the minor axis length minoraxis of the blobs found in input binary image BW when you set the MinorAxisLengthOutputPort property to true.

[bw___,orientation] = Hblob(bw) computes the orientation of the blobs found in input binary image bw when you set the OrientationOutputPort property to true.

[___,eccentricity] = Hblob(bw) computes the eccentricity of the blobs found in input binary image bw when you set the EccentricityOutputPort property to true.

[___,EQDIASQ] = Hblob(bw) computes the equivalent diameter squared EQDIASQ of the blobs found in input binary image bw when you set the EquivalentDiameterSquaredOutputPort property to true.

[___,EXTENT] = Hblob(bw) computes the EXTENT of the blobs found in input binary image bw when the ExtentOutputPort property is set to true.

[___,perimeter] = Hblob(bw) computes the perimeter of the blobs found in input binary image bw when you set the PerimeterOutputPort property to true.

[___,label] = Hblob(bw) returns a label matrix label of the blobs found in input binary image bw when you set the LabelMatrixOutputPort property to true.

Input Arguments

expand all

Binary image, specified as a vector or matrix.

Output Arguments

expand all

Number of pixels in labeled regions, specified as a vector

Centroid coordinates, specified as an M-by-2 matrix. M is the number of blobs.

M-by-4 matrix in the format [x y width height], where M represents the number of blobs and [x,y] represents the upper-left corner of the bounding box.

Lengths of major axes of ellipses, specified as a vector.

Lengths of minor axes of ellipses, specified as a vector.

Angles between the major axes of the ellipses and the x-axis, specified as a vector.

Eccentricities of the ellipses, specified as a vector

Equivalent diameter squared, specified as a vector.

Ratio between area and bounding box, specified as a vector. The vector contains the results of dividing the areas of the blobs by the area of their bounding boxes

Estimate of the perimeter length, specified as a vector. The vector contains an estimate of the perimeter length, in pixels, for each blob.

Label matrix, specified as a matrix.

Object Functions

To use an object function, specify the System object™ as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

collapse all

Create the blob analysis object.

hBlob = vision.BlobAnalysis('AreaOutputPort',false,'BoundingBoxOutputPort',false);

Create the blob.

img = logical([0 0 0 0 0 0; ...
 		0 1 1 1 1 0; ...
 		0 1 1 1 1 0; ...
 		0 1 1 1 1 0; ...
 		0 0 0 0 0 0]);

Find the coordinates for the centroid.

centroid = hBlob(img);

Extended Capabilities

Version History

Introduced in R2012a