Exemple #1
0
    def onApply(self):
        inputVolume = self.inputSelector.currentNode()
        outputVolume = self.outputSelector.currentNode()
        if not (inputVolume and outputVolume):
            qt.QMessageBox.critical(
                slicer.util.mainWindow(), 'Sharpen',
                'Input and output volumes are required for Laplacian')
            return
        # run the filter
        laplacian = vtk.vtkImageLaplacian()
        laplacian.SetInput(inputVolume.GetImageData())
        laplacian.SetDimensionality(3)
        laplacian.GetOutput().Update()
        ijkToRAS = vtk.vtkMatrix4x4()
        inputVolume.GetIJKToRASMatrix(ijkToRAS)
        outputVolume.SetIJKToRASMatrix(ijkToRAS)
        outputVolume.SetAndObserveImageData(laplacian.GetOutput())

        # Section B - add code here
        # (be sure to match indentation)
        # optionally subtract laplacian from original image
        if self.sharpen.checked:
            parameters = {}
            parameters['inputVolume1'] = inputVolume.GetID()
            parameters['inputVolume2'] = outputVolume.GetID()
            parameters['outputVolume'] = outputVolume.GetID()
        slicer.cli.run(slicer.modules.subtractscalarvolumes,
                       None,
                       parameters,
                       wait_for_completion=True)
        selectionNode = slicer.app.applicationLogic().GetSelectionNode()
        selectionNode.SetReferenceActiveVolumeID(outputVolume.GetID())
        slicer.app.applicationLogic().PropagateVolumeSelection(0)
Exemple #2
0
  def onApply(self):
    inputVolume = self.inputSelector.currentNode()
    outputVolume = self.outputSelector.currentNode()
    if not (inputVolume and outputVolume):
      qt.QMessageBox.critical(
          slicer.util.mainWindow(),
         'Sharpen', 'Input and output volumes are required for Laplacian')
      return
    # run the filter
    laplacian = vtk.vtkImageLaplacian()
    laplacian.SetInput(inputVolume.GetImageData())
    laplacian.SetDimensionality(3)
    laplacian.GetOutput().Update()
    ijkToRAS = vtk.vtkMatrix4x4()
    inputVolume.GetIJKToRASMatrix(ijkToRAS)
    outputVolume.SetIJKToRASMatrix(ijkToRAS)
    outputVolume.SetAndObserveImageData(laplacian.GetOutput())

    # Section B - add code here
    # (be sure to match indentation)
    # optionally subtract laplacian from original image
    if self.sharpen.checked:
      parameters = {}
      parameters['inputVolume1'] = inputVolume.GetID()
      parameters['inputVolume2'] = outputVolume.GetID()
      parameters['outputVolume'] = outputVolume.GetID()
    slicer.cli.run( slicer.modules.subtractscalarvolumes, None, parameters, wait_for_completion=True )
    selectionNode = slicer.app.applicationLogic().GetSelectionNode()
    selectionNode.SetReferenceActiveVolumeID(outputVolume.GetID())
    slicer.app.applicationLogic().PropagateVolumeSelection(0)
    def performLaplaceOfGaussian(self, image):
        '''
        '''

        gaussian = vtk.vtkImageGaussianSmooth()
        gaussian.SetInputData(image)
        gaussian.Update()

        laplacian = vtk.vtkImageLaplacian()
        laplacian.SetInputData(gaussian.GetOutput())
        laplacian.Update()

        outImageData = vtk.vtkImageData()
        outImageData.DeepCopy(laplacian.GetOutput())

        return outImageData
Exemple #4
0
    def performLaplaceOfGaussian( self, image ):
        '''
        '''

        gaussian = vtk.vtkImageGaussianSmooth()
        gaussian.SetInputData( image )
        gaussian.Update()

        laplacian = vtk.vtkImageLaplacian()
        laplacian.SetInputData( gaussian.GetOutput() )
        laplacian.Update()

        outImageData = vtk.vtkImageData()
        outImageData.DeepCopy( laplacian.GetOutput() )

        return outImageData
Exemple #5
0
    def run(self, inputVolume, outputVolume):
        """
    Run the actual algorithm
    """

        self.delayDisplay('Running the aglorithm')

        laplacian = vtk.vtkImageLaplacian()
        laplacian.SetInputData(inputVolume.GetImageData())
        laplacian.SetDimensionality(3)
        laplacian.Update()

        ijkToRAS = vtk.vtkMatrix4x4()
        inputVolume.GetIJKToRASMatrix(ijkToRAS)
        outputVolume.SetIJKToRASMatrix(ijkToRAS)
        outputVolume.SetAndObserveImageData(laplacian.GetOutput())
        # make the output volume appear in all the slice views
        selectionNode = slicer.app.applicationLogic().GetSelectionNode()
        selectionNode.SetReferenceActiveVolumeID(outputVolume.GetID())
        slicer.app.applicationLogic().PropagateVolumeSelection(0)

        return True
 def onApply(self):
   inputVolume = self.inputSelector.currentNode()
   outputVolume = self.outputSelector.currentNode()
   if not (inputVolume and outputVolume):
     qt.QMessageBox.critical(
         slicer.util.mainWindow(),
         'Laplace', 'Input and output volumes are required for Laplacian')
     return
   # run the filter
   # Insert code here
   laplacian=vtk.vtkImageLaplacian() 
   laplacian.SetInputData(inputVolume.GetImageData()) 
   laplacian.SetDimensionality(3) 
   laplacian.Update() 
   # (be sure to match indentation)
   ijkToRAS = vtk.vtkMatrix4x4()
   inputVolume.GetIJKToRASMatrix(ijkToRAS)
   outputVolume.SetIJKToRASMatrix(ijkToRAS)
   outputVolume.SetAndObserveImageData(laplacian.GetOutput())
   # make the output volume appear in all the slice views
   selectionNode = slicer.app.applicationLogic().GetSelectionNode()
   selectionNode.SetReferenceActiveVolumeID(outputVolume.GetID())
   slicer.app.applicationLogic().PropagateVolumeSelection(0)
Exemple #7
0
 def onApply(self):
   inputVolume = self.inputSelector.currentNode()
   outputVolume = self.outputSelector.currentNode()
   if not (inputVolume and outputVolume):
     qt.QMessageBox.critical(
         slicer.util.mainWindow(),
         'Laplace', 'Input and output volumes are required for Laplacian')
     return
   # run the filter
   # Insert code here
   # (be sure to match indentation)
   laplacian = vtk.vtkImageLaplacian()
   laplacian.SetInput(inputVolume.GetImageData())
   laplacian.SetDimensionality(3)
   laplacian.GetOutput().Update()
   ijkToRAS = vtk.vtkMatrix4x4()
   inputVolume.GetIJKToRASMatrix(ijkToRAS)
   outputVolume.SetIJKToRASMatrix(ijkToRAS)
   outputVolume.SetAndObserveImageData(laplacian.GetOutput())
   # make the output volume appear in all the slice views
   selectionNode = slicer.app.applicationLogic().GetSelectionNode()
   selectionNode.SetReferenceActiveVolumeID(outputVolume.GetID())
   slicer.app.applicationLogic().PropagateVolumeSelection(0)