From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to calculate the angle between two images?
Date: Tue, 7 Apr 2009 16:11:01 +0000 (UTC)
Organization: STFC Rutherford Appleton Laboratory
Lines: 16
Message-ID: <grftul$7g2$>
References: <gr4ten$oks$> <gr4u55$add$> <gr4v19$60a$> <gr82h2$d9h$> <gr86ie$m8l$> <gr96k1$cgv$> <gra0s1$7d0$> <gra1tq$a1t$> <grad5q$cai$> <graed8$ope$> <grce8v$8g$> <grcfva$cbd$> <grcqo9$17e$> <grcro9$209$> <grd1c5$mk8$> <grd3p1$oph$> <greva3$t2m$> <grflih$arh$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1239120661 7682 (7 Apr 2009 16:11:01 GMT)
NNTP-Posting-Date: Tue, 7 Apr 2009 16:11:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 968489
Xref: comp.soft-sys.matlab:531090

"khoo" <> wrote in message <grflih$arh$>...
> Bro Dave, pls continue to teach me..i dun wan give up with this method in half only you can help me..i already email the mfile to your email...i now dunno my code wrong where and izit i get the correct final graph or not?? and why different angle image still show the same radian..

There is good news and there is bad news.

The good news is I have run your two images through my own software which effectively does the process that you are trying to do, and as I had originally thought, the information regarding your rotation angle is there good and clear. The problem you are having is due to image edge, and aliasing problems. Look at your two histograms im6 & im7 by plotting them, what you should see is a nice relatively smooth almost Gaussian curve, which peaks in a totally different place in both graphs this is the information regarding the rotation. However in addition you have some very large spikes occurring in exactly the same position on both graphs ( at 0 and 90 degrees etc.). When you do your FFT based correlation, these spikes give you the 'same radian' reading that you are observing. You need to remove them from your original histograms before you do your FFT correlation.

Think carefully how you do this, you cannot simply set those angles to zero as this will will introduce  spikes going in the other direction, towards zero, not towards a bigger number. You essentially need to replace them with the 'average' value of the smooth curve around them, so it looks continuous.

I can make a suggestion that you do some research on a 1 dimensional median filter, which should do exactly what you want. Don't  try and smooth the curve -  that just don't work.

Unfortunately spending so much time with this thread I am getting behind with my own work. I am afraid I am going to have to leave you to do the final steps (don't worry about zero packing - that is just a cosmetic step to increase the resolution of the angle measurement). You now know the data you are seeking is there, all you need is the removal of the spikes and away you go. I urge you to look at those histograms. As far as I can see your code is more or less OK.


Dave Robinson