ITK  5.4.0
Insight Toolkit
itkUnaryGeneratorImageFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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"
24
25#include <functional>
26
27namespace itk
28{
29
54template <typename TInputImage, typename TOutputImage>
55class ITK_TEMPLATE_EXPORT UnaryGeneratorImageFilter : public InPlaceImageFilter<TInputImage, TOutputImage>
56{
57public:
58 ITK_DISALLOW_COPY_AND_MOVE(UnaryGeneratorImageFilter);
59
65
67 itkNewMacro(Self);
68
70 itkOverrideGetNameOfClassMacro(UnaryGeneratorImageFilter);
71
72 using InputImageType = TInputImage;
75 using InputImagePixelType = typename InputImageType::PixelType;
76
77 using OutputImageType = TOutputImage;
80 using OutputImagePixelType = typename OutputImageType::PixelType;
81
84
85
86#if !defined(ITK_WRAPPING_PARSER)
91 void
92 SetFunctor(const std::function<ConstRefFunctionType> & f)
93 {
94 m_DynamicThreadedGenerateDataFunction = [this, f](const OutputImageRegionType & outputRegionForThread) {
95 return this->DynamicThreadedGenerateDataWithFunctor(f, outputRegionForThread);
96 };
99 this->Modified();
100 }
101 void
102 SetFunctor(const std::function<ValueFunctionType> & f)
103 {
104 m_DynamicThreadedGenerateDataFunction = [this, f](const OutputImageRegionType & outputRegionForThread) {
105 return this->DynamicThreadedGenerateDataWithFunctor(f, outputRegionForThread);
106 };
107
108 this->Modified();
109 }
110
111
116 void
118 {
119 m_DynamicThreadedGenerateDataFunction = [this, funcPointer](const OutputImageRegionType & outputRegionForThread) {
120 return this->DynamicThreadedGenerateDataWithFunctor(funcPointer, outputRegionForThread);
121 };
124 this->Modified();
125 }
126 void
128 {
129 m_DynamicThreadedGenerateDataFunction = [this, funcPointer](const OutputImageRegionType & outputRegionForThread) {
130 return this->DynamicThreadedGenerateDataWithFunctor(funcPointer, outputRegionForThread);
131 };
132
133 this->Modified();
134 }
135
136
144 template <typename TFunctor>
145 void
146 SetFunctor(const TFunctor & functor)
147 {
148 m_DynamicThreadedGenerateDataFunction = [this, functor](const OutputImageRegionType & outputRegionForThread) {
149 return this->DynamicThreadedGenerateDataWithFunctor(functor, outputRegionForThread);
150 };
153 this->Modified();
154 }
155#endif // !defined( ITK_WRAPPING_PARSER )
156
157protected:
159 ~UnaryGeneratorImageFilter() override = default;
160
170 void
172
173
183 template <typename TFunctor>
184 void
185 DynamicThreadedGenerateDataWithFunctor(const TFunctor &, const OutputImageRegionType & outputRegionForThread);
186 void
187 DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
190private:
191 std::function<void(const OutputImageRegionType &)> m_DynamicThreadedGenerateDataFunction{};
192};
193} // end namespace itk
194
195#ifndef ITK_MANUAL_INSTANTIATION
196# include "itkUnaryGeneratorImageFilter.hxx"
197#endif
198
199#endif
Base class for all process objects that output image data.
typename OutputImageType::PixelType OutputImagePixelType
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
typename OutputImageType::Pointer OutputImagePointer
typename InputImageType::Pointer InputImagePointer
typename InputImageType::PixelType InputImagePixelType
typename InputImageType::RegionType InputImageRegionType
Base class for filters that take an image as input and overwrite that image as the output.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Implements pixel-wise generic "operation" on one image.
OutputImagePixelType(InputImagePixelType) ValueFunctionType
void SetFunctor(const TFunctor &functor)
~UnaryGeneratorImageFilter() override=default
void SetFunctor(ConstRefFunctionType *funcPointer)
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
OutputImagePixelType(const InputImagePixelType &) ConstRefFunctionType
void GenerateOutputInformation() override
void SetFunctor(ValueFunctionType *funcPointer)
void SetFunctor(const std::function< ConstRefFunctionType > &f)
void SetFunctor(const std::function< ValueFunctionType > &f)
void DynamicThreadedGenerateDataWithFunctor(const TFunctor &, const OutputImageRegionType &outputRegionForThread)
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....