mindspore.dataset.vision.Rotate

class mindspore.dataset.vision.Rotate(degrees, resample=Inter.NEAREST, expand=False, center=None, fill_value=0)[source]

Rotate the input image by specified degrees.

Parameters
  • degrees (Union[int, float]) – Rotation degrees.

  • resample (Inter, optional) –

    An optional resampling filter. Default: Inter.NEAREST. It can be Inter.BILINEAR, Inter.NEAREST, Inter.BICUBIC.

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

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

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

  • expand (bool, optional) – Optional expansion flag. Default: False. If set to True, expand the output image to make it large enough to hold the entire rotated image. If set to False or omitted, make the output image the same size as the input. Note that the expand flag assumes rotation around the center and no translation.

  • center (tuple, optional) – Optional center of rotation (a 2-tuple). Default: None. Origin is the top left corner. None sets to the center of the image.

  • fill_value (Union[int, tuple[int]], optional) – Optional fill color for the area outside the rotated image. If it is a 3-tuple, it is used to fill R, G, B channels respectively. If it is an integer, it is used for all RGB channels. The fill_value values must be in range [0, 255]. Default: 0.

Raises
Supported Platforms:

CPU

Examples

>>> import mindspore.dataset as ds
>>> import mindspore.dataset.vision as vision
>>> from mindspore.dataset.vision import Inter
>>>
>>> transforms_list = [vision.Decode(),
...                    vision.Rotate(degrees=30.0,
...                    resample=Inter.NEAREST,
...                    expand=True)]
>>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
...                                                 input_columns=["image"])
Tutorial Examples: