#============================================================================== # # Project: SharpImage # Module: LaplacianRecursiveGaussian.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 Common library clr.AddReference("ManagedITK.GradientFilters") from itk import * class LaplacianRecursiveGaussianScript(ImageToImageScriptObject): # ------------------------------------------------------------------------- Name = "LaplacianRecursiveGaussian" Help = """Computes the Laplacian of an image by convolution with the second derivative of a Gaussian.""" Parameters = """(double) Sigma = the variance of the Gaussian. (1.0) (bool) NormalizeAcrossScale = indicates if the scale is used. (False)""" Sigma = 1.0 NormalizeAcrossScale = False # ------------------------------------------------------------------------- def ThreadedDoWork(self): """ Perform the main functions of the script on a background thread. """ try: self.StartedWork() self.WriteInputName() filterLaplacian = itkLaplacianRecursiveGaussianImageFilter.New( self.Input, self.Output ) self.AddEventHandlersToProcessObject( filterLaplacian ) filterLaplacian.SetInput( self.Input ) filterLaplacian.Sigma = self.Sigma filterLaplacian.NormalizeAcrossScale = self.NormalizeAcrossScale self.WriteLineToConsole( "Sigma=" + self.Sigma.ToString() ) self.WriteLineToConsole( "NormalizeAcrossScale=" + self.NormalizeAcrossScale.ToString() ) filterLaplacian.UpdateLargestPossibleRegion() filterLaplacian.GetOutput( self.Output ) self.DisconnectInputAndOutput() self.DisposeOfObject( filterLaplacian ) self.WriteOutputName() self.FinishedWork( True ) except Exception, ex: self.HandleException( ex ) self.FinishedWork( False ) self.Finalise( )