ImageAlign[ref, i] works well when image i is fully contained within the reference image ref, but not so well when only a subregion of i appears in ref. For example:
r1 = ResourceFunction["RandomPhoto"][200];
r2 = ResourceFunction["RandomPhoto"][200];
i1 = ImageTake[r2, {120, 160}, {80, 180}];
i2 = ImageTake[r2, {90, 180}, {110, 140}];
ref = ImageCompose[r1, i1];
{ref, ImageAlign[ref, i2]}
How can I get ImageAlign to return the region at which they overlap:
ImageCompose[ref, {ImageApply[{.5, 1.5, .5}*# &, i2], .5}, {70, 70}]
I've tried using ImageCorrelate and ImageCorrespondingPoints but can't seem to get it quite right, but I'm sure there's an elegant solution here.


crsp = ImageCorrespondingPoints[h, ref]; transform = Last@FindGeometricTransform[crsp[[1]], crsp[[2]], TransformationClass -> "Translation"]; ImageTransformation[ref, transform]– flinty Jun 02 '20 at 16:29ImageCorrespondingPoints[ref, i2], but unfortunately that is empty. – M.R. Jun 02 '20 at 19:38ImageAlign... We're looking to align some subregion of image, which is an additional breakdance on top of it all! – M.R. Jun 03 '20 at 17:03