Image Processing Toolbox User's Guide |
10. Measure Object Properties in the Image
The regionprops
command measures object or region properties in an image and returns them in a structure array. When applied to an image with labeled components, it creates one structure element for each component.
This example uses regionprops
to create a structure array containing some basic properties for labeled
. When you set the properties
parameter to 'basic'
, the regionprops
function returns three commonly used measurements: area, centroid (or center of mass), and bounding box. The bounding box represents the smallest rectangle that can contain a region, or in this case, a grain of rice.
To find the area of the 51st labeled component, access the Area
field in the 51st element in the graindata
structure array. Note that structure field names are case sensitive.
To find the smallest possible bounding box and the centroid (center of mass) for the same component, use this code:
graindata(51).BoundingBox, graindata(51).Centroid ans = 107.5000 4.5000 13.0000 20.0000 ans = 114.5000 15.4500
9. Display the Label Matrix as a Pseudocolor Indexed Image | 11. Compute Statistical Properties of Objects in the Image |
© 1994-2005 The MathWorks, Inc.