def test_draco(): n_points = 12 img = sphere_tissue_image(size=100, n_points=n_points) draco = DracoMesh(img) assert draco.point_topomesh.nb_wisps(0) == n_points + 1 draco.delaunay_adjacency_complex(surface_cleaning_criteria=[]) image_tetrahedra = np.sort(draco.image_cell_vertex.keys()) image_tetrahedra = image_tetrahedra[image_tetrahedra[:, 0] != 1] draco_tetrahedra = np.sort([ list(draco.triangulation_topomesh.borders(3, t, 3)) for t in draco.triangulation_topomesh.wisps(3) ]) delaunay_consistency = jaccard_index(image_tetrahedra, draco_tetrahedra) draco.adjacency_complex_optimization(n_iterations=2) assert draco.triangulation_topomesh.nb_region_neighbors(0, 2) == n_points image_tetrahedra = np.sort(draco.image_cell_vertex.keys()) image_tetrahedra = image_tetrahedra[image_tetrahedra[:, 0] != 1] draco_tetrahedra = np.sort([ list(draco.triangulation_topomesh.borders(3, t, 3)) for t in draco.triangulation_topomesh.wisps(3) ]) draco_consistency = jaccard_index(image_tetrahedra, draco_tetrahedra) # print delaunay_consistency,' -> ',draco_consistency assert draco_consistency == 1 or (draco_consistency >= 0.9 and draco_consistency > delaunay_consistency) triangular = ['star', 'remeshed', 'projected', 'regular', 'flat'] image_dual_topomesh = draco.dual_reconstruction( reconstruction_triangulation=triangular, adjacency_complex_degree=3) image_volumes = array_dict( nd.sum(np.ones_like(img), img, index=np.unique(img)[1:]) * np.prod(img.voxelsize), np.unique(img)[1:]) compute_topomesh_property(image_dual_topomesh, 'volume', 3) draco_volumes = image_dual_topomesh.wisp_property('volume', 3) for c in image_dual_topomesh.wisps(3): assert np.isclose(image_volumes[c], draco_volumes[c], 0.33)
def test_draco(): n_points = 12 img = sphere_tissue_image(size=100,n_points=n_points) draco = DracoMesh(img) assert draco.point_topomesh.nb_wisps(0) == n_points+1 draco.delaunay_adjacency_complex(surface_cleaning_criteria = []) image_tetrahedra = np.sort(draco.image_cell_vertex.keys()) image_tetrahedra = image_tetrahedra[image_tetrahedra[:,0] != 1] draco_tetrahedra = np.sort([list(draco.triangulation_topomesh.borders(3,t,3)) for t in draco.triangulation_topomesh.wisps(3)]) delaunay_consistency = jaccard_index(image_tetrahedra, draco_tetrahedra) draco.adjacency_complex_optimization(n_iterations=2) assert draco.triangulation_topomesh.nb_region_neighbors(0,2) == n_points image_tetrahedra = np.sort(draco.image_cell_vertex.keys()) image_tetrahedra = image_tetrahedra[image_tetrahedra[:,0] != 1] draco_tetrahedra = np.sort([list(draco.triangulation_topomesh.borders(3,t,3)) for t in draco.triangulation_topomesh.wisps(3)]) draco_consistency = jaccard_index(image_tetrahedra, draco_tetrahedra) # print delaunay_consistency,' -> ',draco_consistency assert draco_consistency == 1 or (draco_consistency >= 0.9 and draco_consistency > delaunay_consistency) triangular = ['star','remeshed','projected','regular','flat'] image_dual_topomesh = draco.dual_reconstruction(reconstruction_triangulation = triangular, adjacency_complex_degree=3) image_volumes = array_dict(nd.sum(np.ones_like(img),img,index=np.unique(img)[1:])*np.prod(img.resolution),np.unique(img)[1:]) compute_topomesh_property(image_dual_topomesh,'volume',3) draco_volumes = image_dual_topomesh.wisp_property('volume',3) for c in image_dual_topomesh.wisps(3): assert np.isclose(image_volumes[c],draco_volumes[c],0.33)
from openalea.draco_stem.draco.draco import DracoMesh from openalea.draco_stem.example_image import sphere_tissue_image from openalea.oalab.colormap.colormap_def import load_colormaps world.clear() size = 100. n_points = 11 n_layers = 2 img = sphere_tissue_image(size=size, n_points=n_points, n_layers=n_layers) world.add(img,"segmented_image",colormap='glasbey',alphamap='constant',bg_id=1,alpha=0.25) draco = DracoMesh(image=img) draco.delaunay_adjacency_complex(surface_cleaning_criteria=[]) world.add(draco.triangulation_topomesh,'adjacency_complex') world['adjacency_complex']['display_3'] = False world['adjacency_complex']['display_0'] = True world['adjacency_complex_vertices']['display_colorbar'] = False world['adjacency_complex_vertices']['polydata_colormap'] = load_colormaps()['glasbey'] world['adjacency_complex_vertices']['point_radius'] = 1.5 draco.adjacency_complex_optimization(n_iterations=3) world['adjacency_complex']['coef_3'] = 0.9 world['adjacency_complex']['display_3'] = True world['adjacency_complex_cells']['display_colorbar'] = False world['adjacency_complex_cells']['polydata_colormap'] = load_colormaps()['grey'] world['adjacency_complex_cells']['intensity_range'] = (-1,0)