MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi
Learn moreOpportunities for recent engineering grads.
Apply TodayMATLAB Central > MATLAB Newsreader > How to calculate the angle between two images? 

Subject: How to calculate the angle between two images? From: khoo Date: 3 Apr, 2009 11:55:03 Message: 1 of 43 
Hi all, currently i face the problem to find the rotation angle...i got one image is rotate in unknown angle compare with the original image, but i not have idea how to calculate the angle cause the angle is a variable angle..can anyone senior teach me here,...need it urgently...and i quite noob in image processing.. 
Subject: How to calculate the angle between two images? From: Dave Robinson Date: 3 Apr, 2009 12:07:01 Message: 2 of 43 
"khoo" <jim_khoo@hotmail.com> wrote in message <gr4ten$oks$1@fred.mathworks.com>... 
Subject: How to calculate the angle between two images? From: khoo Date: 3 Apr, 2009 12:22:01 Message: 3 of 43 
> One method that I found for easily determining the relative 
Subject: How to calculate the angle between two images? From: Dave Robinson Date: 3 Apr, 2009 12:51:01 Message: 4 of 43 
"khoo" <jim_khoo@hotmail.com> wrote in message <gr4v19$60a$1@fred.mathworks.com>... 
Subject: How to calculate the angle between two images? From: khoo Date: 3 Apr, 2009 13:49:01 Message: 5 of 43 
> No I don't have any Matlab code I can give you, I make it a policy not to do this. You need to write your own software in order for you to be able to master the craft  just like all of the Guru's here had to. 
Subject: How to calculate the angle between two images? From: Dave Robinson Date: 3 Apr, 2009 14:15:04 Message: 6 of 43 
"khoo" <jim_khoo@hotmail.com> wrote in message <gr544d$5vk$1@fred.mathworks.com>... 
Subject: How to calculate the angle between two images? From: Skeptic Date: 3 Apr, 2009 14:20:02 Message: 7 of 43 
Dave Robinson wrote a nice algorithm: 
Subject: How to calculate the angle between two images? From: Dave Robinson Date: 3 Apr, 2009 14:39:01 Message: 8 of 43 
Skeptic <skeptic@mailinator.com> wrote in message <6dc4d3178b624e038bea662e35f6eb67@d38g2000prn.googlegroups.com>... 
Subject: How to calculate the angle between two images? From: khoo Date: 3 Apr, 2009 16:29:02 Message: 9 of 43 
> > > Now you need to make 2 histograms (one from each of your angle images) of your trusted angles. What you find is that these histograms are virtually identical, with the exception that they are shifted relative to each other. This shift is equal to the relative rotation of the original images. 
Subject: How to calculate the angle between two images? From: khoo Date: 3 Apr, 2009 16:57:01 Message: 10 of 43 
i want find out how many the angle for the image2 to rotate until the same angle like image 1..so that the two image can be do phase correlation... 
Subject: How to calculate the angle between two images? From: Roger Stafford Date: 3 Apr, 2009 17:47:01 Message: 11 of 43 
"khoo" <jim_khoo@hotmail.com> wrote in message <gr4ten$oks$1@fred.mathworks.com>... 
Subject: How to calculate the angle between two images? From: khoo Date: 3 Apr, 2009 18:00:17 Message: 12 of 43 
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gr5i2l$p34$1@fred.mathworks.com>... 
Subject: How to calculate the angle between two images? From: Roger Stafford Date: 3 Apr, 2009 18:24:01 Message: 13 of 43 
"khoo" <jim_khoo@hotmail.com> wrote in message <gr5irh$g8m$1@fred.mathworks.com>... 
Subject: How to calculate the angle between two images? From: Image Analyst Date: 3 Apr, 2009 20:30:04 Message: 14 of 43 
"khoo" <jim_khoo@hotmail.com> wrote in message 
Subject: How to calculate the angle between two images? From: khoo Date: 4 Apr, 2009 03:09:03 Message: 15 of 43 
"Image Analyst" <imageanalyst@mailinator.com> wrote in message <gr5rkc$pr0$1@fred.mathworks.com>... 
Subject: How to calculate the angle between two images? From: khoo Date: 4 Apr, 2009 04:09:02 Message: 16 of 43 
"Image Analyst" <imageanalyst@mailinator.com> wrote in message <gr5rkc$pr0$1@fred.mathworks.com>... 
Subject: How to calculate the angle between two images? From: khoo Date: 4 Apr, 2009 16:40:03 Message: 17 of 43 
"khoo" <jim_khoo@hotmail.com> wrote in message <gr4v19$60a$1@fred.mathworks.com>... 
Subject: How to calculate the angle between two images? From: Dave Robinson Date: 4 Apr, 2009 17:49:02 Message: 18 of 43 
"khoo" <jim_khoo@hotmail.com> wrote in message <gr82h2$d9h$1@fred.mathworks.com>... 
Subject: How to calculate the angle between two images? From: khoo Date: 4 Apr, 2009 18:53:01 Message: 19 of 43 
> 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 
Subject: How to calculate the angle between two images? From: khoo Date: 5 Apr, 2009 02:56:01 Message: 20 of 43 
> > bro, i no understand wat this mean?? and how to extend the spctra by zero packing??can explain and teach me? 
Subject: How to calculate the angle between two images? From: khoo Date: 5 Apr, 2009 10:24:01 Message: 21 of 43 
"khoo" <jim_khoo@hotmail.com> wrote in message <gr96k1$cgv$1@fred.mathworks.com>... 
Subject: How to calculate the angle between two images? From: Dave Robinson Date: 5 Apr, 2009 10:42:02 Message: 22 of 43 
"khoo" <jim_khoo@hotmail.com> wrote in message <gra0s1$7d0$1@fred.mathworks.com>... 
Subject: How to calculate the angle between two images? From: khoo Date: 5 Apr, 2009 11:12:01 Message: 23 of 43 
"Dave Robinson" <dave.robinson@somewhere.biz> wrote in message 
Subject: How to calculate the angle between two images? From: khoo Date: 5 Apr, 2009 13:54:02 Message: 24 of 43 
> > the max_angle i find is 1 every time..but when i check im8 value, got other value max than 1..so how i need to do the find the peak value? 
Subject: How to calculate the angle between two images? From: Dave Robinson Date: 5 Apr, 2009 14:15:04 Message: 25 of 43 
"khoo" <jim_khoo@hotmail.com> wrote in message <grad5q$cai$1@fred.mathworks.com>... 
Subject: How to calculate the angle between two images? From: khoo Date: 5 Apr, 2009 17:59:01 Message: 26 of 43 
> Why on earth are you trying to convert an image into a 1 dimensional vector? you are correlating 2 histograms  histograms are essentially graphs  in your case angle along the x axis, number of pixels of that angle in y direction. If you have say 256 angles, then each bin represents (2*pi)/256 radians. Thus the histogram will be a vector of 256 numbers, each number representing the number of pixels of that angle. 
Subject: How to calculate the angle between two images? From: khoo Date: 6 Apr, 2009 08:25:03 Message: 27 of 43 
> Why on earth are you trying to convert an image into a 1 dimensional vector? you are correlating 2 histograms  histograms are essentially graphs  in your case angle along the x axis, number of pixels of that angle in y direction. If you have say 256 angles, then each bin represents (2*pi)/256 radians. Thus the histogram will be a vector of 256 numbers, each number representing the number of pixels of that angle. 
Subject: How to calculate the angle between two images? From: Dave Robinson Date: 6 Apr, 2009 08:54:02 Message: 28 of 43 
"khoo" <jim_khoo@hotmail.com> wrote in message <grce8v$8g$1@fred.mathworks.com>... 
Subject: How to calculate the angle between two images? From: khoo Date: 6 Apr, 2009 11:58:01 Message: 29 of 43 
> Why are you histogramming im8? which should be the correlation that you are looking for  just plot im8 and if everything else is correct then you should have one dimensional distribution reaching a peak at the position corresponding to the relative rotation angle of the 2 images. 
Subject: How to calculate the angle between two images? From: Dave Robinson Date: 6 Apr, 2009 12:15:05 Message: 30 of 43 
"khoo" <jim_khoo@hotmail.com> wrote in message <grcqo9$17e$1@fred.mathworks.com>... 
Subject: How to calculate the angle between two images? From: khoo Date: 6 Apr, 2009 13:51:01 Message: 31 of 43 
> Had you considered that the results just might be right? Think about it  when you rotated the image, do the the actual image boundaries rotate?. You had some almost circular details toward the centre of the image, rotating a circle will generate exactly the same angle image irrespective of the amount of twist. If your image contains aliasing (digital stepping in the image), these will always generate detail usually at 0 and 90 degrees. Remember that your x scale needs to be rescaled such that 0 > 256 actually maps to 0 >360 degrees. 
Subject: How to calculate the angle between two images? From: Dave Robinson Date: 6 Apr, 2009 14:32:01 Message: 32 of 43 
"khoo" <jim_khoo@hotmail.com> wrote in message <grd1c5$mk8$1@fred.mathworks.com>... 
Subject: How to calculate the angle between two images? From: Matt Date: 6 Apr, 2009 14:47:01 Message: 33 of 43 
"khoo" <jim_khoo@hotmail.com> wrote in message <gr4ten$oks$1@fred.mathworks.com>... 
Subject: How to calculate the angle between two images? From: khoo Date: 6 Apr, 2009 14:48:01 Message: 34 of 43 
> > Bro Dave, when i rotate the images, i don't think the actual image boundaries will rotate...ABout the other spikes bear, i no sure about it but how to set the zero degree spike to zero?? 
Subject: How to calculate the angle between two images? From: khoo Date: 6 Apr, 2009 15:14:01 Message: 35 of 43 
> > Bro Dave, when i rotate the images, i don't think the actual image boundaries will rotate...ABout the other spikes bear, i no sure about it but how to set the zero degree spike to zero?? 
Subject: How to calculate the angle between two images? From: khoo Date: 6 Apr, 2009 15:16:02 Message: 36 of 43 
"Matt " <xys@whatever.com> wrote in message <grd4l5$m4s$1@fred.mathworks.com>... 
Subject: How to calculate the angle between two images? From: khoo Date: 6 Apr, 2009 17:02:02 Message: 37 of 43 
> > > Had you considered that the results just might be right? Think about it  when you rotated the image, do the the actual image boundaries rotate?. You had some almost circular details toward the centre of the image, rotating a circle will generate exactly the same angle image irrespective of the amount of twist. If your image contains aliasing (digital stepping in the image), these will always generate detail usually at 0 and 90 degrees. Remember that your x scale needs to be rescaled such that 0 > 256 actually maps to 0 >360 degrees. 
Subject: How to calculate the angle between two images? From: Matt Date: 6 Apr, 2009 17:30:18 Message: 38 of 43 
"khoo" <jim_khoo@hotmail.com> wrote in message <grd6bi$bsi$1@fred.mathworks.com>... 
Subject: How to calculate the angle between two images? From: khoo Date: 7 Apr, 2009 07:28:03 Message: 39 of 43 
Bro Dave, i ady get the radians for the images..but now i got one problem show in my program..i use several images with different angles to test the code..but all i get is same radian..how come will like this?? and this is my code currently: 
Subject: How to calculate the angle between two images? From: khoo Date: 7 Apr, 2009 13:48:01 Message: 40 of 43 
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.. 
Subject: How to calculate the angle between two images? From: Dave Robinson Date: 7 Apr, 2009 16:11:01 Message: 41 of 43 
"khoo" <jim_khoo@hotmail.com> wrote in message <grflih$arh$1@fred.mathworks.com>... 
Subject: How to calculate the angle between two images? From: Jeff Date: 9 Dec, 2012 04:02:08 Message: 42 of 43 
I know this is an old topic, but Dave, are you still reading? Anyone really. Dave spoke about zero packing and I would like to know more, but my online searches have not proven fruitful. I am performing the same function as the original poster, finding the rotation angle between images. How does zero packing increase angular resolution and where can I learn how to implement it? 
Subject: How to calculate the angle between two images? From: Michael Meyers Date: 25 Jan, 2013 15:23:07 Message: 43 of 43 
"Jeff" wrote in message <ka12g0$eu4$1@newscl01ah.mathworks.com>... 
No tags are associated with this thread.
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.