Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkBinaryThresholdImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkBinaryThresholdImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2004/03/05 21:44:57 $
00007   Version:   $Revision: 1.5 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkBinaryThresholdImageFilter_h
00018 #define __itkBinaryThresholdImageFilter_h
00019 
00020 #include "itkUnaryFunctorImageFilter.h"
00021 #include "itkConceptChecking.h"
00022 #include "itkSimpleDataObjectDecorator.h"
00023 
00024 namespace itk
00025 {
00026   
00044 namespace Functor {  
00045   
00046 template< class TInput, class TOutput>
00047 class BinaryThreshold
00048 {
00049 public:
00050   BinaryThreshold() {};
00051   ~BinaryThreshold() {};
00052 
00053   void SetLowerThreshold( const TInput & thresh )
00054   { m_LowerThreshold = thresh; }
00055   void SetUpperThreshold( const TInput & thresh )
00056   { m_UpperThreshold = thresh; }
00057   void SetInsideValue( const TOutput & value )
00058   { m_InsideValue = value; }
00059   void SetOutsideValue( const TOutput & value )
00060   { m_OutsideValue = value; }
00061 
00062   inline TOutput operator()( const TInput & A )
00063   {
00064     if ( m_LowerThreshold <= A && A <= m_UpperThreshold )
00065       {
00066       return m_InsideValue;
00067       }
00068     return m_OutsideValue;
00069   }
00070 
00071 private:
00072   TInput      m_LowerThreshold;
00073   TInput      m_UpperThreshold;
00074   TOutput     m_InsideValue;
00075   TOutput     m_OutsideValue;
00076 
00077 };
00078 }
00079 
00080 template <class TInputImage, class TOutputImage>
00081 class ITK_EXPORT BinaryThresholdImageFilter :
00082     public
00083 UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00084                         Functor::BinaryThreshold< 
00085   typename TInputImage::PixelType, 
00086   typename TOutputImage::PixelType> >
00087 {
00088 public:
00090   typedef BinaryThresholdImageFilter  Self;
00091   typedef UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00092                                   Functor::BinaryThreshold< 
00093     typename TInputImage::PixelType, 
00094     typename TOutputImage::PixelType>   
00095   >  Superclass;
00096   typedef SmartPointer<Self>   Pointer;
00097   typedef SmartPointer<const Self>  ConstPointer;
00098 
00100   itkNewMacro(Self);
00101 
00103   itkTypeMacro(BinaryThresholdImageFilter, UnaryFunctorImageFilter);
00104 
00106   typedef typename TInputImage::PixelType  InputPixelType;
00107   typedef typename TOutputImage::PixelType OutputPixelType;
00108 
00110   itkConceptMacro(PixelTypeComparable, (Concept::Comparable<InputPixelType>));
00111 
00113   typedef SimpleDataObjectDecorator<InputPixelType> InputPixelObjectType;
00114   
00117   itkSetMacro(OutsideValue,OutputPixelType);
00118   
00120   itkGetMacro(OutsideValue,OutputPixelType);
00121 
00124   itkSetMacro(InsideValue,OutputPixelType);
00125   
00127   itkGetMacro(InsideValue,OutputPixelType);
00128 
00133   virtual void SetUpperThreshold(const InputPixelType threshold);
00134   virtual void SetUpperThresholdInput( const InputPixelObjectType *);
00135   virtual void SetLowerThreshold(const InputPixelType threshold);
00136   virtual void SetLowerThresholdInput( const InputPixelObjectType *);
00137                  
00139   virtual InputPixelType GetUpperThreshold() const;
00140   virtual InputPixelObjectType *GetUpperThresholdInput();
00141   virtual const InputPixelObjectType *GetUpperThresholdInput() const;
00142   virtual InputPixelType GetLowerThreshold() const;
00143   virtual InputPixelObjectType *GetLowerThresholdInput();
00144   virtual const InputPixelObjectType *GetLowerThresholdInput() const;
00145   
00146 protected:
00147   BinaryThresholdImageFilter();
00148   virtual ~BinaryThresholdImageFilter() {}
00149   void PrintSelf(std::ostream& os, Indent indent) const;
00150 
00153   virtual void BeforeThreadedGenerateData();
00154 
00155 private:
00156   BinaryThresholdImageFilter(const Self&); //purposely not implemented
00157   void operator=(const Self&); //purposely not implemented
00158 
00159   OutputPixelType     m_InsideValue;
00160   OutputPixelType     m_OutsideValue;
00161 
00162 };
00163 
00164 } // end namespace itk
00165 
00166 #ifndef ITK_MANUAL_INSTANTIATION
00167 #include "itkBinaryThresholdImageFilter.txx"
00168 #endif
00169 
00170 #endif

Generated at Wed May 24 22:50:32 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000