cv3.transform.resize

cv3.transform.resize(img, width, height, inter=1, rel=None)[source]

Resize image to specified dimensions.

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

  • width (int or float) – Target width.

  • height (int or float) – Target height.

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

  • rel (bool, optional) – Whether to interpret width and height as relative values. Defaults to None.

Returns:

Resized 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
>>> # Resize to 200x200
>>> resized = cv3.resize(img, 200, 200)