MATLAB Answers

centroid of an image

Asked by Nagarajan sivathanu on 14 Feb 2012
Latest activity Commented on by Dhrubajyoti Das on 28 Oct 2013

I want to find the centroid of an image.How to proceed?



No products are associated with this question.

2 Answers

Answer by Chandra Kurniawan
on 14 Feb 2012
 Accepted answer


did you mean 'find centroid of objects in an image'??

use regionprops with property : centroid

Eg : stat = regionprops(Ilabel,'centroid');

I = imread('coins.png');
Ibw = im2bw(I);
Ibw = imfill(Ibw,'holes');
Ilabel = bwlabel(Ibw);
stat = regionprops(Ilabel,'centroid');
imshow(I); hold on;
for x = 1: numel(stat)


Answer by Sean Lawson
on 14 Feb 2012

Broad question, if the image is your input, simply find the center of the image. But I assume you are asking a more complicated question: like find the centroid of a specific object in an image? if so, need to segment the object out of the image, then find the center point.


Dhrubajyoti Das on 25 Sep 2013

I want to find the centroid of a face but the face is not in the center of the image... How to find the centroid. Can you please give an answer

Image Analyst
on 25 Sep 2013

Start your own new discussion. And be sure to attach your image.

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!