21 #ifndef otbWaveletsBandsListToWaveletsSynopsisImageFilter_hxx
22 #define otbWaveletsBandsListToWaveletsSynopsisImageFilter_hxx
25 #include "itkImageRegionIterator.h"
26 #include "itkImageRegionConstIterator.h"
31 template <
class TImageList,
class TImage>
37 template <
class TImageList,
class TImage>
38 WaveletsBandsListToWaveletsSynopsisImageFilter<TImageList, TImage>::~WaveletsBandsListToWaveletsSynopsisImageFilter()
45 template <
class TImageList,
class TImage>
46 void WaveletsBandsListToWaveletsSynopsisImageFilter<TImageList, TImage>::GenerateOutputInformation(
void)
50 if (this->GetOutput())
52 if (this->GetInput()->Size() > 0)
55 typename InputImageType::Pointer lastBand = this->GetInput()->Back();
58 RegionType largestBandRegion = lastBand->GetLargestPossibleRegion();
61 typename RegionType::SizeType outputSize = largestBandRegion.GetSize();
64 outputSize[0] *= m_DecimationRatio;
65 outputSize[1] *= m_DecimationRatio;
68 RegionType outputLargestRegion;
69 outputLargestRegion.SetSize(outputSize);
72 this->GetOutput()->CopyInformation(lastBand);
73 this->GetOutput()->SetLargestPossibleRegion(outputLargestRegion);
80 template <
class TImageList,
class TImage>
81 void WaveletsBandsListToWaveletsSynopsisImageFilter<TImageList, TImage>::GenerateInputRequestedRegion(
void)
83 typename InputImageListType::Pointer inputPtr = this->GetInput();
84 typename InputImageListType::ConstIterator inputListIt = inputPtr->Begin();
85 while (inputListIt != inputPtr->End())
87 inputListIt.Get()->SetRequestedRegionToLargestPossibleRegion();
96 template <
class TImageList,
class TImage>
97 void WaveletsBandsListToWaveletsSynopsisImageFilter<TImageList, TImage>::DynamicThreadedGenerateData(
const RegionType& outputRegionForThread)
100 typename InputImageListType::Pointer inputPtr = this->GetInput();
101 typename OutputImageType::Pointer outputPtr = this->GetOutput();
105 typedef itk::ImageRegionConstIterator<InputImageType> InputIteratorType;
106 typedef itk::ImageRegionIterator<OutputImageType> OutputIteratorType;
109 typename InputImageListType::ConstIterator inputListIt = inputPtr->Begin();
110 unsigned int bandIndex = 0;
113 unsigned int numberOfDecompositionLevels = (inputPtr->Size() - 1) / 3;
116 typename RegionType::SizeType largestSize = outputPtr->GetLargestPossibleRegion().GetSize();
119 for (; inputListIt != inputPtr->End(); ++inputListIt, ++bandIndex)
122 typename RegionType::OffsetType currentOffset;
123 currentOffset.Fill(0);
126 unsigned int currentLevel = 0;
127 unsigned int currentSubBand = 0;
132 currentLevel = 1 + (bandIndex - 1) / 3;
133 currentSubBand = (bandIndex - 1) % 3;
136 unsigned int offsetX = largestSize[0] / (
unsigned int)std::pow((
double)m_DecimationRatio, (double)1 + numberOfDecompositionLevels - currentLevel);
137 unsigned int offsetY = largestSize[1] / (
unsigned int)std::pow((
double)m_DecimationRatio, (double)1 + numberOfDecompositionLevels - currentLevel);
140 if (currentSubBand == 0)
142 currentOffset[0] += offsetX;
144 else if (currentSubBand == 1)
146 currentOffset[1] += offsetY;
150 currentOffset[0] += offsetX;
151 currentOffset[1] += offsetY;
155 RegionType currentBandRegion = inputListIt.Get()->GetLargestPossibleRegion();
158 RegionType currentOutputRegion = currentBandRegion;
159 typename RegionType::IndexType currentOutputIndex = currentBandRegion.GetIndex();
160 currentOutputIndex += currentOffset;
161 currentOutputRegion.SetIndex(currentOutputIndex);
166 if (currentOutputRegion.Crop(outputRegionForThread))
169 RegionType currentInputRegion = currentBandRegion;
170 currentOutputIndex = currentOutputRegion.GetIndex();
171 typename RegionType::IndexType currentInputIndex = currentBandRegion.GetIndex();
173 for (
unsigned int i = 0; i < InputImageType::ImageDimension; ++i)
175 currentInputIndex[i] += currentOutputIndex[i];
176 currentInputIndex[i] -= currentOffset[i];
178 currentInputRegion.SetSize(currentOutputRegion.GetSize());
179 currentInputRegion.SetIndex(currentInputIndex);
181 InputIteratorType inIt(inputListIt.Get(), currentInputRegion);
182 OutputIteratorType outIt(outputPtr, currentOutputRegion);
189 while (!inIt.IsAtEnd() && !outIt.IsAtEnd())
192 outIt.Set(
static_cast<typename OutputImageType::InternalPixelType
>(inIt.Get()));
WaveletsBandsListToWaveletsSynopsisImageFilter()
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.