OTB  5.9.0
Orfeo Toolbox
otbFunctionToImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12  Some parts of this code are derived from ITK. See ITKCopyright.txt
13  for details.
14 
15 
16  This software is distributed WITHOUT ANY WARRANTY; without even
17  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18  PURPOSE. See the above copyright notices for more information.
19 
20 =========================================================================*/
21 #ifndef otbFunctionToImageFilter_h
22 #define otbFunctionToImageFilter_h
23 
24 #include "itkInPlaceImageFilter.h"
25 #include "itkImageFunction.h"
26 #include "itkImageRegionIterator.h"
27 #include "itkSize.h"
28 #include "itkSpatialFunction.h"
29 
30 namespace otb
31 {
32 
53 template <class TInputImage, class TOutputImage, class TFunction>
54 class ITK_EXPORT FunctionToImageFilter :
55  public itk::InPlaceImageFilter<TInputImage, TOutputImage>
56 {
57 public:
63 
65  itkNewMacro(Self);
66 
68  itkTypeMacro(FunctionToImageFilter, InPlaceImageFilter);
69 
73  typedef TInputImage InputImageType;
74  typedef typename InputImageType::ConstPointer InputImagePointer;
75  typedef typename InputImageType::RegionType InputImageRegionType;
76  typedef typename InputImageType::PixelType InputImagePixelType;
77  typedef TOutputImage OutputImageType;
78  typedef typename OutputImageType::Pointer OutputImagePointer;
79  typedef typename OutputImageType::RegionType OutputImageRegionType;
80  typedef typename OutputImageType::PixelType OutputImagePixelType;
81 
83  typedef TFunction FunctionType;
84  typedef typename FunctionType::Pointer FunctionPointer;
87 
89  void SetFunction(FunctionType* PixelFunction)
90  {
91  m_PixelFunction = PixelFunction;
92  this->Modified();
93  }
95  {
96  return m_PixelFunction;
97  }
98  FunctionType const* GetFunction() const
99  {
100  return m_PixelFunction;
101  }
103 
104 
106  itkStaticConstMacro(InputImageDimension, unsigned int,
107  TInputImage::ImageDimension);
108  itkStaticConstMacro(OutputImageDimension, unsigned int,
109  TOutputImage::ImageDimension);
111 
112 protected:
114  ~FunctionToImageFilter() ITK_OVERRIDE {}
115 
118  void BeforeThreadedGenerateData() ITK_OVERRIDE;
119 
130  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
131  itk::ThreadIdType threadId) ITK_OVERRIDE;
132 
133 private:
134  FunctionToImageFilter(const Self &); //purposely not implemented
135  void operator =(const Self&); //purposely not implemented
136 
138  FunctionPointer m_PixelFunction;
139 };
140 
141 } // end namespace otb
142 
143 #ifndef OTB_MANUAL_INSTANTIATION
145 #endif
146 
147 #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