freDifferenceToRGBImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   F.R.E.E. - flexible registration evaluation engine
00004   Version:   v.1.0.0
00005   Date:      $Date: 2006/09/01 12:00:00 $
00006   Module:    $RCSfile: freDifferenceToRGBImageFilter.h,v $
00007   Language:  C++
00008 
00009 
00010 
00011   Copyright (c) 2007 Ralf o Floca (Department of Medical Informatics,
00012   Institute for Medical Biometry and Informatics, University of Heidelberg,
00013   Germany). All rights reserved.
00014   See FREECopyright.txt or http://www.mi.med.uni-hd.de/free/copyright.htm
00015   for details.
00016 
00017      This software is distributed WITHOUT ANY WARRANTY; without even 
00018      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00019      PURPOSE.  See the above copyright notices for more information.
00020 
00021 =========================================================================*/
00022 
00023 #ifndef __freDifferenceToRGBImageFilter_h
00024 #define __freDifferenceToRGBImageFilter_h
00025 
00026 #include "itkBinaryFunctorImageFilter.h"
00027 
00028 namespace FREE
00029 {
00030   
00057 namespace Functor
00058 {  
00059   
00060 template< class TInput1, class TInput2, class TOutput>
00061 class DifferenceToRGBFunctor
00062 {
00063 public:
00064   DifferenceToRGBFunctor() {};
00065   ~DifferenceToRGBFunctor() {};
00066   inline TOutput operator()( const TInput1 & A, 
00067                              const TInput2 & B)
00068   {
00069     const double dA = static_cast<double>( A );
00070     const double dB = static_cast<double>( B );
00071     const double diff = dA - dB;
00072 
00073                 TOutput output;
00074                 output.Fill(0);
00075 
00076                 if (diff < 0.0) output.SetElement(1,static_cast<typename TOutput::ValueType>( abs(diff)));
00077                 else if (diff > 0.0) output.SetElement(0,static_cast<typename TOutput::ValueType>( abs(diff)));
00078 
00079     return output;
00080   }
00081 }; 
00082 }
00083 
00084 template <class TInputImage1, class TInputImage2, class TOutputImage>
00085 class ITK_EXPORT DifferenceToRGBImageFilter : public
00086                 itk::BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage, 
00087                          Functor::DifferenceToRGBFunctor< 
00088   typename TInputImage1::PixelType, 
00089   typename TInputImage2::PixelType,
00090   typename TOutputImage::PixelType>   >
00091 {
00092 public:
00094   typedef DifferenceToRGBImageFilter  Self;
00095         typedef itk::BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage, 
00096                                                                                                                                                           Functor::DifferenceToRGBFunctor< 
00097     typename TInputImage1::PixelType, 
00098     typename TInputImage2::PixelType,
00099     typename TOutputImage::PixelType>   
00100   >  Superclass;
00101 
00102         typedef itk::SmartPointer<Self>   Pointer;
00103   typedef itk::SmartPointer<const Self>  ConstPointer;
00104 
00106   itkNewMacro(Self);
00107   
00108 protected:
00109   DifferenceToRGBImageFilter() {}
00110   virtual ~DifferenceToRGBImageFilter() {}
00111 
00112 private:
00113   DifferenceToRGBImageFilter(const Self&); //purposely not implemented
00114   void operator=(const Self&); //purposely not implemented
00115 
00116 };
00117 
00118 } // end namespace FREE
00119 
00120 
00121 #endif

Generated at Sat Oct 13 15:47:30 2007 for f.r.e.e. - Flexible Registration and Evaluation Engine by doxygen 1.5.3 written by Dimitri van Heesch, © 1997-2000