This is more a note to self than anything else, but if you find it useful, hooray!
I'm trying to register images for school. There's a neat trick to get rotation & scale roughly aligned, without doing any kind of brute forcing (which is really important, because my images can be any angle offset from one another). You take the log-polar transform of each image, and then cross-correlate the two transformed images. The distance from the center to the cross correlation maximum along the Y axis tells you the rotation, and the same on the X axis tells you the scale (on a logarithmic scale). The end result is that you can avoid the local alignment maxima associated with brute forcing, and save a whole lot of time in the process.
However, it doesn't work perfectly for me yet. Here's a few steps I've taken to improve it:
1. Pad the image that you're going to match the template on.
Python with ctypes_opencv:
ocv.cvCopyMakeBorder(expLP, pad_img, offset,
2. Do not cross-correlate the entire template to match. Instead, match only the central strip. There's plenty of good stuff to match there, and you avoid the correlation penalties of having your template overlap with the padding. If you don't do this, then the scale correction possible will be limited.
resultWidth = pad_img.width - refLP.width/2 + 1
resultHeight = pad_img.height - refLP.height + 1
result = ocv.cvCreateMat(resultHeight,resultWidth,ocv.CV_32F)
0, refLP.width/2, refLP.height))