OTB  10.0.0
Orfeo Toolbox
otbOneRIBandImageToOneComplexBandImage.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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 otbOneRIBandImageToOneComplexBandImage_hxx
22 #define otbOneRIBandImageToOneComplexBandImage_hxx
23 
25 
26 #include "itkImageRegionIterator.h"
27 #include "itkImageRegionConstIterator.h"
28 #include "itkProgressReporter.h"
29 
30 namespace otb
31 {
32 
36 template <class TInputImage, class TOutputImage>
38 {
39  // this->SetNumberOfWorkUnits(1);
40  this->DynamicMultiThreadingOn();
41 }
43 
47 template <class TInputImage, class TOutputImage>
49 {
50  if (this->GetInput()->GetNumberOfComponentsPerPixel() != 2)
51  itkExceptionMacro("Input image must be made of two bands and only two.");
52 }
53 
57 template <class TInputImage, class TOutputImage>
59 {
60 
61  typename OutputImageType::Pointer output = this->GetOutput();
62  typename InputImageType::ConstPointer input = this->GetInput();
63 
64  itk::ImageRegionIterator<OutputImageType> it;
65  itk::ImageRegionConstIterator<TInputImage> itIn;
66 
67  itIn = itk::ImageRegionConstIterator<TInputImage>(input, outputRegionForThread);
68  it = itk::ImageRegionIterator<OutputImageType>(output, outputRegionForThread);
69 
70  it.GoToBegin();
71  itIn.GoToBegin();
72  while (!it.IsAtEnd())
73  {
74 
75  it.Set(static_cast<OutputPixelType>(std::complex<typename InputPixelType::ValueType>(itIn.Get()[0], itIn.Get()[1])));
76 
77  ++it;
78  ++itIn;
79  }
80 }
81 
85 template <class TInputImage, class TOutput>
86 void OneRIBandImageToOneComplexBandImage<TInputImage, TOutput>::PrintSelf(std::ostream& os, itk::Indent indent) const
87 {
88  Superclass::PrintSelf(os, indent);
89 }
90 
91 } // end namespace otb
92 
93 #endif
void PrintSelf(std::ostream &os, itk::Indent indent) const override
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.