OTB  9.0.0
Orfeo Toolbox
otbUnaryFunctorWithIndexWithOutputSizeImageFilter.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 otbUnaryFunctorWithIndexWithOutputSizeImageFilter_h
22 #define otbUnaryFunctorWithIndexWithOutputSizeImageFilter_h
23 
24 #include "itkImageToImageFilter.h"
25 #include "itkImageRegionConstIteratorWithIndex.h"
26 #include "itkProcessObject.h"
27 
28 namespace otb
29 {
41 template <class TInputImage, class TOutputImage, class TFunction>
42 class ITK_EXPORT UnaryFunctorWithIndexWithOutputSizeImageFilter : public itk::ImageToImageFilter<TInputImage, TOutputImage>
43 {
44 public:
47  typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
48  typedef itk::SmartPointer<Self> Pointer;
49  typedef itk::SmartPointer<const Self> ConstPointer;
50 
52  itkNewMacro(Self);
53 
55  itkTypeMacro(UnaryFunctorWithIndexWithOutputSizeImageFilter, ImageToImageFilter);
56 
58  typedef TFunction FunctorType;
59  typedef typename Superclass::InputImageType InputImageType;
60  typedef typename InputImageType::ConstPointer InputImagePointer;
61  typedef typename InputImageType::RegionType InputImageRegionType;
62  typedef typename InputImageType::PixelType InputImagePixelType;
63  typedef typename InputImageType::SizeType InputImageSizeType;
64  typedef typename InputImageType::IndexType InputImageIndexType;
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 
77  {
78  this->Modified();
79  return m_Functor;
80  }
82 
87  const FunctorType& GetFunctor() const
88  {
89  return m_Functor;
90  }
91 
98  void SetFunctor(const FunctorType& functor)
99  {
100  m_Functor = functor;
101  this->Modified();
102  }
104 
105  typedef itk::ImageRegionConstIteratorWithIndex<TInputImage> IteratorType;
106 
107 protected:
112 
117  {
118  }
119 
130  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
131 
135  void GenerateInputRequestedRegion(void) override;
136 
146  {
147  Superclass::GenerateOutputInformation();
148  typename Superclass::OutputImagePointer outputPtr = this->GetOutput();
149  outputPtr->SetNumberOfComponentsPerPixel( // propagate vector length info
150  this->GetFunctor().GetOutputSize());
151  }
153 
154 private:
156  void operator=(const Self&) = delete;
157 
159 };
160 
161 } // namespace otb
162 
163 #ifndef OTB_MANUAL_INSTANTIATION
165 #endif
166 
167 #endif
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::ProcessObjectType
itk::ProcessObject ProcessObjectType
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:70
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::InputImagePixelType
InputImageType::PixelType InputImagePixelType
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:62
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::InputImageSizeType
InputImageType::SizeType InputImageSizeType
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:63
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::InputImageType
Superclass::InputImageType InputImageType
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:59
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::InputImagePointer
InputImageType::ConstPointer InputImagePointer
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:60
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::GenerateOutputInformation
void GenerateOutputInformation() override
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:145
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::Self
UnaryFunctorWithIndexWithOutputSizeImageFilter Self
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:46
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::~UnaryFunctorWithIndexWithOutputSizeImageFilter
~UnaryFunctorWithIndexWithOutputSizeImageFilter() override
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:116
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::Superclass
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:47
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:48
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::InputImageIndexType
InputImageType::IndexType InputImageIndexType
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:64
otbUnaryFunctorWithIndexWithOutputSizeImageFilter.hxx
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:67
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::OutputImagePixelType
OutputImageType::PixelType OutputImagePixelType
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:68
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter
Implements neighborhood-wise generic operation on image.
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:42
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::GetFunctor
FunctorType & GetFunctor()
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:76
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:49
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::SetFunctor
void SetFunctor(const FunctorType &functor)
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:98
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::GetFunctor
const FunctorType & GetFunctor() const
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:87
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::m_Functor
FunctorType m_Functor
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:158
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::OutputImageType
Superclass::OutputImageType OutputImageType
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:65
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::IteratorType
itk::ImageRegionConstIteratorWithIndex< TInputImage > IteratorType
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:105
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::OutputImagePointer
OutputImageType::Pointer OutputImagePointer
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:66
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::InputImageRegionType
InputImageType::RegionType InputImageRegionType
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:61
otb::UnaryFunctorWithIndexWithOutputSizeImageFilter::FunctorType
TFunction FunctorType
Definition: otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h:55