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: 2006/04/18 18:34:23 $
00007   Version:   $Revision: 1.11 $
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   
00052 namespace Functor {  
00053   
00054 template< class TInput, class TOutput>
00055 class BinaryThreshold
00056 {
00057 public:
00058   BinaryThreshold() {};
00059   ~BinaryThreshold() {};
00060 
00061   void SetLowerThreshold( const TInput & thresh )
00062   { m_LowerThreshold = thresh; }
00063   void SetUpperThreshold( const TInput & thresh )
00064   { m_UpperThreshold = thresh; }
00065   void SetInsideValue( const TOutput & value )
00066   { m_InsideValue = value; }
00067   void SetOutsideValue( const TOutput & value )
00068   { m_OutsideValue = value; }
00069 
00070   bool operator!=( const BinaryThreshold & other ) const
00071   {
00072     if( m_LowerThreshold != other.m_LowerThreshold ||
00073         m_UpperThreshold != other.m_UpperThreshold ||
00074         m_InsideValue    != other.m_InsideValue    ||
00075         m_OutsideValue   != other.m_OutsideValue  )
00076         {
00077         return true;
00078         }
00079     return false;
00080    }
00081   bool operator==( const BinaryThreshold & other ) const
00082   {
00083     return !(*this != other);
00084   }
00085 
00086   inline TOutput operator()( const TInput & A )
00087   {
00088     if ( m_LowerThreshold <= A && A <= m_UpperThreshold )
00089       {
00090       return m_InsideValue;
00091       }
00092     return m_OutsideValue;
00093   }
00094 
00095 private:
00096   TInput      m_LowerThreshold;
00097   TInput      m_UpperThreshold;
00098   TOutput     m_InsideValue;
00099   TOutput     m_OutsideValue;
00100 
00101 };
00102 }
00103 
00104 template <class TInputImage, class TOutputImage>
00105 class ITK_EXPORT BinaryThresholdImageFilter :
00106     public
00107 UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00108                         Functor::BinaryThreshold< 
00109   typename TInputImage::PixelType, 
00110   typename TOutputImage::PixelType> >
00111 {
00112 public:
00114   typedef BinaryThresholdImageFilter  Self;
00115   typedef UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00116                                   Functor::BinaryThreshold< 
00117     typename TInputImage::PixelType, 
00118     typename TOutputImage::PixelType>   
00119   >  Superclass;
00120   typedef SmartPointer<Self>   Pointer;
00121   typedef SmartPointer<const Self>  ConstPointer;
00122 
00124   itkNewMacro(Self);
00125 
00127   itkTypeMacro(BinaryThresholdImageFilter, UnaryFunctorImageFilter);
00128 
00130   typedef typename TInputImage::PixelType  InputPixelType;
00131   typedef typename TOutputImage::PixelType OutputPixelType;
00132 
00134   typedef SimpleDataObjectDecorator<InputPixelType> InputPixelObjectType;
00135 
00138   itkSetMacro(OutsideValue,OutputPixelType);
00139 
00141   itkGetMacro(OutsideValue,OutputPixelType);
00142 
00145   itkSetMacro(InsideValue,OutputPixelType);
00146 
00148   itkGetMacro(InsideValue,OutputPixelType);
00149 
00154   virtual void SetUpperThreshold(const InputPixelType threshold);
00155   virtual void SetUpperThresholdInput( const InputPixelObjectType *);
00156   virtual void SetLowerThreshold(const InputPixelType threshold);
00157   virtual void SetLowerThresholdInput( const InputPixelObjectType *);
00159 
00161   virtual InputPixelType GetUpperThreshold() const;
00162   virtual InputPixelObjectType *GetUpperThresholdInput();
00163   virtual const InputPixelObjectType *GetUpperThresholdInput() const;
00164   virtual InputPixelType GetLowerThreshold() const;
00165   virtual InputPixelObjectType *GetLowerThresholdInput();
00166   virtual const InputPixelObjectType *GetLowerThresholdInput() const;
00168 
00169 #ifdef ITK_USE_CONCEPT_CHECKING
00170 
00171   itkConceptMacro(OutputEqualityComparableCheck,
00172                   (Concept::EqualityComparable<OutputPixelType>));
00173   itkConceptMacro(InputPixelTypeComparable,
00174                   (Concept::Comparable<InputPixelType>));
00175   itkConceptMacro(InputOStreamWritableCheck,
00176                   (Concept::OStreamWritable<InputPixelType>));
00177   itkConceptMacro(OutputOStreamWritableCheck,
00178                   (Concept::OStreamWritable<OutputPixelType>));
00179 
00181 #endif
00182 
00183 protected:
00184   BinaryThresholdImageFilter();
00185   virtual ~BinaryThresholdImageFilter() {}
00186   void PrintSelf(std::ostream& os, Indent indent) const;
00187 
00190   virtual void BeforeThreadedGenerateData();
00191 
00192 private:
00193   BinaryThresholdImageFilter(const Self&); //purposely not implemented
00194   void operator=(const Self&); //purposely not implemented
00195 
00196   OutputPixelType     m_InsideValue;
00197   OutputPixelType     m_OutsideValue;
00198 
00199 };
00200 
00201 } // end namespace itk
00202 
00203 #ifndef ITK_MANUAL_INSTANTIATION
00204 #include "itkBinaryThresholdImageFilter.txx"
00205 #endif
00206 
00207 #endif
00208 

Generated at Sat Sep 2 20:10:25 2006 for ITK by doxygen 1.4.7 written by Dimitri van Heesch, © 1997-2000