cv3.transform.rotate

cv3.transform.rotate(img, angle, inter=1, border=0, value=None)[source]

Rotate image by specified angle.

Parameters:
  • img (numpy.ndarray) – Input image.

  • angle (float) – Rotation angle in degrees.

  • inter (int or str, optional) – Interpolation method. Can be one of: ‘nearest’, ‘linear’, ‘area’, ‘cubic’, ‘lanczos4’ or OpenCV flags. Defaults to cv2.INTER_LINEAR.

  • border (int or str, optional) – Border type. Can be one of: ‘constant’, ‘replicate’, ‘reflect’, ‘wrap’, ‘default’ or OpenCV flags. Defaults to cv2.BORDER_CONSTANT.

  • value – Border color value for constant border type. Defaults to None.

Returns:

Rotated image.

Return type:

numpy.ndarray

Example

>>> import cv3
>>> import numpy as np
>>> # Create a simple image
>>> img = np.zeros((100, 100, 3), dtype=np.uint8)
>>> img[25:75, 25:75] = [255, 255, 255]  # White square
>>> # Rotate 45 degrees
>>> rotated = cv3.rotate(img, 45)
>>> # Rotate with custom border color
>>> rotated = cv3.rotate(img, 45, value=[0, 128, 128])