How to align images?
Using ImageFeatureTrack
works pretty well:
{f1, f2} = ImageFeatureTrack[{img1, img2}];
HighlightImage[img1, f1]
HighlightImage[img2, f2]
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}
]
My solution is the following:
Determine the shift between both images:
{merit, trans} =
FindGeometricTransform[img2, img1,
TransformationClass -> "Translation"];
Applying the shifts
imgt = ImageTransformation[img2, trans, DataRange -> Full]
Combine images
Blend[{ColorNegate[img1], imgt}, {0.8, 0.2}]