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

조회 수: 2(최근 30일)
Richard Hall
Richard Hall 2020년 3월 27일
댓글: Richard Hall 2020년 3월 27일
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?

채택된 답변

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

댓글을 달려면 로그인하십시오.

추가 답변(0개)



Community Treasure Hunt

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

Start Hunting!

Translated by