1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
6 Copyright (c) Insight Software Consortium. All rights reserved.
7 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
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 above copyright notices for more information.
13 =========================================================================*/
14 #ifndef __itkBinaryGuerreroFilter_h
15 #define __itkBinaryGuerreroFilter_h
17 #include "itkBinaryFunctorImageFilter.h"
18 #include "itkNumericTraits.h"
25 /** \class BinaryGuerreroFilter
27 * The images to be added are set using the methods:
28 * SetInput1( image1 );
29 * SetInput2( image2 );
31 * \warning No numeric overflow checking is performed in this filter.
33 * \ingroup IntensityImageFilters Multithreaded
37 template< class TInput1, class TInput2=TInput1, class TOutput=TInput1>
41 GuerreroFunctor() : use_correct_formula(false)
43 ~GuerreroFunctor() {};
44 bool operator!=( const GuerreroFunctor & ) const
48 bool operator==( const GuerreroFunctor & other ) const
50 return !(*this != other);
52 inline TOutput operator() ( const TInput1 & A, const TInput2 & B) const
54 //A is the reference image
55 TInput2 Bstar = B - 1000.*blood_mass_factor*(1+B/1000.);
57 if (use_correct_formula)
58 vol_change=static_cast<TOutput>( (A-Bstar) / (1000.+Bstar) );
59 else //Use the original formula as described in Guerrero's paper
60 vol_change=static_cast<TOutput>( 1000. * (Bstar-A) / (A*(1000.+Bstar)) );
62 if (std::isnormal(vol_change))
67 double blood_mass_factor;
68 bool use_correct_formula;
73 //==========================================================================
74 template <class TInputImage1, class TInputImage2=TInputImage1, class TOutputImage=TInputImage1>
75 class ITK_EXPORT BinaryGuerreroFilter :
77 BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
78 Functor::GuerreroFunctor<
79 typename TInputImage1::PixelType,
80 typename TInputImage2::PixelType,
81 typename TOutputImage::PixelType> >
86 /** Standard class typedefs. */
87 typedef BinaryGuerreroFilter Self;
88 typedef BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
89 Functor::GuerreroFunctor<
90 typename TInputImage1::PixelType,
91 typename TInputImage2::PixelType,
92 typename TOutputImage::PixelType> > Superclass;
94 typedef SmartPointer<Self> Pointer;
95 typedef SmartPointer<const Self> ConstPointer;
97 /** Method for creation through the object factory. */
100 /** Runtime information support. */
101 itkTypeMacro(BinaryGuerreroFilter,
102 BinaryFunctorImageFilter);
103 void SetBloodCorrectionFactor(double f)
105 this->GetFunctor().blood_mass_factor=f;
107 void SetUseCorrectFormula(bool use_correct_formula)
109 this->GetFunctor().use_correct_formula=use_correct_formula;
114 BinaryGuerreroFilter() {}
115 virtual ~BinaryGuerreroFilter() {}
118 BinaryGuerreroFilter(const Self&); //purposely not implemented
119 void operator=(const Self&); //purposely not implemented
123 } // end namespace itk