def check_bdb(bdb2d, m, n):
    """
        Check valid a bounding box is valid

        Parameters
        ----------
        bdb2d: dict
            Keys: {'x1', 'x2', 'y1', 'y2'}
            The (x1, y1) position is at the top left corner,
            the (x2, y2) position is at the bottom right corner
        m: int
            width
        n: int
            height

        Returns
        -------
        valid: bool
    """
    if bdb2d['x1'] >= bdb2d['x2'] or bdb2d['y1'] >= bdb2d['y2'] or bdb2d['x1'] > m or bdb2d['y1'] > n:
        return False
    else:
        return True