ComponentMeasurements

ComponentMeasurements[{image,lmat},"prop"]

computes the property "prop" for components of image indicated by the label matrix lmat.

ComponentMeasurements[image,"prop"]

computes the property "prop" for connected components of image.

ComponentMeasurements[,"prop",crit]

only returns measurements for components that satisfy the criterion crit.

ComponentMeasurements[,"prop",crit,format]

formats the result according to the output specification format.

Details and Options

  • ComponentMeasurements can be used to compute different properties for all or some of the components in an image.
  • ComponentMeasurements works with 2D or 3D images and label matrices.
  • A label matrix lmat is an array of non-negative integers, in which each integer represents a component, and 0 represents the background.
  • ComponentMeasurements[,"prop"] returns an expression of the form {,i->vali,}, where vali is the value of "prop" computed for component i of the image.
  • ComponentMeasurements[,{"prop1","prop2",}] computes multiple properties for each component.
  • When using a criterion crit, arguments of crit can access property values using #j referring to "propj" given in the list of properties. A component is selected if crit returns True.
  • The criterion crit can also access other component properties using #propname.
  • ComponentMeasurements[,"Properties"] gives the names of supported properties for the given input as a list of strings. All properties are not supported for all inputs.
  • Properties related to area measurements:
  • "Count"number of elements
    "Area"approximate area, where each pixel area is weighted by its neighborhood configuration
    "FilledCount"number of elements after filling holes
    "EquivalentDiskRadius"radius of a disk that has the same area
    "AreaRadiusCoverage"fraction of pixels within the equivalent disk radius
  • Perimeter properties:
  • "AuthalicRadius"radius of a circle with the same polygonal perimeter length
    "MaxPerimeterDistance"largest distance of an inner element to the perimeter
    "OuterPerimeterCount"number of elements adjacent to the component
    "PerimeterCount"number of elements on the perimeter
    "PerimeterLength"total length of outer pixel sides
    "PerimeterPositions"sorted positions of the perimeter elements
    "PolygonalLength"total length of the polygon formed by the centers of the perimeter elements
  • Position, area, and length measurements are taken in the standard image coordinate system.
  • Centroid properties:
  • "Centroid"center of mass coordinates
    "Medoid"coordinate of the closest element to the centroid
    "MeanCentroidDistance"mean distance of all elements from the centroid
    "MaxCentroidDistance"maximum distance of all elements from the centroid
    "MinCentroidDistance"minimum distance of all elements from the centroid
  • Parameters of the oriented best-fit ellipse:
  • "Length"largest axis of the best-fit ellipse
    "Width"smallest axis of the best-fit ellipse
    "SemiAxes"lengths of the semiaxes of the best-fit ellipse
    "Orientation"angle between the largest axis and the horizontal axis
    "Elongation"elongation, computed as
    "Eccentricity"eccentricity of the best-fit ellipse
  • Shape measurements:
  • "Circularity", with polygonal length and equivalent disk radius
    "FilledCircularity"circularity after filling holes
    "Rectangularity"fraction of pixels within the minimal bounding box
  • Bounding contour properties:
  • "Contours"lines describing the component boundary
    "ContourHierarchy"topological nesting of the contours
  • Bounding box properties:
  • "BoundingBox"axes-oriented bounding box in the form {{xmin,ymin},{xmax,ymax}}
    "BoundingBoxArea"area enclosed by the bounding box
    "MinimalBoundingBox"smallest possible oriented bounding box defined by the four corner vertices
  • Bounding disk properties:
  • "BoundingDiskCenter"bounding disk center coordinates
    "BoundingDiskRadius"bounding disk radius
    "BoundingDiskCoverage"coverage of bounding disk area by the component area
  • Convex hull properties:
  • "ConvexCount"number of elements included in the convex hull
    "ConvexVertices"corner elements of the convex hull
    "ConvexArea"area of the convex hull polygon
    "ConvexPerimeterLength"length of the convex hull polygon
    "ConvexCoverage"fraction of elements occupied in the convex hull
    "CaliperLength"largest diameter of the convex hull (Feret diameter)
    "CaliperWidth"smallest diameter of the convex hull
    "MeanCaliperDiameter"mean of all possible caliper diameters
    "CaliperElongation"1 (caliper width/caliper height)
  • Neighborhood properties:
  • "Neighbors"direct neighbors, given as a set of labels
    "NeighborCount"number of direct neighbors
    "ExteriorNeighbors"labels of exterior neighbors
    "ExteriorNeighborCount"number of exterior neighbors
    "InteriorNeighbors"labels of interior neighbors
    "InteriorNeighborCount"number of interior neighbors
    "AdjacentBorders"list of adjacent image borders
    "AdjacentBorderCount"number of adjacent image borders
  • Basic topological properties:
  • "Fragmentation"number of connected components minus one
    "Holes"number of holes in each component
    "Complexity"total number of components and holes minus one
    "EulerNumber"number of components minus the number of holes
  • Relational topological properties:
  • "EmbeddedComponents"embedded components, given as a list of labels
    "EmbeddedComponentCount"number of embedded components
    "EnclosingComponents"enclosing components, given as a list of labels
    "EnclosingComponentCount"number of enclosing components (nesting level)
  • General properties:
  • "Label"label of the component
    "Mask"binary mask given as an array
    "Shape"shape of the component given as a binary image
  • Pixel value measurements can be computed only if input is of the form image or {m,image}.
  • If both image and m are present, they should be commensurate.
  • The following pixel value measurements are available.
  • Basic pixel value measurements:
  • "Data"image data given as a flat list of channel vectors
    "IntensityData"list of image intensity values
  • Subimage extractions:
  • "Image"content of the image for each component bounding box
    "MaskedImage"subimage masked by the component shape
  • Basic histogram properties, measured for each channel individually, in each component:
  • "Min"minimum value
    "Max"maximum value
    "Mean"average value
    "Median"median value
    "StandardDeviation"standard deviation
    "Total"total of all values
  • Basic image intensity properties:
  • "MinIntensity"minimum intensity
    "MaxIntensity"maximum intensity
    "MeanIntensity"average intensity
    "MedianIntensity"median intensity
    "StandardDeviationIntensity"standard deviation of the intensity distribution
    "TotalIntensity"total intensity
  • Spatial intensity measurements:
  • "Skew"asymmetry in intensity distribution
    "IntensityCentroid"coordinates of the intensity-weighted centroid
  • Statistical measurements:
  • "Entropy"data entropy (base E)
    "Energy"data energy
  • Component-independent global properties:
  • "LabelCount"total number of labels
    "Dimensions"dimensions of the entire input
  • The following format specifications can be used:
  • "ComponentList"a list of i->{,valj,} (default)
    "ComponentAssociation"an association of i->{,valj,}
    "PropertyAssociation"an association of propj->{,vali,}
    "ComponentPropertyAssociation"an association of i-><|,propj->valj,|>
    "PropertyComponentAssociation"an association of propj-><|,i->vali,|>
    "Dataset"a Dataset of component property association
  • ComponentMeasurements takes a CornerNeighbors option. The default setting is CornerNeighbors->True.
  • For images of type "Byte" or "Bit16", data values are normalized to lie between 0 and 1 when computing pixel value properties.

