OTB  6.1.0
Orfeo Toolbox
otbFunctionToImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1999-2011 Insight Software Consortium
3  * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
4  *
5  * This file is part of Orfeo Toolbox
6  *
7  * https://www.orfeo-toolbox.org/
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 #ifndef otbFunctionToImageFilter_h
23 #define otbFunctionToImageFilter_h
24 
25 #include "itkInPlaceImageFilter.h"
26 #include "itkImageFunction.h"
27 #include "itkImageRegionIterator.h"
28 #include "itkSize.h"
29 #include "itkSpatialFunction.h"
30 
31 namespace otb
32 {
33 
54 template <class TInputImage, class TOutputImage, class TFunction>
55 class ITK_EXPORT FunctionToImageFilter :
56  public itk::InPlaceImageFilter<TInputImage, TOutputImage>
57 {
58 public:
64 
66  itkNewMacro(Self);
67 
69  itkTypeMacro(FunctionToImageFilter, InPlaceImageFilter);
70 
74  typedef TInputImage InputImageType;
75  typedef typename InputImageType::ConstPointer InputImagePointer;
76  typedef typename InputImageType::RegionType InputImageRegionType;
77  typedef typename InputImageType::PixelType InputImagePixelType;
78  typedef TOutputImage OutputImageType;
79  typedef typename OutputImageType::Pointer OutputImagePointer;
80  typedef typename OutputImageType::RegionType OutputImageRegionType;
81  typedef typename OutputImageType::PixelType OutputImagePixelType;
82 
84  typedef TFunction FunctionType;
85  typedef typename FunctionType::Pointer FunctionPointer;
88 
90  void SetFunction(FunctionType* PixelFunction)
91  {
92  m_PixelFunction = PixelFunction;
93  this->Modified();
94  }
96  {
97  return m_PixelFunction;
98  }
99  FunctionType const* GetFunction() const
100  {
101  return m_PixelFunction;
102  }
104 
105 
107  itkStaticConstMacro(InputImageDimension, unsigned int,
108  TInputImage::ImageDimension);
109  itkStaticConstMacro(OutputImageDimension, unsigned int,
110  TOutputImage::ImageDimension);
112 
113 protected:
115  ~FunctionToImageFilter() ITK_OVERRIDE {}
116 
119  void BeforeThreadedGenerateData() ITK_OVERRIDE;
120 
131  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
132  itk::ThreadIdType threadId) ITK_OVERRIDE;
133 
134 private:
135  FunctionToImageFilter(const Self &); //purposely not implemented
136  void operator =(const Self&); //purposely not implemented
137 
139  FunctionPointer m_PixelFunction;
140 };
141 
142 } // end namespace otb
143 
144 #ifndef OTB_MANUAL_INSTANTIATION
146 #endif
147 
148 #endif
OutputImageType::Pointer OutputImagePointer
FunctionType::Pointer FunctionPointer
FunctionType const * GetFunction() const
InputImageType::RegionType InputImageRegionType
void SetFunction(FunctionType *PixelFunction)
InputImageType::ConstPointer InputImagePointer
FunctionType::OutputType FunctionValueType
Evaluates a ImageFunction onto a source image.
itk::SmartPointer< Self > Pointer
unsigned int ThreadIdType
OutputImageType::RegionType OutputImageRegionType
OutputImageType::PixelType OutputImagePixelType
InputImageType::PixelType InputImagePixelType
itk::SmartPointer< const Self > ConstPointer
itk::InPlaceImageFilter< TInputImage, TOutputImage > Superclass
Calculate the backscatter for the given pixel.
FunctionType::InputType FunctionPositionType