コード例 #1
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)

        # these will be our markers
        self._inputPoints = None

        # we can't connect the image input directly to the masksource,
        # so we have to keep track of it separately.
        self._inputImage = None
        self._inputImageObserverID = None

        # we need to modify the mask (I) as well.  The problem with a
        # ProgrammableFilter is that you can't request GetOutput() before
        # the input has been set...
        self._maskSource = vtk.vtkProgrammableSource()
        self._maskSource.SetExecuteMethod(self._maskSourceExecute)

        self._dualGreyReconstruct = vtkdevide.vtkImageGreyscaleReconstruct3D()
        # first input is I (the modified mask)
        self._dualGreyReconstruct.SetDual(1)
        self._dualGreyReconstruct.SetInput1(
            self._maskSource.GetStructuredPointsOutput())

        # we'll use this to synthesise a volume according to the seed points
        self._markerSource = vtk.vtkProgrammableSource()
        self._markerSource.SetExecuteMethod(self._markerSourceExecute)
        # second input is J (the marker)
        self._dualGreyReconstruct.SetInput2(
            self._markerSource.GetStructuredPointsOutput())

        # we'll use this to change the markerImage into something we can use
        self._imageThreshold = vtk.vtkImageThreshold()
        # everything equal to or above 1.0 will be "on"
        self._imageThreshold.ThresholdByUpper(1.0)
        self._imageThresholdObserverID = self._imageThreshold.AddObserver(
            'EndEvent', self._observerImageThreshold)

        module_utils.setup_vtk_object_progress(
            self, self._dualGreyReconstruct,
            'Performing dual greyscale reconstruction')

        NoConfigModuleMixin.__init__(
            self, {
                'Module (self)': self,
                'vtkImageGreyscaleReconstruct3D': self._dualGreyReconstruct
            })

        self.sync_module_logic_with_config()
コード例 #2
0
ファイル: greyReconstruct.py プロジェクト: nagyistoce/devide
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)


        self._greyReconstruct = vtkdevide.vtkImageGreyscaleReconstruct3D()

        NoConfigModuleMixin.__init__(
            self,
            {'Module (self)' : self,
             'vtkImageGreyscaleReconstruct3D' : self._greyReconstruct})
        
        module_utils.setup_vtk_object_progress(
            self, self._greyReconstruct,
            'Performing greyscale reconstruction')

        self.sync_module_logic_with_config()
コード例 #3
0
ファイル: imageFillHoles.py プロジェクト: nagyistoce/devide
    def __init__(self, module_manager):
        ModuleBase.__init__(self, module_manager)

        self._imageBorderMask = vtkdevide.vtkImageBorderMask()
        # input image value for border
        self._imageBorderMask.SetBorderMode(1)
        # maximum of output for interior
        self._imageBorderMask.SetInteriorMode(3)

        self._imageGreyReconstruct = vtkdevide.vtkImageGreyscaleReconstruct3D()
        # we're going to use the dual, instead of inverting mask and image,
        # performing greyscale reconstruction, and then inverting the result
        # again.  (we should compare results though)
        self._imageGreyReconstruct.SetDual(1)

        # marker J is second input
        self._imageGreyReconstruct.SetInput(1,
                                            self._imageBorderMask.GetOutput())

        module_utils.setup_vtk_object_progress(self, self._imageBorderMask,
                                               'Creating image mask.')

        module_utils.setup_vtk_object_progress(self,
                                               self._imageGreyReconstruct,
                                               'Performing reconstruction.')

        self._config.holesTouchEdges = (0, 0, 0, 0, 0, 0)

        configList = [
            ('Allow holes to touch edges:', 'holesTouchEdges', 'tuple:int,6',
             'text',
             'Indicate which edges (minX, maxX, minY, maxY, minZ, maxZ) may\n'
             'be touched by holes.  In other words, a hole touching such an\n'
             'edge will not be considered background and will be filled.')
        ]

        ScriptedConfigModuleMixin.__init__(
            self, configList, {
                'Module (self)': self,
                'vtkImageBorderMask': self._imageBorderMask,
                'vtkImageGreyReconstruct': self._imageGreyReconstruct
            })

        self.sync_module_logic_with_config()
