def __init__(self, inputs = (1,1)): """ Initialization """ FourierFilters.FourierFilter.__init__(self, inputs) self.filter = vtk.vtkImageButterworthHighPass() self.filterDesc = "High pass filter in frequency domain using Butterworth algorithm\nInput: Complex image\nOutput: Complex image"
def __init__(self, module_manager): SimpleVTKClassModuleBase.__init__( self, module_manager, vtk.vtkImageButterworthHighPass(), 'Processing.', ('vtkImageData',), ('vtkImageData',), replaceDoc=True, inputFunctions=None, outputFunctions=None)
def __init__(self, module_manager): SimpleVTKClassModuleBase.__init__(self, module_manager, vtk.vtkImageButterworthHighPass(), 'Processing.', ('vtkImageData', ), ('vtkImageData', ), replaceDoc=True, inputFunctions=None, outputFunctions=None)
def filterpass(self, lowcutoff=None, highcutoff=None, order=3): """ Low-pass and high-pass filtering become trivial in the frequency domain. A portion of the pixels/voxels are simply masked or attenuated. This function applies a high pass Butterworth filter that attenuates the frequency domain image with the function |G_Of_Omega| The gradual attenuation of the filter is important. A simple high-pass filter would simply mask a set of pixels in the frequency domain, but the abrupt transition would cause a ringing effect in the spatial domain. :param list lowcutoff: the cutoff frequencies :param list highcutoff: the cutoff frequencies :param int order: order determines sharpness of the cutoff curve """ #https://lorensen.github.io/VTKExamples/site/Cxx/ImageProcessing/IdealHighPass fft = vtk.vtkImageFFT() fft.SetInputData(self._data) fft.Update() out = fft.GetOutput() if highcutoff: butterworthLowPass = vtk.vtkImageButterworthLowPass() butterworthLowPass.SetInputData(out) butterworthLowPass.SetCutOff(highcutoff) butterworthLowPass.SetOrder(order) butterworthLowPass.Update() out = butterworthLowPass.GetOutput() if lowcutoff: butterworthHighPass = vtk.vtkImageButterworthHighPass() butterworthHighPass.SetInputData(out) butterworthHighPass.SetCutOff(lowcutoff) butterworthHighPass.SetOrder(order) butterworthHighPass.Update() out = butterworthHighPass.GetOutput() butterworthRfft = vtk.vtkImageRFFT() butterworthRfft.SetInputData(out) butterworthRfft.Update() butterworthReal = vtk.vtkImageExtractComponents() butterworthReal.SetInputData(butterworthRfft.GetOutput()) butterworthReal.SetComponents(0) butterworthReal.Update() caster = vtk.vtkImageCast() caster. SetOutputScalarTypeToUnsignedChar() caster.SetInputData(butterworthReal.GetOutput()) caster.Update() return self._update(caster.GetOutput())
#!/usr/bin/env python import vtk from vtk.util.misc import vtkGetDataRoot VTK_DATA_ROOT = vtkGetDataRoot() # This script shows the result of an ideal highpass filter in frequency space. # Image pipeline reader = vtk.vtkPNGReader() reader.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/fullhead15.png") fft = vtk.vtkImageFFT() fft.SetDimensionality(2) fft.SetInputConnection(reader.GetOutputPort()) #fft DebugOn highPass = vtk.vtkImageButterworthHighPass() highPass.SetInputConnection(fft.GetOutputPort()) highPass.SetOrder(2) highPass.SetXCutOff(0.2) highPass.SetYCutOff(0.1) highPass.ReleaseDataFlagOff() #highPass DebugOn viewer = vtk.vtkImageViewer() viewer.SetInputConnection(highPass.GetOutputPort()) viewer.SetColorWindow(10000) viewer.SetColorLevel(5000) #viewer DebugOn viewer.Render() # --- end of script --
def main(): colors = vtk.vtkNamedColors() fileName = get_program_parameters() # Read the image. readerFactory = vtk.vtkImageReader2Factory() reader = readerFactory.CreateImageReader2(fileName) reader.SetFileName(fileName) reader.Update() fft = vtk.vtkImageFFT() fft.SetInputConnection(reader.GetOutputPort()) idealHighPass = vtk.vtkImageIdealHighPass() idealHighPass.SetInputConnection(fft.GetOutputPort()) idealHighPass.SetXCutOff(0.1) idealHighPass.SetYCutOff(0.1) idealRfft = vtk.vtkImageRFFT() idealRfft.SetInputConnection(idealHighPass.GetOutputPort()) idealReal = vtk.vtkImageExtractComponents() idealReal.SetInputConnection(idealRfft.GetOutputPort()) idealReal.SetComponents(0) butterworthHighPass = vtk.vtkImageButterworthHighPass() butterworthHighPass.SetInputConnection(fft.GetOutputPort()) butterworthHighPass.SetXCutOff(0.1) butterworthHighPass.SetYCutOff(0.1) butterworthRfft = vtk.vtkImageRFFT() butterworthRfft.SetInputConnection(butterworthHighPass.GetOutputPort()) butterworthReal = vtk.vtkImageExtractComponents() butterworthReal.SetInputConnection(butterworthRfft.GetOutputPort()) butterworthReal.SetComponents(0) # Create the actors. idealColor = vtk.vtkImageMapToWindowLevelColors() idealColor.SetWindow(500) idealColor.SetLevel(0) idealColor.SetInputConnection(idealReal.GetOutputPort()) idealActor = vtk.vtkImageActor() idealActor.GetMapper().SetInputConnection(idealColor.GetOutputPort()) idealActor.GetProperty().SetInterpolationTypeToNearest() butterworthColor = vtk.vtkImageMapToWindowLevelColors() butterworthColor.SetWindow(500) butterworthColor.SetLevel(0) butterworthColor.SetInputConnection(butterworthReal.GetOutputPort()) butterworthActor = vtk.vtkImageActor() butterworthActor.GetMapper().SetInputConnection(butterworthColor.GetOutputPort()) butterworthActor.GetProperty().SetInterpolationTypeToNearest() # Setup the renderers. idealRenderer = vtk.vtkRenderer() idealRenderer.SetViewport(0.0, 0.0, 0.5, 1.0) idealRenderer.AddActor(idealActor) idealRenderer.ResetCamera() idealRenderer.SetBackground(colors.GetColor3d("SlateGray")) butterworthRenderer = vtk.vtkRenderer() butterworthRenderer.SetViewport(0.5, 0.0, 1.0, 1.0) butterworthRenderer.AddActor(butterworthActor) butterworthRenderer.SetActiveCamera(idealRenderer.GetActiveCamera()) butterworthRenderer.SetBackground(colors.GetColor3d("LightSlateGray")) renderWindow = vtk.vtkRenderWindow() renderWindow.SetSize(600, 300) renderWindow.SetWindowName('IdealHighPass') renderWindow.AddRenderer(idealRenderer) renderWindow.AddRenderer(butterworthRenderer) renderWindowInteractor = vtk.vtkRenderWindowInteractor() style = vtk.vtkInteractorStyleImage() renderWindowInteractor.SetInteractorStyle(style) renderWindowInteractor.SetRenderWindow(renderWindow) idealRenderer.GetActiveCamera().Dolly(1.4) idealRenderer.ResetCameraClippingRange() renderWindowInteractor.Initialize() renderWindowInteractor.Start()