mindspore.dataset.vision.c_transforms.CenterCrop
- class mindspore.dataset.vision.c_transforms.CenterCrop(size)[source]
Crop the input image at the center to the given size.
- Parameters
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).
Examples
>>> # crop image to a square >>> transforms_list1 = [c_vision.Decode(), c_vision.CenterCrop(50)] >>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list1, ... input_columns=["image"]) >>> # crop image to portrait style >>> transforms_list2 = [c_vision.Decode(), c_vision.CenterCrop((60, 40))] >>> image_folder_dataset_1 = image_folder_dataset_1.map(operations=transforms_list2, ... input_columns=["image"])