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: 2008-10-24 08:14:12 $
00007   Version:   $Revision: 1.17 $
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   
00058 namespace Functor {  
00059   
00060 template< class TInput, class TOutput>
00061 class BinaryThreshold
00062 {
00063 public:
00064   BinaryThreshold()
00065     {
00066     m_LowerThreshold = NumericTraits<TInput>::NonpositiveMin();
00067     m_UpperThreshold = NumericTraits<TInput>::max();
00068     m_OutsideValue   = NumericTraits<TOutput>::Zero;
00069     m_InsideValue    = NumericTraits<TOutput>::max();
00070     }
00071   ~BinaryThreshold() {};
00072 
00073   void SetLowerThreshold( const TInput & thresh )
00074     { m_LowerThreshold = thresh; }
00075   void SetUpperThreshold( const TInput & thresh )
00076     { m_UpperThreshold = thresh; }
00077   void SetInsideValue( const TOutput & value )
00078     { m_InsideValue = value; }
00079   void SetOutsideValue( const TOutput & value )
00080     { m_OutsideValue = value; }
00081 
00082   bool operator!=( const BinaryThreshold & other ) const
00083     {
00084     if( m_LowerThreshold != other.m_LowerThreshold ||
00085         m_UpperThreshold != other.m_UpperThreshold ||
00086         m_InsideValue    != other.m_InsideValue    ||
00087         m_OutsideValue   != other.m_OutsideValue  )
00088       {
00089       return true;
00090       }
00091     return false;
00092     }
00093   bool operator==( const BinaryThreshold & other ) const
00094     {
00095     return !(*this != other);
00096     }
00097 
00098   inline TOutput operator()( const TInput & A )
00099     {
00100     if ( m_LowerThreshold <= A && A <= m_UpperThreshold )
00101       {
00102       return m_InsideValue;
00103       }
00104     return m_OutsideValue;
00105     }
00106 private:
00107   TInput      m_LowerThreshold;
00108   TInput      m_UpperThreshold;
00109   TOutput     m_InsideValue;
00110   TOutput     m_OutsideValue;
00111 
00112 };
00113 }
00114 
00115 template <class TInputImage, class TOutputImage>
00116 class ITK_EXPORT BinaryThresholdImageFilter :
00117     public
00118 UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00119                         Functor::BinaryThreshold< 
00120   typename TInputImage::PixelType, 
00121   typename TOutputImage::PixelType> >
00122 {
00123 public:
00125   typedef BinaryThresholdImageFilter  Self;
00126   typedef UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00127                                   Functor::BinaryThreshold< 
00128     typename TInputImage::PixelType, 
00129     typename TOutputImage::PixelType>   
00130   >                                   Superclass;
00131   typedef SmartPointer<Self>          Pointer;
00132   typedef SmartPointer<const Self>    ConstPointer;
00133 
00135   itkNewMacro(Self);
00136 
00138   itkTypeMacro(BinaryThresholdImageFilter, UnaryFunctorImageFilter);
00139 
00141   typedef typename TInputImage::PixelType  InputPixelType;
00142   typedef typename TOutputImage::PixelType OutputPixelType;
00143 
00145   typedef SimpleDataObjectDecorator<InputPixelType> InputPixelObjectType;
00146 
00149   itkSetMacro(OutsideValue,OutputPixelType);
00150 
00152   itkGetConstReferenceMacro(OutsideValue,OutputPixelType);
00153 
00156   itkSetMacro(InsideValue,OutputPixelType);
00157 
00159   itkGetConstReferenceMacro(InsideValue,OutputPixelType);
00160 
00165   virtual void SetUpperThreshold(const InputPixelType threshold);
00166   virtual void SetUpperThresholdInput( const InputPixelObjectType *);
00167   virtual void SetLowerThreshold(const InputPixelType threshold);
00168   virtual void SetLowerThresholdInput( const InputPixelObjectType *);
00170 
00172   virtual InputPixelType GetUpperThreshold() const;
00173   virtual InputPixelObjectType *GetUpperThresholdInput();
00174   virtual const InputPixelObjectType *GetUpperThresholdInput() const;
00175   virtual InputPixelType GetLowerThreshold() const;
00176   virtual InputPixelObjectType *GetLowerThresholdInput();
00177   virtual const InputPixelObjectType *GetLowerThresholdInput() const;
00179 
00180 #ifdef ITK_USE_CONCEPT_CHECKING
00181 
00182   itkConceptMacro(OutputEqualityComparableCheck,
00183                   (Concept::EqualityComparable<OutputPixelType>));
00184   itkConceptMacro(InputPixelTypeComparable,
00185                   (Concept::Comparable<InputPixelType>));
00186   itkConceptMacro(InputOStreamWritableCheck,
00187                   (Concept::OStreamWritable<InputPixelType>));
00188   itkConceptMacro(OutputOStreamWritableCheck,
00189                   (Concept::OStreamWritable<OutputPixelType>));
00190 
00192 #endif
00193 
00194 protected:
00195   BinaryThresholdImageFilter();
00196   virtual ~BinaryThresholdImageFilter() {}
00197   void PrintSelf(std::ostream& os, Indent indent) const;
00198 
00201   virtual void BeforeThreadedGenerateData();
00202 
00203 private:
00204   BinaryThresholdImageFilter(const Self&); //purposely not implemented
00205   void operator=(const Self&); //purposely not implemented
00206 
00207   OutputPixelType     m_InsideValue;
00208   OutputPixelType     m_OutsideValue;
00209 
00210 };
00211 
00212 } // end namespace itk
00213 
00214 #ifndef ITK_MANUAL_INSTANTIATION
00215 #include "itkBinaryThresholdImageFilter.txx"
00216 #endif
00217 
00218 #endif
00219 

Generated at Sat Feb 28 12:03:14 2009 for ITK by doxygen 1.5.6 written by Dimitri van Heesch, © 1997-2000