mindspore.dataset.vision.FiveCrop

class mindspore.dataset.vision.FiveCrop(size)[source]

Crop the given image into one central crop and four corners.

Parameters

size (Union[int, Sequence[int, int]]) – The size of the cropped image. If a single integer is provided, a square of size (size, size) will be cropped with this value. If a Sequence of length 2 is provided, an image of size (height, width) will be cropped.

Raises
  • TypeError – If size is not of type integer or Sequence of integer.

  • ValueError – If size is not positive.

Supported Platforms:

CPU

Examples

>>> import numpy
>>> from mindspore.dataset.transforms import Compose
>>>
>>> transforms_list = Compose([vision.Decode(to_pil=True),
...                            vision.FiveCrop(size=200),
...                            # 4D stack of 5 images
...                            lambda *images: numpy.stack([vision.ToTensor()(image) for image in images])])
>>> # apply the transform to dataset through map function
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
...                                                 input_columns="image")