OTB  9.0.0
Orfeo Toolbox
otbBinaryFunctorNeighborhoodImageFilter.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 otbBinaryFunctorNeighborhoodImageFilter_h
22 #define otbBinaryFunctorNeighborhoodImageFilter_h
23 
24 #include "itkImageToImageFilter.h"
25 #include "itkImageRegionIteratorWithIndex.h"
26 #include "itkConstNeighborhoodIterator.h"
27 #include "itkSize.h"
28 
29 namespace otb
30 {
31 
46 template <class TInputImage1, class TInputImage2, class TOutputImage, class TFunction>
47 class ITK_EXPORT BinaryFunctorNeighborhoodImageFilter : public itk::ImageToImageFilter<TInputImage1, TOutputImage>
48 {
49 public:
52  typedef itk::ImageToImageFilter<TInputImage1, TOutputImage> Superclass;
53  typedef itk::SmartPointer<Self> Pointer;
54  typedef itk::SmartPointer<const Self> ConstPointer;
55 
57  itkNewMacro(Self);
58 
61 
63  typedef TFunction FunctorType;
64  typedef TInputImage1 Input1ImageType;
65  typedef typename Input1ImageType::ConstPointer Input1ImageConstPointer;
66  typedef typename Input1ImageType::Pointer Input1ImagePointer;
67  typedef typename Input1ImageType::RegionType Input1ImageRegionType;
68  typedef typename Input1ImageType::PixelType Input1ImagePixelType;
69  typedef TInputImage2 Input2ImageType;
70  typedef typename Input2ImageType::ConstPointer Input2ImageConstPointer;
71  typedef typename Input2ImageType::Pointer Input2ImagePointer;
72  typedef typename Input2ImageType::RegionType Input2ImageRegionType;
73  typedef typename Input2ImageType::PixelType Input2ImagePixelType;
74  typedef TOutputImage OutputImageType;
75  typedef typename OutputImageType::Pointer OutputImagePointer;
76  typedef typename OutputImageType::RegionType OutputImageRegionType;
77  typedef typename OutputImageType::PixelType OutputImagePixelType;
78 
79  typedef itk::ProcessObject ProcessObjectType;
80 
82  void SetInput1(const TInputImage1* image1);
83 
85  void SetInput2(const TInputImage2* image2);
86 
88  const TInputImage1* GetInput1();
89  const TInputImage2* GetInput2();
91 
97  {
98  return m_Functor;
99  }
100 
107  void SetFunctor(const FunctorType& functor)
108  {
109  m_Functor = functor;
110  this->Modified();
111  }
113 
114  typedef itk::ConstNeighborhoodIterator<TInputImage1> NeighborhoodIteratorType1;
115  typedef itk::ConstNeighborhoodIterator<TInputImage2> NeighborhoodIteratorType2;
116 
117  typedef typename NeighborhoodIteratorType1::RadiusType RadiusType1;
118  typedef typename NeighborhoodIteratorType2::RadiusType RadiusType2;
119 
120  typedef typename itk::Size<Input1ImageType::ImageDimension> RadiusSizeType;
121 
122  itkSetMacro(Radius, RadiusSizeType);
123 
125  void SetRadius(unsigned int radius)
126  {
127  m_Radius.Fill(radius);
128  }
129 
130 protected:
133  {
134  }
135 
146  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
147 
151  void GenerateInputRequestedRegion(void) override;
152 
154 
155 private:
157  void operator=(const Self&) = delete;
158 
160 };
161 
162 } // end namespace otb
163 
164 #ifndef OTB_MANUAL_INSTANTIATION
166 #endif
167 
168 #endif
otb::BinaryFunctorNeighborhoodImageFilter::Input1ImagePointer
Input1ImageType::Pointer Input1ImagePointer
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:66
otb::BinaryFunctorNeighborhoodImageFilter::~BinaryFunctorNeighborhoodImageFilter
~BinaryFunctorNeighborhoodImageFilter() override
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:132
otb::BinaryFunctorNeighborhoodImageFilter
Implements neighborhood-wise generic operation of two images.
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:47
otb::BinaryFunctorNeighborhoodImageFilter::Input1ImagePixelType
Input1ImageType::PixelType Input1ImagePixelType
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:68
otb::BinaryFunctorNeighborhoodImageFilter::OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:76
otb::BinaryFunctorImageFilter
Implements pixel-wise generic operation on two images.
Definition: otbBinaryFunctorImageFilter.h:44
otb::BinaryFunctorNeighborhoodImageFilter::Superclass
itk::ImageToImageFilter< TInputImage1, TOutputImage > Superclass
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:52
otb::BinaryFunctorNeighborhoodImageFilter::NeighborhoodIteratorType1
itk::ConstNeighborhoodIterator< TInputImage1 > NeighborhoodIteratorType1
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:114
otb::BinaryFunctorNeighborhoodImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:53
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::BinaryFunctorNeighborhoodImageFilter::Input1ImageConstPointer
Input1ImageType::ConstPointer Input1ImageConstPointer
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:65
otb::BinaryFunctorNeighborhoodImageFilter::ProcessObjectType
itk::ProcessObject ProcessObjectType
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:79
otb::BinaryFunctorNeighborhoodImageFilter::Input1ImageType
TInputImage1 Input1ImageType
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:64
otb::BinaryFunctorNeighborhoodImageFilter::Input1ImageRegionType
Input1ImageType::RegionType Input1ImageRegionType
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:67
otb::BinaryFunctorNeighborhoodImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:54
otb::BinaryFunctorNeighborhoodImageFilter::OutputImageType
TOutputImage OutputImageType
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:74
otb::BinaryFunctorNeighborhoodImageFilter::RadiusType1
NeighborhoodIteratorType1::RadiusType RadiusType1
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:117
otb::BinaryFunctorNeighborhoodImageFilter::Input2ImageType
TInputImage2 Input2ImageType
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:69
otb::BinaryFunctorNeighborhoodImageFilter::SetFunctor
void SetFunctor(const FunctorType &functor)
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:107
otb::BinaryFunctorNeighborhoodImageFilter::OutputImagePixelType
OutputImageType::PixelType OutputImagePixelType
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:77
otb::BinaryFunctorNeighborhoodImageFilter::RadiusType2
NeighborhoodIteratorType2::RadiusType RadiusType2
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:118
otb::BinaryFunctorNeighborhoodImageFilter::GetFunctor
FunctorType & GetFunctor()
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:96
otb::BinaryFunctorNeighborhoodImageFilter::Input2ImagePixelType
Input2ImageType::PixelType Input2ImagePixelType
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:73
otb::Functor::CBAMI< itk::ConstNeighborhoodIterator< TInputImage1 >, itk::ConstNeighborhoodIterator< TInputImage2 >, TOutputImage::PixelType >
otb::BinaryFunctorNeighborhoodImageFilter::Input2ImagePointer
Input2ImageType::Pointer Input2ImagePointer
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:71
otb::BinaryFunctorNeighborhoodImageFilter::Self
BinaryFunctorNeighborhoodImageFilter Self
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:51
otb::BinaryFunctorNeighborhoodImageFilter::OutputImagePointer
OutputImageType::Pointer OutputImagePointer
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:75
otb::BinaryFunctorNeighborhoodImageFilter::Input2ImageConstPointer
Input2ImageType::ConstPointer Input2ImageConstPointer
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:70
otb::BinaryFunctorNeighborhoodImageFilter::Input2ImageRegionType
Input2ImageType::RegionType Input2ImageRegionType
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:72
otb::BinaryFunctorNeighborhoodImageFilter::RadiusSizeType
itk::Size< Input1ImageType::ImageDimension > RadiusSizeType
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:120
otb::BinaryFunctorNeighborhoodImageFilter::SetRadius
void SetRadius(unsigned int radius)
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:125
otbBinaryFunctorNeighborhoodImageFilter.hxx
otb::BinaryFunctorNeighborhoodImageFilter::NeighborhoodIteratorType2
itk::ConstNeighborhoodIterator< TInputImage2 > NeighborhoodIteratorType2
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:115
otb::BinaryFunctorNeighborhoodImageFilter::FunctorType
TFunction FunctorType
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:60
otb::BinaryFunctorNeighborhoodImageFilter::m_Radius
RadiusSizeType m_Radius
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:153
otb::BinaryFunctorNeighborhoodImageFilter::m_Functor
FunctorType m_Functor
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:159