mindspore.dataset.vision.py_transforms.RandomRotation

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

Rotate the input PIL image by a random angle.

Parameters
  • degrees (Union[int, float, sequence]) – Range of random rotation degrees. If degrees is a number, the range will be converted to (-degrees, degrees). If degrees is a sequence, it should be (min, max).

  • resample (Inter mode, optional) –

    An optional resampling filter (default=Inter.NEAREST). If omitted, or if the image has mode “1” or “P”, it is set to be Inter.NEAREST. It can be any of [Inter.NEAREST, Inter.ANTIALIAS, Inter.BILINEAR, Inter.BICUBIC].

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

    • Inter.ANTIALIAS, means the resampling method is antialias interpolation.

    • Inter.BILINEAR, means the resampling method is bilinear interpolation.

    • Inter.BICUBIC, means the resampling 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. Default None sets to the center of the image.

  • fill_value (int or tuple, optional) – Optional fill color for the area outside the rotated image (default=0). If it is a 3-tuple, it is used for R, G, B channels respectively. If it is an integer, it is used for all RGB channels. Default is 0.

Examples

>>> from mindspore.dataset.transforms.py_transforms import Compose
>>> transforms_list = Compose([py_vision.Decode(),
...                            py_vision.RandomRotation(30),
...                            py_vision.ToTensor()])
>>> # apply the transform to dataset through map function
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
...                                                 input_columns="image")