MCPcopy Create free account
hub / github.com/DragonisCV/RAM / img_rotate

Function img_rotate

ram/data/utils/transforms.py:196–214  ·  view source on GitHub ↗

Rotate image. Args: img (ndarray): Image to be rotated. angle (float): Rotation angle in degrees. Positive values mean counter-clockwise rotation. center (tuple[int]): Rotation center. If the center is None, initialize it as the center of the imag

(img, angle, center=None, scale=1.0)

Source from the content-addressed store, hash-verified

194
195
196def img_rotate(img, angle, center=None, scale=1.0):
197 """Rotate image.
198
199 Args:
200 img (ndarray): Image to be rotated.
201 angle (float): Rotation angle in degrees. Positive values mean
202 counter-clockwise rotation.
203 center (tuple[int]): Rotation center. If the center is None,
204 initialize it as the center of the image. Default: None.
205 scale (float): Isotropic scale factor. Default: 1.0.
206 """
207 (h, w) = img.shape[:2]
208
209 if center is None:
210 center = (w // 2, h // 2)
211
212 matrix = cv2.getRotationMatrix2D(center, angle, scale)
213 rotated_img = cv2.warpAffine(img, matrix, (w, h))
214 return rotated_img

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected