regionprops( aImage, 'Centroid', 'Image' ) vs regionprops( aImage, 'Centroid' );

3 views (last 30 days)
I am new to MatLab.
I am working with code harvested from the internet that lacks comments.
In one place there is a call:
x = regionprops( aImage, 'Centroid', 'Image' );
and in another place is a call
x = regionprops( aImage, 'Centroid' );
using the same image.
The Help for regionprops is extensive, but I cannot figure outwhat the difference would be between those two calls.
Can somebody fill me in? Is this something that needs to be documented?

Accepted Answer

Walter Roberson
Walter Roberson on 27 Mar 2020
Each option to regionprops() tells it another property to measure and return
  • Centroid: Center of mass of the region, returned as a 1-by-Q vector. The first element of Centroid is the horizontal coordinate (or x-coordinate) of the center of mass. The second element is the vertical coordinate (or y-coordinate). All other elements of Centroid are in order of dimension.
  • Image: Image the same size as the bounding box of the region, returned as a binary (logical) array. The on pixels correspond to the region, and all other pixels are off.
Thus the first of the calls returns a struct into x that has fields Centroid and Image with values as described above, and the second of the calls returns a struct into x that has only field Centroid with value as described above.
The 'Image' option does not change the way that the centroid is computed: it says to also compute something more and return it.
  1 Comment
Richard Hall
Richard Hall on 27 Mar 2020
Wonderful answer.
If only "help regionprops" was as informative in such a clear manner.
Thank you.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!