Main Content

regionprops3

Measure properties of 3-D volumetric image regions

Description

example

stats= regionprops3(BW,properties)measures a set of properties for each connected component (object) in the 3-D volumetric binary imageBW. The outputstatsdenote different properties for each object.

For all syntaxes, you can omit thepropertiesargument. In this case,regionprops3returns the"Volume","Centroid","BoundingBox"measurements.

stats= regionprops3(CC,properties)measures a set of properties for each connected component (object) inCC, which is a structure returned bybwconncomp.

stats= regionprops3(L,properties)measures a set of properties for each labeled region in the 3-D label imageL.

stats= regionprops3(___,V,properties)measures a set of properties for each labeled region in the 3-D volumetric grayscale imageV. The first input (BW,CC, orL) identifies the regions inV.

Examples

collapse all

Create a binary image with two spheres.

[x,y,z] = meshgrid(1:50,1:50,1:50); bw1 = sqrt((x-10).^2 + (y-15).^2 + (z-35).^2) < 5; bw2 = sqrt((x-20).^2 + (y-30).^2 + (z-15).^2) < 10; bw = bw1 | bw2;

Get the centers and radii of the two spheres.

s = regionprops3(bw,"Centroid",“公关incipalAxisLength"); centers = s.Centroid
centers =2×320 30 15 10 15 35
diameters = mean(s.PrincipalAxisLength,2)
diameters =2×119.9641 9.8241
radii = diameters/2
radii =2×19.9820 4.9120

Make a 9-by-9 cube of 0s that contains a 3-by-3 cube of 1s at its center.

innercube = ones(3,3,3); cube_in_cube = padarray(innercube,[3 3],0,'both');

Get all statistics on the cube within the cube.

stats = regionprops3(cube_in_cube,'all')
stats=1×18 tableVolume Centroid BoundingBox SubarrayIdx Image EquivDiameter Extent VoxelIdxList VoxelList PrincipalAxisLength Orientation EigenVectors EigenValues ConvexHull ConvexImage ConvexVolume Solidity SurfaceArea ______ ___________ ___________ ___________________________________ _______________ _____________ ______ _____________ _____________ _______________________ ___________ ____________ ____________ _____________ _______________ ____________ ________ ___________ 27 5 5 2 1x6 double {[4 5 6]} {[4 5 6]} {[1 2 3]} {3x3x3 logical} 3.7221 1 {27x1 double} {27x3 double} 3.873 3.873 3.873 0 0 0 {3x3 double} {3x1 double} {24x3 double} {3x3x3 logical} 27 1 41.07

Input Arguments

collapse all

Volumetric binary image, specified as a 3-D logical array.

Data Types:logical

Connected components of a 3-D volumetric image, specified as a structure returned bybwconncompusing a 3-D connectivity value, such as 6, 18, or 26.CC.ImageSizemust be a 1-by-3 vector.

Data Types:struct

Label image, specified as one of the following.

  • A 3-D numeric array. Voxels labeled0are the background. Voxels labeled1make up one object; voxels labeled2make up a second object; and so on.regionprops3treats negative-valued voxels as background and rounds down input voxels that are not integers. You can get a numeric label image from labeling functions such as分水岭orlabelmatrix.

  • A 3-D categorical array. Each category corresponds to a different region.

Data Types:single|double|int8|int16|int32|uint8|uint16|uint32|categorical

Type of measurement, specified as a comma-separated list of strings or character vectors, a cell array of strings or character vectors,"all"or"basic".

  • If you specify"all", thenregionprops3computes all the shape measurements. If you also specify a grayscale image, thenregionprops3returns all of the voxel value measurements.

  • If you specify"basic"or do not specify thepropertiesargument, thenregionprops3computes only the"Volume","Centroid","BoundingBox"measurements.

The following table lists all the properties that provide shape measurements. TheVoxel Value Measurementstable lists additional properties that are valid only when you specify a grayscale image.

Shape Measurements

Property Name Description
"BoundingBox" Smallest cuboid containing the region, returned as a 1-by-6 vector of the form[ulf_x ulf_y ulf_z width_x width_y width_z].ulf_x,ulf_y,ulf_zspecify the upper-left front corner of the cuboid.width_x,width_y,width_zspecify the width of the cuboid along each dimension.
"Centroid"

Center of mass of the region, returned as a 1-by-3 vector. The three elements specify the (x,y,z) coordinates of the center of mass.

"ConvexHull" Smallest convex polygon that can contain the region, returned as ap-by-3 matrix. Each row of the matrix contains thex-,y-,andz-coordinates of one vertex of the polygon.
"ConvexImage" Image of the convex hull, returned as a volumetric binary image with all voxels within the hull filled in (set toon). The image is the size of the bounding box of the region.
"ConvexVolume" Number of voxels inConvexImage, returned as a scalar.
"EigenValues" Eigenvalues of the voxels representing a region, returned as a 3-by-1 vector.regionprops3uses the eigenvalues to calculate the principal axes lengths.
"EigenVectors" Eigenvectors of the voxels representing a region, returned as a 3-by-3 vector.regionprops3uses the eigenvectors to calculate the orientation of the ellipsoid that has the same normalized second central moments as the region.
"EquivDiameter" Diameter of a sphere with the same volume as the region, returned as a scalar. Computed as(6 *体积/ pi) ^ (1/3).
"Extent" Ratio of voxels in the region to voxels in the total bounding box, returned as a scalar. Computed as the value ofVolumedivided by the volume of the bounding box.[Volume/(bounding box width * bounding box height * bounding box depth)]
"Image" Bounding box of the region, returned as a volumetric binary image that is the same size as the bounding box of the region. Theonvoxels correspond to the region, and all other voxels areoff.
"Orientation"

Euler angles[2], returned as a 1-by-3 vector. The angles are based on the right-hand rule.regionprops3interprets the angles by looking at the origin along thex-,y-,andz-axis representing roll, pitch, and yaw respectively. A positive angle represents a rotation in the counterclockwise direction. Rotation operations are not commutative so they must be applied in the correct order to have the intended effect.

“公关incipalAxisLength" Length (in voxels) of the major axes of the ellipsoid that have the same normalized second central moments as the region, returned as 1-by-3 vector.regionprops3sorts the values from highest to lowest.
"Solidity" Proportion of the voxels in the convex hull that are also in the region, returned as a scalar. Computed asVolume/ConvexVolume.
"SubarrayIdx" Indices used to extract elements inside the object bounding box, returned as a cell array such thatL(idx{:})extracts the elements ofLinside the object bounding box.
"SurfaceArea" Distance around the boundary of the region[1], returned as a scalar.
"Volume" Count of the actual number ofonvoxels in the region, returned as a scalar. Volume represents the metric or measure of the number of voxels in the regions within the volumetric binary image,BW.
"VoxelIdxList" Linear indices of the voxels in the region, returned as ap-element vector.
"VoxelList" 像素点的位置the region, returned as ap-by-3 matrix. Each row of the matrix has the form[x y z]and specifies the coordinates of one voxel in the region.

The voxel value measurement properties in the following table are valid only when you specify a grayscale volumetric image,V.

Voxel Value Measurements

Property Name Description
"MaxIntensity" Value of the voxel with the greatest intensity in the region, returned as a scalar.
"MeanIntensity" Mean of all the intensity values in the region, returned as a scalar.
"MinIntensity" Value of the voxel with the lowest intensity in the region, returned as a scalar.
"VoxelValues" Value of the voxels in the region, returned as ap1的向量,pis the number of voxels in the region. Each element in the vector contains the value of a voxel in the region.
"WeightedCentroid" Center of the region based on location and intensity value, returned as ap-by-3 vector of coordinates. The first element ofWeightedCentroidis the horizontal coordinate (orx-coordinate) of the weighted centroid. The second element is the vertical coordinate (ory协调)。在这rd element is the planar coordinate (orz协调)。

Data Types:char|string|cell

Volumetric grayscale image, specified as a 3-D numeric array. The size of the image must match the size of the binary imageBW, connected component structureCC, or label matrixL.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32

Output Arguments

collapse all

Measurement values, returned as a table. The number of rows in the table corresponds to the number of objects inBW,CC.NumObjects, ormax(L(:)). The variables (columns) in each table row denote the properties calculated for each region, as specified byproperties. If the input image is a categorical label imageL, thenstatsincludes an additional variable with the property"LabelName".

References

[1] Lehmann, Gaetan and David Legland.Efficient N-Dimensional surface estimation using Crofton formula and run-length encoding, The Insight Journal, 2012.https://insight-journal.org/browse/publication/852.

[2]Shoemake, Ken,Graphics Gems IV. Edited by Paul S. Heckbert, Morgan Kaufmann, 1994, pp. 222–229.

Version History

Introduced in R2017b