Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: How to calculate the angle between two images?
Replies: 41   Last Post: Dec 8, 2012 11:02 PM

 Messages: [ Previous | Next ]
 khoo Posts: 63 Registered: 8/9/08
Re: How to calculate the angle between two images?
Posted: Apr 4, 2009 2:53 PM

> 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.
>
> Regards
>
> Dave Robinson

bro, i face some error at the times there...

this is the error code i get
??? Error using ==> times
Matrix dimensions must agree.

and this is the code currently..which do until the .* you teach me..

clear all;clc

im11=rgb2gray(im1);
im111=im2double(im11);
p1=atan2(dy,dx);
im1111=edge(p1,'canny');
bw1 = bwmorph(im1111,'dilate');
im11111=p1.*bw1;
im6=hist(im11111);
im66=fft(im6);

im22=rgb2gray(im2);
im222=im2double(im22);
p2=atan2(dy,dx);
im2222=edge(p2,'canny');
bw2 = bwmorph(im2222,'dilate');
im22222=p2.*bw2;
im7=hist(im22222);
im77=fft(im7);
im777=conj(im77);

im8=im66.*im777;
imshow(im8)

and this is both image i try to find the angles

[IMG]http://i278.photobucket.com/albums/kk119/khoo011/image1.jpg[/IMG]
[IMG]http://i278.photobucket.com/albums/kk119/khoo011/image2.jpg[/IMG]

Date Subject Author
4/3/09 khoo
4/3/09 Dave Robinson
4/3/09 khoo
4/3/09 Dave Robinson
4/3/09 khoo
4/3/09 Dave Robinson
4/3/09 khoo
4/3/09 khoo
4/4/09 khoo
4/4/09 Dave Robinson
4/4/09 khoo
4/4/09 khoo
4/5/09 khoo
4/5/09 Dave Robinson
4/5/09 khoo
4/5/09 khoo
4/5/09 Dave Robinson
4/5/09 khoo
4/6/09 khoo
4/6/09 Dave Robinson
4/6/09 khoo
4/6/09 Dave Robinson
4/6/09 khoo
4/6/09 Dave Robinson
4/6/09 khoo
4/6/09 khoo
4/6/09 khoo
4/7/09 khoo
4/7/09 khoo
4/7/09 Dave Robinson
12/8/12 Jeff
4/3/09 Skeptic
4/3/09 Dave Robinson
4/3/09 Roger Stafford
4/3/09 khoo
4/3/09 Roger Stafford
4/3/09 ImageAnalyst
4/3/09 khoo
4/4/09 khoo
4/6/09 Matt
4/6/09 khoo
4/6/09 Matt