#============================================================================== # # Project: SharpImage # Module: RegionalMinima.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 Intensity library clr.AddReference("ManagedITK.IntensityFilters") from itk import * class RegionalMinimaScript(ImageToImageScriptObject): # ------------------------------------------------------------------------- Name = "RegionalMinima" Help = """Computes the regional minima within the input image. Regional minima are flat zones surounded by pixels of higher value.""" Parameters = """(bool) FullyConnected = the connectivity. (False) (bool) FlatIsMinima = indicates if a flat image is a minima. (True)""" FullyConnected = False FlatIsMinima = True # ------------------------------------------------------------------------- def ThreadedDoWork(self): """ Perform the main functions of the script. """ """ NOTE: This function is invoked on a background thread. """ try: self.StartedWork() self.WriteInputName() filterRegionalMinima = itkRegionalMinimaImageFilter.New( self.Input, self.Output ) self.AddEventHandlersToProcessObject( filterRegionalMinima ) filterRegionalMinima.SetInput( self.Input ) filterRegionalMinima.FullyConnected = self.FullyConnected filterRegionalMinima.FlatIsMinima = self.FlatIsMinima self.WriteLineToConsole( "FullyConnected=" + self.FullyConnected.ToString() ) self.WriteLineToConsole( "FlatIsMinima=" + self.FlatIsMinima.ToString() ) filterRegionalMinima.UpdateLargestPossibleRegion() filterRegionalMinima.GetOutput( self.Output ) self.DisconnectInputAndOutput() self.DisposeOfObject( filterRegionalMinima ) self.WriteOutputName() self.FinishedWork( True ) except Exception, ex: self.HandleException( ex ) self.FinishedWork( False ) self.Finalise( )