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

Réponses (2)

Image Analyst
Image Analyst le 6 Avr 2017

0 votes

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 le 6 Avr 2017

0 votes

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 commentaire

Yuri Minami
Yuri Minami le 6 Avr 2017
Thank you. yes I want to know the center of mass of a blighter area.

Connectez-vous pour commenter.

Produits

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by