mindspore.dataset.vision.c_transforms.Crop

class mindspore.dataset.vision.c_transforms.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, an image of size (height, width) will be cropped. 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 int 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

>>> decode_op = c_vision.Decode()
>>> crop_op = c_vision.Crop((0, 0), 32)
>>> transforms_list = [decode_op, crop_op]
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
...                                                 input_columns=["image"])