ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkUnaryFunctorImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkUnaryFunctorImageFilter_h
19 #define itkUnaryFunctorImageFilter_h
20 
21 #include "itkMath.h"
22 #include "itkInPlaceImageFilter.h"
24 
25 namespace itk
26 {
48 template< typename TInputImage, typename TOutputImage, typename TFunction >
49 class UnaryFunctorImageFilter:public InPlaceImageFilter< TInputImage, TOutputImage >
50 {
51 public:
57 
59  itkNewMacro(Self);
60 
63 
65  typedef TFunction FunctorType;
66 
67  typedef TInputImage InputImageType;
68  typedef typename InputImageType::ConstPointer InputImagePointer;
69  typedef typename InputImageType::RegionType InputImageRegionType;
70  typedef typename InputImageType::PixelType InputImagePixelType;
71 
72  typedef TOutputImage OutputImageType;
73  typedef typename OutputImageType::Pointer OutputImagePointer;
74  typedef typename OutputImageType::RegionType OutputImageRegionType;
75  typedef typename OutputImageType::PixelType OutputImagePixelType;
76 
82  const FunctorType & GetFunctor() const { return m_Functor; }
84 
91  void SetFunctor(const FunctorType & functor)
92  {
93  if ( m_Functor != functor )
94  {
95  m_Functor = functor;
96  this->Modified();
97  }
98  }
100 
101 protected:
104 
113  virtual void GenerateOutputInformation() ITK_OVERRIDE;
114 
125  void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
126  ThreadIdType threadId) ITK_OVERRIDE;
127 
128 private:
129  UnaryFunctorImageFilter(const Self &) ITK_DELETE_FUNCTION;
130  void operator=(const Self &) ITK_DELETE_FUNCTION;
131 
133 };
134 } // end namespace itk
135 
136 #ifndef ITK_MANUAL_INSTANTIATION
137 #include "itkUnaryFunctorImageFilter.hxx"
138 #endif
139 
140 #endif
InputImageType::ConstPointer InputImagePointer
Light weight base class for most itk classes.
InputImageType::RegionType InputImageRegionType
InPlaceImageFilter< TInputImage, TOutputImage > Superclass
OutputImageType::Pointer OutputImagePointer
OutputImageType::PixelType OutputImagePixelType
const FunctorType & GetFunctor() const
InputImageType::PixelType InputImagePixelType
virtual void Modified() const
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId) override
Implements pixel-wise generic operation on one image.
OutputImageType::RegionType OutputImageRegionType
Base class for filters that take an image as input and overwrite that image as the output...
SmartPointer< const Self > ConstPointer
void SetFunctor(const FunctorType &functor)
virtual void GenerateOutputInformation() override