From: "khoo" <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to calculate the angle between two images?
Date: Sun, 5 Apr 2009 10:24:01 +0000 (UTC)
Organization: haha
Lines: 58
Message-ID: <gra0s1$7d0$>
References: <gr4ten$oks$> <gr4u55$add$> <gr4v19$60a$> <gr82h2$d9h$> <gr86ie$m8l$> <gr96k1$cgv$>
Reply-To: "khoo" <>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1238927041 7584 (5 Apr 2009 10:24:01 GMT)
NNTP-Posting-Date: Sun, 5 Apr 2009 10:24:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1113304
Xref: comp.soft-sys.matlab:530421

"khoo" <> wrote in message <gr96k1$cgv$>...
> > > 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

bw1 = bwmorph(im1111,'dilate');


bw2 = bwmorph(im2222,'dilate');


the max_angle i find is 1 every time..but when i check im8 value, got other value max  than how i need to do the find the peak value?