OTB  10.0.0
Orfeo Toolbox
otbUnaryFunctorNeighborhoodVectorImageFilter.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 otbUnaryFunctorNeighborhoodVectorImageFilter_hxx
22 #define otbUnaryFunctorNeighborhoodVectorImageFilter_hxx
23 
25 #include "itkImageRegionIterator.h"
26 #include "itkNeighborhoodAlgorithm.h"
27 #include "itkProgressReporter.h"
28 
29 namespace otb
30 {
31 
35 template <class TInputImage, class TOutputImage, class TFunction>
37 {
38  this->DynamicMultiThreadingOn();
39  this->SetNumberOfRequiredInputs(1);
40  this->InPlaceOff();
41  for (unsigned int i = 0; i < InputImageDimension; ++i)
42  m_Radius[i] = 3;
43 }
45 
49 template <class TInputImage, class TOutputImage, class TFunction>
51 {
52  Superclass::GenerateOutputInformation();
53 
54  this->GetOutput()->SetNumberOfComponentsPerPixel(this->GetInput()->GetNumberOfComponentsPerPixel());
55 }
56 
60 template <class TInputImage, class TOutputImage, class TFunction>
62 {
63 
64  InputImageRegionType inputRegionForThread;
65  this->CallCopyOutputRegionToInputRegion(inputRegionForThread, outputRegionForThread);
66 
67  NeighborhoodIteratorType neighInputIt(this->GetRadius(), this->GetInput(), inputRegionForThread);
68  itk::ZeroFluxNeumannBoundaryCondition<TInputImage> nbc;
69  neighInputIt.OverrideBoundaryCondition(&nbc);
70  neighInputIt.GoToBegin();
71 
72  itk::ImageRegionIterator<TOutputImage> outputIt(this->GetOutput(), outputRegionForThread);
73  outputIt.GoToBegin();
74 
75  while (!outputIt.IsAtEnd() && !neighInputIt.IsAtEnd())
76  {
77  outputIt.Set(m_Functor(neighInputIt));
78 
79  ++neighInputIt;
80  ++outputIt;
81 
82  }
83 }
84 
85 } // end namespace otb
86 
87 #endif
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
itk::ConstNeighborhoodIterator< TInputImage > NeighborhoodIteratorType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.