"khoo" <email@example.com> wrote in message <firstname.lastname@example.org>... > 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.