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)
| 194 | |
| 195 | |
| 196 | def 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 |
nothing calls this directly
no outgoing calls
no test coverage detected