21 #ifndef otbNormalizeVectorImageFilter_hxx
22 #define otbNormalizeVectorImageFilter_hxx
28 template <
class TInputImage,
class TOutputImage>
31 m_IsGivenMean =
false;
32 m_IsGivenStdDev =
false;
37 m_CovarianceEstimator = CovarianceEstimatorFilterType::New();
41 template <
class TInputImage,
class TOutputImage>
45 Superclass::GenerateOutputInformation();
47 if ((m_UseMean && !m_IsGivenMean) || (m_UseStdDev && !m_IsGivenStdDev))
49 m_CovarianceEstimator->SetInput(
const_cast<InputImageType*
>(this->GetInput()));
50 m_CovarianceEstimator->Update();
55 typename TInputImage::PixelType vector(this->GetInput()->GetNumberOfComponentsPerPixel());
56 vector.Fill(itk::NumericTraits<typename TInputImage::PixelType::ValueType>::Zero);
57 this->GetFunctor().SetMean(vector);
62 typename TInputImage::PixelType vector(this->GetInput()->GetNumberOfComponentsPerPixel());
63 vector.Fill(itk::NumericTraits<typename TInputImage::PixelType::ValueType>::One);
64 this->GetFunctor().SetStdDev(vector);
69 this->GetFunctor().SetMean(m_CovarianceEstimator->GetMean());
71 if (!m_IsGivenStdDev && m_UseStdDev)
74 for (
unsigned int i = 0; i < sigma.Size(); ++i)
75 sigma[i] = std::sqrt(m_CovarianceEstimator->GetCovariance()(i, i));
77 this->GetFunctor().SetStdDev(sigma);
84 #endif // otbNormalizeVectorImageFilter_hxx