Exemplo n.º 1
0
if args.mask is not None:
    mask = np.load(args.mask)
    step_size = args.step_size * mask
else:
    step_size = args.step_size

mesh = TriMesh_Vtk(surface_file_in, None)
smooth_vertices = mesh.laplacian_smooth(
                    nb_iter=args.nb_step, 
                    diffusion_step=step_size, 
                    l2_dist_weighted=args.dist_weighted, 
                    area_weighted=args.area_weighted, 
                    backward_step=not(args.forward_step), 
                    flow_file=None)


smoothed_mesh = TriMesh_Vtk(mesh.get_triangles(), smooth_vertices)


# Save
smoothed_mesh.save(surface_file_out)

# Display
if args.vi:
    mesh.display('input surface')
    
if args.vo:
    smoothed_mesh.display('output surface')

#print "\n!!! Smooth surface Saved  !!!\n"
Exemplo n.º 2
0
import numpy as np
import time

import trimeshpy
from trimeshpy.trimesh_vtk import TriMesh_Vtk
from trimeshpy.trimeshflow_vtk import TriMeshFlow_Vtk
from trimeshpy.vtk_util import lines_to_vtk_polydata, save_polydata

# Test files
file_name = trimeshpy.data.brain_lh

mesh = TriMesh_Vtk(file_name, None)
triangles = mesh.get_triangles()
vertices = mesh.get_vertices()
mesh.display(display_name="Trimeshpy: Initial Mesh")

# pre-smooth
vertices = mesh.laplacian_smooth(2, 10.0, l2_dist_weighted=False, area_weighted=False, backward_step=True, flow_file=None)
mesh.set_vertices(vertices)
mesh.display(display_name="Trimeshpy: Smoothed Mesh")

tri_mesh_flow = TriMeshFlow_Vtk(triangles, vertices)

# Test parameters
nb_step = 10
diffusion_step = 10
saved_flow = trimeshpy.data.output_test_flow
saved_fib = trimeshpy.data.output_test_fib

# Test functions
Exemplo n.º 3
0
    
#filter
if args.index is not None:
    print args.index
    mask = np.zeros([len(vts_label)], dtype=np.bool )
    for index in args.index:
        if index == -1:
            print "selected region :", index, "None" 
        else:
            print "selected region :", index, label_name[index]
            
        mask = np.logical_or(mask, (vts_label == index))
    if args.inverse_mask:
        mask = ~mask
    vts_color[~mask] = [0,0,0]
    
    if args.white:
        vts_color[mask] = [255,255,255]

mesh.update_polydata()
mesh.set_colors(vts_color)

if args.v:
    mesh.display()

if args.out_surface is not None:
    mesh.save(args.o)
    
if args.out_vts_mask is not None:
    np.save(args.out_vts_mask, mask)
Exemplo n.º 4
0
    end_normal = end_mesh.vertices_normal(args.ed_not_normed, args.ed_not_weighted)
    
    # save only not masked points
    if args.mask is not None:
        np.save(args.end_normal, end_normal[mask])
    else:
        np.save(args.end_normal, end_normal)
    
if args.end_surf is not None:
    end_mesh.save(args.end_surf)
    
if args.info is not None:
    info = np.array([args.nb_step, args.step_size], np.object)
    np.save(args.info, info)
    
# display 
if args.vi:
    mesh.display('input surface')

if args.vo:
    end_mesh.display('output surface')
    
if args.vf:
    lines = np.swapaxes(flow, 0, 1)
    actor = fvtk.line(lines, colors=[0.5,0,0.1])
    ren = fvtk.ren()
    fvtk.add(ren, actor)
    fvtk.show(ren)
    
#print "\n !!! tracking Saved !!!\n"