コード例 #4
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)

        # these will be our markers
        self._inputPoints = None

        # we can't connect the image input directly to the masksource,
        # so we have to keep track of it separately.
        self._inputImage = None
        self._inputImageObserverID = None

        # we need to modify the mask (I) as well.  The problem with a
        # ProgrammableFilter is that you can't request GetOutput() before
        # the input has been set...
        self._maskSource = vtk.vtkProgrammableSource()
        self._maskSource.SetExecuteMethod(self._maskSourceExecute)

        self._dualGreyReconstruct = vtkdevide.vtkImageGreyscaleReconstruct3D()
        # first input is I (the modified mask)
        self._dualGreyReconstruct.SetDual(1)
        self._dualGreyReconstruct.SetInput1(self._maskSource.GetStructuredPointsOutput())

        # we'll use this to synthesise a volume according to the seed points
        self._markerSource = vtk.vtkProgrammableSource()
        self._markerSource.SetExecuteMethod(self._markerSourceExecute)
        # second input is J (the marker)
        self._dualGreyReconstruct.SetInput2(self._markerSource.GetStructuredPointsOutput())

        # we'll use this to change the markerImage into something we can use
        self._imageThreshold = vtk.vtkImageThreshold()
        # everything equal to or above 1.0 will be "on"
        self._imageThreshold.ThresholdByUpper(1.0)
        self._imageThresholdObserverID = self._imageThreshold.AddObserver("EndEvent", self._observerImageThreshold)

        module_utils.setup_vtk_object_progress(
            self, self._dualGreyReconstruct, "Performing dual greyscale reconstruction"
        )

        NoConfigModuleMixin.__init__(
            self, {"Module (self)": self, "vtkImageGreyscaleReconstruct3D": self._dualGreyReconstruct}
        )

        self.sync_module_logic_with_config()
コード例 #5
0
ファイル: imageFillHoles.py プロジェクト: fvpolpeta/devide
    def __init__(self, module_manager):
        ModuleBase.__init__(self, module_manager)

        self._imageBorderMask = vtkdevide.vtkImageBorderMask()
        # input image value for border
        self._imageBorderMask.SetBorderMode(1)
        # maximum of output for interior
        self._imageBorderMask.SetInteriorMode(3)
        
        self._imageGreyReconstruct = vtkdevide.vtkImageGreyscaleReconstruct3D()
        # we're going to use the dual, instead of inverting mask and image,
        # performing greyscale reconstruction, and then inverting the result
        # again.  (we should compare results though)
        self._imageGreyReconstruct.SetDual(1)

        # marker J is second input
        self._imageGreyReconstruct.SetInput(
            1, self._imageBorderMask.GetOutput())

        module_utils.setup_vtk_object_progress(self, self._imageBorderMask,
                                           'Creating image mask.')
        
        
        module_utils.setup_vtk_object_progress(self, self._imageGreyReconstruct,
                                           'Performing reconstruction.')
        

        self._config.holesTouchEdges = (0,0,0,0,0,0)

        configList = [
            ('Allow holes to touch edges:', 'holesTouchEdges',
             'tuple:int,6', 'text',
             'Indicate which edges (minX, maxX, minY, maxY, minZ, maxZ) may\n'
             'be touched by holes.  In other words, a hole touching such an\n'
             'edge will not be considered background and will be filled.')
            ]

        ScriptedConfigModuleMixin.__init__(
            self, configList,
            {'Module (self)' : self,
             'vtkImageBorderMask' : self._imageBorderMask,
             'vtkImageGreyReconstruct' : self._imageGreyReconstruct})

        self.sync_module_logic_with_config()
コード例 #6
0
    def __init__(self, module_manager):
        
        ModuleBase.__init__(self, module_manager)

        self._imageMathSubtractH = vtk.vtkImageMathematics()
        self._imageMathSubtractH.SetOperationToAddConstant()
        
        self._reconstruct = vtkdevide.vtkImageGreyscaleReconstruct3D()
        # second input is marker
        self._reconstruct.SetInput(1, self._imageMathSubtractH.GetOutput())

        self._imageMathSubtractR = vtk.vtkImageMathematics()
        self._imageMathSubtractR.SetOperationToSubtract()

        self._imageMathSubtractR.SetInput(1, self._reconstruct.GetOutput())

        module_utils.setup_vtk_object_progress(self, self._imageMathSubtractH,
                                           'Preparing marker image.')

        module_utils.setup_vtk_object_progress(self, self._reconstruct,
                                           'Performing reconstruction.')

        module_utils.setup_vtk_object_progress(self, self._imageMathSubtractR,
                                           'Subtracting reconstruction.')

        self._config.h = 50

        configList = [
            ('H-dome height:', 'h', 'base:float', 'text',
             'The required difference in brightness between an h-dome and\n'
             'its surroundings.')]

        ScriptedConfigModuleMixin.__init__(
            self, configList,
            {'Module (self)' : self,
             'ImageMath Subtract H' : self._imageMathSubtractH,
             'ImageGreyscaleReconstruct3D' : self._reconstruct,
             'ImageMath Subtract R' : self._imageMathSubtractR})

        self.sync_module_logic_with_config()