示例#1
0
def test_draco_two_layers():
    n_points = 12
    img = sphere_tissue_image(size=100, n_points=n_points)

    draco = DracoMesh(img)

    draco.construct_adjacency_complex()

    triangular = ['star', 'remeshed', 'projected', 'regular', 'flat']
    image_dual_topomesh = draco.dual_reconstruction(
        reconstruction_triangulation=triangular, adjacency_complex_degree=3)
示例#2
0
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)
示例#3
0
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)
示例#4
0
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)
world['adjacency_complex_cells']['preserve_faces'] = True
world['adjacency_complex_cells']['x_slice'] = (0,90)

triangular = ['star','remeshed','projected','flat']
image_dual_topomesh = draco.dual_reconstruction(reconstruction_triangulation = triangular, adjacency_complex_degree=3, maximal_edge_length=5.1)



from openalea.cellcomplex.property_topomesh.property_topomesh_analysis import compute_topomesh_property, compute_topomesh_vertex_property_from_faces

compute_topomesh_property(image_dual_topomesh,'barycenter',2)
compute_topomesh_property(image_dual_topomesh,'normal',2,normal_method='orientation')

compute_topomesh_vertex_property_from_faces(image_dual_topomesh,'normal',adjacency_sigma=2,neighborhood=5)
compute_topomesh_property(image_dual_topomesh,'mean_curvature',2)
compute_topomesh_vertex_property_from_faces(image_dual_topomesh,'mean_curvature',adjacency_sigma=2,neighborhood=5)
compute_topomesh_vertex_property_from_faces(image_dual_topomesh,'gaussian_curvature',adjacency_sigma=2,neighborhood=5)

world.add(image_dual_topomesh ,'dual_reconstruction')
world['dual_reconstruction']['coef_3'] = 0.99