OTB  9.0.0
Orfeo Toolbox
otbImageOfVectorsToMonoChannelExtractROI.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 otbImageOfVectorsToMonoChannelExtractROI_hxx
22 #define otbImageOfVectorsToMonoChannelExtractROI_hxx
23 
25 
26 namespace otb
27 {
28 
32 template <class TInputImage, class TOutputImage>
34 {
35 }
36 
40 template <class TInputImage, class TOutputImage>
42 {
43  Superclass::PrintSelf(os, indent);
44 }
45 
55 template <class TInputImage, class TOutputImage>
57 {
58  typename Superclass::InputImageConstPointer inputPtr = this->GetInput();
59  // Analysis of processed channel
60  if ((m_Channel <= 0) || (m_Channel > InputImagePixelType::Dimension))
61  {
62  itkExceptionMacro(<< "otb::ExtractImImageOfVectorsToMonoChannelExtractROIageFilter::GenerateOutputInformation "
63  << " Channel must be in the following range: [1;" << InputImagePixelType::Dimension << "] "
64  << typeid(itk::ImageBase<InputImageDimension>*).name());
65  }
67 
68  // Call base class implementation
69  Superclass::GenerateOutputInformation();
70 }
71 
72 template <class TInputImage, class TOutputImage>
74  itk::ThreadIdType threadId)
75 {
76  itkDebugMacro(<< "Actually executing");
77 
78  // Get the input and output pointers
79  typename Superclass::InputImageConstPointer inputPtr = this->GetInput();
80  typename Superclass::OutputImagePointer outputPtr = this->GetOutput();
81 
82  // support progress methods/callbacks
83  itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels());
84 
85  // Define the portion of the input to walk for this thread
86  InputImageRegionType inputRegionForThread;
87  this->CallCopyOutputRegionToInputRegion(inputRegionForThread, outputRegionForThread);
88 
89  // Define the iterators.
90  typedef itk::ImageRegionIterator<OutputImageType> OutputIterator;
91  typedef itk::ImageRegionConstIterator<InputImageType> InputIterator;
92 
93  OutputIterator outIt(outputPtr, outputRegionForThread);
94  InputIterator inIt(inputPtr, inputRegionForThread);
95 
96  // Loop through the processed channels
97  unsigned int channelIn(m_Channel - 1);
98 
99  InputImagePixelType pixelInput;
100  while (!outIt.IsAtEnd())
101  {
102  OutputImagePixelType pixelOutput;
103  pixelInput = inIt.Get();
104  pixelOutput = static_cast<OutputValueType>(pixelInput[channelIn]);
105  outIt.Set(pixelOutput);
106  ++outIt;
107  ++inIt;
108  progress.CompletedPixel();
109  }
110 }
111 
112 } // end namespace otb
113 
114 #endif
otb::ImageOfVectorsToMonoChannelExtractROI::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbImageOfVectorsToMonoChannelExtractROI.hxx:41
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otbImageOfVectorsToMonoChannelExtractROI.h
otb::ImageOfVectorsToMonoChannelExtractROI::ThreadedGenerateData
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, itk::ThreadIdType threadId) override
Definition: otbImageOfVectorsToMonoChannelExtractROI.hxx:73
otb::ExtractROIBase::OutputImageRegionType
TOutputImage::RegionType OutputImageRegionType
Definition: otbExtractROIBase.h:68
otb::ImageOfVectorsToMonoChannelExtractROI::GenerateOutputInformation
void GenerateOutputInformation() override
Definition: otbImageOfVectorsToMonoChannelExtractROI.hxx:56
otb::ExtractROIBase::InputImagePixelType
TInputImage::PixelType InputImagePixelType
Definition: otbExtractROIBase.h:73
otb::ExtractROIBase::OutputImagePixelType
TOutputImage::PixelType OutputImagePixelType
Definition: otbExtractROIBase.h:72
otb::ImageOfVectorsToMonoChannelExtractROI::ImageOfVectorsToMonoChannelExtractROI
ImageOfVectorsToMonoChannelExtractROI()
Definition: otbImageOfVectorsToMonoChannelExtractROI.hxx:33
otb::ExtractROIBase::InputImageRegionType
TInputImage::RegionType InputImageRegionType
Definition: otbExtractROIBase.h:69
otb::ImageOfVectorsToMonoChannelExtractROI::OutputValueType
OutputImageType::ValueType OutputValueType
Definition: otbImageOfVectorsToMonoChannelExtractROI.h:61