21 #ifndef otbShiftScaleSampleListFilter_hxx
22 #define otbShiftScaleSampleListFilter_hxx
25 #include "itkProgressReporter.h"
32 template <
class TInputSampleList,
class TOutputSampleList>
37 template <
class TInputSampleList,
class TOutputSampleList>
44 outputSampleListPtr->SetMeasurementVectorSize(inputSampleListPtr->GetMeasurementVectorSize());
47 if (inputSampleListPtr->Size() == 0)
48 itkExceptionMacro(<<
"Input Sample List is empty");
52 if (inputSampleListPtr->GetMeasurementVectorSize() != m_Scales.Size() || inputSampleListPtr->GetMeasurementVectorSize() != m_Shifts.Size())
53 itkExceptionMacro(<<
"Inconsistent measurement vector size : Input Sample List size " << inputSampleListPtr->GetMeasurementVectorSize()
54 <<
" Scale measurement vector size " << m_Scales.Size() <<
" Shift measurement vector size " << m_Shifts.Size());
58 for (
unsigned int idx = 0; idx < invertedScales.Size(); ++idx)
60 if (m_Scales[idx] - 1e-10 < 0.)
61 invertedScales[idx] = 0.;
63 invertedScales[idx] = 1 / m_Scales[idx];
67 outputSampleListPtr->Clear();
69 typename InputSampleListType::ConstIterator inputIt = inputSampleListPtr->Begin();
72 itk::ProgressReporter progress(
this, 0, inputSampleListPtr->Size());
75 while (inputIt != inputSampleListPtr->End())
82 currentOutputMeasurement.SetSize(currentInputMeasurement.GetSize());
85 for (
unsigned int idx = 0; idx < invertedScales.Size(); ++idx)
87 currentOutputMeasurement[idx] =
static_cast<OutputValueType>((currentInputMeasurement[idx] - m_Shifts[idx]) * invertedScales[idx]);
91 outputSampleListPtr->PushBack(currentOutputMeasurement);
94 progress.CompletedPixel();
100 template <
class TInputSampleList,
class TOutputSampleList>
104 Superclass::PrintSelf(os, indent);