mmcv/image/transforms/geometry.py
def bbox_clip(bboxes, img_shape):
    """Clip bboxes to fit the image shape.

    Args:
        bboxes (ndarray): Shape (..., 4*k)
        img_shape (tuple): (height, width) of the image.

    Returns:
        ndarray: Clipped bboxes.
    """
    assert bboxes.shape[-1] % 4 == 0
    clipped_bboxes = np.empty_like(bboxes, dtype=bboxes.dtype)
    clipped_bboxes[..., 0::2] = np.maximum(
        np.minimum(bboxes[..., 0::2], img_shape[1] - 1), 0)
    clipped_bboxes[..., 1::2] = np.maximum(
        np.minimum(bboxes[..., 1::2], img_shape[0] - 1), 0)
    return clipped_bboxes
def bbox_clip(bboxes, img_shape):
    assert bboxes.shape[-1] % 4 == 0
    clipped_bboxes = np.empty_like(bboxes, dtype=bboxes.dtype)
    clipped_bboxes[..., 0::2] = np.maximum(
        np.minimum(bboxes[..., 0::2], img_shape[1] - 1), 0)
    clipped_bboxes[..., 1::2] = np.maximum(
        np.minimum(bboxes[..., 1::2], img_shape[0] - 1), 0)
    return clipped_bboxes
def bbox_clip ( bboxes , img_shape ) : assert bboxes . shape [ - 1 ] % 4 == 0 clipped_bboxes = np . empty_like ( bboxes , dtype = bboxes . dtype ) clipped_bboxes [ ... , 0 : : 2 ] = np . maximum ( np . minimum ( bboxes [ ... , 0 : : 2 ] , img_shape [ 1 ] - 1 ) , 0 ) clipped_bboxes [ ... , 1 : : 2 ] = np . maximum ( np . minimum ( bboxes [ ... , 1 : : 2 ] , img_shape [ 0 ] - 1 ) , 0 ) return clipped_bboxes
Clip bboxes to fit the image shape.

    Args:
        bboxes (ndarray): Shape (..., 4*k)
        img_shape (tuple): (height, width) of the image.

    Returns:
        ndarray: Clipped bboxes.
Clip bboxes to fit the image shape .