Examples

open allclose all

Basic Examples  (2)

Measure a property for connected components in an image:

Measure a property only for larger components:

Scope  (24)

Data  (7)

Measurements of a 2D integer label matrix:

Measurements of a 2D image component based on connectivity of its nonzero pixels:

Pixel value measurements of a 2D image:

Pixel value measurements of a 2D color image:

Pixel value measurement of a 2D color image and its corresponding label matrix:

Measurements of a 3D integer label matrix:

Measure properties in 3D:

Properties  (7)

Size measurements:

Sizes of filled components:

Centroid positions:

Lengths of the semiaxes of the best-fit ellipsoids:

Axes-oriented bounding boxes:

List of adjacent borders:

Compute multiple properties:

Criteria  (5)

Select based on the computed property:

Select based on a different property:

Select based on multiple computed properties:

Use a set of properties for selection that is different from those being measured and returned:

Specify what computed property should be used as each function argument:

Output Format  (5)

Format the output as an association of components and component-property values:

Format the output as an association of properties and component-property values:

Format the output as a nested association of components and component-property values:

Format the output as a nested association of properties and component-property values:

Format the output as a dataset of components and component-property values:

Options  (2)

CornerNeighbors  (2)

By default, components are assumed to be connected if they have corner neighbors:

Assume four-connectedness:

By default, all eight neighbors of a cell are treated as adjacent:

Consider only the four direct neighbors as adjacent:

Applications  (5)

Find sickle cells:

Compute the mean color value for each component:

Select complete and non-overlapping cells:

Binarize the image to get the foreground:

Compute centroids and equivalent disk radius of image-enclosed large components:

Highlight selected components:

Replace each pixel with a property of a component to which it belongs:

Compute an image segmentation:

Replace each segment with its mean color:

Use mean intensity of each component:

Compute the connectivity graph of a cartographic map:

Properties & Relations  (8)

Compute measurements for large components only:

Use DeleteSmallComponents to delete small components first:

Notice that labels are normalized:

Compute measurements for components not touching the image borders:

Use DeleteBorderComponents to delete border components first:

Compute for components with one hole, not touching the image borders:

Use SelectComponents to delete components that either do not have holes or touch borders:

Extract the complete list of properties supported for 2D images:

Extract the complete list of properties supported for 3D images:

List of 2D shape properties, when no image is specified:

List of 3D shape properties, when no image is specified:

Extract a list of properties that use pixel values:

Possible Issues  (2)

Some properties cannot be defined for certain components:

Some properties cannot yet be computed for 3D images and label matrices:

Wolfram Research (2010), ComponentMeasurements, Wolfram Language function, https://reference.wolfram.com/language/ref/ComponentMeasurements.html (updated 2017).

Text

Wolfram Research (2010), ComponentMeasurements, Wolfram Language function, https://reference.wolfram.com/language/ref/ComponentMeasurements.html (updated 2017).

CMS

Wolfram Language. 2010. "ComponentMeasurements." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017. https://reference.wolfram.com/language/ref/ComponentMeasurements.html.

APA

Wolfram Language. (2010). ComponentMeasurements. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ComponentMeasurements.html

BibTeX

@misc{reference.wolfram_2023_componentmeasurements, author="Wolfram Research", title="{ComponentMeasurements}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/ComponentMeasurements.html}", note=[Accessed: 19-April-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_componentmeasurements, organization={Wolfram Research}, title={ComponentMeasurements}, year={2017}, url={https://reference.wolfram.com/language/ref/ComponentMeasurements.html}, note=[Accessed: 19-April-2024 ]}