Esempio n. 1
0
#rotation and update of vertices
#The mesh can be rotated by any angle to get a different projection perspective
n11 = 0.05 * np.pi
n22 = 0.05 * np.pi

#Scale and rotate mesh
MHexam.scale_mesh(scale1)
MHexam.rotate_mesh(n11, "xy")
MHexam.rotate_mesh(n22, "zx")

#Initialisation of edges
MHexam.unique_edges()
#Identification of edges
MHexam.silhouette_vertices("Lodox", ViewP)
#projecting alignment points
points_proj = pm.project_points_ss(MHexam.silvert1, l0=ViewP, p0=p0)

#PLOT 1: Plotting mesh, silhouette points and projected points
print "Plot figure z-axis reversed (because z=0 is top of scan)"
mlab.figure(1, bgcolor=(1, 1, 1), size=(800, 800))
mlab.clf()
mlab.triangular_mesh(MHexam.vertices[:, 0],
                     MHexam.vertices[:, 1],
                     MHexam.vertices[:, 2] * (-1),
                     MHexam.faces,
                     colormap='Greens',
                     representation='surface',
                     opacity=0.2)

#points on the airway
mlab.points3d(MHexam.silvert1[:, 0],
#rotation and update of vertices
#The mesh can be rotated by any angle to get a different projection perspective
n11=0.05*np.pi
n22=0.05*np.pi

#Scale and rotate mesh
MHexam.scale_mesh(scale1)
MHexam.rotate_mesh(n11, "xy")    
MHexam.rotate_mesh(n22,"zx")

#Initialisation of edges
MHexam.unique_edges()
#Identification of edges
MHexam.silhouette_vertices("Lodox", ViewP)
#projecting alignment points
points_proj=pm.project_points_ss(MHexam.silvert1, l0=ViewP, p0=p0) 
        
#PLOT 1: Plotting mesh, silhouette points and projected points
print "Plot figure z-axis reversed (because z=0 is top of scan)"
mlab.figure(1, bgcolor=(1,1,1), size=(800,800))
mlab.clf()
mlab.triangular_mesh(MHexam.vertices[:,0], MHexam.vertices[:,1], 
                             MHexam.vertices[:,2]*(-1), MHexam.faces,
                             colormap='Greens', representation='surface',
                             opacity=0.2)

#points on the airway
mlab.points3d(MHexam.silvert1[:,0], MHexam.silvert1[:,1], MHexam.silvert1[:,2]*(-1), 
              scale_factor=1, color=(0,0,0))
#    #projected points
mlab.points3d(points_proj[:,0], points_proj[:,1], points_proj[:,2]*(-1), 
###################################################################################
#3D mesh manipulation and silhouette detection

#rotation and update of vertices
n11=0.05*np.pi
n22=0.05*np.pi

#3D mesh
MH.scale_mesh(scale1)
MHexam.scale_mesh(scale1)
MH.rotate_mesh(n11, "xy")
MHexam.rotate_mesh(n11, "xy")    
MH.rotate_mesh(n22, "zx")
MHexam.rotate_mesh(n22,"zx")
#Initialisation of edges
MH.unique_edges()
#Identification of edges
MH.silhouette_vertices("Lodox", ViewP)
#projecting alignment points
points_bif3Dproj=pm.project_points_ss(MH.points, l0=ViewP, p0=p0) 
skel_3Dproj=pm.project_points_ss(MH.skel, l0=ViewP, p0=p0)
points_proj=pm.project_points_ss(MH.silvert1, l0=ViewP, p0=p0) 
        
#PLOT 1: Plotting
meshplot_module.plot_big(MH, MHexam, points_proj, points_bif3Dproj, skel_3Dproj, ViewP, proj_type, fnum=1)
#mlab.savefig("figure1.x3d") #exporting as x3d
#mlab.savefig("figure1.png", magnification=2)
mlab.show()

n11 = 0.05 * np.pi
n22 = 0.05 * np.pi

#3D mesh
MH.scale_mesh(scale1)
MHexam.scale_mesh(scale1)
MH.rotate_mesh(n11, "xy")
MHexam.rotate_mesh(n11, "xy")
MH.rotate_mesh(n22, "zx")
MHexam.rotate_mesh(n22, "zx")
#Initialisation of edges
MH.unique_edges()
#Identification of edges
MH.silhouette_vertices("Lodox", ViewP)
#projecting alignment points
points_bif3Dproj = pm.project_points_ss(MH.points, l0=ViewP, p0=p0)
skel_3Dproj = pm.project_points_ss(MH.skel, l0=ViewP, p0=p0)
points_proj = pm.project_points_ss(MH.silvert1, l0=ViewP, p0=p0)

#PLOT 1: Plotting
meshplot_module.plot_big(MH,
                         MHexam,
                         points_proj,
                         points_bif3Dproj,
                         skel_3Dproj,
                         ViewP,
                         proj_type,
                         fnum=1)
#mlab.savefig("figure1.x3d") #exporting as x3d
#mlab.savefig("figure1.png", magnification=2)
mlab.show()