No BSD License  

Highlights from
Centroid Calculation Function

3.61538

3.6 | 13 ratings Rate this file 51 Downloads (last 30 days) File Size: 723 Bytes File ID: #5457

Centroid Calculation Function

by

 

11 Jul 2004 (Updated )

Calculates centroid of an object present in an image.

| Watch this File

File Information
Description

Function takes a picture as an argument (suitably should contain only one object whose centroid is to be obtained) and returns the x and y coordinates of its centroid.

Required Products Image Processing Toolbox
MATLAB release MATLAB 6.5 (R13)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (14)
03 Jun 2012 Mohammad Ali Bagheri

the following code is easier and faster:
X_hist=sum(image,1);
Y_hist=sum(image,2);
X=1:N; Y=1:M;
centX=sum(X.*X_hist)/sum(X_hist);
centY=sum(Y'.*Y_hist)/sum(Y_hist);

Besides, you may use "meshgrid" command instead of defining x variable in your code (i.e. x=meshgrid(1:columns,1:rows);)

10 Mar 2010 Anton Kylling

Calculates the centroid of the entire image.

21 May 2008 Kameron Rausch

This is a first order centroiding algorithm but is not suitable for determining the centroids of objects when a background in present.

02 Apr 2008 Javeria Malik

thanks fahad this is the first step of my project implementation
Many thanks

18 Mar 2008 Anonimous -

Thanks a lot for this code. It will be very useful for me =)

02 Mar 2008 islam ali

thank you for this code but if there is shadow of object in pic. can this code measure the real C.G of the object

11 Dec 2007 Asma Mughal

it helped me im my Computer Vision Assignment

16 Nov 2007 Steve Jenkins  
10 Mar 2007 c koley

no

08 Dec 2006 saga y  
17 Nov 2006 Shirley Hui

Works well.

06 Sep 2006 Lester Chong

Simple to implement. With instructions

06 Oct 2005 shaun truong  
10 Aug 2005 Carl Fischer

quick and useful. Save yourself a few minutes of coding.

Contact us