I can't make this code work so perhaps I'm applying it incorrectly. I want to register a smaller image to a larger one where the scale of the images differ and the smaller image will match only a portion of the larger. For example, crop the rotated Lena image and try matching it with the full unrotated image using either rigid or affine transformations. It doesn't work. In particular, the code first resizes the smaller image to the size of the larger image. A rigid transformation now can't possibly work. If I put a border around the cropped image, it still doesn't help. Suggestions will be welcomed.