#============================================================================== # # Project: SharpImage # Module: HMaxima.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 Morphology library clr.AddReference("ManagedITK.MorphologicalFilters") from itk import * class HMaximaScript(ImageToImageScriptObject): # ------------------------------------------------------------------------- Name = "HMaxima" Help = """Suppress local maxima whose height above the baseline is less than height.""" Parameters = """(pixel) Height = the height above the baseline. (2)""" Height = 2 # ------------------------------------------------------------------------- def ThreadedDoWork(self): """ Perform the main functions of the script on a background thread. """ try: self.StartedWork() self.WriteInputName() filterHMaxima = itkHMaximaImageFilter.New( self.Input, self.Output ) self.AddEventHandlersToProcessObject( filterHMaxima ) filterHMaxima.SetInput( self.Input ) filterHMaxima.Height = itkPixel( self.Input.PixelType, self.Height ) self.WriteLineToConsole( "Height=" + self.Height.ToString() ) filterHMaxima.GetOutput( self.Output ) filterHMaxima.UpdateLargestPossibleRegion() self.DisconnectInputAndOutput() self.DisposeOfObject( filterHMaxima ) self.WriteOutputName() self.FinishedWork( True ) except Exception, ex: self.HandleException( ex ) self.FinishedWork( False ) self.Finalise( )