OTB  9.0.0
Orfeo Toolbox
otbTwoNRIBandsImageToNComplexBandsImage.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbTwoNRIBandsImageToNComplexBandsImage_hxx
22 #define otbTwoNRIBandsImageToNComplexBandsImage_hxx
23 
25 
26 #include "itkImageRegionIterator.h"
27 #include "itkImageRegionConstIterator.h"
28 #include "itkProgressReporter.h"
29 #include "itkVariableLengthVector.h"
30 
31 
32 namespace otb
33 {
34 
38 template <class TInputImage, class TOutputImage>
40 {
41  // this->SetNumberOfThreads(1);
42 }
43 
47 template <class TInputImage, class TOutputImage>
49 {
50  Superclass::GenerateOutputInformation();
51 
52  unsigned int nbCompo = this->GetInput()->GetNumberOfComponentsPerPixel();
53 
54  if ((nbCompo % 2) != 0)
55  {
56  itkExceptionMacro("Number of bands of the input images must be an even number");
57  }
58  else
59  {
60  this->GetOutput()->SetNumberOfComponentsPerPixel(nbCompo / 2);
61  }
62 }
63 
67 template <class TInputImage, class TOutputImage>
69 {
70  unsigned int nbCompo = this->GetInput()->GetNumberOfComponentsPerPixel();
71 
72  if ((nbCompo % 2) != 0)
73  itkExceptionMacro("Number of bands of the input images must be an even number");
74 }
75 
79 template <class TInputImage, class TOutputImage>
81  itk::ThreadIdType threadId)
82 {
83 
84  unsigned int nbCompo = this->GetInput()->GetNumberOfComponentsPerPixel();
85 
86  itk::VariableLengthVector<std::complex<typename InputPixelType::ValueType>> vlv(nbCompo / 2);
87 
88 
89  // support progress methods/callbacks
90  itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels());
91 
92  itk::ImageRegionConstIterator<TInputImage> inIt;
93  inIt = itk::ImageRegionConstIterator<TInputImage>(this->GetInput(), outputRegionForThread);
94 
95  itk::ImageRegionIterator<OutputImageType> outIt;
96  outIt = itk::ImageRegionIterator<OutputImageType>(this->GetOutput(), outputRegionForThread);
97 
98 
99  inIt.GoToBegin();
100  outIt.GoToBegin();
101 
102  while (!outIt.IsAtEnd())
103  {
104 
105  unsigned int k = 0;
106  for (unsigned int i = 0; i < nbCompo - 1; i = i + 2)
107  {
108  vlv[k] = std::complex<typename InputPixelType::ValueType>(inIt.Get()[i], inIt.Get()[i + 1]);
109  k++;
110  }
111 
112 
113  outIt.Set(vlv);
114 
115 
116  ++inIt;
117  ++outIt;
118 
119  progress.CompletedPixel();
120  }
121 }
122 
126 template <class TInputImage, class TOutput>
127 void TwoNRIBandsImageToNComplexBandsImage<TInputImage, TOutput>::PrintSelf(std::ostream& os, itk::Indent indent) const
128 {
129  Superclass::PrintSelf(os, indent);
130 }
131 
132 } // end namespace otb
133 
134 #endif
otb::TwoNRIBandsImageToNComplexBandsImage::TwoNRIBandsImageToNComplexBandsImage
TwoNRIBandsImageToNComplexBandsImage()
Definition: otbTwoNRIBandsImageToNComplexBandsImage.hxx:39
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::TwoNRIBandsImageToNComplexBandsImage::ThreadedGenerateData
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, itk::ThreadIdType threadId) override
Definition: otbTwoNRIBandsImageToNComplexBandsImage.hxx:80
otb::TwoNRIBandsImageToNComplexBandsImage::OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
Definition: otbTwoNRIBandsImageToNComplexBandsImage.h:67
otbTwoNRIBandsImageToNComplexBandsImage.h
otb::TwoNRIBandsImageToNComplexBandsImage::BeforeThreadedGenerateData
void BeforeThreadedGenerateData(void) override
Definition: otbTwoNRIBandsImageToNComplexBandsImage.hxx:68
otb::TwoNRIBandsImageToNComplexBandsImage::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbTwoNRIBandsImageToNComplexBandsImage.hxx:127
otb::TwoNRIBandsImageToNComplexBandsImage::GenerateOutputInformation
void GenerateOutputInformation(void) override
Definition: otbTwoNRIBandsImageToNComplexBandsImage.hxx:48