centre_crop_to_shape

centre_crop_to_shape(x, y, data_format='NCHW')[source]

A function to center crop image to shape.

Centre crop x so that x has shape of y and y height and width must be smaller than x heigh width.

Parameters
  • x (ndarray, torch.tensor) – Image to be cropped.

  • y (ndarray, torch.tensor) – Reference image for getting cropping shape, should be of 3 channels.

  • data_format (str) – Should either be NCHW or NHWC.

Returns

(ndarray, torch.tensor) Cropped image.