imrotate
-
Description: Rotates the input image.
-
Parameters
- img (
np.ndarray): The input image to be rotated. - angle (
float): The rotation angle in degrees, counterclockwise. - scale (
float): The scaling factor. Default is 1. - interpolation (
str | int | INTER): Interpolation method. Available options:INTER.NEAREST,INTER.BILINEAR,INTER.CUBIC,INTER.AREA,INTER.LANCZOS4. Default isINTER.BILINEAR. - bordertype (
Union[str, int, BORDER]): The border type. Available options include: BORDER.CONSTANT, BORDER.REPLICATE, BORDER.REFLECT, BORDER.REFLECT_101. Default is BORDER.CONSTANT. - bordervalue (
Union[int, Tuple[int, int, int]]): The value used to fill the border. Only used when bordertype is BORDER.CONSTANT. Default is None. - expand (
bool): Whether to expand the output image to fit the entire rotated image. Default isTrue. - center (
tuple[int, int] | None): The center of rotation.Nonemeans image center.
- img (
-
Returns
- np.ndarray: The rotated image.
-
Example
import capybara as cb
img = cb.imread('lena.png')
rotate_img = cb.imrotate(img, 45, bordertype=cb.BORDER.CONSTANT, expand=True)
# Resize the rotated image to the original size for visualization
rotate_img = cb.imresize(rotate_img, [img.shape[0], img.shape[1]])