cv3.transform.xshift

cv3.transform.xshift(img, x, border=0, value=None, rel=None)[source]

Shift image horizontally by x pixels.

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

  • x (int or float) – Shift in x direction.

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

  • rel (bool, optional) – Whether to interpret x as relative value. Defaults to None.

Returns:

Horizontally shifted 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
>>> # Shift by 10 pixels in x direction
>>> shifted = cv3.xshift(img, 10)