Пример #1
0
def createEuclide(image):
    euclide = vtk.vtkImageEuclideanDistance()
    euclide.SetInput(image)
    euclide.SetDimensionality(3)
    euclide.SetAlgorithmToSaitoCached()
    #euclide.InitializeOn()
    return euclide.GetOutput()
Пример #2
0
 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(
         self, module_manager,
         vtk.vtkImageEuclideanDistance(), 'Processing.',
         ('vtkImageData',), ('vtkImageData',),
         replaceDoc=True,
         inputFunctions=None, outputFunctions=None)
 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(self,
                                       module_manager,
                                       vtk.vtkImageEuclideanDistance(),
                                       'Processing.', ('vtkImageData', ),
                                       ('vtkImageData', ),
                                       replaceDoc=True,
                                       inputFunctions=None,
                                       outputFunctions=None)
Пример #4
0
def createEuclide2D(image):
    euclide = vtk.vtkImageEuclideanDistance()
    euclide.SetInput(image)
    euclide.SetDimensionality(2)
    euclide.ConsiderAnisotropyOn()
    euclide.SetAlgorithmToSaitoCached() 
    euclide.SetMaximumDistance(image.GetDimensions()[0]*image.GetDimensions()[1])
    euclide.InitializeOn()
    return euclide.GetOutput()
	def __init__(self):
		"""
		Initialization
		"""		   
		lib.ProcessingFilter.ProcessingFilter.__init__(self, (1, 1))
		self.vtkfilter = vtk.vtkImageEuclideanDistance()
		self.vtkfilter.AddObserver("ProgressEvent", lib.messenger.send)
		lib.messenger.connect(self.vtkfilter, 'ProgressEvent', self.updateProgress)
		self.descs = {"Algorithm":"Calculation algorithm","ConsiderAnisotropy":"Consider anisotropy","CastToUnsignedChar":"Cast to unsigned char"}
		self.filterDesc = "Computes squared Euclidean distance transform\nInput: Binary image\nOutput: Grayscale image"
Пример #6
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)
        # initialise any mixins we might have
        NoConfigModuleMixin.__init__(self)

        self._distance = vtk.vtkImageEuclideanDistance()
        # this seems to yield more accurate results in this case
        # it would probably be better to calculate only 2d distance fields
        self._distance.ConsiderAnisotropyOff()

        self._xEndPoints = []
        self._noFlipXes = []
        self._pf1 = vtk.vtkProgrammableFilter()  # yeah
        self._pf1.SetInput(self._distance.GetOutput())
        self._pf1.SetExecuteMethod(self.pf1Execute)

        self._pf2 = vtk.vtkProgrammableFilter()
        self._pf2.SetInput(self._pf1.GetOutput())
        self._pf2.SetExecuteMethod(self.pf2Execute)

        self._mc = vtk.vtkMarchingCubes()
        self._mc.SetInput(self._pf1.GetOutput())
        self._mc.SetValue(0, 0.1)

        self._iv = vtk.vtkImplicitVolume()
        self._iv.SetVolume(self._pf2.GetOutput())

        self._cpd = vtk.vtkClipPolyData()
        self._cpd.SetClipFunction(self._iv)
        self._cpd.SetInput(self._mc.GetOutput())
        #self._cpd.InsideOutOn()

        module_utils.setup_vtk_object_progress(
            self, self._distance, 'Calculating distance field...')
        module_utils.setup_vtk_object_progress(self, self._pf1,
                                               'Signing distance field...')
        module_utils.setup_vtk_object_progress(self, self._pf2,
                                               'Creating implicit volume...')
        module_utils.setup_vtk_object_progress(self, self._mc,
                                               'Extracting isosurface...')
        module_utils.setup_vtk_object_progress(self, self._cpd,
                                               'Clipping isosurface...')

        self._iObj = self._distance
        self._oObj = self._cpd
        #self._oObj = self._pf2

        self._viewFrame = self._createViewFrame({
            'distance': self._distance,
            'pf1': self._pf1,
            'pf2': self._pf2,
            'mc': self._mc,
            'cpd': self._cpd
        })
Пример #7
0
    def __init__(self):
        """
		Initialization
		"""
        lib.ProcessingFilter.ProcessingFilter.__init__(self, (1, 1))
        self.vtkfilter = vtk.vtkImageEuclideanDistance()
        self.vtkfilter.AddObserver("ProgressEvent", lib.messenger.send)
        lib.messenger.connect(self.vtkfilter, 'ProgressEvent',
                              self.updateProgress)
        self.descs = {
            "Algorithm": "Calculation algorithm",
            "ConsiderAnisotropy": "Consider anisotropy",
            "CastToUnsignedChar": "Cast to unsigned char"
        }
        self.filterDesc = "Computes squared Euclidean distance transform\nInput: Binary image\nOutput: Grayscale image"
