mindspore.dataset.vision.c_transforms.CenterCrop

class mindspore.dataset.vision.c_transforms.CenterCrop(size)[source]

Crops 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

>>> import mindspore.dataset.vision.c_transforms as c_vision
>>>
>>> # crop image to a square
>>> transforms_list1 = [c_vision.Decode(), c_vision.CenterCrop(50)]
>>> data1 = data1.map(operations=transforms_list1, input_columns=["image"])
>>> # crop image to portrait style
>>> transforms_list2 = [c_vision.Decode(), c_vision.CenterCrop((60, 40))]
>>> data2 = data2.map(operations=transforms_list2, input_columns=["image"])