Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 16 down vote accepted

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.

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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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