mindspore.dataset.vision.Affine

class mindspore.dataset.vision.Affine(degrees, translate, scale, shear, resample=Inter.NEAREST, fill_value=0)[source]

Apply Affine transformation to the input image, keeping the center of the image unchanged.

Parameters
  • degrees (float) – Rotation angle in degrees between -180 and 180, clockwise direction.

  • translate (Sequence[float, float]) – The horizontal and vertical translations, must be a sequence of size 2.

  • scale (float) – Scaling factor, which must be positive.

  • shear (Union[float, Sequence[float, float]]) – Shear angle value in degrees between -180 to 180. If float is provided, shear along the x axis with this value, without shearing along the y axis; If Sequence[float, float] is provided, shear along the x axis and y axis with these two values separately.

  • resample (Inter, optional) –

    An optional resampling filter. Default: Inter.NEAREST. It can be any of [Inter.BILINEAR, Inter.NEAREST, Inter.BICUBIC, Inter.AREA].

    • Inter.BILINEAR, means resample method is bilinear interpolation.

    • Inter.NEAREST, means resample method is nearest-neighbor interpolation.

    • Inter.BICUBIC, means resample method is bicubic interpolation.

    • Inter.AREA, means resample method is pixel area interpolation.

  • fill_value (Union[int, tuple[int, int, int]], optional) – Optional fill_value to fill the area outside the transform in the output image. There must be three elements in tuple and the value of single element is [0, 255]. Default: 0.

Raises
Supported Platforms:

CPU

Examples

>>> from mindspore.dataset.vision import Inter
>>>
>>> decode_op = vision.Decode()
>>> affine_op = vision.Affine(degrees=15, translate=[0.2, 0.2], scale=1.1, shear=[1.0, 1.0],
...                           resample=Inter.BILINEAR)
>>> affine_list = [decode_op, affine_op]
>>> image_folder_dataset = image_folder_dataset.map(operations=affine_list, input_columns=["image"])