ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkTernaryGeneratorImageFilter.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 itkTernaryGeneratorImageFilter_h
19#define itkTernaryGeneratorImageFilter_h
20
24
25#include <functional>
26
27namespace itk
28{
53template <typename TInputImage1, typename TInputImage2, typename TInputImage3, typename TOutputImage>
54class ITK_TEMPLATE_EXPORT TernaryGeneratorImageFilter : public InPlaceImageFilter<TInputImage1, TOutputImage>
55{
56public:
57 ITK_DISALLOW_COPY_AND_MOVE(TernaryGeneratorImageFilter);
58
64
66 itkNewMacro(Self);
67
69 itkOverrideGetNameOfClassMacro(TernaryGeneratorImageFilter);
70
72 using Input1ImageType = TInputImage1;
73 using Input1ImagePointer = typename Input1ImageType::ConstPointer;
74 using Input1ImageRegionType = typename Input1ImageType::RegionType;
75 using Input1ImagePixelType = typename Input1ImageType::PixelType;
77
78 using Input2ImageType = TInputImage2;
79 using Input2ImagePointer = typename Input2ImageType::ConstPointer;
80 using Input2ImageRegionType = typename Input2ImageType::RegionType;
81 using Input2ImagePixelType = typename Input2ImageType::PixelType;
83
84 using Input3ImageType = TInputImage3;
85 using Input3ImagePointer = typename Input3ImageType::ConstPointer;
86 using Input3ImageRegionType = typename Input3ImageType::RegionType;
87 using Input3ImagePixelType = typename Input3ImageType::PixelType;
89
90 using OutputImageType = TOutputImage;
91 using OutputImagePointer = typename OutputImageType::Pointer;
92 using OutputImageRegionType = typename OutputImageType::RegionType;
93 using OutputImagePixelType = typename OutputImageType::PixelType;
94
95
98 const Input3ImagePixelType &);
99
101 const Input2ImagePixelType &,
102 const Input3ImagePixelType &);
104
106 void
107 SetInput1(const TInputImage1 * image1);
108 virtual void
110 virtual void
113
115 virtual void
117
120 virtual const Input1ImagePixelType &
122
124 void
125 SetInput2(const TInputImage2 * image2);
126 virtual void
128 virtual void
131
133 virtual void
135
138 virtual const Input2ImagePixelType &
140
142 void
143 SetInput3(const TInputImage3 * image3);
144 virtual void
146 virtual void
149
151 virtual void
153
156 virtual const Input3ImagePixelType &
158
159
160#if !defined(ITK_WRAPPING_PARSER)
165 void
166 SetFunctor(const std::function<ConstRefFunctionType> & f)
167 {
168 // the closure creates a copy of f
169 m_DynamicThreadedGenerateDataFunction = [this, f](const OutputImageRegionType & outputRegionForThread) {
170 return this->DynamicThreadedGenerateDataWithFunctor(f, outputRegionForThread);
171 };
173
174 this->Modified();
175 }
176 void
177 SetFunctor(const std::function<ValueFunctionType> & f)
178 {
179 // the capture creates a copy of f
180 m_DynamicThreadedGenerateDataFunction = [this, f](const OutputImageRegionType & outputRegionForThread) {
181 return this->DynamicThreadedGenerateDataWithFunctor(f, outputRegionForThread);
182 };
183
184 this->Modified();
185 }
186
191 void
193 {
194 m_DynamicThreadedGenerateDataFunction = [this, funcPointer](const OutputImageRegionType & outputRegionForThread) {
195 return this->DynamicThreadedGenerateDataWithFunctor(funcPointer, outputRegionForThread);
196 };
198
199 this->Modified();
200 }
201 void
203 {
204 m_DynamicThreadedGenerateDataFunction = [this, funcPointer](const OutputImageRegionType & outputRegionForThread) {
205 return this->DynamicThreadedGenerateDataWithFunctor(funcPointer, outputRegionForThread);
206 };
207
208 this->Modified();
209 }
210
211
220 template <typename TFunctor>
221 void
222 SetFunctor(const TFunctor & functor)
223 {
224 // the capture creates a copy of the functor
225 m_DynamicThreadedGenerateDataFunction = [this, functor](const OutputImageRegionType & outputRegionForThread) {
226 return this->DynamicThreadedGenerateDataWithFunctor(functor, outputRegionForThread);
227 };
229
230 this->Modified();
231 }
232#endif // !defined( ITK_WRAPPING_PARSER )
233
235 static constexpr unsigned int Input1ImageDimension = TInputImage1::ImageDimension;
236 static constexpr unsigned int Input2ImageDimension = TInputImage2::ImageDimension;
237 static constexpr unsigned int Input3ImageDimension = TInputImage3::ImageDimension;
238 static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
239
243
244protected:
246 ~TernaryGeneratorImageFilter() override = default;
247
248 void
250
261 template <typename TFunctor>
262 void
263 DynamicThreadedGenerateDataWithFunctor(const TFunctor &, const OutputImageRegionType & outputRegionForThread);
264 void
265 DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
267
268
269private:
271};
272} // end namespace itk
273
274#ifndef ITK_MANUAL_INSTANTIATION
275# include "itkTernaryGeneratorImageFilter.hxx"
276#endif
277
278#endif
virtual void Modified() const
Decorates any "simple" data type (data types without smart pointers) with a DataObject API.
Implements transparent reference counting.
void SetInput3(const TInputImage3 *image3)
typename OutputImageType::RegionType OutputImageRegionType
virtual void SetInput3(const Input3ImagePixelType &input3)
virtual void SetConstant3(const Input3ImagePixelType &input3)
virtual void SetInput2(const DecoratedInput2ImagePixelType *input2)
std::function< void(const OutputImageRegionType &)> m_DynamicThreadedGenerateDataFunction
~TernaryGeneratorImageFilter() override=default
typename Input3ImageType::RegionType Input3ImageRegionType
void GenerateOutputInformation() override
typename Input3ImageType::ConstPointer Input3ImagePointer
void SetFunctor(ValueFunctionType *funcPointer)
typename Input2ImageType::PixelType Input2ImagePixelType
virtual void SetInput1(const Input1ImagePixelType &input1)
SimpleDataObjectDecorator< Input3ImagePixelType > DecoratedInput3ImagePixelType
SimpleDataObjectDecorator< Input2ImagePixelType > DecoratedInput2ImagePixelType
typename Input2ImageType::ConstPointer Input2ImagePointer
OutputImagePixelType(*)(const Input1ImagePixelType &, const Input2ImagePixelType &, const Input3ImagePixelType &) FunctionType
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
void SetFunctor(const std::function< ConstRefFunctionType > &f)
typename Input1ImageType::PixelType Input1ImagePixelType
virtual const Input3ImagePixelType & GetConstant3() const
typename Input1ImageType::ConstPointer Input1ImagePointer
void SetFunctor(ConstRefFunctionType *funcPointer)
virtual const Input1ImagePixelType & GetConstant1() const
typename Input3ImageType::PixelType Input3ImagePixelType
void SetInput2(const TInputImage2 *image2)
void SetInput1(const TInputImage1 *image1)
virtual const Input2ImagePixelType & GetConstant2() const
SimpleDataObjectDecorator< Input1ImagePixelType > DecoratedInput1ImagePixelType
virtual void SetInput1(const DecoratedInput1ImagePixelType *input1)
virtual void SetConstant2(const Input2ImagePixelType &input2)
virtual void SetConstant1(const Input1ImagePixelType &input1)
typename Input1ImageType::RegionType Input1ImageRegionType
OutputImagePixelType(Input1ImagePixelType, Input2ImagePixelType, Input3ImagePixelType) ValueFunctionType
void DynamicThreadedGenerateDataWithFunctor(const TFunctor &, const OutputImageRegionType &outputRegionForThread)
virtual void SetInput2(const Input2ImagePixelType &input2)
typename Input2ImageType::RegionType Input2ImageRegionType
typename OutputImageType::Pointer OutputImagePointer
InPlaceImageFilter< TInputImage1, TOutputImage > Superclass
typename OutputImageType::PixelType OutputImagePixelType
virtual void SetInput3(const DecoratedInput3ImagePixelType *input3)
OutputImagePixelType(const Input1ImagePixelType &, const Input2ImagePixelType &, const Input3ImagePixelType &) ConstRefFunctionType
void SetFunctor(const std::function< ValueFunctionType > &f)
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....