centroid of a image

12 views (last 30 days)
Yuri Minami
Yuri Minami on 6 Apr 2017
Commented: Yuri Minami on 6 Apr 2017
I dont undertand how we can find a centroid of a image. I want to know x and y of the place where the centroid is set. Also I want to plot the point in the image.
thank you

Answers (2)

Image Analyst
Image Analyst on 6 Apr 2017
The centroid will be in the center of the image. The "weighted" centroid, or center of mass, will depend on the gray levels in the image. Both can be gotten from regionprops() as my Image Segmentation Tutorial shows: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862&sort=downloads_desc
labeledImage = bwlabel(true(size(grayImage)));
props = regionprops(labeledImage, grayImage, 'Centroid', 'WeightedCentroid');
props is a structure with fields for both of those measurements.

Walter Roberson
Walter Roberson on 6 Apr 2017
The centroid of an image is always at the exact center of the image. Every pixel has the same "weight" as every other pixel for the purposes of determining centroids.
If you want bright pixels to be more important than dark pixels, then possibly you are interested in centre of mass rather than centroid.
If you want to find the centroid of a portion of the image, then create an ROI (a binary mask) and use regionprops() to calculate its centroid.
  1 Comment
Yuri Minami
Yuri Minami on 6 Apr 2017
Thank you. yes I want to know the center of mass of a blighter area.

Sign in to comment.

Tags

Products

Community Treasure Hunt

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

Start Hunting!