OTB  7.1.0
Orfeo Toolbox
otbUnaryFunctorNeighborhoodVectorImageFilter.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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->SetNumberOfRequiredInputs(1);
39  this->InPlaceOff();
40  for (unsigned int i = 0; i < InputImageDimension; ++i)
41  m_Radius[i] = 3;
42 }
44 
48 template <class TInputImage, class TOutputImage, class TFunction>
50 {
51  Superclass::GenerateOutputInformation();
52 
53  this->GetOutput()->SetNumberOfComponentsPerPixel(this->GetInput()->GetNumberOfComponentsPerPixel());
54 }
55 
59 template <class TInputImage, class TOutputImage, class TFunction>
61  itk::ThreadIdType threadId)
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  // support progress methods/callbacks
76  itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels());
77 
78  while (!outputIt.IsAtEnd() && !neighInputIt.IsAtEnd())
79  {
80  outputIt.Set(m_Functor(neighInputIt));
81 
82  ++neighInputIt;
83  ++outputIt;
84 
85  progress.CompletedPixel();
86  }
87 }
88 
89 } // end namespace otb
90 
91 #endif
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, itk::ThreadIdType threadId) override
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.