def imrotate(img,<EOL>angle,<EOL>center=None,<EOL>scale=<NUM_LIT:1.0>,<EOL>border_value=<NUM_LIT:0>,<EOL>auto_bound=False):
if center is not None and auto_bound:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>h, w = img.shape[:<NUM_LIT:2>]<EOL>if center is None:<EOL><INDENT>center = ((w - <NUM_LIT:1>) * <NUM_LIT:0.5>, (h - <NUM_LIT:1>) * <NUM_LIT:0.5>)<EOL><DEDENT>assert isinstance(center, tuple)<EOL>matrix = cv2.getRotationMatrix2D(center, -angle, scale)<EOL>if auto_bound:<EOL><INDENT>cos = np.abs(matrix[<NUM_LIT:0>, <NUM_LIT:0>])<EOL>sin = np.abs(matrix[<NUM_LIT:0>, <NUM_LIT:1>])<EOL>new_w = h * sin + w * cos<EOL>new_h = h * cos + w * sin<EOL>matrix[<NUM_LIT:0>, <NUM_LIT:2>] += (new_w - w) * <NUM_LIT:0.5><EOL>matrix[<NUM_LIT:1>, <NUM_LIT:2>] += (new_h - h) * <NUM_LIT:0.5><EOL>w = int(np.round(new_w))<EOL>h = int(np.round(new_h))<EOL><DEDENT>rotated = cv2.warpAffine(img, matrix, (w, h), borderValue=border_value)<EOL>return rotated<EOL>
Rotate an image.

    Args:
        img (ndarray): Image to be rotated.
        angle (float): Rotation angle in degrees, positive values mean
            clockwise rotation.
        center (tuple): Center of the rotation in the source image, by default
            it is the center of the image.
        scale (float): Isotropic scale factor.
        border_value (int): Border value.
        auto_bound (bool): Whether to adjust the image size to cover the whole
            rotated image.

    Returns:
        ndarray: The rotated image.