21 #ifndef otbGaussianAdditiveNoiseSampleListFilter_hxx
22 #define otbGaussianAdditiveNoiseSampleListFilter_hxx
25 #include "itkMersenneTwisterRandomVariateGenerator.h"
26 #include "itkProgressReporter.h"
33 template <
class TInputSampleList,
class TOutputSampleList>
38 m_NumberOfIteration = 1;
41 template <
class TInputSampleList,
class TOutputSampleList>
44 typedef itk::Statistics::MersenneTwisterRandomVariateGenerator GeneratorType;
45 GeneratorType::Pointer generator = GeneratorType::GetInstance();
48 m_WhiteGaussianNoiseCoefficients.clear();
51 unsigned int size = this->GetInput()->GetMeasurementVectorSize();
54 itkExceptionMacro(<<
"MeasurementVector size is " << size <<
" , expected non null size ");
57 for (
unsigned int i = 0; i < size; ++i)
59 double ran = generator->GetNormalVariate(m_Mean, m_Variance);
60 m_WhiteGaussianNoiseCoefficients.push_back(ran);
64 template <
class TInputSampleList,
class TOutputSampleList>
72 outputSampleListPtr->Clear();
75 outputSampleListPtr->SetMeasurementVectorSize(inputSampleListPtr->GetMeasurementVectorSize());
78 itk::ProgressReporter progress(
this, 0, inputSampleListPtr->Size() * m_NumberOfIteration);
81 for (
unsigned int currIteration = 0; currIteration < m_NumberOfIteration; currIteration++)
83 typename InputSampleListType::ConstIterator inputIt = inputSampleListPtr->Begin();
86 while (inputIt != inputSampleListPtr->End())
89 this->GenerateRandomSequence();
96 currentOutputMeasurement.SetSize(currentInputMeasurement.GetSize());
99 for (
unsigned int idx = 0; idx < inputSampleListPtr->GetMeasurementVectorSize(); ++idx)
101 currentOutputMeasurement[idx] =
102 static_cast<OutputValueType>((
static_cast<double>(currentInputMeasurement[idx]) + m_WhiteGaussianNoiseCoefficients[idx]));
106 outputSampleListPtr->PushBack(currentOutputMeasurement);
109 progress.CompletedPixel();
116 template <
class TInputSampleList,
class TOutputSampleList>
120 Superclass::PrintSelf(os, indent);