(css, image_shape)
return max(css[0], 0), min(css[1], image_shape[1]), min(css[2], image_shape[0]), max(css[3], 0)
Make sure a tuple in (top, right, bottom, left) order is within the bounds of the image.

    :param css:  plain tuple representation of the rect in (top, right, bottom, left) order
    :param image_shape: numpy shape of the image array
    :return: a trimmed plain tuple representation of the rect in (top, right, bottom, left) order
Make sure a tuple in (top, right, bottom, left) order is within the bounds of the image.
Make sure a tuple in ( top right bottom left ) order is within the bounds of the image .
def _trim_css_to_bounds(css, image_shape):
    """
    Make sure a tuple in (top, right, bottom, left) order is within the bounds of the image.

    :param css:  plain tuple representation of the rect in (top, right, bottom, left) order
    :param image_shape: numpy shape of the image array
    :return: a trimmed plain tuple representation of the rect in (top, right, bottom, left) order
    """
    return max(css[0], 0), min(css[1], image_shape[1]), min(css[2], image_shape[0]), max(css[3], 0)
def _trim_css_to_bounds ( css , image_shape ) : return max ( css [ 0 ] , 0 ) , min ( css [ 1 ] , image_shape [ 1 ] ) , min ( css [ 2 ] , image_shape [ 0 ] ) , max ( css [ 3 ] , 0 )