1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #ifndef __itkBinaryGuerreroFilter_h
19 #define __itkBinaryGuerreroFilter_h
20 #include "itkBinaryFunctorImageFilter.h"
21 #include "itkNumericTraits.h"
28 /** \class BinaryGuerreroFilter
30 * The images to be added are set using the methods:
31 * SetInput1( image1 );
32 * SetInput2( image2 );
34 * \warning No numeric overflow checking is performed in this filter.
36 * \ingroup IntensityImageFilters Multithreaded
40 template< class TInput1, class TInput2=TInput1, class TOutput=TInput1>
44 GuerreroFunctor() : use_correct_formula(false)
46 ~GuerreroFunctor() {};
47 bool operator!=( const GuerreroFunctor & ) const
51 bool operator==( const GuerreroFunctor & other ) const
53 return !(*this != other);
55 inline TOutput operator() ( const TInput1 & A, const TInput2 & B) const
57 //A is the reference image
58 TInput2 Bstar = B - 1000.*blood_mass_factor*(1+B/1000.);
60 if (use_correct_formula)
61 vol_change=static_cast<TOutput>( (A-Bstar) / (1000.+Bstar) );
62 else //Use the original formula as described in Guerrero's paper
63 vol_change=static_cast<TOutput>( 1000. * (Bstar-A) / (A*(1000.+Bstar)) );
65 if (IsNormal(vol_change))
70 double blood_mass_factor;
71 bool use_correct_formula;
76 //==========================================================================
77 template <class TInputImage1, class TInputImage2=TInputImage1, class TOutputImage=TInputImage1>
78 class ITK_EXPORT BinaryGuerreroFilter :
80 BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
81 Functor::GuerreroFunctor<
82 typename TInputImage1::PixelType,
83 typename TInputImage2::PixelType,
84 typename TOutputImage::PixelType> >
89 /** Standard class typedefs. */
90 typedef BinaryGuerreroFilter Self;
91 typedef BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
92 Functor::GuerreroFunctor<
93 typename TInputImage1::PixelType,
94 typename TInputImage2::PixelType,
95 typename TOutputImage::PixelType> > Superclass;
97 typedef SmartPointer<Self> Pointer;
98 typedef SmartPointer<const Self> ConstPointer;
100 /** Method for creation through the object factory. */
103 /** Runtime information support. */
104 itkTypeMacro(BinaryGuerreroFilter,
105 BinaryFunctorImageFilter);
106 void SetBloodCorrectionFactor(double f)
108 this->GetFunctor().blood_mass_factor=f;
110 void SetUseCorrectFormula(bool use_correct_formula)
112 this->GetFunctor().use_correct_formula=use_correct_formula;
117 BinaryGuerreroFilter() {}
118 virtual ~BinaryGuerreroFilter() {}
121 BinaryGuerreroFilter(const Self&); //purposely not implemented
122 void operator=(const Self&); //purposely not implemented
126 } // end namespace itk