How to align images?

Using ImageFeatureTrack works pretty well:

{f1, f2} = ImageFeatureTrack[{img1, img2}];
HighlightImage[img1, f1]
HighlightImage[img2, f2]

Initial Points

Same Points Identified in img2

Now calculate the offset:

shift = Mean[
   Cases[f1 - f2, {x_, y_} /; NumericQ[x] && NumericQ[y]]
   ];

And compose the images. I used ColorNegate so you can see what's going on:

ImageCompose[
 img1,
 {ColorNegate[img2], 0.5},
 shift,
 {0, 0}
 ]

Aligned images


My solution is the following:

Determine the shift between both images:

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

enter image description here

Applying the shifts

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

Combine images

Blend[{ColorNegate[img1], imgt}, {0.8, 0.2}]

enter image description here