21 #ifndef otbNormalizeVectorImageFilter_h
22 #define otbNormalizeVectorImageFilter_h
24 #include <vnl/vnl_math.h>
39 template <
class TInput,
class TOutput>
51 typedef typename itk::NumericTraits<typename RealVectorType::ValueType>::RealType
RealType;
55 unsigned int length = input.Size();
56 TOutput output(length);
57 for (
unsigned int i = 0; i < length; ++i)
59 output[i] =
static_cast<typename TOutput::ValueType
>((
static_cast<RealType>(input[i]) -
m_Mean[i]) /
m_StdDev[i]);
65 void SetMean(
const itk::VariableLengthVector<T>& m)
68 for (
unsigned int i = 0; i <
m_Mean.Size(); ++i)
78 void SetStdDev(
const itk::VariableLengthVector<T>& sigma)
81 for (
unsigned int i = 0; i <
m_StdDev.Size(); ++i)
84 if (
m_StdDev[i] == itk::NumericTraits<RealType>::Zero)
86 throw itk::ExceptionObject(__FILE__, __LINE__,
"Cannot divide by zero !", ITK_LOCATION);
95 for (
unsigned int i = 0; i <
m_StdDev.Size(); ++i)
98 if (
m_StdDev[i] == itk::NumericTraits<RealType>::Zero)
100 throw itk::ExceptionObject(__FILE__, __LINE__,
"Cannot divide by zero !", ITK_LOCATION);
131 template <
class TInputImage,
class TOutputImage>
134 Functor::NormalizeVectorImageFunctor<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
154 typedef typename itk::NumericTraits<typename TInputImage::PixelType>::RealType
RealVectorType;
155 typedef typename itk::NumericTraits<typename RealVectorType::ValueType>::RealType
RealType;
163 void SetMean(
const itk::VariableLengthVector<T>& m)
165 this->GetFunctor().SetMean(m);
166 m_IsGivenMean =
true;
172 void SetStdDev(
const itk::VariableLengthVector<T>& sigma)
174 this->GetFunctor().SetStdDev(sigma);
175 m_IsGivenStdDev =
true;
183 this->GetFunctor().SetVariance(
var);
184 m_IsGivenStdDev =
true;
190 itkSetMacro(UseMean,
bool);
191 itkSetMacro(UseStdDev,
bool);
199 void GenerateOutputInformation()
override;
204 void operator=(
const Self&);
218 #ifndef OTB_MANUAL_INSTANTIATION
222 #endif // otbNormalizeVectorImageFilter_h