centre_crop

centre_crop(img, crop_shape, data_format='NCHW')[source]

A function to center crop image with given crop shape.

Parameters:
  • img (numpy.ndarray, torch.Tensor) – Input image, should be of 3 channels.

  • crop_shape (numpy.ndarray, torch.Tensor) – The subtracted amount in the form of [subtracted height, subtracted width].

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

Returns:

Cropped image.

Return type:

(numpy.ndarray, torch.Tensor)