OTB  9.0.0
Orfeo Toolbox
otbOneRIBandImageToOneComplexBandImage.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 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->SetNumberOfThreads(1);
40 }
41 
45 template <class TInputImage, class TOutputImage>
47 {
48  if (this->GetInput()->GetNumberOfComponentsPerPixel() != 2)
49  itkExceptionMacro("Input image must be made of two bands and only two.");
50 }
51 
55 template <class TInputImage, class TOutputImage>
57  itk::ThreadIdType threadId)
58 {
59 
60  // support progress methods/callbacks
61  itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels());
62 
63  typename OutputImageType::Pointer output = this->GetOutput();
64  typename InputImageType::ConstPointer input = this->GetInput();
65 
66  itk::ImageRegionIterator<OutputImageType> it;
67  itk::ImageRegionConstIterator<TInputImage> itIn;
68 
69  itIn = itk::ImageRegionConstIterator<TInputImage>(input, outputRegionForThread);
70  it = itk::ImageRegionIterator<OutputImageType>(output, outputRegionForThread);
71 
72  it.GoToBegin();
73  itIn.GoToBegin();
74  while (!it.IsAtEnd())
75  {
76 
77  it.Set(static_cast<OutputPixelType>(std::complex<typename InputPixelType::ValueType>(itIn.Get()[0], itIn.Get()[1])));
78 
79  ++it;
80  ++itIn;
81  progress.CompletedPixel();
82  }
83 }
84 
88 template <class TInputImage, class TOutput>
89 void OneRIBandImageToOneComplexBandImage<TInputImage, TOutput>::PrintSelf(std::ostream& os, itk::Indent indent) const
90 {
91  Superclass::PrintSelf(os, indent);
92 }
93 
94 } // end namespace otb
95 
96 #endif
otb::OneRIBandImageToOneComplexBandImage::OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
Definition: otbOneRIBandImageToOneComplexBandImage.h:67
otb::OneRIBandImageToOneComplexBandImage::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbOneRIBandImageToOneComplexBandImage.hxx:89
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otbOneRIBandImageToOneComplexBandImage.h
otb::OneRIBandImageToOneComplexBandImage::BeforeThreadedGenerateData
void BeforeThreadedGenerateData(void) override
Definition: otbOneRIBandImageToOneComplexBandImage.hxx:46
otb::OneRIBandImageToOneComplexBandImage::OutputPixelType
OutputImageType::PixelType OutputPixelType
Definition: otbOneRIBandImageToOneComplexBandImage.h:64
otb::OneRIBandImageToOneComplexBandImage::OneRIBandImageToOneComplexBandImage
OneRIBandImageToOneComplexBandImage()
Definition: otbOneRIBandImageToOneComplexBandImage.hxx:37
otb::OneRIBandImageToOneComplexBandImage::ThreadedGenerateData
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, itk::ThreadIdType threadId) override
Definition: otbOneRIBandImageToOneComplexBandImage.hxx:56