To Find The Centroid Of Images Using Matlab

2 views (last 30 days)
Hi, Below I am placing my code where I need some help to proceed further.
fx = 3.5:3.5:56; fy = 2; a=128; b=128; c=512;
[x1,y1]=meshgrid(-1:2/511:+1,-1:2/511:+1); circ1=sqrt(x1.^1+y1.^1)<1;
% Aberration z8=sqrt(8).*(3.*x1.^3+3.*x1.*y1.^2-2.*x1);
[x,y] = meshgrid(-1:2/127:+1,-1:2/127:+1); circ=sqrt(x.^2+y.^2)<1; for j1 = numel(fx):-1:1 h{j1} = circ.*cos(pi*(x*fx(j1) + y*fy)); end
M = cell(c/a); M(:) = h; M = cell2mat(M');
%Fourier Transform Before Adding Aberration z1=fftshift(fft2(M,512,512)); q1=abs(z1);
figure(1) imagesc(q1); colormap gray; axis image; axis off title('Focal Spots Without Aberration');
%Fourier Transform After Adding Aberration N=exp(sqrt(-1).*(M+z8)); z2=fftshift(fft2(N,512,512)); q2=abs(z2);
figure(2) imagesc(q2); colormap gray; axis image; axis off title('Focal Spots With Aberration'); %%%%%%%%%%%%%%%%% In the above code, two figures are obtained:fig(1) & fig(2). I need to find the centroid of those white spots(crop the image to consider only the lower row of 16 white spots) in both the figures separately. It will really be a great help for me if anyone helps me out in this regard.
Thanking You!

Answers (1)

Image Analyst
Image Analyst on 9 Sep 2012
You code doesn't run. What is q1?
You can see how to get centroids from regions in an image (your row of "white spots") by looking at my BlobsDemo image segmentation tutorial: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!