mindspore.dataset.vision.Crop
- class mindspore.dataset.vision.Crop(coordinates, size)[source]
Crop the input image at a specific location.
- Parameters
coordinates (sequence) – Coordinates of the upper left corner of the cropping image. Must be a sequence of two values, in the form of (top, left).
size (Union[int, sequence]) – The output size of the cropped image. If size is an integer, a square crop of size (size, size) is returned. If size is a sequence of length 2, it should be (height, width). The size value(s) must be larger than 0.
- Raises
TypeError – If coordinates is not of type sequence.
TypeError – If size is not of type integer or sequence.
ValueError – If coordinates is less than 0.
ValueError – If size is less than or equal to 0.
RuntimeError – If given tensor shape is not <H, W> or <H, W, C>.
- Supported Platforms:
CPU
Examples
>>> import mindspore.dataset as ds >>> import mindspore.dataset.vision as vision >>> >>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory") >>> decode_op = vision.Decode() >>> crop_op = vision.Crop((0, 0), 32) >>> transforms_list = [decode_op, crop_op] >>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list, ... input_columns=["image"])
- Tutorial Examples: