ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkUnaryGeneratorImageFilter.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 itkUnaryGeneratorImageFilter_h
19 #define itkUnaryGeneratorImageFilter_h
20 
21 #include "itkMath.h"
22 #include "itkInPlaceImageFilter.h"
24 
25 #include <functional>
26 
27 namespace itk
28 {
29 
54 template< typename TInputImage, typename TOutputImage >
56  public InPlaceImageFilter< TInputImage, TOutputImage >
57 {
58 public:
59  ITK_DISALLOW_COPY_AND_ASSIGN(UnaryGeneratorImageFilter);
60 
66 
68  itkNewMacro(Self);
69 
72 
73  using InputImageType = TInputImage;
74  using InputImagePointer = typename InputImageType::ConstPointer;
76  using InputImagePixelType = typename InputImageType::PixelType;
77 
78  using OutputImageType = TOutputImage;
79  using OutputImagePointer = typename OutputImageType::Pointer;
81  using OutputImagePixelType = typename OutputImageType::PixelType;
82 
85 
86 
87 #if !defined( ITK_WRAPPING_PARSER )
88 
92  void SetFunctor( const std::function<ConstRefFunctionType> &f)
93  {
94  m_DynamicThreadedGenerateDataFunction = [this, f](const OutputImageRegionType & outputRegionForThread)
95  { return this->DynamicThreadedGenerateDataWithFunctor(f, outputRegionForThread); };
96 
97  this->Modified();
98  }
99  void SetFunctor( const std::function<ValueFunctionType> &f)
100  {
101  m_DynamicThreadedGenerateDataFunction = [this, f](const OutputImageRegionType & outputRegionForThread)
102  { return this->DynamicThreadedGenerateDataWithFunctor(f, outputRegionForThread); };
103 
104  this->Modified();
105  }
106 
107 
112  void SetFunctor( ConstRefFunctionType *funcPointer)
113  {
114  m_DynamicThreadedGenerateDataFunction = [this, funcPointer](const OutputImageRegionType & outputRegionForThread)
115  { return this->DynamicThreadedGenerateDataWithFunctor(funcPointer, outputRegionForThread); };
116 
117  this->Modified();
118  }
119  void SetFunctor( ValueFunctionType *funcPointer)
120  {
121  m_DynamicThreadedGenerateDataFunction = [this, funcPointer](const OutputImageRegionType & outputRegionForThread)
122  { return this->DynamicThreadedGenerateDataWithFunctor(funcPointer, outputRegionForThread); };
123 
124  this->Modified();
125  }
126 
127 
135  template <typename TFunctor>
136  void SetFunctor( const TFunctor & functor)
137  {
138  m_DynamicThreadedGenerateDataFunction = [this, functor](const OutputImageRegionType & outputRegionForThread)
139  { return this->DynamicThreadedGenerateDataWithFunctor(functor, outputRegionForThread); };
140 
141  this->Modified();
142  }
143 #endif // !defined( ITK_WRAPPING_PARSER )
144 
145 protected:
147  ~UnaryGeneratorImageFilter() override = default;
148 
157  void GenerateOutputInformation() override;
158 
159 
169  template <typename TFunctor>
170  void DynamicThreadedGenerateDataWithFunctor(const TFunctor &, const OutputImageRegionType & outputRegionForThread);
171  void DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
173 
174 private:
175  std::function<void(const OutputImageRegionType &)> m_DynamicThreadedGenerateDataFunction;
176 };
177 } // end namespace itk
178 
179 #ifndef ITK_MANUAL_INSTANTIATION
180 #include "itkUnaryGeneratorImageFilter.hxx"
181 #endif
182 
183 #endif
typename OutputImageType::Pointer OutputImagePointer
~UnaryGeneratorImageFilter() override=default
void SetFunctor(ConstRefFunctionType *funcPointer)
void SetFunctor(const std::function< ValueFunctionType > &f)
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
typename OutputImageType::RegionType OutputImageRegionType
Base class for all process objects that output image data.
void SetFunctor(const TFunctor &functor)
void SetFunctor(const std::function< ConstRefFunctionType > &f)
typename OutputImageType::PixelType OutputImagePixelType
typename InputImageType::PixelType InputImagePixelType
typename InputImageType::Pointer InputImagePointer
void GenerateOutputInformation() override
OutputImagePixelType(const InputImagePixelType &) ConstRefFunctionType
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
std::function< void(const OutputImageRegionType &)> m_DynamicThreadedGenerateDataFunction
virtual void Modified() const
OutputImagePixelType(InputImagePixelType) ValueFunctionType
void DynamicThreadedGenerateDataWithFunctor(const TFunctor &, const OutputImageRegionType &outputRegionForThread)
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
typename InputImageType::RegionType InputImageRegionType
typename OutputImageType::PixelType OutputImagePixelType
void SetFunctor(ValueFunctionType *funcPointer)
Base class for filters that take an image as input and overwrite that image as the output...
Implements pixel-wise generic &quot;operation&quot; on one image.