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

itkConstrainedValueDifferenceImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkConstrainedValueDifferenceImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-04-01 14:36:11 $
00007   Version:   $Revision: 1.8 $
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 __itkConstrainedValueDifferenceImageFilter_h
00018 #define __itkConstrainedValueDifferenceImageFilter_h
00019 
00020 #include "itkBinaryFunctorImageFilter.h"
00021 #include "itkNumericTraits.h"
00022 
00023 namespace itk
00024 {
00025   
00054 namespace Functor {  
00055   
00056 template< class TInput1, class TInput2, class TOutput>
00057 class ConstrainedValueDifference
00058 {
00059 public:
00060   ConstrainedValueDifference() {};
00061   ~ConstrainedValueDifference() {};
00062   bool operator!=( const ConstrainedValueDifference & ) const
00063     {
00064     return false;
00065     }
00066   bool operator==( const ConstrainedValueDifference & other ) const
00067     {
00068     return !(*this != other);
00069     }
00070   inline TOutput operator()( const TInput1 & A, 
00071                              const TInput2 & B) const
00072     {
00073     const double dA = static_cast<double>( A );
00074     const double dB = static_cast<double>( B );
00075     const double diff = dA - dB;
00076     const double cdiff1 = diff > NumericTraits<TOutput>::NonpositiveMin() ?
00077       diff : NumericTraits<TOutput>::NonpositiveMin(); 
00078     const double cdiff2 = cdiff1 < NumericTraits<TOutput>::max() ?
00079       cdiff1 : NumericTraits<TOutput>::max();
00080     return static_cast<TOutput>( cdiff2 );
00081     }
00082 }; 
00083 }
00084 
00085 template <class TInputImage1, class TInputImage2, class TOutputImage>
00086 class ITK_EXPORT ConstrainedValueDifferenceImageFilter :
00087     public
00088 BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage, 
00089                          Functor::ConstrainedValueDifference< 
00090   typename TInputImage1::PixelType, 
00091   typename TInputImage2::PixelType,
00092   typename TOutputImage::PixelType>   >
00093 {
00094 public:
00096   typedef ConstrainedValueDifferenceImageFilter  Self;
00097   typedef BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage, 
00098                                    Functor::ConstrainedValueDifference< 
00099     typename TInputImage1::PixelType, 
00100     typename TInputImage2::PixelType,
00101     typename TOutputImage::PixelType> >
00102                                     Superclass;
00103   typedef SmartPointer<Self>        Pointer;
00104   typedef SmartPointer<const Self>  ConstPointer;
00105 
00107   itkNewMacro(Self);
00108 
00110   itkTypeMacro(ConstrainedValueDifferenceImageFilter, 
00111                BinaryFunctorImageFilter);
00112 
00113 #ifdef ITK_USE_CONCEPT_CHECKING
00114 
00115   itkConceptMacro(Input1ConvertibleToDoubleCheck,
00116     (Concept::Convertible<typename TInputImage1::PixelType, double>));
00117   itkConceptMacro(Input2ConvertibleToDoubleCheck,
00118     (Concept::Convertible<typename TInputImage2::PixelType, double>));
00119   itkConceptMacro(DoubleConvertibleToOutputCheck,
00120     (Concept::Convertible<double, typename TOutputImage::PixelType>));
00121   itkConceptMacro(DoubleGreaterThanOutputCheck,
00122     (Concept::GreaterThanComparable<double, typename TOutputImage::PixelType>));
00123 
00125 #endif
00126 
00127 protected:
00128   ConstrainedValueDifferenceImageFilter() {}
00129   virtual ~ConstrainedValueDifferenceImageFilter() {}
00130 
00131 private:
00132   ConstrainedValueDifferenceImageFilter(const Self&); //purposely not implemented
00133   void operator=(const Self&); //purposely not implemented
00134 
00135 };
00136 
00137 } // end namespace itk
00138 
00139 
00140 #endif
00141 

Generated at Tue Sep 15 02:40:41 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000