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 height width.

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

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

  • data_format (str) – Either “NCHW” or “NHWC”.

Returns

Cropped image.

Return type

(numpy.ndarray, torch.tensor)