23 #ifndef otbDecimateImageFilter_hxx
24 #define otbDecimateImageFilter_hxx
30 #include "itkImageRegionIterator.h"
31 #include "itkProgressReporter.h"
36 template <
class TInputImage,
class TOutputImage>
39 Superclass::PrintSelf(os, indent);
40 os << indent <<
"DecimationFactor = " << m_DecimationFactor <<
"\n";
43 template <
class TInputImage,
class TOutputImage>
46 Superclass::GenerateOutputInformation();
48 if (GetDecimationFactor() > 1)
50 this->GetOutput()->CopyInformation(this->GetInput());
53 this->CallCopyInputRegionToOutputRegion(newRegion, this->GetInput()->GetLargestPossibleRegion());
54 this->GetOutput()->SetRegions(newRegion);
56 for (
unsigned int i = 0; i < OutputImageDimension; ++i)
63 template <
class TInputImage,
class TOutputImage>
66 Superclass::CallCopyOutputRegionToInputRegion(destRegion, srcRegion);
68 typename OutputImageRegionType::IndexType srcIndex = srcRegion.GetIndex();
69 typename OutputImageRegionType::SizeType srcSize = srcRegion.GetSize();
71 typename InputImageRegionType::IndexType destIndex;
72 typename InputImageRegionType::SizeType destSize;
74 for (
unsigned int i = 0; i < InputImageDimension; ++i)
76 destIndex[i] = srcIndex[i] * GetDecimationFactor();
77 destSize[i] = (srcSize[i] - 1) * GetDecimationFactor() + 1;
80 destRegion.SetIndex(destIndex);
81 destRegion.SetSize(destSize);
84 template <
class TInputImage,
class TOutputImage>
87 Superclass::CallCopyInputRegionToOutputRegion(destRegion, srcRegion);
89 typename InputImageRegionType::IndexType srcIndex = srcRegion.GetIndex();
90 typename InputImageRegionType::SizeType srcSize = srcRegion.GetSize();
92 typename OutputImageRegionType::IndexType destIndex;
93 typename OutputImageRegionType::SizeType destSize;
95 for (
unsigned int i = 0; i < InputImageDimension; ++i)
97 destIndex[i] = srcIndex[i] / GetDecimationFactor();
98 destSize[i] = (srcSize[i] - 1) / GetDecimationFactor() + 1;
101 destRegion.SetIndex(destIndex);
102 destRegion.SetSize(destSize);
105 template <
class TInputImage,
class TOutputImage>
107 itk::ThreadIdType itkNotUsed(threadId))
110 this->CallCopyOutputRegionToInputRegion(inputRegionForThread, outputRegionForThread);
116 itk::ImageRegionIterator<InputImageType> outputIter(this->GetOutput(), outputRegionForThread);
117 outputIter.GoToBegin();
119 while (!decimationIterator.
IsAtEnd() && !outputIter.IsAtEnd())
121 outputIter.Set(
static_cast<OutputPixelType>(decimationIterator.Get()));
124 ++decimationIterator;