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: 2002/04/29 19:09:21 $
00007   Version:   $Revision: 1.1 $
00008 
00009   Copyright (c) 2002 Insight 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 
00023 namespace itk
00024 {
00025   
00043 namespace Functor {  
00044   
00045   template< class TInput, class TOutput>
00046   class BinaryThreshold
00047   {
00048   public:
00049     BinaryThreshold() {};
00050     ~BinaryThreshold() {};
00051 
00052     void SetLowerThreshold( const TInput & thresh )
00053       { m_LowerThreshold = thresh; }
00054     void SetUpperThreshold( const TInput & thresh )
00055       { m_UpperThreshold = thresh; }
00056     void SetInsideValue( const TOutput & value )
00057       { m_InsideValue = value; }
00058     void SetOutsideValue( const TOutput & value )
00059       { m_OutsideValue = value; }
00060 
00061     inline TOutput operator()( const TInput & A )
00062     {
00063       if ( m_LowerThreshold <= A && A <= m_UpperThreshold )
00064         {
00065         return m_InsideValue;
00066         }
00067       return m_OutsideValue;
00068     }
00069 
00070   private:
00071     TInput      m_LowerThreshold;
00072     TInput      m_UpperThreshold;
00073     TOutput     m_InsideValue;
00074     TOutput     m_OutsideValue;
00075 
00076   };
00077 }
00078 
00079 template <class TInputImage, class TOutputImage>
00080 class ITK_EXPORT BinaryThresholdImageFilter :
00081     public
00082     UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00083     Functor::BinaryThreshold< 
00084               typename TInputImage::PixelType, 
00085               typename TOutputImage::PixelType> >
00086 {
00087 public:
00089   typedef BinaryThresholdImageFilter  Self;
00090   typedef UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00091     Functor::BinaryThreshold< 
00092               typename TInputImage::PixelType, 
00093               typename TOutputImage::PixelType>   
00094                 >  Superclass;
00095   typedef SmartPointer<Self>   Pointer;
00096   typedef SmartPointer<const Self>  ConstPointer;
00097 
00099   itkNewMacro(Self);
00100 
00102   itkTypeMacro(BinaryThresholdImageFilter, UnaryFunctorImageFilter);
00103 
00105   typedef typename TInputImage::PixelType  InputPixelType;
00106   typedef typename TOutputImage::PixelType OutputPixelType;
00107 
00109   itkConceptMacro(PixelTypeComparable, (Concept::Comparable<InputPixelType>));
00110 
00113   itkSetMacro(OutsideValue,OutputPixelType);
00114   
00116   itkGetMacro(OutsideValue,OutputPixelType);
00117 
00120   itkSetMacro(InsideValue,OutputPixelType);
00121   
00123   itkGetMacro(InsideValue,OutputPixelType);
00124 
00129   itkSetMacro( UpperThreshold, InputPixelType );
00130   itkSetMacro( LowerThreshold, InputPixelType );
00131                  
00133   itkGetMacro( UpperThreshold, InputPixelType );
00134   itkGetMacro( LowerThreshold, InputPixelType );
00135 
00136   
00137 protected:
00138   BinaryThresholdImageFilter();
00139   virtual ~BinaryThresholdImageFilter() {}
00140   void PrintSelf(std::ostream& os, Indent indent) const;
00141 
00144   virtual void BeforeThreadedGenerateData();
00145 
00146 private:
00147   BinaryThresholdImageFilter(const Self&); //purposely not implemented
00148   void operator=(const Self&); //purposely not implemented
00149 
00150   InputPixelType      m_LowerThreshold;
00151   InputPixelType      m_UpperThreshold;
00152   OutputPixelType     m_InsideValue;
00153   OutputPixelType     m_OutsideValue;
00154 
00155 };
00156 
00157 } // end namespace itk
00158 
00159 #ifndef ITK_MANUAL_INSTANTIATION
00160 #include "itkBinaryThresholdImageFilter.txx"
00161 #endif
00162 
00163 #endif

Generated at Fri May 21 01:14:27 2004 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000