Calculating Centroids in a Specfic Region of an Image
7 views (last 30 days)
Show older comments
Ibraheem Salim
on 9 Jun 2015
Commented: Image Analyst
on 16 Jun 2015
Hey !
I am here with a question that I am trying to find the total number of centroid in a specific region. Let say I have an image of which I have calculated the centroids,Now i want to calculate the numbers of centroid of some specific region,for example rectangular bottom portion. Hope will get answer ASAP
0 Comments
Accepted Answer
Image Analyst
on 9 Jun 2015
I'll assume you have a list of centroids in arrays xCentroids and yCentroids, and that x1, x2, y1, y2 define your rectangular region. So then
xInRange = xCentroids >= x1 & xCentroids <= x2;
yInRange = yCentroids >= y1 & yCentroids <= y2;
bothInRange = xInRange & yInRange;
% Count the number that are in the rectangular region:
count = sum(bothInRange);
If you have a non-rectangular region, like some arbitrarily shaped blob, then let me know.
2 Comments
Image Analyst
on 16 Jun 2015
I don't know what you want. This algorithm computes the distance from one centroid to the next indexed one, which is kind of meaningless because of the way the indexes are ordered, and it's not even what you asked originally.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!