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);

回答(1 个)

Sean de Wolski
Sean de Wolski 2011-6-23

0 个投票

You might want to read this:
and this:

2 个评论

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

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Image Processing Toolbox 的更多信息

提问:

2011-6-23

Community Treasure Hunt

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

Start Hunting!

Translated by