Effacer les filtres
Effacer les filtres

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

3 vues (au cours des 30 derniers jours)
Richard Hall
Richard Hall le 27 Mar 2020
Commenté : Richard Hall le 27 Mar 2020
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?

Réponse acceptée

Walter Roberson
Walter Roberson le 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 commentaire
Richard Hall
Richard Hall le 27 Mar 2020
Wonderful answer.
If only "help regionprops" was as informative in such a clear manner.
Thank you.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by