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:
pad_img=ocv.cvCreateImage(ocv.cvSize(cropWidth*3,cropHeight*3),
expIPLimg.depth,expIPLimg.nChannels)
offset=ocv.cvPoint(cropWidth,cropHeight)
ocv.cvCopyMakeBorder(expLP, pad_img, offset,
ocv.IPL_BORDER_CONSTANT, ocv.cvAvg(expLP))
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)
ocv.cvSetImageROI(refLP,ocv.cvRect(refLP.width/4,
0, refLP.width/2, refLP.height))
ocv.cvMatchTemplate(pad_img,refLP,result,ocv.CV_TM_CCOEFF_NORMED)
Funny encounter today with some jailbait at the Woodstocks bar. Here's how it went:
(2 young girls walk up next to me at the bar, and are wondering what the trinkets in the glass at the bar are)
Me: "those are bottle openers."
Them: "you smell like beer."
Me: "that's because I'm drinking it."
The real question, though, is how they know what beer smells like, but don't know what a bottle opener looks like. Hmmmm....
Oh boy, was I seething at Apple after upgrading to 10.6. It seemed like just about everything broke. All of my Python development stuff went to hell in a handbasket (a stylish, well-designed handbasket). My 600$ (educational) copy of the Adobe CS3 Design pack would not even install. To boot, X11 did not work, so I couldn't even use trusty old NXclient to remote desktop on my linux box.
I'm not sure why, but I didn't bother searching for anyone with similar problems at the time. After going through the trouble to revert to 10.5, I did that search, and found all kinds of exactly similar problems, mostly caused by cruft from the old system. After a fresh OS X 10.6 install, things are in much better shape. Yes, there are other ways to clean up the cruft, but fresh installs feel so nice. CS3 still won't install, but I can live with Inkscape and the GIMP.
Long story short: OS X is not the bulletproof OS that it is often advertised as, but it's also not as bad as I thought.
Oh, one quirk:
Everyone mentions how much space 10.6 frees up on their hard drive. That's nonsense. It may use a tiny bit less space, but the real "increase" in hard disk space comes because they switched to calling kilobytes 1000 bytes, rather than 1024 bytes (and MB are 1000 KB, and so forth). Because it divides the total number of bytes by an accordingly smaller number, you end up with a "bigger" hard drive. This has long been what the hard drive manufacturers do, but it's awfully shady and very arbitrary for Apple to make that switch now.