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

itkSubtractConstantFromImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkSubtractConstantFromImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-06-29 19:49:06 $
00007   Version:   $Revision: 1.1 $
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 
00018 #ifndef __itkSubtractConstantFromImageFilter_h
00019 #define __itkSubtractConstantFromImageFilter_h
00020 
00021 #include "itkUnaryFunctorImageFilter.h"
00022 #include "itkNumericTraits.h"
00023 
00024 namespace itk
00025 {
00026   
00043 namespace Functor {  
00044   
00045 template< class TInput, class TConstant, class TOutput>
00046 class SubtractConstantFrom
00047 {
00048 public:
00049   SubtractConstantFrom() : m_Constant(NumericTraits<TConstant>::One) {};
00050   ~SubtractConstantFrom() {};
00051   bool operator!=( const SubtractConstantFrom & other ) const
00052     {
00053     return !(*this == other);
00054     }
00055   bool operator==( const SubtractConstantFrom & other ) const
00056     {
00057     return other.m_Constant == m_Constant;
00058     }
00059   inline TOutput operator()( const TInput & A )
00060     {
00061     // Because the user has to specify the constant we don't
00062     // check if the cte is not 0;
00063     return static_cast<TOutput>( A - m_Constant );
00064     }
00065   void SetConstant(TConstant ct) {this->m_Constant = ct; }
00066   const TConstant GetConstant() const { return m_Constant; }
00067   
00068   TConstant m_Constant;
00069 };
00070 }
00071 
00072 template <class TInputImage, class TConstant, class TOutputImage>
00073 class ITK_EXPORT SubtractConstantFromImageFilter :
00074       public
00075 UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00076                         Functor::SubtractConstantFrom< 
00077    typename TInputImage::PixelType, TConstant,
00078    typename TOutputImage::PixelType> >
00079 {
00080 public:
00082   typedef SubtractConstantFromImageFilter                 Self;
00083   typedef UnaryFunctorImageFilter<
00084     TInputImage,TOutputImage, 
00085     Functor::SubtractConstantFrom< 
00086       typename TInputImage::PixelType, TConstant,
00087       typename TOutputImage::PixelType>   >             Superclass;
00088   typedef SmartPointer<Self>                            Pointer;
00089   typedef SmartPointer<const Self>                      ConstPointer;
00090 
00092   itkNewMacro(Self);
00093 
00095   itkTypeMacro(SubtractConstantFromImageFilter, UnaryFunctorImageFilter);
00096 
00097   
00099   void SetConstant(TConstant ct)
00100     {
00101     this->GetFunctor().SetConstant(ct);
00102     this->Modified();
00103     }
00105 
00106 
00107 #ifdef ITK_USE_CONCEPT_CHECKING
00108 
00109   itkConceptMacro(InputConvertibleToOutputCheck,
00110                   (Concept::Convertible<typename TInputImage::PixelType,
00111                    typename TOutputImage::PixelType>));
00112   itkConceptMacro(Input1Input2OutputSubtractOperatorCheck,
00113                   (Concept::AdditiveOperators<typename TInputImage::PixelType,
00114                    TConstant,
00115                    typename TOutputImage::PixelType>));
00116 
00118 #endif
00119 
00120 protected:
00121   SubtractConstantFromImageFilter() {};
00122   virtual ~SubtractConstantFromImageFilter() {};
00123    
00124   SubtractConstantFromImageFilter(const Self&); //purposely not implemented
00125   void operator=(const Self&); //purposely not implemented
00126 
00127 };
00128 
00129 
00130 } // end namespace itk
00131 
00132 #endif
00133 

Generated at Tue Jul 29 22:42:10 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000