# Image transformation

I have to images (img1, img2) which should be overlapped.

The best solution which I find is the following:

{merit, trans} = FindGeometricTransform[img2, img1, TransformationClass -> "Similarity"]

imgt = ImageTransformation[img2, trans, DataRange -> Full];

overlapped = Blend[{ColorNegate[img1], imgt}, {0.5, 0.5}]

ImageAssemble[{img1, img2, overlapped}]


In the lower part of the overlapped image a small vertical misalignment of the horizontal lines is seen.

How can the adjustment be optimized/improved?

• Try adding Method -> {"ImageAlign", {"Keypoints", "BRISK"}} or some other variant of Keypoints related methods, like "AKAZE" or "KAZE" or "ORB"
– UDB
Aug 9, 2017 at 17:50

Mathematica 11.1 introduces keypoints-based registration methods. As your example exhbits patterns with relatively large homogeneous regions, a global intensity difference based target function might lead to suboptimal results as in your attempt. Try using keypoints, e.g. binary robust invariant scalable keypoints (BRISK):

img1 = Import@"https://i.imgur.com/RJEFiuO.png";
img2 = Import@"https://i.imgur.com/J79TrG9.png";
{merit, trans} = FindGeometricTransform[img2, img1,
Method -> {"ImageAlign", {"Keypoints", "BRISK"}},
TransformationClass -> "Similarity"];
imgt = ImageTransformation[img2, trans, DataRange -> Full];
overlapped = Blend[{ColorNegate[img1], imgt}, {0.5, 0.5}];
ImageAssemble[{img1, img2, imgt, overlapped}]


You might want to see the locations of the corresponding keypoints used inside FindGeometricTransform (demonstrated using code given in the Neat Examples section of ImageCorrespondingPoints):

matches = ImageCorrespondingPoints[img1, img2, Method -> "BRISK",
TransformationClass -> "Similarity"];