what does centroid of an image indicates exactly

I measured centroid of an image using regionprops. I got 14 values.. 7 rows with 2 columns... what it indicates?

 Accepted Answer

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

as u told i got this from matlab help. i need to find distance between two legs of a walking person video. i used regionprops(centroid).so, trying to justify the answer from centroid
Still not sure what your problem is though. The center of mass does not have to be in the region. You know that, right? Like the centroid of V, C, L, or almost any other alphabet letter does not lie in the solid part of the letter. Similarly if you have the legs as an upside down V, and they're connected (all one object), then there will be one centroid that is between the legs.
i want to find the centroid to know the motion of the person between the frames of the video.
project topic is-girl jumping rope in the video. So how can I do it. PLease help me.
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.
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!