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

kiki
kiki 2011년 6월 23일
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.
Sean de Wolski
Sean de Wolski 2011년 6월 23일
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