0

I have an image and several 2D points [(x, y), ...]. I would like to rotate both the image and the points by 90 degrees.

For the image I can simply use np.rot90. For the points I figured I have to rotate them 90 degrees around the center of the image to make them align correctly (for this I used https://stackoverflow.com/a/58781388/2445065)

Original image (note: red point is not part of the image):

enter image description here

After rotating the image and the point:

enter image description here

Whereas I would expect the red dot to be at the bottom left corner of the yellow square... Does anyone know what I'm doing wrong? Thanks in advance

Steven
  • 1,023
  • 5
  • 12
  • 29

1 Answers1

0

I finally found it:

To align the points and additional translation is require. np.rot90 does not equal a translation around the center but rather a rotation around the center PLUS a translation such that the top left corner of the rotated image is located at (0, 0).

You can get the translation by subtracting |origin_rotated.x - origin_original.x| from the x-coordinate and |origin_rotated.y - origin_original.y| from the y-coordinate.

Steven
  • 1,023
  • 5
  • 12
  • 29