Path: news.mathworks.com!not-for-mail 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$1@fred.mathworks.com> References: <gr4ten$oks$1@fred.mathworks.com> <gr4u55$add$1@fred.mathworks.com> <gr4v19$60a$1@fred.mathworks.com> <gr82h2$d9h$1@fred.mathworks.com> <gr86ie$m8l$1@fred.mathworks.com> <gr96k1$cgv$1@fred.mathworks.com> <gra0s1$7d0$1@fred.mathworks.com> <gra1tq$a1t$1@fred.mathworks.com> <grad5q$cai$1@fred.mathworks.com> <graed8$ope$1@fred.mathworks.com> <grce8v$8g$1@fred.mathworks.com> <grcfva$cbd$1@fred.mathworks.com> <grcqo9$17e$1@fred.mathworks.com> <grcro9$209$1@fred.mathworks.com> <grd1c5$mk8$1@fred.mathworks.com> <grd3p1$oph$1@fred.mathworks.com> <greva3$t2m$1@fred.mathworks.com> <grflih$arh$1@fred.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: webapp-05-blr.mathworks.com Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1239120661 7682 172.30.248.35 (7 Apr 2009 16:11:01 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Tue, 7 Apr 2009 16:11:01 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 968489 Xref: news.mathworks.com comp.soft-sys.matlab:531090 "khoo" <jim_khoo@hotmail.com> wrote in message <grflih$arh$1@fred.mathworks.com>... > Bro Dave, pls continue to teach me..i dun wan give up with this method in half way...now 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. Regards Dave Robinson