def edge_direction_3D(E, r=4): D = conv_tri_3D(E, r) Ox, Oy, Oz = np.gradient(D) M = np.sqrt(Ox * Ox + Oy * Oy + Oz * Oz) Ox, Oy, Oz = (Ox, Oy, Oz) / maxeps(M, 1e-5) theta = np.arctan(Oy / maxeps(Oz, 1e-5)) phi = np.arctan(Oz / maxeps(M, 1e-5)) Px = np.sin(theta) * np.cos(phi) Py = np.sin(theta) * np.sin(phi) Pz = np.cos(phi) return Px, Py, Pz, D
def edge_direction_3D(E,r=4): D = conv_tri_3D(E,r) Ox,Oy,Oz = np.gradient(D) M = np.sqrt(Ox*Ox+Oy*Oy+Oz*Oz) Ox,Oy,Oz = (Ox,Oy,Oz)/maxeps(M,1e-5) theta = np.arctan(Oy/maxeps(Oz,1e-5)) phi = np.arctan(Oz/maxeps(M,1e-5)) Px= np.sin(theta)*np.cos(phi) Py= np.sin(theta)*np.sin(phi) Pz= np.cos(phi) return Px,Py,Pz,D
def edge_auto_nms_3D(E,sigma1=1,sigma2=5,r=1,m=1.001,border_s=0, debug_save=False, size_check=False): E = normal_img(E) if sigma1>0: Eb = conv_tri_3D(E,sigma1) else: Eb = E vmin,vmax = E.min(),E.max() dX, dY, dZ, _ = edge_direction_3D(Eb,r=sigma2) if size_check: print(E.shape) if debug_save: savearr(dX,"dX.txt") savearr(dY,"dY.txt") savearr(dZ,"dZ.txt") savearr(E,"E.txt") Enms = edgeNms3d(Eb, dY,dX, dZ, r=r, s=border_s, m=m) return normal_img(Enms)
def edge_auto_nms_3D(E, sigma1=1, sigma2=5, r=1, m=1.001, border_s=0, debug_save=False, size_check=False): E = normal_img(E) if sigma1 > 0: Eb = conv_tri_3D(E, sigma1) else: Eb = E vmin, vmax = E.min(), E.max() dX, dY, dZ, _ = edge_direction_3D(Eb, r=sigma2) if size_check: print(E.shape) if debug_save: savearr(dX, "dX.txt") savearr(dY, "dY.txt") savearr(dZ, "dZ.txt") savearr(E, "E.txt") Enms = edgeNms3d(Eb, dY, dX, dZ, r=r, s=border_s, m=m) return normal_img(Enms)