MATLAB Answers

Further documentation for regionprops

2 views (last 30 days)
Veena Chatti
Veena Chatti on 9 Jul 2020
Commented: Walter Roberson on 13 Jul 2020
I'm looking for more detailed documentation on the mathematical definition of the Centroid property returned by regionprops. Does anyone know where I can find further information or references?
The MATLAB documentation says that it's the center of mass of a region within a bounding box. I am looking for the precise equation this definition uses.


Sign in to comment.

Answers (1)

Mahesh Taparia
Mahesh Taparia on 13 Jul 2020
Edited: Mahesh Taparia on 13 Jul 2020
The centroid coordinate is the mean of the points coordinates (x and y coordinate values) of each connected component.

  1 Comment

Walter Roberson
Walter Roberson on 13 Jul 2020
Not exactly .
When regionprops is passed a binary matrix, it does connected component detection based upon the binary values. Each connected component detected will have its properties measured. For centroid, the mean of the coordinate values is taken, as Mahesh describes.
When regionprops is passed a label matrix, it rounds down values, ignores locations that are negative or 0, and then for each unique positive integer, all locations in the image with the same (rounded) value are treated as one object. The difference against the binary image case is that objects designated by the same matrix do not need to be connected.
For example if you bwthresh an image and the take double() of the binary array, then that would be a label array in which all of the entries that are 1 are the same object, and so allowing you to get the centroid of everything at the same time.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!