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;
218 #ifndef OTB_MANUAL_INSTANTIATION
NormalizeVectorImageFunctor.
TOutput operator()(const TInput &input)
void SetStdDev(const itk::VariableLengthVector< T > &sigma)
itk::NumericTraits< typename RealVectorType::ValueType >::RealType RealType
itk::NumericTraits< TInput >::RealType RealVectorType
virtual ~NormalizeVectorImageFunctor()
void SetMean(const itk::VariableLengthVector< T > &m)
void SetVariance(const itk::VariableLengthVector< T > &var)
RealVectorType GetMean() const
RealVectorType GetStdDev() const
NormalizeVectorImageFunctor()
Normalize an VectorImage by setting its mean to zero and possibly variance to one (band by band).
itk::SmartPointer< Self > Pointer
NormalizeVectorImageFilter Self
~NormalizeVectorImageFilter() override
itk::SmartPointer< const Self > ConstPointer
CovarianceEstimatorFilterPointerType m_CovarianceEstimator
itk::NumericTraits< typename TInputImage::PixelType >::RealType RealVectorType
CovarianceEstimatorFilterType::Pointer CovarianceEstimatorFilterPointerType
UnaryFunctorVectorImageFilter< TInputImage, TOutputImage, Functor::NormalizeVectorImageFunctor< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
void operator=(const Self &)
void SetMean(const itk::VariableLengthVector< T > &m)
void SetVariance(const itk::VariableLengthVector< T > &var)
itk::NumericTraits< typename RealVectorType::ValueType >::RealType RealType
TInputImage InputImageType
StreamingStatisticsVectorImageFilter< InputImageType > CovarianceEstimatorFilterType
NormalizeVectorImageFilter(const Self &)
TOutputImage OutputImageType
void SetStdDev(const itk::VariableLengthVector< T > &sigma)
This class streams the whole input image through the PersistentStatisticsImageFilter.
itk::SmartPointer< Self > Pointer
Implements neighborhood-wise generic operation of one vector image.
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.