How to rotate images and coordinate together in Python?

35 Views Asked by At

My task is cephalometric landmark detection,I have images path with coordinates show in this data frame.

filename X1 Y1
/Images_data/binary0006.png 89 80
/Images_data/binary0008.png 37 70

I'm working on a data augmentation and I try to rotate image and coordinate together.

Example of the data.

Image and Coordinate X1 Y1 (red point:

Image and Coordinate X1 Y1 (red point)

I try to rotate coordinate and image from this code below.

ox, oy = (x,y) # Coordinate point
px, py = 112,112 # Center point
angle = 45
qx = int(ox + math.cos(angle) * (px - ox) - math.sin(angle) * (py - oy))
qy = int(oy + math.sin(angle) * (px - ox) + math.cos(angle) * (py - oy))
rotated_image1 = Original_Image.rotate(45,center=(112,112))
plt.imshow(rotated_image1)
plt.scatter((qx),(qy), color='red', marker='o',s=30)

But images and coordinates don't have the same rotating axis. That means the output coordinate isn't true.

Output

How can I solve this?

0

There are 0 best solutions below