1 #ifndef __itkBinaryGuerreroFilter_h
2 #define __itkBinaryGuerreroFilter_h
3 #include "itkBinaryFunctorImageFilter.h"
4 #include "itkNumericTraits.h"
11 /** \class BinaryGuerreroFilter
13 * The images to be added are set using the methods:
14 * SetInput1( image1 );
15 * SetInput2( image2 );
17 * \warning No numeric overflow checking is performed in this filter.
19 * \ingroup IntensityImageFilters Multithreaded
23 template< class TInput1, class TInput2=TInput1, class TOutput=TInput1>
27 GuerreroFunctor() : use_correct_formula(false)
29 ~GuerreroFunctor() {};
30 bool operator!=( const GuerreroFunctor & ) const
34 bool operator==( const GuerreroFunctor & other ) const
36 return !(*this != other);
38 inline TOutput operator() ( const TInput1 & A, const TInput2 & B) const
40 //A is the reference image
41 TInput2 Bstar = B - 1000.*blood_mass_factor*(1+B/1000.);
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)) );
48 if (IsNormal(vol_change))
53 double blood_mass_factor;
54 bool use_correct_formula;
59 //==========================================================================
60 template <class TInputImage1, class TInputImage2=TInputImage1, class TOutputImage=TInputImage1>
61 class ITK_EXPORT BinaryGuerreroFilter :
63 BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
64 Functor::GuerreroFunctor<
65 typename TInputImage1::PixelType,
66 typename TInputImage2::PixelType,
67 typename TOutputImage::PixelType> >
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;
80 typedef SmartPointer<Self> Pointer;
81 typedef SmartPointer<const Self> ConstPointer;
83 /** Method for creation through the object factory. */
86 /** Runtime information support. */
87 itkTypeMacro(BinaryGuerreroFilter,
88 BinaryFunctorImageFilter);
89 void SetBloodCorrectionFactor(double f)
91 this->GetFunctor().blood_mass_factor=f;
93 void SetUseCorrectFormula(bool use_correct_formula)
95 this->GetFunctor().use_correct_formula=use_correct_formula;
100 BinaryGuerreroFilter() {}
101 virtual ~BinaryGuerreroFilter() {}
104 BinaryGuerreroFilter(const Self&); //purposely not implemented
105 void operator=(const Self&); //purposely not implemented
109 } // end namespace itk