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
评论列表
文章目录