mindspore.dataset.vision.ResizedCrop

class mindspore.dataset.vision.ResizedCrop(top, left, height, width, size, interpolation=Inter.BILINEAR)[source]

Crop the input image at a specific region and resize it to desired size.

Parameters
  • top (int) – Horizontal ordinate of the upper left corner of the crop region.

  • left (int) – Vertical ordinate of the upper left corner of the crop region.

  • height (int) – Height of the crop region.

  • width (int) – Width of the cropp region.

  • size (Union[int, Sequence[int, int]]) – The size of the output image. If int is provided, the smaller edge of the image will be resized to this value, keeping the image aspect ratio the same. If Sequence[int, int] is provided, it should be (height, width).

  • interpolation (Inter, optional) –

    Image interpolation method. Default: Inter.BILINEAR. It can be Inter.LINEAR, Inter.NEAREST, Inter.BICUBIC, Inter.AREA or Inter.PILCUBIC.

    • Inter.LINEAR , bilinear interpolation.

    • Inter.NEAREST , nearest-neighbor interpolation.

    • Inter.BICUBIC , bicubic interpolation.

    • Inter.AREA :, pixel area interpolation.

    • Inter.PILCUBIC , cubic interpolation based on the implementation of Pillow

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.ResizedCrop(0, 0, 128, 128, (100, 75), Inter.BILINEAR)]
>>> 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: