15 #include "itkNaryFunctorImageFilter.h" 16 #include "itkNumericTraits.h" 17 #include "itkDiffusionTensor3D.h" 31 template<
class TInput,
class TOutput >
35 typedef typename NumericTraits< TOutput >::RealType RealType;
38 inline TOutput operator()(
const std::vector< TInput > & B)
40 RealType sum = NumericTraits< TOutput >::Zero;
41 RealType sum_sqr = NumericTraits< TOutput >::Zero;
43 for(
unsigned int i=0; i< B.size(); i++ )
45 sum_sqr += static_cast< TOutput >(B[i]) * static_cast< TOutput >(B[i]);
46 sum += static_cast< TOutput >(B[i]);
48 return static_cast<TOutput>( (sum_sqr - (sum * sum) / B.size() ) /B.size() );
50 bool operator== (
const Variance&)
const 54 bool operator!= (
const Variance&)
const 128 template <
class TInputImage,
class TOutputImage>
131 NaryFunctorImageFilter<TInputImage,TOutputImage,
132 Functor::Variance<typename TInputImage::PixelType, typename TOutputImage::PixelType > >
137 typedef NaryFunctorImageFilter<TInputImage,TOutputImage,
139 typename TInputImage::PixelType > > Superclass;
140 typedef SmartPointer<Self> Pointer;
141 typedef SmartPointer<const Self> ConstPointer;
148 NaryFunctorImageFilter);
150 #ifdef ITK_USE_CONCEPT_CHECKING 152 itkConceptMacro(InputConvertibleToOutputCheck,
153 (Concept::Convertible<
typename TInputImage::PixelType,
154 typename TOutputImage::PixelType>));
155 itkConceptMacro(InputHasZeroCheck,
156 (Concept::HasZero<typename TInputImage::PixelType>));
165 NaryVarianceImageFilter(
const Self&);
166 void operator=(
const Self&);
Helper class for calculating variance of images which interfaces with NaryVarianceImageFilter.
Definition: itkNaryVarianceImageFilter.h:32
Implements an operator for calculating pixel-wise variance of two images.
Definition: itkNaryVarianceImageFilter.h:129
NaryVarianceImageFilter Self
Standard class typedefs.
Definition: itkNaryVarianceImageFilter.h:136