]> Creatis software - clitk.git/blob - itk/itkBinaryGuerreroFilter.h
removed headers
[clitk.git] / itk / itkBinaryGuerreroFilter.h
1 #ifndef __itkBinaryGuerreroFilter_h
2 #define __itkBinaryGuerreroFilter_h
3 #include "itkBinaryFunctorImageFilter.h"
4 #include "itkNumericTraits.h"
5
6 #include <cmath>
7
8 namespace itk
9 {
10   
11 /** \class BinaryGuerreroFilter
12  * \brief  *
13  * The images to be added are set using the methods:
14  * SetInput1( image1 );
15  * SetInput2( image2 );
16  * 
17  * \warning No numeric overflow checking is performed in this filter.
18  *
19  * \ingroup IntensityImageFilters  Multithreaded
20  */
21 namespace Functor {  
22   
23 template< class TInput1, class TInput2=TInput1, class TOutput=TInput1>
24 class GuerreroFunctor
25 {
26     public:
27         GuerreroFunctor() : use_correct_formula(false)
28             {};
29         ~GuerreroFunctor() {};
30         bool operator!=( const GuerreroFunctor & ) const
31         {
32             return false;
33         }
34         bool operator==( const GuerreroFunctor & other ) const
35         {
36             return !(*this != other);
37         }
38         inline TOutput operator() ( const TInput1 & A, const TInput2 & B) const
39         {
40             //A is the reference image
41             TInput2 Bstar = B - 1000.*blood_mass_factor*(1+B/1000.);
42             TOutput vol_change;
43             if (use_correct_formula)
44                 vol_change=static_cast<TOutput>( (A-Bstar) / (1000.+Bstar) );
45             else //Use the original formula as described in Guerrero's paper
46                 vol_change=static_cast<TOutput>( 1000. * (Bstar-A) / (A*(1000.+Bstar)) );
47
48             if (IsNormal(vol_change))
49                 return vol_change;
50             else
51                 return 0.;
52         }
53         double blood_mass_factor;
54         bool use_correct_formula;
55 }; 
56
57 }
58
59 //==========================================================================
60 template <class TInputImage1, class TInputImage2=TInputImage1, class TOutputImage=TInputImage1>
61 class ITK_EXPORT BinaryGuerreroFilter :
62     public
63 BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage, 
64                          Functor::GuerreroFunctor< 
65   typename TInputImage1::PixelType, 
66   typename TInputImage2::PixelType,
67   typename TOutputImage::PixelType>   >
68
69
70 {
71 public:
72   /** Standard class typedefs. */
73   typedef BinaryGuerreroFilter               Self;
74   typedef BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage, 
75                                    Functor::GuerreroFunctor< 
76     typename TInputImage1::PixelType, 
77     typename TInputImage2::PixelType,
78     typename TOutputImage::PixelType> > Superclass;
79
80   typedef SmartPointer<Self>        Pointer;
81   typedef SmartPointer<const Self>  ConstPointer;
82
83   /** Method for creation through the object factory. */
84   itkNewMacro(Self);
85
86   /** Runtime information support. */
87   itkTypeMacro(BinaryGuerreroFilter, 
88                BinaryFunctorImageFilter);
89   void SetBloodCorrectionFactor(double f)
90   {
91       this->GetFunctor().blood_mass_factor=f;
92   }
93   void SetUseCorrectFormula(bool use_correct_formula)
94   {
95       this->GetFunctor().use_correct_formula=use_correct_formula;
96   }
97
98
99 protected:
100   BinaryGuerreroFilter() {}
101   virtual ~BinaryGuerreroFilter() {}
102
103 private:
104   BinaryGuerreroFilter(const Self&); //purposely not implemented
105   void operator=(const Self&); //purposely not implemented
106
107 };
108
109 } // end namespace itk
110
111
112 #endif