Пример #8
0
    def euclideanDistance(self, anisotropy=False, maxDistance=None):
        """Implementation of the Euclidean DT (Distance Transform) using Saito's algorithm.
        The distance map produced contains the square of the Euclidean distance values.
        The algorithm has a O(n^(D+1)) complexity over nxnx...xn images in D dimensions.

        Check out also: https://en.wikipedia.org/wiki/Distance_transform

        :param bool anisotropy: used to define whether Spacing should be used
            in the computation of the distances.
        :param float maxDistance: any distance bigger than maxDistance will not be
            computed but set to this specified value instead.

        See example script: |euclDist.py|_
        """
        euv = vtk.vtkImageEuclideanDistance()
        euv.SetInputData(self._data)
        euv.SetConsiderAnisotropy(anisotropy)
        if maxDistance is not None:
            euv.InitializeOn()
            euv.SetMaximumDistance(maxDistance)
        euv.SetAlgorithmToSaito()
        euv.Update()
        return Volume(euv.GetOutput())
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()

# This script shows how to use vtkImageEuclideanDistance
# Image pipeline
reader = vtk.vtkPNGReader()
reader.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/fullhead15.png")
cast = vtk.vtkImageCast()
cast.SetOutputScalarTypeToShort()
cast.SetInputConnection(reader.GetOutputPort())
thresh = vtk.vtkImageThreshold()
thresh.SetInputConnection(cast.GetOutputPort())
thresh.ThresholdByUpper(2000.0)
thresh.SetInValue(0)
thresh.SetOutValue(200)
thresh.ReleaseDataFlagOff()
dist = vtk.vtkImageEuclideanDistance()
dist.SetInputConnection(thresh.GetOutputPort())
dist.SetAlgorithmToSaitoCached()
viewer = vtk.vtkImageViewer()
viewer.SetInputConnection(dist.GetOutputPort())
viewer.SetColorWindow(117)
viewer.SetColorLevel(43)
viewer.Render()
#skipping source
# --- end of script --
Пример #10
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)
        # initialise any mixins we might have
        NoConfigModuleMixin.__init__(self)


        self._distance = vtk.vtkImageEuclideanDistance()
        # this seems to yield more accurate results in this case
        # it would probably be better to calculate only 2d distance fields
        self._distance.ConsiderAnisotropyOff()

        self._xEndPoints = []
        self._noFlipXes = []
        self._pf1 = vtk.vtkProgrammableFilter() # yeah
        self._pf1.SetInput(self._distance.GetOutput())
        self._pf1.SetExecuteMethod(self.pf1Execute)

        self._pf2 = vtk.vtkProgrammableFilter()
        self._pf2.SetInput(self._pf1.GetOutput())
        self._pf2.SetExecuteMethod(self.pf2Execute)

        self._mc = vtk.vtkMarchingCubes()
        self._mc.SetInput(self._pf1.GetOutput())
        self._mc.SetValue(0,0.1)

        self._iv = vtk.vtkImplicitVolume()
        self._iv.SetVolume(self._pf2.GetOutput())

        self._cpd = vtk.vtkClipPolyData()
        self._cpd.SetClipFunction(self._iv)
        self._cpd.SetInput(self._mc.GetOutput())
        #self._cpd.InsideOutOn()

        module_utils.setup_vtk_object_progress(self, self._distance,
                                           'Calculating distance field...')
        module_utils.setup_vtk_object_progress(self, self._pf1,
                                           'Signing distance field...')
        module_utils.setup_vtk_object_progress(self, self._pf2,
                                           'Creating implicit volume...')
        module_utils.setup_vtk_object_progress(self, self._mc,
                                           'Extracting isosurface...')
        module_utils.setup_vtk_object_progress(self, self._cpd,
                                           'Clipping isosurface...')
        
        
        
        

        self._iObj = self._distance
        self._oObj = self._cpd
        #self._oObj = self._pf2
        
        self._viewFrame = self._createViewFrame({'distance' :
                                                 self._distance,
                                                 'pf1' :
                                                 self._pf1,
                                                 'pf2' :
                                                 self._pf2,
                                                 'mc' :
                                                 self._mc,
                                                 'cpd' :
                                                 self._cpd})