contours.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:LabelsManager 作者: SebastianoF 项目源码 文件源码
def contour_from_array_at_label_l(im_arr, l, thr=0.3, omit_axis=None, verbose=0):
    if verbose > 0:
        print(l)
    array_label_l = im_arr == l
    assert isinstance(array_label_l, np.ndarray)
    gra = np.gradient(array_label_l.astype(np.bool).astype(np.float64))
    if omit_axis is None:
        norm_gra = np.sqrt(gra[0] ** 2 + gra[1] ** 2 + gra[2] ** 2) > thr
    elif omit_axis == 'x':
        norm_gra = np.sqrt(gra[1] ** 2 + gra[2] ** 2) > thr
    elif omit_axis == 'y':
        norm_gra = np.sqrt(gra[0] ** 2 + gra[2] ** 2) > thr
    elif omit_axis == 'z':
        norm_gra = np.sqrt(gra[0] ** 2 + gra[1] ** 2) > thr
    else:
        raise IOError
    return norm_gra
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号