mdbloice / Augmentor

Image augmentation library in Python for machine learning.
https://augmentor.readthedocs.io/en/stable
MIT License
5.08k stars 866 forks source link

Rotation degrees are opposite. #252

Open YiweiZou opened 1 year ago

YiweiZou commented 1 year ago

In the python module, Image.py rotation with positive degrees returns a rotated image with the given number of degrees counterclockwise around its center, but not clockwise. So the function rotate90, rotate270, rotate, rotate_without_crop give out results with left and right opposite.

And also to mention, rotate function can't rotate with certain degrees when max_left_raotion == max_right_rotation.

mdbloice commented 1 year ago

Hi @YiweiZou - so in your case the rotate function always results in the rotations going in the wrong direction? So for example:

p.rotate(probability=0.7, max_left_rotation=0, max_right_rotation=10)

This would result in a rotation going in the wrong direction (counter clockwise)?

As for the max_left_rotation == max_right_rotation that might well be a bug and I will investigate that....

YiweiZou commented 1 year ago

Hi @YiweiZou - so in your case the rotate function always results in the rotations going in the wrong direction? So for example:

p.rotate(probability=0.7, max_left_rotation=0, max_right_rotation=10)

This would result in a rotation going in the wrong direction (counter clockwise)?

As for the max_left_rotation == max_right_rotation that might well be a bug and I will investigate that....

Yes, for the example, the images would randomly rotation within 0-10 degrees counterclockwise.

itstechaj commented 1 year ago

Hi @YiweiZou - so in your case the rotate function always results in the rotations going in the wrong direction? So for example:

p.rotate(probability=0.7, max_left_rotation=0, max_right_rotation=10)

This would result in a rotation going in the wrong direction (counter clockwise)?

As for the max_left_rotation == max_right_rotation that might well be a bug and I will investigate that....

Hi @mdbloice ,

After reviewing the Operations.py file, I noticed that you assigned the angle of rotation as positive for clockwise rotation and negative for anticlockwise rotation. However, this is opposite to the default behavior of the image.rotate() method. In image.rotate() method, when a positive angle of rotation is provided, it performs an anticlockwise rotation, whereas a negative angle results in a clockwise rotation.

To address this inconsistency, I added a negative sign whenever you are passing the angle in the image.rotate() method in the Operations.py file. By adjusting the sign of the angle of rotation passed to the image.rotate() method, I ensured that the rotations are now correctly aligned with the intended clockwise and anticlockwise directions.

Since implementing these modifications I have tested, and all rotations have been functioning correctly in my local system.

Thank you.