OTB  9.0.0
Orfeo Toolbox
otbUnaryFunctorNeighborhoodWithOffsetImageFilter.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 otbUnaryFunctorNeighborhoodWithOffsetImageFilter_h
22 #define otbUnaryFunctorNeighborhoodWithOffsetImageFilter_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 UnaryFunctorNeighborhoodWithOffsetImageFilter : 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(UnaryFunctorNeighborhoodWithOffsetImageFilter, 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 InputImageType::OffsetType InputImageOffsetType;
66  typedef typename Superclass::OutputImageType OutputImageType;
67  typedef typename OutputImageType::Pointer OutputImagePointer;
68  typedef typename OutputImageType::RegionType OutputImageRegionType;
69  typedef typename OutputImageType::PixelType OutputImagePixelType;
70 
71  typedef itk::ProcessObject ProcessObjectType;
72 
74  itkSetMacro(Radius, InputImageSizeType);
75  itkGetMacro(Radius, InputImageSizeType);
77 
79  void SetRadius(unsigned int radius)
80  {
81  m_Radius.Fill(radius);
82  }
83 
85  virtual void SetOffset(InputImageOffsetType off)
86  {
87  m_Offset = off;
88  this->GetFunctor().SetOffset(off);
89  this->Modified();
90  }
91  itkGetMacro(Offset, InputImageOffsetType);
93 
99  {
100  this->Modified();
101  return m_Functor;
102  }
104 
109  const FunctorType& GetFunctor() const
110  {
111  return m_Functor;
112  }
113 
120  void SetFunctor(const FunctorType& functor)
121  {
122  m_Functor = functor;
123  this->Modified();
124  }
126 
127  typedef itk::ConstNeighborhoodIterator<TInputImage> NeighborhoodIteratorType;
128  typedef typename NeighborhoodIteratorType::RadiusType RadiusType;
129  typedef unsigned char RadiusSizeType;
130 
131 protected:
136 
141  {
142  }
143 
144  void BeforeThreadedGenerateData() override;
145 
156  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
157 
161  void GenerateInputRequestedRegion(void) override;
162  std::vector<FunctorType> m_FunctorList;
163 
164 private:
166  void operator=(const Self&) = delete;
167 
169 
171 
173 };
174 
175 } // namespace otb
176 
177 #ifndef OTB_MANUAL_INSTANTIATION
179 #endif
180 
181 #endif
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::Superclass
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:48
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::OutputImageType
Superclass::OutputImageType OutputImageType
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:66
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::m_Functor
FunctorType m_Functor
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:170
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter
Implements neighborhood-wise generic operation on image.
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:43
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::GetFunctor
const FunctorType & GetFunctor() const
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:109
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::GetFunctor
FunctorType & GetFunctor()
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:98
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::RadiusSizeType
unsigned char RadiusSizeType
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:129
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otbUnaryFunctorNeighborhoodWithOffsetImageFilter.hxx
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::RadiusType
NeighborhoodIteratorType::RadiusType RadiusType
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:128
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::NeighborhoodIteratorType
itk::ConstNeighborhoodIterator< TInputImage > NeighborhoodIteratorType
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:127
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::InputImageType
Superclass::InputImageType InputImageType
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:60
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::m_Offset
InputImageOffsetType m_Offset
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:172
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::InputImageOffsetType
InputImageType::OffsetType InputImageOffsetType
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:65
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::SetFunctor
void SetFunctor(const FunctorType &functor)
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:120
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::SetRadius
void SetRadius(unsigned int radius)
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:79
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:50
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::SetOffset
virtual void SetOffset(InputImageOffsetType off)
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:85
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::OutputImagePixelType
OutputImageType::PixelType OutputImagePixelType
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:69
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::m_Radius
InputImageSizeType m_Radius
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:168
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::m_FunctorList
std::vector< FunctorType > m_FunctorList
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:162
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::InputImagePointer
InputImageType::ConstPointer InputImagePointer
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:61
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::ProcessObjectType
itk::ProcessObject ProcessObjectType
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:71
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:49
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:68
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::InputImagePixelType
InputImageType::PixelType InputImagePixelType
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:63
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::FunctorType
TFunction FunctorType
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:56
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::OutputImagePointer
OutputImageType::Pointer OutputImagePointer
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:67
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::InputImageRegionType
InputImageType::RegionType InputImageRegionType
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:62
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::~UnaryFunctorNeighborhoodWithOffsetImageFilter
~UnaryFunctorNeighborhoodWithOffsetImageFilter() override
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:140
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::Self
UnaryFunctorNeighborhoodWithOffsetImageFilter Self
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:47
otb::UnaryFunctorNeighborhoodWithOffsetImageFilter::InputImageSizeType
InputImageType::SizeType InputImageSizeType
Definition: otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h:64