Ejemplo n.º 1
0
def extract_orig_mesh(vol):
    assert len(vol.shape) == 3
    vertices, simplices, normals, _ = measure.marching_cubes_lewiner(vol, 0.5)
    vertices = vertices * 2.0
    mesh = dict()
    mesh['v'] = vertices
    mesh['f'] = simplices
    mesh['f'] = mesh['f'][:, (1, 0, 2)]
    mesh['vn'] = util.calc_normal(mesh)
    print('mesh[v] =', type(mesh['v']), mesh['v'].shape)
    print('mesh[vn] =', type(mesh['vn']), mesh['vn'].shape)
    print('mesh[f] =', type(mesh['f']), mesh['f'].shape)

    return mesh
Ejemplo n.º 2
0
def extract_orig_mesh(vol):
    assert len(vol.shape) == 3
    vertices, simplices, normals, _ = measure.marching_cubes_lewiner(vol, level=0.5) # https://scikit-image.org/docs/dev/api/skimage.measure.html#marching-cubes-lewiner
    vertices = vertices*2.0
    mesh = dict()
    mesh['v'] = vertices
    mesh['f'] = simplices
    mesh['f'] = mesh['f'][:, (1, 0, 2)] # to ensure that normals computed by opendr are facing outwards wrt. the mesh
    mesh['vn'] = util.calc_normal(mesh) # normals from marchingCube are only slightly diff. from opendr's
    print('mesh[v] =', type(mesh['v']), mesh['v'].shape)
    print('mesh[vn] =', type(mesh['vn']), mesh['vn'].shape)
    print('mesh[f] =', type(mesh['f']), mesh['f'].shape)

    return mesh, normals