Unverified Commit d7c895a3 authored by Hongkai Zhang's avatar Hongkai Zhang Committed by GitHub
Browse files

support multiple interpolation modes for imrotate (#545)

* support multiple interpolation modes for imrotate

* reformat code
parent c8435966
...@@ -227,6 +227,7 @@ def imrotate(img, ...@@ -227,6 +227,7 @@ def imrotate(img,
center=None, center=None,
scale=1.0, scale=1.0,
border_value=0, border_value=0,
interpolation='bilinear',
auto_bound=False): auto_bound=False):
"""Rotate an image. """Rotate an image.
...@@ -239,6 +240,7 @@ def imrotate(img, ...@@ -239,6 +240,7 @@ def imrotate(img,
used. used.
scale (float): Isotropic scale factor. scale (float): Isotropic scale factor.
border_value (int): Border value. border_value (int): Border value.
interpolation (str): Same as :func:`resize`.
auto_bound (bool): Whether to adjust the image size to cover the whole auto_bound (bool): Whether to adjust the image size to cover the whole
rotated image. rotated image.
...@@ -262,7 +264,11 @@ def imrotate(img, ...@@ -262,7 +264,11 @@ def imrotate(img,
matrix[1, 2] += (new_h - h) * 0.5 matrix[1, 2] += (new_h - h) * 0.5
w = int(np.round(new_w)) w = int(np.round(new_w))
h = int(np.round(new_h)) h = int(np.round(new_h))
rotated = cv2.warpAffine(img, matrix, (w, h), borderValue=border_value) rotated = cv2.warpAffine(
img,
matrix, (w, h),
flags=cv2_interp_codes[interpolation],
borderValue=border_value)
return rotated return rotated
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment