OTB  9.0.0
Orfeo Toolbox
otbUnaryFunctorVectorImageFilter.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 otbUnaryFunctorVectorImageFilter_hxx
22 #define otbUnaryFunctorVectorImageFilter_hxx
23 
25 #include "itkImageRegionIterator.h"
26 #include "itkProgressReporter.h"
27 
28 namespace otb
29 {
30 
34 template <class TInputImage, class TOutputImage, class TFunction>
36 {
37  this->SetNumberOfRequiredInputs(1);
38  this->InPlaceOff();
39 }
41 
45 template <class TInputImage, class TOutputImage, class TFunction>
47 {
48  Superclass::GenerateOutputInformation();
49 
50  this->GetOutput()->SetNumberOfComponentsPerPixel(this->GetInput()->GetNumberOfComponentsPerPixel());
51 }
52 
56 template <class TInputImage, class TOutputImage, class TFunction>
58  itk::ThreadIdType threadId)
59 {
60  InputImageRegionType inputRegionForThread;
61  this->CallCopyOutputRegionToInputRegion(inputRegionForThread, outputRegionForThread);
63 
64  itk::ImageRegionConstIterator<InputImageType> inputIt(this->GetInput(), inputRegionForThread);
65  inputIt.GoToBegin();
66 
67  itk::ImageRegionIterator<OutputImageType> outputIt(this->GetOutput(), outputRegionForThread);
68  outputIt.GoToBegin();
69 
70  // support progress methods/callbacks
71  itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels());
72 
73  while (!outputIt.IsAtEnd() && !inputIt.IsAtEnd())
74  {
75  outputIt.Set(m_Functor(inputIt.Get()));
76 
77  ++inputIt;
78  ++outputIt;
79 
80  progress.CompletedPixel();
81  }
82 }
83 
84 } // end namespace otb
85 
86 #endif
otb::UnaryFunctorVectorImageFilter::GenerateOutputInformation
void GenerateOutputInformation(void) override
Definition: otbUnaryFunctorVectorImageFilter.hxx:46
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::UnaryFunctorVectorImageFilter< TInputImage, TOutputImage, Functor::NormalizeVectorImageFunctor< TInputImage::PixelType, TOutputImage::PixelType > >::InputImageRegionType
InputImageType::RegionType InputImageRegionType
Definition: otbUnaryFunctorVectorImageFilter.h:64
otb::UnaryFunctorVectorImageFilter::UnaryFunctorVectorImageFilter
UnaryFunctorVectorImageFilter()
Definition: otbUnaryFunctorVectorImageFilter.hxx:35
otb::UnaryFunctorVectorImageFilter::ThreadedGenerateData
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, itk::ThreadIdType threadId) override
Definition: otbUnaryFunctorVectorImageFilter.hxx:57
otbUnaryFunctorVectorImageFilter.h
otb::UnaryFunctorVectorImageFilter< TInputImage, TOutputImage, Functor::NormalizeVectorImageFunctor< TInputImage::PixelType, TOutputImage::PixelType > >::OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
Definition: otbUnaryFunctorVectorImageFilter.h:68