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 of length 2, it should be in shape of (min, max).
resample (Inter, optional) –
An optional resampling filter (default=Inter.NEAREST). If the image is in mode of “1” or “P”, it is set to Inter.NEAREST by default. It can be any of [Inter.NEAREST, Inter.ANTIALIAS, Inter.BILINEAR, Inter.BICUBIC].
Inter.NEAREST, nearest-neighbor interpolation.
Inter.ANTIALIAS, antialias interpolation.
Inter.BILINEAR, bilinear interpolation.
Inter.BICUBIC, 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, keep 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, which must be a tuple of length 2 (default=None). Origin is the top left corner. Default None means to set the center of the image.
fill_value (int or tuple, optional) – Pixel fill value for the area outside the rotated image (default=0). If fill_value is a tuple of length 3, it is used to fill R, G, B channels respectively. If fill_value is an integer, it is used to fill all RGB channels.
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")