#============================================================================== # # Project: SharpImage # Module: MinMaxCurvatureFlow.py # Language: IronPython # Author: Dan Mueller # Date: $Date: 2007-07-06 10:57:00 +1000 (Fri, 06 Jul 2007) $ # Revision: $Revision: 2 $ # # Copyright (c) Queensland University of Technology (QUT) 2007. # All rights reserved. # # This software is distributed WITHOUT ANY WARRANTY; without even # the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR # PURPOSE. See the above copyright notices for more information. # #============================================================================== # Import the base script class import ImageToImageScript from ImageToImageScript import * # Add reference and import Denoising library clr.AddReference("ManagedITK.NoiseFilters") from itk import * class MinMaxCurvatureFlowScript(ImageToImageScriptObject): # ------------------------------------------------------------------------- Name = "MinMaxCurvatureFlow" Help = """Performs denoising of the input image using min/max curvature driven flow.""" Parameters = """(double) TimeStep = the time step in the finite difference equation. (0.05) (int) Iterations = the number of iterations. (2) (int) StencilRadius = the radius of the stencil operator. (2)""" TimeStep = 0.05 Iterations = 2 StencilRadius = 2 # ------------------------------------------------------------------------- def ThreadedDoWork(self): """ Perform the main functions of the script on a background thread. """ try: self.StartedWork() self.WriteInputName() filterFlow = itkMinMaxCurvatureFlowImageFilter.New( self.Input, self.Output ) self.AddEventHandlersToProcessObject( filterFlow ) filterFlow.SetInput( self.Input ) filterFlow.TimeStep = self.TimeStep filterFlow.NumberOfIterations = self.Iterations filterFlow.StencilRadius = self.StencilRadius self.WriteLineToConsole( "TimeStep=" + filterFlow.TimeStep.ToString() ) self.WriteLineToConsole( "Iterations=" + filterFlow.NumberOfIterations.ToString() ) self.WriteLineToConsole( "StencilRadius=" + filterFlow.StencilRadius.ToString() ) filterFlow.UpdateLargestPossibleRegion() filterFlow.GetOutput( self.Output ) self.DisconnectInputAndOutput() self.DisposeOfObject( filterFlow ) self.WriteOutputName() self.FinishedWork( True ) except Exception, ex: self.HandleException( ex ) self.FinishedWork( False ) self.Finalise( )