OTB  9.0.0
Orfeo Toolbox
otbUnaryFunctorNeighborhoodImageFilter.h
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 otbUnaryFunctorNeighborhoodImageFilter_h
22 #define otbUnaryFunctorNeighborhoodImageFilter_h
23 
24 #include "itkImageToImageFilter.h"
25 #include "itkImageRegionIteratorWithIndex.h"
26 #include "itkConstNeighborhoodIterator.h"
27 #include "itkProcessObject.h"
28 
29 namespace otb
30 {
42 template <class TInputImage, class TOutputImage, class TFunction>
43 class ITK_EXPORT UnaryFunctorNeighborhoodImageFilter : public itk::ImageToImageFilter<TInputImage, TOutputImage>
44 {
45 public:
48  typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
49  typedef itk::SmartPointer<Self> Pointer;
50  typedef itk::SmartPointer<const Self> ConstPointer;
51 
53  itkNewMacro(Self);
54 
56  itkTypeMacro(UnaryFunctorNeighborhoodImageFilter, ImageToImageFilter);
57 
59  typedef TFunction FunctorType;
60  typedef typename Superclass::InputImageType InputImageType;
61  typedef typename InputImageType::ConstPointer InputImagePointer;
62  typedef typename InputImageType::RegionType InputImageRegionType;
63  typedef typename InputImageType::PixelType InputImagePixelType;
64  typedef typename InputImageType::SizeType InputImageSizeType;
65  typedef typename Superclass::OutputImageType OutputImageType;
66  typedef typename OutputImageType::Pointer OutputImagePointer;
67  typedef typename OutputImageType::RegionType OutputImageRegionType;
68  typedef typename OutputImageType::PixelType OutputImagePixelType;
69 
70  typedef itk::ProcessObject ProcessObjectType;
71 
73  itkSetMacro(Radius, InputImageSizeType);
74  itkGetMacro(Radius, InputImageSizeType);
76 
78  void SetRadius(unsigned int radius)
79  {
80  m_Radius.Fill(radius);
81  }
82 
88  {
89  this->Modified();
90  return m_Functor;
91  }
93 
98  const FunctorType& GetFunctor() const
99  {
100  return m_Functor;
101  }
102 
109  void SetFunctor(const FunctorType& functor)
110  {
111  m_Functor = functor;
112  this->Modified();
113  }
115 
116  typedef itk::ConstNeighborhoodIterator<TInputImage> NeighborhoodIteratorType;
117  typedef typename NeighborhoodIteratorType::RadiusType RadiusType;
118  typedef unsigned char RadiusSizeType;
119 
120 protected:
125 
130  {
131  }
132 
143  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
144 
148  void GenerateInputRequestedRegion(void) override;
149 
150 private:
151  UnaryFunctorNeighborhoodImageFilter(const Self&) = delete;
152  void operator=(const Self&) = delete;
153 
156 };
157 
158 } // namespace otb
159 
160 #ifndef OTB_MANUAL_INSTANTIATION
162 #endif
163 
164 #endif
otb::UnaryFunctorNeighborhoodImageFilter::InputImageRegionType
InputImageType::RegionType InputImageRegionType
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:62
otb::UnaryFunctorNeighborhoodImageFilter::SetRadius
void SetRadius(unsigned int radius)
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:78
otb::Functor::OutcoreFunctor< itk::ConstNeighborhoodIterator< TInputImage1 >, TOutputImage::PixelType >
otb::UnaryFunctorNeighborhoodImageFilter::RadiusSizeType
unsigned char RadiusSizeType
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:118
otb::UnaryFunctorNeighborhoodImageFilter::InputImagePointer
InputImageType::ConstPointer InputImagePointer
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:61
otb::UnaryFunctorNeighborhoodImageFilter::SetFunctor
void SetFunctor(const FunctorType &functor)
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:109
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::UnaryFunctorNeighborhoodImageFilter::Superclass
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:48
otbUnaryFunctorNeighborhoodImageFilter.hxx
otb::UnaryFunctorNeighborhoodImageFilter::m_Functor
FunctorType m_Functor
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:155
otb::UnaryFunctorNeighborhoodImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:50
otb::UnaryFunctorNeighborhoodImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:49
otb::UnaryFunctorNeighborhoodImageFilter::InputImagePixelType
InputImageType::PixelType InputImagePixelType
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:63
otb::UnaryFunctorNeighborhoodImageFilter::RadiusType
NeighborhoodIteratorType::RadiusType RadiusType
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:117
otb::UnaryFunctorNeighborhoodImageFilter::OutputImagePointer
OutputImageType::Pointer OutputImagePointer
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:66
otb::UnaryFunctorNeighborhoodImageFilter::OutputImagePixelType
OutputImageType::PixelType OutputImagePixelType
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:68
otb::UnaryFunctorNeighborhoodImageFilter::OutputImageType
Superclass::OutputImageType OutputImageType
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:65
otb::UnaryFunctorNeighborhoodImageFilter::InputImageType
Superclass::InputImageType InputImageType
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:60
otb::UnaryFunctorNeighborhoodImageFilter::OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:67
otb::UnaryFunctorNeighborhoodImageFilter::~UnaryFunctorNeighborhoodImageFilter
~UnaryFunctorNeighborhoodImageFilter() override
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:129
otb::UnaryFunctorNeighborhoodImageFilter::GetFunctor
const FunctorType & GetFunctor() const
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:98
otb::UnaryFunctorNeighborhoodImageFilter::NeighborhoodIteratorType
itk::ConstNeighborhoodIterator< TInputImage > NeighborhoodIteratorType
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:116
otb::UnaryFunctorNeighborhoodImageFilter::GetFunctor
FunctorType & GetFunctor()
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:87
otb::UnaryFunctorNeighborhoodImageFilter
Implements neighborhood-wise generic operation on image.
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:43
otb::UnaryFunctorNeighborhoodImageFilter::m_Radius
InputImageSizeType m_Radius
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:154
otb::UnaryFunctorNeighborhoodImageFilter::ProcessObjectType
itk::ProcessObject ProcessObjectType
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:70
otb::UnaryFunctorNeighborhoodImageFilter::Self
UnaryFunctorNeighborhoodImageFilter Self
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:47
otb::UnaryFunctorNeighborhoodImageFilter::InputImageSizeType
InputImageType::SizeType InputImageSizeType
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:64
otb::UnaryFunctorNeighborhoodImageFilter::FunctorType
TFunction FunctorType
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:56