0

I am using the function findTransformECC for automatic image alignment. I am only correcting for a shift so I use the warp mode MOTION_TRANSLATION. Image alignment works perfectly with cv2.warpAffine.

Next thing I would like to do is to use the warpMatrix to shift a whole batch of images. I can do this without loading the images in Python so I do not want to use the OpenCV functions to do the job. However, I do not fully understand the contents of the warpMatrix.

My matrix looks like:

array([[1., 0., 7.1342],
       [0., 1., 7.0116]], dtype=float32)

I suppose the last column represents the shift in pixels. But which row corresponds to which axis? And what do the other columns represent?

Wilmar van Ommeren
  • 7,469
  • 6
  • 34
  • 65
  • first row is for Horizontal translation, second is for vertical translation. – Optimus 1072 Jul 28 '17 at 08:37
  • basically the transformation involved is `[x y 1]' = W * [X Y 1]' `. For translation model it comes out to be `x = X + W(0, 2)` & `y = Y + W(1, 2)` . – Optimus 1072 Jul 28 '17 at 08:41
  • The 3x2 matrix is a transformation matrix, as you wanted just the translation matrix to be calculated then only the last column is populated which are the translation values in pixels. the diagonal 1s would be the scale in X and Y-axis, the 0s are the rotations, see https://stackoverflow.com/questions/10667834/trying-to-understand-the-affine-transform for a more detailed explanation. Note that without the last row there is no z-axis transformation, anyway I'm voting to close as a dupe of the linked post – EdChum Jul 28 '17 at 08:49

0 Answers0