OTB  6.7.0
Orfeo Toolbox
otbWaveletFilterBank.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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"
29 #include "itkImageRegionIterator.h"
32 
33 #include "otbWaveletOperatorBase.h"
34 
35 namespace otb {
36 
85 template <class TInputImage, class TOutputImage,
86  class TWaveletOperator,
87  Wavelet::WaveletDirection TDirectionOfTransformation>
88 class ITK_EXPORT WaveletFilterBank
89  : public itk::ImageToImageFilter<TInputImage, TOutputImage>
90 {
91 public:
97 
99  itkNewMacro(Self);
100 
102  itkTypeMacro(WaveletFilterBank, ImageToImageFilter);
103 
104 protected:
106  virtual ~WaveletFilterBank();
107 
108 private:
109  WaveletFilterBank(const Self &);
110  void operator =(const Self&);
111 }; // end of class
112 
156 template <class TInputImage, class TOutputImage, class TWaveletOperator>
157 class ITK_EXPORT WaveletFilterBank<TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD>
158  : public itk::ImageToImageFilter<TInputImage, TOutputImage>
159 {
160 public:
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;
179  typedef typename InputImageType::PixelType InputPixelType;
180 
181  typedef TOutputImage OutputImageType;
182  typedef typename OutputImageType::Pointer OutputImagePointerType;
183  typedef typename OutputImageType::RegionType OutputImageRegionType;
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:
220  ~WaveletFilterBank() override {}
221 
226  void GenerateOutputInformation() override;
227 
237  void GenerateInputRequestedRegion()
238  throw (itk::InvalidRequestedRegionError) override;
239 
243  void BeforeThreadedGenerateData() override;
244 
249  virtual void AllocateInternalData(const OutputImageRegionType& outputRegion);
250 
254  void AfterThreadedGenerateData() override;
255 
261  void CallCopyOutputRegionToInputRegion
262  (InputImageRegionType& destRegion, const OutputImageRegionType& srcRegion) override;
263  void CallCopyInputRegionToOutputRegion
264  (OutputImageRegionType& destRegion, const InputImageRegionType& srcRegion) override;
266 
271  virtual void CallCopyOutputRegionToInputRegion(unsigned int direction,
272  InputImageRegionType& destRegion,
273  const OutputImageRegionType& srcRegion);
274  virtual void CallCopyInputRegionToOutputRegion(unsigned int direction,
275  OutputImageRegionType& destRegion,
276  const InputImageRegionType& srcRegion);
278 
280  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
281 
283  virtual void ThreadedGenerateDataAtDimensionN(unsigned int idx, unsigned int direction,
284  itk::ProgressReporter& reporter,
285  const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId);
286 
287 private:
288  WaveletFilterBank(const Self &);
289  void operator =(const Self&);
290 
291  unsigned int m_UpSampleFilterFactor;
292  unsigned int m_SubsampleImageFactor;
293 
300  std::vector<InternalImagesTabular> m_InternalImages;
301 }; // end of class
302 
346 template <class TInputImage, class TOutputImage, class TWaveletOperator>
347 class ITK_EXPORT WaveletFilterBank<TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE>
348  : public itk::ImageToImageFilter<TInputImage, TOutputImage>
349 {
350 public:
356 
358  itkNewMacro(Self);
359 
361  itkTypeMacro(WaveletFilterBank, ImageToImageFilter);
362 
364  typedef TInputImage InputImageType;
365  typedef typename InputImageType::Pointer InputImagePointerType;
366  typedef typename InputImageType::RegionType InputImageRegionType;
369  typedef typename InputImageType::PixelType InputPixelType;
370 
371  typedef TOutputImage OutputImageType;
372  typedef typename OutputImageType::Pointer OutputImagePointerType;
373  typedef typename OutputImageType::RegionType OutputImageRegionType;
376  typedef typename OutputImageType::PixelType OutputPixelType;
377 
378  typedef TWaveletOperator WaveletOperatorType;
379  typedef typename WaveletOperatorType::LowPassOperator LowPassOperatorType;
380  typedef typename WaveletOperatorType::HighPassOperator HighPassOperatorType;
381 
383  itkStaticConstMacro(DirectionOfTransformation, DirectionOfTransformationEnumType, Wavelet::INVERSE);
384 
386  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
387  itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
389 
393  itkGetMacro(UpSampleFilterFactor, unsigned int);
394  itkSetMacro(UpSampleFilterFactor, unsigned int);
396 
404  itkGetMacro(SubsampleImageFactor, unsigned int);
405  itkSetMacro(SubsampleImageFactor, unsigned int);
407 
408 protected:
410  ~WaveletFilterBank() override {}
411 
412  void VerifyInputInformation() override
413  {
414 
415  }
416 
421  void GenerateOutputInformation() override;
422 
432  void GenerateInputRequestedRegion()
433  throw (itk::InvalidRequestedRegionError) override;
434 
438  void BeforeThreadedGenerateData() override;
439 
444  virtual void AllocateInternalData(const OutputImageRegionType& outputRegion);
445 
449  void AfterThreadedGenerateData() override;
450 
456  void CallCopyOutputRegionToInputRegion
457  (InputImageRegionType& destRegion, const OutputImageRegionType& srcRegion) override;
458  void CallCopyInputRegionToOutputRegion
459  (OutputImageRegionType& destRegion, const InputImageRegionType& srcRegion) override;
461 
466  virtual void CallCopyOutputRegionToInputRegion(unsigned int direction,
467  InputImageRegionType& destRegion,
468  const OutputImageRegionType& srcRegion);
469  virtual void CallCopyInputRegionToOutputRegion(unsigned int direction,
470  OutputImageRegionType& destRegion,
471  const InputImageRegionType& srcRegion);
473 
475  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
476 
481  virtual void ThreadedGenerateDataAtDimensionN(unsigned int direction,
482  itk::ProgressReporter& reporter,
483  const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId);
484 
485 private:
486  WaveletFilterBank(const Self &);
487  void operator =(const Self&);
488 
489  unsigned int m_UpSampleFilterFactor;
490  unsigned int m_SubsampleImageFactor;
491 
497  typedef std::vector<OutputImagePointerType> InternalImagesTabular;
498  std::vector<InternalImagesTabular> m_InternalImages;
499 
500 }; // end of class
501 
502 } // end of namespace otb
503 
504 #ifndef OTB_MANUAL_INSTANTIATION
505 #include "otbWaveletFilterBank.hxx"
506 #endif
507 
508 #endif
itk::Size< Monteverdi_DIMENSION > SizeType
Definition: mvdTypes.h:137
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
itk::SmartPointer< const Self > ConstPointer
itk::Index< Monteverdi_DIMENSION > IndexType
Definition: mvdTypes.h:133
unsigned int ThreadIdType
itk::SmartPointer< Self > Pointer
One level stationary wavelet transform.