Sign in

Not a member? | Forgot your Password?

Search matlab

Search tips

Subscribe to matlab

Search tips

Free PDF Downloads

A Quadrature Signals Tutorial: Complex, But Not Complicated

Understanding the 'Phasing Method' of Single Sideband Demodulation

Complex Digital Signal Processing in Telecommunications

Introduction to Sound Processing

C++ Tutorial

Introduction of C Programming for DSP Applications

Fixed-Point Arithmetic: An Introduction

Cascaded Integrator-Comb (CIC) Filter Introduction

Discussion Groups

FIR Filter Design Software

See Also

Embedded SystemsFPGA

Discussion Groups | Matlab DSP | how to find centroid of an object in an image???

Technical discussion about Matlab and issues related to Digital Signal Processing.


Post a new Thread

Is this thread worth a thumbs up?


how to find centroid of an object in an image??? - DXT_77 - May 23 4:58:00 2003

hi every body,

i have an image which has a picture of a ball in it
and i want to find the centroid of that ball
so when i display it on a 2dplot i know the exact pixel coord
and then i can find it's real coord.
the problem is i don't know how how to find or the formula for
centroid of an object?

thanks for any help,


Re: how to find centroid of an object in an image??? - Zahra A Shah - May 23 15:00:00 2003

Are you working with binary images. If so, then the following code will help you find the centroid of the image:
% read the image
i = imread('ball.bmp');
% convert to double
i = double(i);
% invert the image so that we can label the image
% the invert function is not given in the DIP toolbox
% i am attaching it with this email
i = invert(i);
% apply 8-connected algo
[labels,count] = bwlabel(i,8);
% calculate features. For more type help imfeature
features = imfeature(labels,'Centroid');
i = 1;
while i <= count
        % display centroid of all the subimages in the image
       i = i + 1;
Hope this helps.
Good luck

Zahra Atiq Shah

It's Samaritans' Week. Help Samaritans help others.
Call 08709 000032 to give or donate online now at

Attachment (not stored)
Type: application/octet-stream