From fe53df6d69047b7462a10fcab8c91d125cce1d6c Mon Sep 17 00:00:00 2001 From: tfmoraes Date: Thu, 16 Dec 2010 18:17:23 +0000 Subject: [PATCH] ENH: The value to generate the surface was hardcoded --- invesalius/data/surface_process.py | 68 +++++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/invesalius/data/surface_process.py b/invesalius/data/surface_process.py index 1025fbb..55f724f 100644 --- a/invesalius/data/surface_process.py +++ b/invesalius/data/surface_process.py @@ -57,46 +57,48 @@ class SurfaceProcess(multiprocessing.Process): # Create vtkPolyData from vtkImageData #print "Generating Polydata" #if self.mode == "CONTOUR": - #print "Contour" - #contour = vtk.vtkContourFilter() - #contour.SetInput(image) - #contour.SetValue(0, 127.5) # initial threshold - #contour.ComputeScalarsOn() - #contour.ComputeGradientsOn() - #contour.ComputeNormalsOn() - #polydata = contour.GetOutput() + #print "Contour" + #contour = vtk.vtkContourFilter() + #contour.SetInput(image) + #contour.SetValue(0, self.min_value) # initial threshold + #contour.SetValue(1, self.max_value) # final threshold + #contour.ComputeScalarsOn() + #contour.ComputeGradientsOn() + #contour.ComputeNormalsOn() + #polydata = contour.GetOutput() #else: #mode == "GRAYSCALE": - mcubes = vtk.vtkDiscreteMarchingCubes() + mcubes = vtk.vtkMarchingCubes() mcubes.SetInput(image) - mcubes.SetValue(0, 255) + mcubes.SetValue(0, self.min_value) + mcubes.SetValue(1, self.max_value) mcubes.ComputeScalarsOn() mcubes.ComputeGradientsOn() mcubes.ComputeNormalsOn() polydata = mcubes.GetOutput() - print "Decimating" - if not self.decimate_reduction: - decimation = vtk.vtkDecimatePro() - decimation.SetInput(polydata) - decimation.SetTargetReduction(self.decimate_reduction) - decimation.PreserveTopologyOn() - decimation.SplittingOff() - polydata = decimation.GetOutput() - - if self.smooth_iterations and self.smooth_relaxation_factor: - print "Smoothing" - smoother = vtk.vtkWindowedSincPolyDataFilter() - smoother.SetInput(polydata) - smoother.SetNumberOfIterations(self.smooth_iterations) - smoother.SetFeatureAngle(120) - smoother.SetNumberOfIterations(30) - smoother.BoundarySmoothingOn() - smoother.SetPassBand(0.1) - smoother.FeatureEdgeSmoothingOn() - smoother.NonManifoldSmoothingOn() - smoother.NormalizeCoordinatesOn() - smoother.Update() - polydata = smoother.GetOutput() + #print "Decimating" + #if self.decimate_reduction: + #decimation = vtk.vtkDecimatePro() + #decimation.SetInput(polydata) + #decimation.SetTargetReduction(0) + #decimation.PreserveTopologyOn() + #decimation.SplittingOff() + #polydata = decimation.GetOutput() + + #if self.smooth_iterations and self.smooth_relaxation_factor: + #print "Smoothing" + #smoother = vtk.vtkWindowedSincPolyDataFilter() + #smoother.SetInput(polydata) + #smoother.SetNumberOfIterations(self.smooth_iterations) + #smoother.SetFeatureAngle(120) + #smoother.SetNumberOfIterations(30) + #smoother.BoundarySmoothingOn() + #smoother.SetPassBand(0.01) + #smoother.FeatureEdgeSmoothingOn() + #smoother.NonManifoldSmoothingOn() + #smoother.NormalizeCoordinatesOn() + #smoother.Update() + #polydata = smoother.GetOutput() print "Saving" filename = tempfile.mktemp(suffix='_%s.vtp' % (self.pid)) -- libgit2 0.21.2