Detecting defects/differences in printed images
All the comments in the comment section were very constructive, thank you.

In the end, I ended up using the solution here

For my case, most of my images are not expected to tilt more than a few degree, lighting and depths are strictly controlled. So a Euclidean Motion model (MOTION_EUCLIDEAN) should suffice for findTransformECC which computed the transformation matrix that is required to correct the misalignment.