Path: news.mathworks.com!not-for-mail
From: "khoo" <jim_khoo@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to calculate the angle between two images?
Date: Fri, 3 Apr 2009 12:22:01 +0000 (UTC)
Organization: haha
Lines: 50
Message-ID: <gr4v19$60a$1@fred.mathworks.com>
References: <gr4ten$oks$1@fred.mathworks.com> <gr4u55$add$1@fred.mathworks.com>
Reply-To: "khoo" <jim_khoo@hotmail.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1238761321 6154 172.30.248.37 (3 Apr 2009 12:22:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 3 Apr 2009 12:22:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1113304
Xref: news.mathworks.com comp.soft-sys.matlab:530020

> 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

  4) 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.


i no understand this two sentence meaning..can u explain it or provide the code need to be used??