# ImageAlign doesn't always work correctly

I've been working with ImageAlign in Mathematica 8 and I'm having trouble getting it working reliably. Perhaps there are some subtleties that I'm not yet aware of? Here's an example:

mandrill = ExampleData[{"TestImage", "Mandrill"}]
eye = ImageTake[mandrill, {50, 91} , {150, 190}]


Now ImageAlign is supposed to be able to align these two images, returning, say, the eye in the right place on the original image:

ImageAlign[mandrill, eye, Background -> Gray]


but it appears in the wrong place. According to the documentation, it should appear in the correct location, but it shows up in the bottom corner. There are Transformation options, but they seem to make no difference to the success of the function.

Strangely, I have been achieving some success with other images, although it's not consistent. Are there some restrictions that I'm not aware of?

-

The subimage may be too small:

ImageCorrespondingPoints[mandrill, eye]


returns

{{}, {}}


When you take more of the image (e.g., replace "91" by "191"), Mathematica finds some corresponding points and ImageAlign works.

"Too small" probably depends on the nature of the two images as well as their sizes. The docs state that ImageCorrespondingPoints uses ImageKeyPoints which in turn is said to use the SURF method to find keypoints. Indeed,

ImageKeypoints[eye]


returns an empty list. If you increase the "91" to "100", a single keypoint is obtained, a pair of corresponding points is found, and ImageAlign succeeds.

-
Ah, yes, if it's using that keypoints thing it might be having trouble... –  cormullion Jan 17 '12 at 22:59