I have 2 images. One is the reference image and the other is the rotated version of the reference image. I would like to find what is the angle by which the 2nd image is rotated wrt 1st one. Also in future, the second image will be scaled and translated along with this rotation !. This has to be done automatically (without human interference in selecting feature points etc)
Now to do this I am using Fourier Mellin transform. But this is not accurate and dosent work for all angles :(. Is there any other means to achive this task ?
Is there a Fourier Mellin transform readily implemented on Matlab ?
Thanks in advance,
Ayyala
In what way will the image be scaled? Do you mean stretched geometrically or do you mean all the pixel values will be scaled?
------
>and translated along with this rotation !. This has to be done automatically (without human interference in selecting feature points etc)
-----
One thing you can try is to compute
P1=abs(fft(radon(Image1)))
P2=abs(fft(radon(Image2)))
You will see that P1 is shifted with respect to P2 by an amount corresponding to the rotation. You can use your favorite shift measurement technique (e.g. correlation) to calculate the shift, and hence the rotation. Also, translation will not affect P1 and P2.
%%%%%%%%%%%%%%%%
P1=abs(fft(radon(Image1)));
P2=abs(fft(radon(Image2)));
a = sum(P1);
b = sum(P2);
a = a-mean(a);
b = b-mean(b);
[m n] = max(xcorr(a, b));
angle = length(a)-n+1 % The angle of rotation
%%%%%%%%%%%%%%%%
The code above worked just fine. However, what is the purpose of "fft" after radon transform? Can we skip the "fft" part? Thanks.
Y.L. Tang
"Matt " <x...@whatever.com> wrote in message <h1g8gu$mrc$1...@fred.mathworks.com>...
thetas = [-45 : 45]; % Enter desired range
P1 = radon(Image1,0); % Only 1 projection is needed for reference image
P2 = radon(Image2,thetas); % All projections to be considered for the other image
% Compare the projections for Image2 to the projection for Image1 using cross
% correlation. The most correlated projection gives the amount of image rotation.
for ii = 1:length(thetas)
b = P2(:,ii);
this_correlation = abs(ifft(P1.*conj(b)));
angle_scores(ii) = max(max(this_correlation));
end
"Yuan-Liang Tang" <john.do...@example.com> wrote in message <h8q5ba$fds$1...@fred.mathworks.com>...
while trying this code i got this error....can you tell me WHY ?????
??? Error using ==> times
Matrix dimensions must agree.
Make sure that P1 is a column vector and P2 has the same number of rows as P1.
However, I've changed the way I solve this problem now. Two points to note for anybody stumbling on this:
1) What I said about only needing one radon projection for the reference might be true in theory, but I found in practice with noisy data that this was not so good. I've actually abandoned the radon approach.
2) I now solve my rotation problem in an entirely different way. I'm not sure how generally applicable this solution is, but it worked well for my application (very large images, only small angles of rotation possible, very precise estimate of rotation necessary).
I find the polar transforms of the reference and acquired images, and then do a typical registration between these using cross-correlation. The shift required in the theta dimension tells you the rotation required (the other dimension has radius info which I don't use).
I got a Matlab function for creating a polar transform from this page:
http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/
This function lets you specify the sampling in both the theta and radial dimensions. I upsample quite a bit in the theta dimension (better precision on the angle estimate) and downsample in the radial dimension (to keep memory costs down - my images are quite large).
Hope this approach is useful to others.
Why not just increase the number of projection angles used for the reference image, so as to decrease the SNR?
I did try that when I started having issues. I didn't have much luck with it; I'm not sure why but it's probably because the angles of rotation are so small in my data. I could probably upsample the images to make this work better, but my images are quite large and I frequently have memory issues in Matlab. I liked the polar transform approach better because I was able to upsample in just the one dimension.