23 #ifndef otbSubsampleImageFilter_hxx
24 #define otbSubsampleImageFilter_hxx
29 #include "itkImageRegionIterator.h"
30 #include "itkProgressReporter.h"
35 template <
class TInputImage,
class TOutputImage, Wavelet::WaveletDirection TDirectionOfTransformation>
38 Superclass::PrintSelf(os, indent);
39 os << indent <<
"SubsampleFactor = [" << m_SubsampleFactor[0];
40 for (
unsigned int i = 1; i < InputImageDimension; ++i)
42 os <<
", " << m_SubsampleFactor[i];
47 template <
class TInputImage,
class TOutputImage, Wavelet::WaveletDirection TDirectionOfTransformation>
50 for (
unsigned int i = 0; i < InputImageDimension; ++i)
52 if (m_SubsampleFactor[i] != 1)
59 template <
class TInputImage,
class TOutputImage, Wavelet::WaveletDirection TDirectionOfTransformation>
62 Superclass::GenerateOutputInformation();
64 if (!IsSubsampleFactorOne())
67 this->CallCopyInputRegionToOutputRegion(newRegion, this->GetInput()->GetLargestPossibleRegion());
68 this->GetOutput()->SetRegions(newRegion);
72 template <
class TInputImage,
class TOutputImage, Wavelet::WaveletDirection TDirectionOfTransformation>
76 Superclass::CallCopyOutputRegionToInputRegion(destRegion, srcRegion);
80 typename OutputImageRegionType::IndexType srcIndex = srcRegion.GetIndex();
81 typename OutputImageRegionType::SizeType srcSize = srcRegion.GetSize();
83 typename InputImageRegionType::IndexType destIndex;
84 typename InputImageRegionType::SizeType destSize;
86 for (
unsigned int i = 0; i < InputImageDimension; ++i)
89 destIndex[i] = srcIndex[i] / m_SubsampleFactor[i];
90 destSize[i] = srcSize[i] / m_SubsampleFactor[i];
93 destRegion.SetIndex(destIndex);
94 destRegion.SetSize(destSize);
98 template <
class TInputImage,
class TOutputImage, Wavelet::WaveletDirection TDirectionOfTransformation>
102 Superclass::CallCopyInputRegionToOutputRegion(destRegion, srcRegion);
106 typename InputImageRegionType::IndexType srcIndex = srcRegion.GetIndex();
107 typename InputImageRegionType::SizeType srcSize = srcRegion.GetSize();
109 typename OutputImageRegionType::IndexType destIndex;
110 typename OutputImageRegionType::SizeType destSize;
112 for (
unsigned int i = 0; i < InputImageDimension; ++i)
114 destIndex[i] = srcIndex[i] * m_SubsampleFactor[i];
115 destSize[i] = srcSize[i] * m_SubsampleFactor[i];
118 destRegion.SetIndex(destIndex);
119 destRegion.SetSize(destSize);
123 template <
class TInputImage,
class TOutputImage, Wavelet::WaveletDirection TDirectionOfTransformation>
127 output->FillBuffer(0);
130 template <
class TInputImage,
class TOutputImage, Wavelet::WaveletDirection TDirectionOfTransformation>
132 itk::ThreadIdType itkNotUsed(threadId))
141 this->CallCopyOutputRegionToInputRegion(inputRegionForThread, outputRegionForThread);
166 for (
unsigned int i = 0; i < OutputImageDimension; ++i)
168 outputIndex[i] = inputIndex[i] * m_SubsampleFactor[i];