cv3.transform.transform

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

Apply affine transformation to image.

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

  • angle (float) – Rotation angle in degrees.

  • scale (float) – Scaling factor.

  • 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:

Transformed 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 and scale by 1.5
>>> transformed = cv3.transform(img, 45, 1.5)
>>> # Rotate with custom border color
>>> transformed = cv3.transform(img, 45, 1.5, value='red')