Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the sign of the angle in image.rotate() method #256

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions Augmentor/Operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,10 @@ def perform_operation(self, images):
rotation = random_right

def do(image):
return image.rotate(rotation, expand=self.expand, resample=Image.BICUBIC, fillcolor=self.fillcolor)
# By default, the image.rotate() method rotates the image in the anticlockwise direction for a positive rotation angle.
# To rotate the image in the clockwise direction, provide a negative rotation angle.
# return image.rotate(rotation, expand=self.expand, resample=Image.BICUBIC, fillcolor=self.fillcolor)
return image.rotate(-rotation, expand=self.expand, resample=Image.BICUBIC, fillcolor=self.fillcolor)

augmented_images = []

Expand Down Expand Up @@ -723,9 +726,15 @@ def perform_operation(self, images):

def do(image):
if self.rotation == -1:
return image.rotate(90 * random_factor, expand=True)
# By default, the image.rotate() method rotates the image in the anticlockwise direction for a positive rotation angle.
# To rotate the image in the clockwise direction, provide a negative rotation angle.
# return image.rotate(90 * random_factor, expand=True)
return image.rotate(-1*90 * random_factor, expand=True)
else:
return image.rotate(self.rotation, expand=True)
# By default, the image.rotate() method rotates the image in the anticlockwise direction for a positive rotation angle.
# To rotate the image in the clockwise direction, provide a negative rotation angle.
# return image.rotate(self.rotation, expand=True)
return image.rotate(-self.rotation, expand=True)

augmented_images = []

Expand Down Expand Up @@ -812,8 +821,11 @@ def do(image):
x = image.size[0]
y = image.size[1]

# By default, the image.rotate() method rotates the image in the anticlockwise direction for a positive rotation angle.
# To rotate the image in the clockwise direction, provide a negative rotation angle.
# Rotate, while expanding the canvas size
image = image.rotate(rotation, expand=True, resample=Image.BICUBIC)
# image = image.rotate(rotation, expand=True, resample=Image.BICUBIC)
image = image.rotate(-rotation, expand=True, resample=Image.BICUBIC)

# Get size after rotation, which includes the empty space
X = image.size[0]
Expand Down