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
disp(features.Centroid);
i = i + 1;
end
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 http://www.samaritans.org/support/donations.shtm | |||
| |||
|