Image Processing Toolbox User's Guide Previous page   Next Page

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.

MATLAB responds with

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.

returns the following results

To find the smallest possible bounding box and the centroid (center of mass) for the same component, use this code:

Previous page  9. Display the Label Matrix as a Pseudocolor Indexed Image 11. Compute Statistical Properties of Objects in the Image Next page

© 1994-2005 The MathWorks, Inc.