(a, b)
return area_i / np.maximum(area_a[:, np.newaxis], 1)
return iof of a and b, numpy version for data augenmentation
return iof of a and b, numpy version for data augenmentation
return iof of a and b numpy version for data augenmentation
def matrix_iof(a, b):
    """
    return iof of a and b, numpy version for data augenmentation
    """
    lt = np.maximum(a[:, np.newaxis, :2], b[:, :2])
    rb = np.minimum(a[:, np.newaxis, 2:], b[:, 2:])

    area_i = np.prod(rb - lt, axis=2) * (lt < rb).all(axis=2)
    area_a = np.prod(a[:, 2:] - a[:, :2], axis=1)
    return area_i / np.maximum(area_a[:, np.newaxis], 1)
def matrix_iof ( a , b ) : lt = np . maximum ( a [ : , np . newaxis , : 2 ] , b [ : , : 2 ] ) rb = np . minimum ( a [ : , np . newaxis , 2 : ] , b [ : , 2 : ] ) area_i = np . prod ( rb - lt , axis = 2 ) * ( lt < rb ) . all ( axis = 2 ) area_a = np . prod ( a [ : , 2 : ] - a [ : , : 2 ] , axis = 1 ) return area_i / np . maximum ( area_a [ : , np . newaxis ] , 1 )