Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: How to calculate the angle between two images?
Replies: 41   Last Post: Dec 8, 2012 11:02 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Dave Robinson

Posts: 1,338
Registered: 1/25/05
Re: How to calculate the angle between two images?
Posted: Apr 3, 2009 8:07 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"khoo" <jim_khoo@hotmail.com> wrote in message <gr4ten$oks$1@fred.mathworks.com>...
> 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..

One method that I found for easily determining the relative
angle of 'twist' between a known reference image and a rotated image was accomplished very reliably even for arbitrary images.

1) Compute the vertical and horizontal gradient of every
pixel
2) Use the atan2 function to convert the image to an angle
image. Note that pixels on a featureless region returns
angles that are purely dictated by noise.
3) Calculate an edge image - using edge, Canny is a good
choice, but Sobel will probably work - depending on the
complexity of the image.
4) Fatten up the edge lines using morphology operators
dilate/erode. Binarize into a mask image
5) Mask the angle image with above mask, thus removing
meaningless angle pixels. We are only looking at gradients
that are real.
6) Apply this to the reference image, and the target image
7) Histogram the results. Remember as the pixels represent
angles, the histogram essentially wraps round 0 mapping to
2Pi radians.
8) Compare the histograms, I found correlation a good way
to do this, the peak on the correlogram provides you with
the relative rotation between the two images.

One danger point is that if your image suffers badly from
digital stepping (aliasing) you can get peaks at 0 and 90
degrees on both images. So you need to do something
intelligent at removing this from your histograms prior to
doing your comparison.

One of the fun things that I tried, was to use fast
correlation to do the matching. I FFT'd both histograms,
then extended the spectra by zero packing, done the
multiplication in the frequency domain, then followed up by
the IFFT. This generated a very nicely interpolated measure
of the relative rotation between the two images.

Hope that this is helpful, and makes sense

Regards

Dave Robinson


Date Subject Author
4/3/09
Read How to calculate the angle between two images?
khoo
4/3/09
Read Re: How to calculate the angle between two images?
Dave Robinson
4/3/09
Read Re: How to calculate the angle between two images?
khoo
4/3/09
Read Re: How to calculate the angle between two images?
Dave Robinson
4/3/09
Read Re: How to calculate the angle between two images?
khoo
4/3/09
Read Re: How to calculate the angle between two images?
Dave Robinson
4/3/09
Read Re: How to calculate the angle between two images?
khoo
4/3/09
Read Re: How to calculate the angle between two images?
khoo
4/4/09
Read Re: How to calculate the angle between two images?
khoo
4/4/09
Read Re: How to calculate the angle between two images?
Dave Robinson
4/4/09
Read Re: How to calculate the angle between two images?
khoo
4/4/09
Read Re: How to calculate the angle between two images?
khoo
4/5/09
Read Re: How to calculate the angle between two images?
khoo
4/5/09
Read Re: How to calculate the angle between two images?
Dave Robinson
4/5/09
Read Re: How to calculate the angle between two images?
khoo
4/5/09
Read Re: How to calculate the angle between two images?
khoo
4/5/09
Read Re: How to calculate the angle between two images?
Dave Robinson
4/5/09
Read Re: How to calculate the angle between two images?
khoo
4/6/09
Read Re: How to calculate the angle between two images?
khoo
4/6/09
Read Re: How to calculate the angle between two images?
Dave Robinson
4/6/09
Read Re: How to calculate the angle between two images?
khoo
4/6/09
Read Re: How to calculate the angle between two images?
Dave Robinson
4/6/09
Read Re: How to calculate the angle between two images?
khoo
4/6/09
Read Re: How to calculate the angle between two images?
Dave Robinson
4/6/09
Read Re: How to calculate the angle between two images?
khoo
4/6/09
Read Re: How to calculate the angle between two images?
khoo
4/6/09
Read Re: How to calculate the angle between two images?
khoo
4/7/09
Read Re: How to calculate the angle between two images?
khoo
4/7/09
Read Re: How to calculate the angle between two images?
khoo
4/7/09
Read Re: How to calculate the angle between two images?
Dave Robinson
12/8/12
Read Re: How to calculate the angle between two images?
Jeff
4/3/09
Read Re: How to calculate the angle between two images?
Skeptic
4/3/09
Read Re: How to calculate the angle between two images?
Dave Robinson
4/3/09
Read Re: How to calculate the angle between two images?
Roger Stafford
4/3/09
Read Re: How to calculate the angle between two images?
khoo
4/3/09
Read Re: How to calculate the angle between two images?
Roger Stafford
4/3/09
Read Re: How to calculate the angle between two images?
ImageAnalyst
4/3/09
Read Re: How to calculate the angle between two images?
khoo
4/4/09
Read Re: How to calculate the angle between two images?
khoo
4/6/09
Read Re: How to calculate the angle between two images?
Matt
4/6/09
Read Re: How to calculate the angle between two images?
khoo
4/6/09
Read Re: How to calculate the angle between two images?
Matt

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.