Skip to content

Commit d9cd716

Browse files
authored
Merge pull request #443 from MarieRoald/floating-point-rotation-angle
Minor improvements for geometric rotations
2 parents 49f34c6 + 9246273 commit d9cd716

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

augraphy/augmentations/geometric.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Geometric(Augmentation):
3131
xn (int) = image width * xn (float and 0.0 - 1.0);
3232
yn (int) = image height * yn (float and 0.0 - 1.0)
3333
:type crop: tuple, optional
34-
:param rotate_range: Pair of ints determining the range from which to sample
34+
:param rotate_range: Pair of ints or floats determining the range from which to sample
3535
the image rotation.
3636
:type rotate_range: tuple, optional
3737
:param randomize: Flag to apply random geometric transformations.
@@ -118,7 +118,7 @@ def randomize_parameters(self, image):
118118
random.randint(0, int(ysize / 5)),
119119
]
120120
self.padding_value = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
121-
self.padding_typee = random.choice(["fill", "mirror", "duplicate"])
121+
self.padding_type = random.choice(["fill", "mirror", "duplicate"])
122122

123123
def run_crop(self, image, mask, keypoints, bounding_boxes):
124124
"""Crop image based on the input cropping box.
@@ -597,15 +597,15 @@ def run_rotation(self, image, mask, keypoints, bounding_boxes):
597597

598598
# generate random angle
599599
if (self.rotate_range[0] != 0) | (self.rotate_range[1] != 0):
600-
angle = random.randint(self.rotate_range[0], self.rotate_range[1])
600+
angle = random.uniform(self.rotate_range[0], self.rotate_range[1])
601601
else:
602602
angle = 0
603603
# rotate image
604604
if angle != 0:
605605
ysize, xsize = image.shape[:2]
606606

607607
# rotate image
608-
image = rotate_image_PIL(image, angle, expand=1)
608+
image = rotate_image_PIL(image, angle, expand=1, background_value=self.padding_value)
609609

610610
# rotate mask
611611
if mask is not None:

0 commit comments

Comments
 (0)