OTB  10.0.0
Orfeo Toolbox
otbWaveletFilterBank.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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  {
105  this->DynamicMultiThreadingOff();
106  }
108 
109 private:
111  void operator=(const Self&);
112 }; // end of class
113 
157 template <class TInputImage, class TOutputImage, class TWaveletOperator>
158 class ITK_EXPORT WaveletFilterBank<TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD> : public itk::ImageToImageFilter<TInputImage, TOutputImage>
159 {
160 public:
163  typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
164  typedef itk::SmartPointer<Self> Pointer;
165  typedef itk::SmartPointer<const Self> ConstPointer;
166 
168  itkNewMacro(Self);
169 
171  itkTypeMacro(WaveletFilterBank, ImageToImageFilter);
172 
174  typedef TInputImage InputImageType;
175  typedef typename InputImageType::Pointer InputImagePointerType;
176  typedef typename InputImageType::RegionType InputImageRegionType;
177  typedef typename InputImageType::SizeType InputSizeType;
178  typedef typename InputImageType::IndexType InputIndexType;
179  typedef typename InputImageType::PixelType InputPixelType;
180 
181  typedef TOutputImage OutputImageType;
182  typedef typename OutputImageType::Pointer OutputImagePointerType;
183  typedef typename OutputImageType::RegionType OutputImageRegionType;
184  typedef typename OutputImageType::SizeType OutputSizeType;
185  typedef typename OutputImageType::IndexType OutputIndexType;
186  typedef typename OutputImageType::PixelType OutputPixelType;
187 
188  typedef TWaveletOperator WaveletOperatorType;
189  typedef typename WaveletOperatorType::LowPassOperator LowPassOperatorType;
190  typedef typename WaveletOperatorType::HighPassOperator HighPassOperatorType;
191 
193  itkStaticConstMacro(DirectionOfTransformation, DirectionOfTransformationEnumType, Wavelet::FORWARD);
194 
196  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
197  itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
199 
203  itkGetMacro(UpSampleFilterFactor, unsigned int);
204  itkSetMacro(UpSampleFilterFactor, unsigned int);
206 
214  itkGetMacro(SubsampleImageFactor, unsigned int);
215  itkSetMacro(SubsampleImageFactor, unsigned int);
217 
218 protected:
221  {
222  }
223 
228  void GenerateOutputInformation() override;
229 
239  void GenerateInputRequestedRegion() override;
240 
244  void BeforeThreadedGenerateData() override;
245 
250  virtual void AllocateInternalData(const OutputImageRegionType& outputRegion);
251 
255  void AfterThreadedGenerateData() override;
256 
262  void CallCopyOutputRegionToInputRegion(InputImageRegionType& destRegion, const OutputImageRegionType& srcRegion) override;
263  void CallCopyInputRegionToOutputRegion(OutputImageRegionType& destRegion, const InputImageRegionType& srcRegion) override;
265 
270  virtual void CallCopyOutputRegionToInputRegion(unsigned int direction, InputImageRegionType& destRegion, const OutputImageRegionType& srcRegion);
271  virtual void CallCopyInputRegionToOutputRegion(unsigned int direction, OutputImageRegionType& destRegion, const InputImageRegionType& srcRegion);
273 
275  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
276 
278  virtual void ThreadedGenerateDataAtDimensionN(unsigned int idx, unsigned int direction, itk::ProgressReporter& reporter,
279  const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId);
280 
281 private:
283  void operator=(const Self&);
284 
287 
293  typedef std::vector<OutputImagePointerType> InternalImagesTabular;
294  std::vector<InternalImagesTabular> m_InternalImages;
295 }; // end of class
296 
340 template <class TInputImage, class TOutputImage, class TWaveletOperator>
341 class ITK_EXPORT WaveletFilterBank<TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE> : public itk::ImageToImageFilter<TInputImage, TOutputImage>
342 {
343 public:
346  typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
347  typedef itk::SmartPointer<Self> Pointer;
348  typedef itk::SmartPointer<const Self> ConstPointer;
349 
351  itkNewMacro(Self);
352 
354  itkTypeMacro(WaveletFilterBank, ImageToImageFilter);
355 
357  typedef TInputImage InputImageType;
358  typedef typename InputImageType::Pointer InputImagePointerType;
359  typedef typename InputImageType::RegionType InputImageRegionType;
360  typedef typename InputImageType::SizeType InputSizeType;
361  typedef typename InputImageType::IndexType InputIndexType;
362  typedef typename InputImageType::PixelType InputPixelType;
363 
364  typedef TOutputImage OutputImageType;
365  typedef typename OutputImageType::Pointer OutputImagePointerType;
366  typedef typename OutputImageType::RegionType OutputImageRegionType;
367  typedef typename OutputImageType::SizeType OutputSizeType;
368  typedef typename OutputImageType::IndexType OutputIndexType;
369  typedef typename OutputImageType::PixelType OutputPixelType;
370 
371  typedef TWaveletOperator WaveletOperatorType;
372  typedef typename WaveletOperatorType::LowPassOperator LowPassOperatorType;
373  typedef typename WaveletOperatorType::HighPassOperator HighPassOperatorType;
374 
376  itkStaticConstMacro(DirectionOfTransformation, DirectionOfTransformationEnumType, Wavelet::INVERSE);
377 
379  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
380  itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
382 
386  itkGetMacro(UpSampleFilterFactor, unsigned int);
387  itkSetMacro(UpSampleFilterFactor, unsigned int);
389 
397  itkGetMacro(SubsampleImageFactor, unsigned int);
398  itkSetMacro(SubsampleImageFactor, unsigned int);
400 
401 protected:
404  {
405  }
406 
407  void VerifyInputInformation() const override
408  {
409  }
410 
415  void GenerateOutputInformation() override;
416 
426  void GenerateInputRequestedRegion() override;
427 
431  void BeforeThreadedGenerateData() override;
432 
437  virtual void AllocateInternalData(const OutputImageRegionType& outputRegion);
438 
442  void AfterThreadedGenerateData() override;
443 
449  void CallCopyOutputRegionToInputRegion(InputImageRegionType& destRegion, const OutputImageRegionType& srcRegion) override;
450  void CallCopyInputRegionToOutputRegion(OutputImageRegionType& destRegion, const InputImageRegionType& srcRegion) override;
452 
457  virtual void CallCopyOutputRegionToInputRegion(unsigned int direction, InputImageRegionType& destRegion, const OutputImageRegionType& srcRegion);
458  virtual void CallCopyInputRegionToOutputRegion(unsigned int direction, OutputImageRegionType& destRegion, const InputImageRegionType& srcRegion);
460 
462  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
463 
468  virtual void ThreadedGenerateDataAtDimensionN(unsigned int direction, itk::ProgressReporter& reporter, const OutputImageRegionType& outputRegionForThread,
469  itk::ThreadIdType threadId);
470 
471 private:
473  void operator=(const Self&);
474 
477 
483  typedef std::vector<OutputImagePointerType> InternalImagesTabular;
484  std::vector<InternalImagesTabular> m_InternalImages;
485 
486 }; // end of class
487 
488 } // end of namespace otb
489 
490 #ifndef OTB_MANUAL_INSTANTIATION
491 #include "otbWaveletFilterBank.hxx"
492 #endif
493 
494 #endif
One level stationary wavelet transform.
itk::SmartPointer< const Self > ConstPointer
virtual ~WaveletFilterBank()
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
void operator=(const Self &)
itk::SmartPointer< Self > Pointer
WaveletFilterBank(const Self &)
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.