Commit fe53df6d69047b7462a10fcab8c91d125cce1d6c

Authored by tfmoraes
1 parent da748282

ENH: The value to generate the surface was hardcoded

Showing 1 changed file with 35 additions and 33 deletions   Show diff stats
invesalius/data/surface_process.py
@@ -57,46 +57,48 @@ class SurfaceProcess(multiprocessing.Process): @@ -57,46 +57,48 @@ class SurfaceProcess(multiprocessing.Process):
57 # Create vtkPolyData from vtkImageData 57 # Create vtkPolyData from vtkImageData
58 #print "Generating Polydata" 58 #print "Generating Polydata"
59 #if self.mode == "CONTOUR": 59 #if self.mode == "CONTOUR":
60 - #print "Contour"  
61 - #contour = vtk.vtkContourFilter()  
62 - #contour.SetInput(image)  
63 - #contour.SetValue(0, 127.5) # initial threshold  
64 - #contour.ComputeScalarsOn()  
65 - #contour.ComputeGradientsOn()  
66 - #contour.ComputeNormalsOn()  
67 - #polydata = contour.GetOutput() 60 + #print "Contour"
  61 + #contour = vtk.vtkContourFilter()
  62 + #contour.SetInput(image)
  63 + #contour.SetValue(0, self.min_value) # initial threshold
  64 + #contour.SetValue(1, self.max_value) # final threshold
  65 + #contour.ComputeScalarsOn()
  66 + #contour.ComputeGradientsOn()
  67 + #contour.ComputeNormalsOn()
  68 + #polydata = contour.GetOutput()
68 #else: #mode == "GRAYSCALE": 69 #else: #mode == "GRAYSCALE":
69 - mcubes = vtk.vtkDiscreteMarchingCubes() 70 + mcubes = vtk.vtkMarchingCubes()
70 mcubes.SetInput(image) 71 mcubes.SetInput(image)
71 - mcubes.SetValue(0, 255) 72 + mcubes.SetValue(0, self.min_value)
  73 + mcubes.SetValue(1, self.max_value)
72 mcubes.ComputeScalarsOn() 74 mcubes.ComputeScalarsOn()
73 mcubes.ComputeGradientsOn() 75 mcubes.ComputeGradientsOn()
74 mcubes.ComputeNormalsOn() 76 mcubes.ComputeNormalsOn()
75 polydata = mcubes.GetOutput() 77 polydata = mcubes.GetOutput()
76 78
77 - print "Decimating"  
78 - if not self.decimate_reduction:  
79 - decimation = vtk.vtkDecimatePro()  
80 - decimation.SetInput(polydata)  
81 - decimation.SetTargetReduction(self.decimate_reduction)  
82 - decimation.PreserveTopologyOn()  
83 - decimation.SplittingOff()  
84 - polydata = decimation.GetOutput()  
85 -  
86 - if self.smooth_iterations and self.smooth_relaxation_factor:  
87 - print "Smoothing"  
88 - smoother = vtk.vtkWindowedSincPolyDataFilter()  
89 - smoother.SetInput(polydata)  
90 - smoother.SetNumberOfIterations(self.smooth_iterations)  
91 - smoother.SetFeatureAngle(120)  
92 - smoother.SetNumberOfIterations(30)  
93 - smoother.BoundarySmoothingOn()  
94 - smoother.SetPassBand(0.1)  
95 - smoother.FeatureEdgeSmoothingOn()  
96 - smoother.NonManifoldSmoothingOn()  
97 - smoother.NormalizeCoordinatesOn()  
98 - smoother.Update()  
99 - polydata = smoother.GetOutput() 79 + #print "Decimating"
  80 + #if self.decimate_reduction:
  81 + #decimation = vtk.vtkDecimatePro()
  82 + #decimation.SetInput(polydata)
  83 + #decimation.SetTargetReduction(0)
  84 + #decimation.PreserveTopologyOn()
  85 + #decimation.SplittingOff()
  86 + #polydata = decimation.GetOutput()
  87 +
  88 + #if self.smooth_iterations and self.smooth_relaxation_factor:
  89 + #print "Smoothing"
  90 + #smoother = vtk.vtkWindowedSincPolyDataFilter()
  91 + #smoother.SetInput(polydata)
  92 + #smoother.SetNumberOfIterations(self.smooth_iterations)
  93 + #smoother.SetFeatureAngle(120)
  94 + #smoother.SetNumberOfIterations(30)
  95 + #smoother.BoundarySmoothingOn()
  96 + #smoother.SetPassBand(0.01)
  97 + #smoother.FeatureEdgeSmoothingOn()
  98 + #smoother.NonManifoldSmoothingOn()
  99 + #smoother.NormalizeCoordinatesOn()
  100 + #smoother.Update()
  101 + #polydata = smoother.GetOutput()
100 102
101 print "Saving" 103 print "Saving"
102 filename = tempfile.mktemp(suffix='_%s.vtp' % (self.pid)) 104 filename = tempfile.mktemp(suffix='_%s.vtp' % (self.pid))