khoo
Posts:
63
Registered:
8/9/08


Re: How to calculate the angle between two images?
Posted:
Apr 5, 2009 6:24 AM


"khoo" <jim_khoo@hotmail.com> wrote in message <gr96k1$cgv$1@fred.mathworks.com>... > > > bro, i no understand wat this mean?? and how to extend the spctra by zero packing??can explain and teach me? > > > > Doing it at matching points, as Roger suggests is one good way of doing it, however unless you have ImageAnalysts point 2) problem, this shouldn't be necessary. However without seeing your images  it is difficult to say. > > > > First consider your two histograms, these represent the number of meaningful angle pixels binned into a 'x axis' position representing an angle. The complete x axis of the histogram represents an angle of 0 >2pi. as your image rotates, so the predominant edges will rotate by that angle, and thus comparing the two histograms, what you should see is the same general pattern in both histograms but being shifted one way or other by their relative rotation angle, as measured on the x axis of the histograms. > > > > Now ignoring zero packing for a moment, if you do see this general similarity, then one way to find the angle of offset is by applying correlation, not to the images but to the histograms themselves. > > > > Fast convolution using the FFT is particularly suited for this operation as bot FFT correlation, and the histograms themselves can be considered cylindrical, namely details that get shifted say left off of the histogram don't get lost  they reappear at the right side of the histogram, (remember we are on an angular scale) FFT correlation has exactly the same effect, and normally you have to work like blazes to remove the wrap around effect from your computation, here it is just what we want. > > > > The computation itself should be easy, simply FFT both histograms  remember this results in complex answers  don't throw away the phase, do complex arithmetic for the next phase which is > > > > multiply the spectrum of one histogram by the complex conjugate of the second spectrum (remember to .* not *) then find the real part of the inverse transform of the product. > > > > Look at this resulting vector, and hopefully you should find a peak value corresponding to the relative rotation angle between the two images. If you do, come back and we will discuss the zero packing to get better angular resolution, if not then we need to see the type of image you are working with.
bro dave, this is the code i do until currently..but i dunno how to find the max radian between two images
clear all;clc
im1=imread('image1.jpg'); im11=rgb2gray(im1); im111=im2double(im11); [dx,dy]=gradient(im111); p1=atan2(dy,dx); im1111=edge(p1,'canny'); bw1 = bwmorph(im1111,'dilate'); im11111=p1.*bw1;
%subplot(2,1,1);hist(im11111); im6=hist(im11111); %im66=gaussian(im6,5); im66=fft(im6);
im=imread('image2.jpg'); im2=imresize(im,size(im11),'bicubic'); im22=rgb2gray(im2); im222=im2double(im22); [dx,dy]=gradient(im222); p2=atan2(dy,dx); im2222=edge(p2,'canny'); bw2 = bwmorph(im2222,'dilate'); im22222=p2.*bw2;
%subplot(2,1,2);hist(im22222); im7=hist(im22222); im77=conj(fft(im7)); im8=real(ifft(im66.*im77)) max_value=max(max(im8)); [max_angle1,]=find(im8==max_value) hist(im8)
the max_angle i find is 1 every time..but when i check im8 value, got other value max than 1..so how i need to do the find the peak value?

