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 defined by
Inter
. Default:Inter.BILINEAR
.
- Raises
TypeError – If top is not of type int.
ValueError – If top is negative.
TypeError – If left is not of type int.
ValueError – If left is negative.
TypeError – If height is not of type int.
ValueError – If height is not positive.
TypeError – If width is not of type int.
ValueError – If width is not positive.
TypeError – If size is not of type int or Sequence[int, int].
ValueError – If size is not posotive.
RuntimeError – If shape of the input image is not <H, W> or <H, W, C>.
- 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: