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}]

mandrill and the mandrill eye

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]

enter image description here

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?


1 Answer 1


The subimage may be too small:

ImageCorrespondingPoints[mandrill, eye]


{{}, {}}

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,


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.

  • $\begingroup$ Ah, yes, if it's using that keypoints thing it might be having trouble... $\endgroup$
    – cormullion
    Jan 17, 2012 at 22:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.