← Back to all transforms
ShiftScaleRotate
Description
Randomly apply affine transforms: translate, scale and rotate the input. Args: shift_limit ((float, float) or float): shift factor range for both height and width. If shift_limit is a single float value, the range will be (-shift_limit, shift_limit). Absolute values for lower and upper bounds should lie in range [-1, 1]. Default: (-0.0625, 0.0625). scale_limit ((float, float) or float): scaling factor range. If scale_limit is a single float value, the range will be (-scale_limit, scale_limit). Note that the scale_limit will be biased by 1. If scale_limit is a tuple, like (low, high), sampling will be done from the range (1 + low, 1 + high). Default: (-0.1, 0.1). rotate_limit ((int, int) or int): rotation range. If rotate_limit is a single int value, the range will be (-rotate_limit, rotate_limit). Default: (-45, 45). interpolation (OpenCV flag): flag that is used to specify the interpolation algorithm. Should be one of: cv2.INTER_NEAREST, cv2.INTER_LINEAR, cv2.INTER_CUBIC, cv2.INTER_AREA, cv2.INTER_LANCZOS4. Default: cv2.INTER_LINEAR. border_mode (OpenCV flag): flag that is used to specify the pixel extrapolation method. Should be one of: cv2.BORDER_CONSTANT, cv2.BORDER_REPLICATE, cv2.BORDER_REFLECT, cv2.BORDER_WRAP, cv2.BORDER_REFLECT_101. Default: cv2.BORDER_REFLECT_101 value (int, float, list of int, list of float): padding value if border_mode is cv2.BORDER_CONSTANT. mask_value (int, float, list of int, list of float): padding value if border_mode is cv2.BORDER_CONSTANT applied for masks. shift_limit_x ((float, float) or float): shift factor range for width. If it is set then this value instead of shift_limit will be used for shifting width. If shift_limit_x is a single float value, the range will be (-shift_limit_x, shift_limit_x). Absolute values for lower and upper bounds should lie in the range [-1, 1]. Default: None. shift_limit_y ((float, float) or float): shift factor range for height. If it is set then this value instead of shift_limit will be used for shifting height. If shift_limit_y is a single float value, the range will be (-shift_limit_y, shift_limit_y). Absolute values for lower and upper bounds should lie in the range [-, 1]. Default: None. rotate_method (str): rotation method used for the bounding boxes. Should be one of "largest_box" or "ellipse". Default: "largest_box" p (float): probability of applying the transform. Default: 0.5. Targets: image, mask, keypoints, bboxes Image types: uint8, float32
Parameters
- p: float (default: 0.5)
- shift_limit: int | tuple[int, int] | float | tuple[float, float] (default: (-0.0625, 0.0625))
- scale_limit: int | tuple[int, int] | float | tuple[float, float] (default: (-0.1, 0.1))
- rotate_limit: int | tuple[int, int] | float | tuple[float, float] (default: (-45, 45))
- interpolation: Literal['cv2.INTER_NEAREST', 'cv2.INTER_LINEAR', 'cv2.INTER_CUBIC', 'cv2.INTER_AREA', 'cv2.INTER_LANCZOS4', 'cv2.INTER_BITS', 'cv2.INTER_NEAREST_EXACT', 'cv2.INTER_MAX'] (default: 1)
- border_mode: Literal['cv2.BORDER_CONSTANT', 'cv2.BORDER_REPLICATE', 'cv2.BORDER_REFLECT', 'cv2.BORDER_WRAP', 'cv2.BORDER_DEFAULT', 'cv2.BORDER_TRANSPARENT'] (default: 4)
- value: float | Sequence[float] (default: 0)
- mask_value: float | Sequence[float] (default: 0)
- shift_limit_x: float | tuple[float, float] | None (default: null)
- shift_limit_y: float | tuple[float, float] | None (default: null)
- rotate_method: Literal['largest_box', 'ellipse'] (default: 'largest_box')
Targets
- Image
- Mask
- Keypoints
- BBoxes
Try it out
Original Image (width = 484, height = 733):
Transformed Image:
Transform not yet applied