Image centroid in matlab

I have about 400 images I need to find its centroid in such a way that all other images have the same centroid in respect to the first image centroid (44.5 79.6). I was able to do it manually by calculating for each image as below.But it quite tedious doing it for 400 images. Please I need help/code that can execute the task.Thanks
Im1 = imread('image1.png');
[x,y] = ait_centroid(Im1);
Im01=uint16(Im1);
Im2 = imread('image2.png');
[x,y] = ait_centroid(Im2);
Im02=circshift(Im2, [-2 -4]); [x,y] = ait_centroid(Im02);
Im02=uint16(Im02);
Im3 = imread('image3.png'); [x,y] = ait_centroid(Im3); Im03=circshift(Im3, [-3 -5]); [x,y] = ait_centroid(Im03); Im03=uint16(Im03);

Answers (1)

Sean de Wolski
Sean de Wolski on 23 Jun 2011

0 votes

You might want to read this:
and this:

2 Comments

kiki
kiki on 23 Jun 2011
Thanks for the links. I have come across them. I quite understand how looping works but question is based on how to write a program that can automatically center each image to say (44.5 79.5) by performing circshifts on each image (depending on their initial center) so that all matches the centroid of Im1.
just subtract their centroid from im1's centroid to get your displacement vector. The translate with circshift or, if you have the IPT, my imtranslate:
http://www.mathworks.com/matlabcentral/fileexchange/27251-imtranslate

Sign in to comment.

Categories

Asked:

on 23 Jun 2011

Community Treasure Hunt

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

Start Hunting!