From: Matt J on
"Ja-yun " <silodraw(a)gmail.com> wrote in message <htsl5u$p3j$1(a)fred.mathworks.com>...

> Are the backgrounds of two figs have to be black?
=========

Yes, as Roger told you in the other thread you posted

http://www.mathworks.com/matlabcentral/newsreader/view_thread/283299

if the backgrounds are not black, the background will contribute to the radon transform, making the algorithm think that the object in the image consists of both the dog and the white area around it.

You don't want that, because the background white area does not rotate with the dog. It fills the same unrotated square region in both images, which will confuse the algorithm.


> and i don't quite understand what these steps mean
===============

Forget it. I had a number of mistakes. Here is a better version of the code, which also allows you to detect rotations over a full 360 degrees


clear, close all
fig2=255-double( rgb2gray(imread('dogk.png')) );
fig1=255-double( rgb2gray(imread('dog90.png')) );


fig1=fig1/norm(fig1(:)); fig2=fig2/norm(fig2(:));

F1=radon(fig1,0:359);
F2=radon(fig2,0:359);


PF1=fft2(F1);
PF2=fft2(F2);

den=abs(PF1.*PF2); %den=1;

PhaseCorr=(PF2.*conj(PF1))./den; PhaseCorr(den==0)=0;


result=ifft2(PhaseCorr);


result=abs(result);
figure(3); imdisp(result)