def cropping_center(img, crop_shape, batch=False):
    """
    Crop an array at the centre

    Args:
        img: input array
        crop_shape: new spatial dimensions (h,w)
    """

    orig_shape = img.shape
    if not batch:
        h_0 = int((orig_shape[0] - crop_shape[0]) * 0.5)
        w_0 = int((orig_shape[1] - crop_shape[1]) * 0.5)
        img = img[h_0:h_0 + crop_shape[0], w_0:w_0 + crop_shape[1]]
    else:
        h_0 = int((orig_shape[1] - crop_shape[0]) * 0.5)
        w_0 = int((orig_shape[2] - crop_shape[1]) * 0.5)
        img = img[:, h_0:h_0 + crop_shape[0], w_0:w_0 + crop_shape[1]]
    return img