draco.triangulation_topomesh = triangulation_topomesh triangular= ['star','flat'] triangular = ['star','remeshed','projected','exact','flat'] image_dual_topomesh = draco.dual_reconstruction(reconstruction_triangulation = triangular, adjacency_complex_degree=3) #image_dual_topomesh = draco.draco_topomesh(reconstruction_triangulation = triangular) world.add(image_dual_topomesh ,'dual_reconstuction') import openalea.draco_stem.stem.tissue_mesh_quality reload(openalea.draco_stem.stem.tissue_mesh_quality) from openalea.draco_stem.stem.tissue_mesh_quality import evaluate_topomesh_quality quality_criteria=["Mesh Complexity","Triangle Area Deviation","Triangle Eccentricity","Vertex Valence","Image Accuracy","Vertex Distance","Cell 2 Adjacency","Cell Convexity","Epidermis Cell Angle","Cell Cliques"] dual_quality = evaluate_topomesh_quality(image_dual_topomesh,quality_criteria,image=draco.segmented_image,image_cell_vertex=draco.image_cell_vertex,image_labels=draco.image_labels,image_cell_volumes=draco.image_cell_volumes,image_graph=draco.image_graph) from vplants.meshing.cute_plot import spider_plot import matplotlib.pyplot as plt figure = plt.figure(2) figure.clf() spider_plot(figure,np.array([dual_quality[c] for c in quality_criteria]),color1=np.array([0.3,0.6,1.]),color2=np.array([1.,0.,0.]),xlabels=quality_criteria,ytargets=0.8 * np.ones_like(quality_criteria,float),n_points=100*len(quality_criteria),linewidth=2,smooth_factor=0.0,spline_order=1) plt.show(block=False) raw_input() triangular_string = "" for t in triangular: triangular_string += t+"_" topomesh_filename = dirname+"/output_meshes/"+filename+"/"+filename+"_"+triangular_string+"topomesh.ply"
topomesh_img = compute_topomesh_image(image_topomesh, idra.segmented_image) world.add(topomesh_img, "CGAL_image", colormap="glasbey", alphamap="constant", bg_id=1) quality_criteria = [ "Mesh Complexity", "Triangle Area Deviation", "Triangle Eccentricity", "Vertex Valence", "Image Accuracy", "Vertex Distance", "Cell 2 Adjacency", "Cell Convexity", "Epidermis Cell Angle", "Cell Cliques" ] cgal_quality = evaluate_topomesh_quality( image_topomesh, quality_criteria, image=idra.segmented_image, image_cell_vertex=image_cell_vertex, image_labels=idra.image_labels, image_cell_volumes=idra.image_cell_volumes) from vplants.meshing.cute_plot import spider_plot import matplotlib.pyplot as plt figure = plt.figure(0) figure.clf() spider_plot(figure, np.array([cgal_quality[c] for c in quality_criteria]), color1=np.array([0.3, 0.6, 1.]), color2=np.array([1., 0., 0.]), xlabels=quality_criteria, ytargets=0.8 * np.ones_like(quality_criteria, float),
world.add(image_dual_topomesh, 'dual_reconstuction') import openalea.draco_stem.stem.tissue_mesh_quality reload(openalea.draco_stem.stem.tissue_mesh_quality) from openalea.draco_stem.stem.tissue_mesh_quality import evaluate_topomesh_quality quality_criteria = [ "Mesh Complexity", "Triangle Area Deviation", "Triangle Eccentricity", "Vertex Valence", "Image Accuracy", "Vertex Distance", "Cell 2 Adjacency", "Cell Convexity", "Epidermis Cell Angle", "Cell Cliques" ] dual_quality = evaluate_topomesh_quality( image_dual_topomesh, quality_criteria, image=draco.segmented_image, image_cell_vertex=draco.image_cell_vertex, image_labels=draco.image_labels, image_cell_volumes=draco.image_cell_volumes, image_graph=draco.image_graph) from vplants.meshing.cute_plot import spider_plot import matplotlib.pyplot as plt figure = plt.figure(2) figure.clf() spider_plot(figure, np.array([dual_quality[c] for c in quality_criteria]), color1=np.array([0.3, 0.6, 1.]), color2=np.array([1., 0., 0.]), xlabels=quality_criteria, ytargets=0.8 * np.ones_like(quality_criteria, float),
idra = IdraMesh(image_file=inputfile) world.add(idra.segmented_image,filename,colormap="glasbey",alphamap="constant",bg_id=1) raw_input() image_topomesh = idra.idra_topomesh(mesh_fineness=1.0) #world.add(image_topomesh,"CGAL_topomesh") cell_vertex_file = dirname+"/output_meshes/"+filename+"/image_cell_vertex.dict" image_cell_vertex = pickle.load(open(cell_vertex_file,'rb')) image_cell_vertex = dict(zip(image_cell_vertex.keys(),np.array(image_cell_vertex.values())*idra.resolution)) from openalea.mesh.utils.image_tools import compute_topomesh_image topomesh_img = compute_topomesh_image(image_topomesh,idra.segmented_image) world.add(topomesh_img,"CGAL_image",colormap="glasbey",alphamap="constant",bg_id=1) quality_criteria=["Mesh Complexity","Triangle Area Deviation","Triangle Eccentricity","Vertex Valence","Image Accuracy","Vertex Distance","Cell 2 Adjacency","Cell Convexity","Epidermis Cell Angle","Cell Cliques"] cgal_quality = evaluate_topomesh_quality(image_topomesh,quality_criteria,image=idra.segmented_image,image_cell_vertex=image_cell_vertex,image_labels=idra.image_labels,image_cell_volumes=idra.image_cell_volumes) from vplants.meshing.cute_plot import spider_plot import matplotlib.pyplot as plt figure = plt.figure(0) figure.clf() spider_plot(figure,np.array([cgal_quality[c] for c in quality_criteria]),color1=np.array([0.3,0.6,1.]),color2=np.array([1.,0.,0.]),xlabels=quality_criteria,ytargets=0.8 * np.ones_like(quality_criteria,float),n_points=100*len(quality_criteria),linewidth=2,smooth_factor=0.0,spline_order=1) plt.show(block=False) raw_input() optimized_topomesh = optimize_topomesh(image_topomesh,omega_forces={'regularization':0.01,'laplacian':1.0,'planarization':0.27,'epidermis_planarization':0.27},cell_vertex_motion=True,image_cell_vertex=image_cell_vertex,edge_flip=True,iterations=20) world.add(optimized_topomesh,"STEM_topomesh")