1

I have been learning how to rotate images without cropping recently. But I am slightly confused with the third column of cv2's getRotationMatrix2D. It returns a matrix of size 2 by 3.

enter image description here

Although my code is working based off Rotate an image without cropping in OpenCV in C++ and Python 2.7.3 + OpenCV 2.4 after rotation window doesn't fit Image, I would be glad and keen to know what exactly the third column of this transformation matrix does.

ilovewt
  • 911
  • 2
  • 10
  • 18
  • 2
    In this case, you are asking about the theory? [This](https://docs.opencv.org/2.4/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.html#theory) may be helpful – Yunus Temurlenk Apr 16 '20 at 06:24
  • 1
    pure rotation is around the position (0,0) if you want to rotate around another center you basically first translate the image, rotate around rhe new (0,0) and translate back. You can combine all those transformation steps to a single one. – Micka Apr 16 '20 at 18:58

1 Answers1

2

Thanks @Yunus for the documentation link. According to the documentation

The transformation maps the rotation center to itself. If this is not the target, adjust the shift.

which means M_rotation * vector_of_rotation_center = vector_of_rotation_center and the expression in the documentation is set such that the equation holds.

The first two columns in the rotation matrix specifies the rotation transformation and scaling transformation; the third column is used to specify the translation transformation.

ryan2718281
  • 139
  • 5
  • I'm a little confused about this too, translation of what? You only rotate? Or are all pixels translated by a common value in rototation? – Olli Sep 28 '21 at 10:31