what does centroid of an image indicates exactly

2 views (last 30 days)
I measured centroid of an image using regionprops. I got 14 values.. 7 rows with 2 columns... what it indicates?

Accepted Answer

Image Analyst
Image Analyst on 11 May 2013
It is the non-weighted center of your binary blobs. If you have 7 rows, then you have 7 blobs. Did you look at the help? Because it's explained in the help:
'Centroid' 1-by-Q vector that specifies the center of mass of the region. Note that the first element of Centroid is the horizontal coordinate(or x-coordinate) of the center of mass, and the second element is the vertical coordinate (or y-coordinate). All other elements of Centroid are in order of dimension.
I'm pretty sure you must have seen that already, so what in there does not answer your question?
  5 Comments
Walter Roberson
Walter Roberson on 31 May 2019
Suppose you have a binary image (logical) that has only one connected region. Then if you use regionprops() and ask for Centroid, then the centroid returned will be the centroid of that one region.
Suppose you have a binary image (logical) that has more than one connected region. Then if you use regionprops() and ask for Centroid, then you will get one centroid returned for each disconnected region.
Suppose now that you have a integer or floating point (numeric, not logical) that has values 0 and 1 in several discontinuous regions. THen if you use regionprops() and ask for Centroid, then you will get one overall centroid returned.
So if you pass logical values, then MATLAB assumes that each disconnected area is a distinct region. However, if you pass non-logical values, then MATLAB assumes that each distinct numeric value is a region even if there are different islands of that value.
Image Analyst
Image Analyst on 31 May 2019
Demo to illustrate:
data = uint8([1,0,1,1,0, 1]) % Integer
props = regionprops(data)
allAreas = [props.Area]
numRegions = length(props)
allAreas = [props.Area]
data = logical([1,0,1,1,0, 1]) % Logical/binary/boolean
props = regionprops(data)
allAreas = [props.Area]
numRegions = length(props)
allAreas = [props.Area]
First one gives one region, second one gives 3 regions.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!