MATLAB Answers

centroid of an image

조회 수: 455(최근 30일)
I want to find the centroid of an image.How to proceed?

  댓글 수: 1

Dipti S
Dipti S 1 Mar 2019
Something like
centers = stats1.Centroid;

Sign in to comment.

채택된 답변

Chandra Kurniawan
Chandra Kurniawan 14 Feb 2012
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)

  댓글 수: 1

J Shaw
J Shaw 20 Feb 2018
If I use this code, I get a centroid array that has 255 elements. What is the meaning for each element? Thanks!

Sign in to comment.

추가 답변(1개)

Sean Lawson
Sean Lawson 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.

  댓글 수: 4

표시 이전 댓글 수: 1
Image Analyst
Image Analyst 25 Sep 2013
Start your own new discussion. And be sure to attach your image.
Dhrubajyoti Das
Dhrubajyoti Das 28 Oct 2013
Biswas Lohani V K
Biswas Lohani V K 25 Jan 2016
HEllo everyone, What is the syntax for this bb = stats(object).BoundingBox; bc = stats(object).Centroid;
could you please define how this code works
Thank you

Sign in to comment.

Translated by