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 ]
 Dave Robinson Posts: 1,338 Registered: 1/25/05
Re: How to calculate the angle between two images?
Posted: Apr 7, 2009 12:11 PM

"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

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