OTB  9.0.0
Orfeo Toolbox
otbWaveletFilterBank.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  * Copyright (C) 2007-2012 Institut Mines Telecom / Telecom Bretagne
4  *
5  * This file is part of Orfeo Toolbox
6  *
7  * https://www.orfeo-toolbox.org/
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 
23 #ifndef otbWaveletFilterBank_h
24 #define otbWaveletFilterBank_h
25 
26 #include "itkProgressReporter.h"
27 #include "itkImageToImageFilter.h"
28 #include "itkConstNeighborhoodIterator.h"
29 #include "itkImageRegionIterator.h"
30 #include "itkNeighborhoodAlgorithm.h"
31 #include "itkNeighborhoodInnerProduct.h"
32 
33 #include "otbWaveletOperatorBase.h"
34 
35 namespace otb
36 {
37 
86 template <class TInputImage, class TOutputImage, class TWaveletOperator, Wavelet::WaveletDirection TDirectionOfTransformation>
87 class ITK_EXPORT WaveletFilterBank : public itk::ImageToImageFilter<TInputImage, TOutputImage>
88 {
89 public:
92  typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
93  typedef itk::SmartPointer<Self> Pointer;
94  typedef itk::SmartPointer<const Self> ConstPointer;
95 
97  itkNewMacro(Self);
98 
100  itkTypeMacro(WaveletFilterBank, ImageToImageFilter);
101 
102 protected:
104  virtual ~WaveletFilterBank();
105 
106 private:
107  WaveletFilterBank(const Self&);
108  void operator=(const Self&);
109 }; // end of class
110 
154 template <class TInputImage, class TOutputImage, class TWaveletOperator>
155 class ITK_EXPORT WaveletFilterBank<TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD> : public itk::ImageToImageFilter<TInputImage, TOutputImage>
156 {
157 public:
160  typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
161  typedef itk::SmartPointer<Self> Pointer;
162  typedef itk::SmartPointer<const Self> ConstPointer;
163 
165  itkNewMacro(Self);
166 
168  itkTypeMacro(WaveletFilterBank, ImageToImageFilter);
169 
171  typedef TInputImage InputImageType;
172  typedef typename InputImageType::Pointer InputImagePointerType;
173  typedef typename InputImageType::RegionType InputImageRegionType;
174  typedef typename InputImageType::SizeType InputSizeType;
175  typedef typename InputImageType::IndexType InputIndexType;
176  typedef typename InputImageType::PixelType InputPixelType;
177 
178  typedef TOutputImage OutputImageType;
179  typedef typename OutputImageType::Pointer OutputImagePointerType;
180  typedef typename OutputImageType::RegionType OutputImageRegionType;
181  typedef typename OutputImageType::SizeType OutputSizeType;
182  typedef typename OutputImageType::IndexType OutputIndexType;
183  typedef typename OutputImageType::PixelType OutputPixelType;
184 
185  typedef TWaveletOperator WaveletOperatorType;
186  typedef typename WaveletOperatorType::LowPassOperator LowPassOperatorType;
187  typedef typename WaveletOperatorType::HighPassOperator HighPassOperatorType;
188 
190  itkStaticConstMacro(DirectionOfTransformation, DirectionOfTransformationEnumType, Wavelet::FORWARD);
191 
193  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
194  itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
196 
200  itkGetMacro(UpSampleFilterFactor, unsigned int);
201  itkSetMacro(UpSampleFilterFactor, unsigned int);
203 
211  itkGetMacro(SubsampleImageFactor, unsigned int);
212  itkSetMacro(SubsampleImageFactor, unsigned int);
214 
215 protected:
218  {
219  }
220 
225  void GenerateOutputInformation() override;
226 
236  void GenerateInputRequestedRegion() override;
237 
241  void BeforeThreadedGenerateData() override;
242 
247  virtual void AllocateInternalData(const OutputImageRegionType& outputRegion);
248 
252  void AfterThreadedGenerateData() override;
253 
259  void CallCopyOutputRegionToInputRegion(InputImageRegionType& destRegion, const OutputImageRegionType& srcRegion) override;
260  void CallCopyInputRegionToOutputRegion(OutputImageRegionType& destRegion, const InputImageRegionType& srcRegion) override;
262 
267  virtual void CallCopyOutputRegionToInputRegion(unsigned int direction, InputImageRegionType& destRegion, const OutputImageRegionType& srcRegion);
268  virtual void CallCopyInputRegionToOutputRegion(unsigned int direction, OutputImageRegionType& destRegion, const InputImageRegionType& srcRegion);
270 
272  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
273 
275  virtual void ThreadedGenerateDataAtDimensionN(unsigned int idx, unsigned int direction, itk::ProgressReporter& reporter,
276  const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId);
277 
278 private:
279  WaveletFilterBank(const Self&);
280  void operator=(const Self&);
281 
284 
290  typedef std::vector<OutputImagePointerType> InternalImagesTabular;
291  std::vector<InternalImagesTabular> m_InternalImages;
292 }; // end of class
293 
337 template <class TInputImage, class TOutputImage, class TWaveletOperator>
338 class ITK_EXPORT WaveletFilterBank<TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE> : public itk::ImageToImageFilter<TInputImage, TOutputImage>
339 {
340 public:
343  typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
344  typedef itk::SmartPointer<Self> Pointer;
345  typedef itk::SmartPointer<const Self> ConstPointer;
346 
348  itkNewMacro(Self);
349 
351  itkTypeMacro(WaveletFilterBank, ImageToImageFilter);
352 
354  typedef TInputImage InputImageType;
355  typedef typename InputImageType::Pointer InputImagePointerType;
356  typedef typename InputImageType::RegionType InputImageRegionType;
357  typedef typename InputImageType::SizeType InputSizeType;
358  typedef typename InputImageType::IndexType InputIndexType;
359  typedef typename InputImageType::PixelType InputPixelType;
360 
361  typedef TOutputImage OutputImageType;
362  typedef typename OutputImageType::Pointer OutputImagePointerType;
363  typedef typename OutputImageType::RegionType OutputImageRegionType;
364  typedef typename OutputImageType::SizeType OutputSizeType;
365  typedef typename OutputImageType::IndexType OutputIndexType;
366  typedef typename OutputImageType::PixelType OutputPixelType;
367 
368  typedef TWaveletOperator WaveletOperatorType;
369  typedef typename WaveletOperatorType::LowPassOperator LowPassOperatorType;
370  typedef typename WaveletOperatorType::HighPassOperator HighPassOperatorType;
371 
373  itkStaticConstMacro(DirectionOfTransformation, DirectionOfTransformationEnumType, Wavelet::INVERSE);
374 
376  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
377  itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
379 
383  itkGetMacro(UpSampleFilterFactor, unsigned int);
384  itkSetMacro(UpSampleFilterFactor, unsigned int);
386 
394  itkGetMacro(SubsampleImageFactor, unsigned int);
395  itkSetMacro(SubsampleImageFactor, unsigned int);
397 
398 protected:
401  {
402  }
403 
404  void VerifyInputInformation() override
405  {
406  }
407 
412  void GenerateOutputInformation() override;
413 
423  void GenerateInputRequestedRegion() override;
424 
428  void BeforeThreadedGenerateData() override;
429 
434  virtual void AllocateInternalData(const OutputImageRegionType& outputRegion);
435 
439  void AfterThreadedGenerateData() override;
440 
446  void CallCopyOutputRegionToInputRegion(InputImageRegionType& destRegion, const OutputImageRegionType& srcRegion) override;
447  void CallCopyInputRegionToOutputRegion(OutputImageRegionType& destRegion, const InputImageRegionType& srcRegion) override;
449 
454  virtual void CallCopyOutputRegionToInputRegion(unsigned int direction, InputImageRegionType& destRegion, const OutputImageRegionType& srcRegion);
455  virtual void CallCopyInputRegionToOutputRegion(unsigned int direction, OutputImageRegionType& destRegion, const InputImageRegionType& srcRegion);
457 
459  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
460 
465  virtual void ThreadedGenerateDataAtDimensionN(unsigned int direction, itk::ProgressReporter& reporter, const OutputImageRegionType& outputRegionForThread,
466  itk::ThreadIdType threadId);
467 
468 private:
469  WaveletFilterBank(const Self&);
470  void operator=(const Self&);
471 
474 
480  typedef std::vector<OutputImagePointerType> InternalImagesTabular;
481  std::vector<InternalImagesTabular> m_InternalImages;
482 
483 }; // end of class
484 
485 } // end of namespace otb
486 
487 #ifndef OTB_MANUAL_INSTANTIATION
488 #include "otbWaveletFilterBank.hxx"
489 #endif
490 
491 #endif
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::OutputSizeType
OutputImageType::SizeType OutputSizeType
Definition: otbWaveletFilterBank.h:181
otb::Wavelet::INVERSE
@ INVERSE
Definition: otbWaveletOperatorBase.h:39
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::~WaveletFilterBank
~WaveletFilterBank() override
Definition: otbWaveletFilterBank.h:217
otbWaveletOperatorBase.h
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::InputPixelType
InputImageType::PixelType InputPixelType
Definition: otbWaveletFilterBank.h:359
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::m_SubsampleImageFactor
unsigned int m_SubsampleImageFactor
Definition: otbWaveletFilterBank.h:283
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::OutputImagePointerType
OutputImageType::Pointer OutputImagePointerType
Definition: otbWaveletFilterBank.h:362
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::m_SubsampleImageFactor
unsigned int m_SubsampleImageFactor
Definition: otbWaveletFilterBank.h:473
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::WaveletOperatorType
TWaveletOperator WaveletOperatorType
Definition: otbWaveletFilterBank.h:185
otb::Wavelet::Wavelet
Wavelet
Definition: otbWaveletGenerator.h:35
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::Self
WaveletFilterBank Self
Definition: otbWaveletFilterBank.h:159
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbWaveletFilterBank.h:161
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::OutputImageType
TOutputImage OutputImageType
Definition: otbWaveletFilterBank.h:178
otb::WaveletFilterBank::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbWaveletFilterBank.h:94
otb::WaveletFilterBank::Superclass
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
Definition: otbWaveletFilterBank.h:92
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::LowPassOperatorType
WaveletOperatorType::LowPassOperator LowPassOperatorType
Definition: otbWaveletFilterBank.h:369
otb::WaveletFilterBank::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbWaveletFilterBank.h:93
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::m_InternalImages
std::vector< InternalImagesTabular > m_InternalImages
Definition: otbWaveletFilterBank.h:291
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::Self
WaveletFilterBank Self
Definition: otbWaveletFilterBank.h:342
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::InternalImagesTabular
std::vector< OutputImagePointerType > InternalImagesTabular
Definition: otbWaveletFilterBank.h:480
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::OutputImageType
TOutputImage OutputImageType
Definition: otbWaveletFilterBank.h:361
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::DirectionOfTransformationEnumType
Wavelet::WaveletDirection DirectionOfTransformationEnumType
Definition: otbWaveletFilterBank.h:372
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::Superclass
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
Definition: otbWaveletFilterBank.h:343
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::DirectionOfTransformationEnumType
Wavelet::WaveletDirection DirectionOfTransformationEnumType
Definition: otbWaveletFilterBank.h:189
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::InputSizeType
InputImageType::SizeType InputSizeType
Definition: otbWaveletFilterBank.h:174
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::~WaveletFilterBank
~WaveletFilterBank() override
Definition: otbWaveletFilterBank.h:400
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
Definition: otbWaveletFilterBank.h:363
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::InputImagePointerType
InputImageType::Pointer InputImagePointerType
Definition: otbWaveletFilterBank.h:355
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::m_InternalImages
std::vector< InternalImagesTabular > m_InternalImages
Definition: otbWaveletFilterBank.h:481
otbWaveletFilterBank.hxx
otb::Wavelet::WaveletDirection
WaveletDirection
Definition: otbWaveletOperatorBase.h:36
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::OutputImagePointerType
OutputImageType::Pointer OutputImagePointerType
Definition: otbWaveletFilterBank.h:179
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::InputPixelType
InputImageType::PixelType InputPixelType
Definition: otbWaveletFilterBank.h:176
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::InputIndexType
InputImageType::IndexType InputIndexType
Definition: otbWaveletFilterBank.h:175
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::WaveletOperatorType
TWaveletOperator WaveletOperatorType
Definition: otbWaveletFilterBank.h:368
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::m_UpSampleFilterFactor
unsigned int m_UpSampleFilterFactor
Definition: otbWaveletFilterBank.h:472
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
Definition: otbWaveletFilterBank.h:180
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::OutputSizeType
OutputImageType::SizeType OutputSizeType
Definition: otbWaveletFilterBank.h:364
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::InputIndexType
InputImageType::IndexType InputIndexType
Definition: otbWaveletFilterBank.h:358
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::Superclass
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
Definition: otbWaveletFilterBank.h:160
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::HighPassOperatorType
WaveletOperatorType::HighPassOperator HighPassOperatorType
Definition: otbWaveletFilterBank.h:370
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::VerifyInputInformation
void VerifyInputInformation() override
Definition: otbWaveletFilterBank.h:404
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbWaveletFilterBank.h:345
otb::Wavelet::FORWARD
@ FORWARD
Definition: otbWaveletOperatorBase.h:38
otb::WaveletFilterBank
One level stationary wavelet transform.
Definition: otbWaveletFilterBank.h:87
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbWaveletFilterBank.h:344
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::InternalImagesTabular
std::vector< OutputImagePointerType > InternalImagesTabular
Definition: otbWaveletFilterBank.h:290
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::m_UpSampleFilterFactor
unsigned int m_UpSampleFilterFactor
Definition: otbWaveletFilterBank.h:282
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::InputSizeType
InputImageType::SizeType InputSizeType
Definition: otbWaveletFilterBank.h:357
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::OutputIndexType
OutputImageType::IndexType OutputIndexType
Definition: otbWaveletFilterBank.h:365
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::InputImageType
TInputImage InputImageType
Definition: otbWaveletFilterBank.h:351
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbWaveletFilterBank.h:162
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::OutputPixelType
OutputImageType::PixelType OutputPixelType
Definition: otbWaveletFilterBank.h:366
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::InputImageType
TInputImage InputImageType
Definition: otbWaveletFilterBank.h:168
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::OutputPixelType
OutputImageType::PixelType OutputPixelType
Definition: otbWaveletFilterBank.h:183
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::LowPassOperatorType
WaveletOperatorType::LowPassOperator LowPassOperatorType
Definition: otbWaveletFilterBank.h:186
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::InputImageRegionType
InputImageType::RegionType InputImageRegionType
Definition: otbWaveletFilterBank.h:173
otb::WaveletFilterBank::Self
WaveletFilterBank Self
Definition: otbWaveletFilterBank.h:91
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::HighPassOperatorType
WaveletOperatorType::HighPassOperator HighPassOperatorType
Definition: otbWaveletFilterBank.h:187
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::OutputIndexType
OutputImageType::IndexType OutputIndexType
Definition: otbWaveletFilterBank.h:182
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE >::InputImageRegionType
InputImageType::RegionType InputImageRegionType
Definition: otbWaveletFilterBank.h:356
otb::WaveletFilterBank< TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD >::InputImagePointerType
InputImageType::Pointer InputImagePointerType
Definition: otbWaveletFilterBank.h:172