Properties of connected regions
The BlobAnalysis
object computes statistics
for connected regions in a binary image.
Use the step
syntax below with input binary
image, BW
, blob analysis object, H
,
and any optional properties. The step
method computes
and returns statistics of the input binary image depending on the
property values specified. The order of the returned values when there
are multiple outputs are in the order they are described below:
[AREA,CENTROID,BBOX] = step(
returns
the area, centroid and the bounding box of the blobs when the H
,BW
)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.
[___,
computes
the major axis length MAJORAXIS
]
= step(H
,BW
)MAJORAXIS
of the blobs
found in input binary image BW
when the MajorAxisLengthOutputPort
property is set
to true
.
[___,
computes
the minor axis length MINORAXIS
]
= step(H
,BW
)MINORAXIS
of the blobs
found in input binary image BW
when the MinorAxisLengthOutputPort
property is set
to true
.
[___,
computes
the ORIENTATION
]
= step(H
,BW
)ORIENTATION
of the blobs found in input
binary image BW
when the OrientationOutputPort
property
is set to true
.
[___,
computes
the ECCENTRICITY
]
= step(H
,BW
)ECCENTRICITY
of the blobs found in input
binary image BW
when the EccentricityOutputPort
property
is set to true
.
[___,
computes
the equivalent diameter squared EQDIASQ of the blobs found in input
binary image EQDIASQ
]
= step(H
,BW
)BW
when the EquivalentDiameterSquaredOutputPort
property
is set to true
.
[___,
computes
the EXTENT of the blobs found in input binary image EXTENT
]
= step(H
,BW
)BW
when the ExtentOutputPort
property is set to true
.
[___,
computes
the PERIMETER
]
= step(H
,BW
)PERIMETER
of the blobs found in input binary
image BW
when the PerimeterOutputPort
property
is set to true
.
[___,
returns
a label matrix LABEL
]
= step(H
,BW
)LABEL
of the blobs found in input
binary image BW
when the LabelMatrixOutputPort
property
is set to true.
Input/Output  Format  Supported Data Types 

BW  Vector or matrix that represents a binary image  Boolean 
AREA  Vector that represents the number of pixels in labeled regions  32bit signed integer 
CENTROID  Mby2 matrix of centroid coordinates, where M represents the number of blobs 

BBOX  Mby4 matrix of [x y width height] bounding box coordinates, where M represents the number of blobs and [x y] represents the upper left corner of the bounding box.  32bit signed integer 
MAJORAXIS  Vector that represents the lengths of major axes of ellipses 

MINORAXIS  Vector that represents the lengths of minor axes of ellipses  Same as MajorAxis port 
ORIENTATION  Vector that represents the angles between the major axes of the ellipses and the xaxis.  Same as MajorAxis port 
ECCENTRICITY  Vector that represents the eccentricities of the ellipses  Same as MajorAxis port 
EQDIASQ  Vector that represents the equivalent diameters squared  Same as Centroid port 
EXTENT  Vector that represents the results of dividing the areas of the blobs by the area of their bounding boxes  Same as Centroid port 
PERIMETER  Vector containing an estimate of the perimeter length, in pixels, for each blob  Same as Centroid port 
LABEL  Label matrix  8, 16, or 32bit unsigned integer 
Starting in R2016b, instead of using the step
method
to perform the operation defined by the System
object™, you can
call the object with arguments, as if it were a function. For example, y
= step(obj,x)
and y = obj(x)
perform
equivalent operations.
H = vision.BlobAnalysis
returns
a blob analysis System object, H
, used to compute
statistics for connected regions in a binary image.
H = vision.BlobAnalysis(
returns
a blob analysis object, Name
,Value
)H
, with each specified property
set to the specified value. You can specify additional namevalue
pair arguments in any order as (Name1
, Value1
,...,NameN
,ValueN
).

Return blob area Setting this property to 

Return coordinates of blob centroids Set this property to 

Return coordinates of bounding boxes Set this property to 

Return vector whose values represent lengths of ellipses' major axes Set this property to 

Return vector whose values represent lengths of ellipses' minor axes Set this property to 

Return vector whose values represent angles between ellipses' major axes and xaxis Set this property to true to output a vector whose values represent
the angles between the major axes of the ellipses and the xaxis.
This property applies when you set the 

Return vector whose values represent ellipses' eccentricities Set this property to 

Return vector whose values represent equivalent diameters squared Set this property to 

Return vector whose values represent results of dividing blob areas by bounding box areas Set this property to 

Return vector whose values represent estimates of blob perimeter lengths Set this property to 

Output data type of statistics Specify the data type of the output statistics as


Which pixels are connected to each other Specify connectivity of pixels as 

Return label matrix Set this property to 

Maximum number of labeled regions in each input image Specify the maximum number of blobs in the input image 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.
The default is 

Minimum blob area in pixels Specify the minimum blob area in pixels. The default is


Maximum blob area in pixels Specify the maximum blob area in pixels. The default is


Exclude blobs that contain at least one image border pixel Set this property to 
step  Compute and returns statistics of input binary image 
Common to All System Objects  

clone  Create System object with same property values 
getNumInputs  Expected number of inputs to a System object 
getNumOutputs  Expected number of outputs of a System object 
isLocked  Check locked states of a System object (logical) 
release  Allow System object property value changes 
Find the centroid of a blob.
hblob = vision.BlobAnalysis; hblob.AreaOutputPort = false; hblob.BoundingBoxOutputPort = false; 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]); centroid = step(hblob, img); % [x y] coordinates of the centroid
This object implements the algorithm, inputs, and outputs described on the Blob Analysis block reference page. The object properties correspond to the block parameters, except:
The Warn if maximum number of blobs is exceeded block parameter does not have a corresponding object property. The object does not issue a warning.
The Output blob statistics as a variablesize signal block parameter does not have a corresponding object property.