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
23
24#include <functional>
25
26namespace itk
27{
52template <typename TInputImage1, typename TInputImage2, typename TInputImage3, typename TOutputImage>
53class ITK_TEMPLATE_EXPORT TernaryGeneratorImageFilter : public InPlaceImageFilter<TInputImage1, TOutputImage>
54{
55public:
56 ITK_DISALLOW_COPY_AND_MOVE(TernaryGeneratorImageFilter);
57
63
65 itkNewMacro(Self);
66
68 itkOverrideGetNameOfClassMacro(TernaryGeneratorImageFilter);
69
71 using Input1ImageType = TInputImage1;
72 using Input1ImagePointer = typename Input1ImageType::ConstPointer;
73 using Input1ImageRegionType = typename Input1ImageType::RegionType;
74 using Input1ImagePixelType = typename Input1ImageType::PixelType;
76
77 using Input2ImageType = TInputImage2;
78 using Input2ImagePointer = typename Input2ImageType::ConstPointer;
79 using Input2ImageRegionType = typename Input2ImageType::RegionType;
80 using Input2ImagePixelType = typename Input2ImageType::PixelType;
82
83 using Input3ImageType = TInputImage3;
84 using Input3ImagePointer = typename Input3ImageType::ConstPointer;
85 using Input3ImageRegionType = typename Input3ImageType::RegionType;
86 using Input3ImagePixelType = typename Input3ImageType::PixelType;
88
89 using OutputImageType = TOutputImage;
90 using OutputImagePointer = typename OutputImageType::Pointer;
91 using OutputImageRegionType = typename OutputImageType::RegionType;
92 using OutputImagePixelType = typename OutputImageType::PixelType;
93
94
97 const Input3ImagePixelType &);
98
100 const Input2ImagePixelType &,
101 const Input3ImagePixelType &);
103
106 void
107 SetInput1(const TInputImage1 * image1);
108 virtual void
110 virtual void
114 virtual void
116
119 virtual const Input1ImagePixelType &
121
124 void
125 SetInput2(const TInputImage2 * image2);
126 virtual void
128 virtual void
132 virtual void
134
137 virtual const Input2ImagePixelType &
139
142 void
143 SetInput3(const TInputImage3 * image3);
144 virtual void
146 virtual void
150 virtual void
152
155 virtual const Input3ImagePixelType &
157
158
159#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 };
172
173 this->Modified();
174 }
175 void
176 SetFunctor(const std::function<ValueFunctionType> & f)
177 {
178 // the capture creates a copy of f
179 m_DynamicThreadedGenerateDataFunction = [this, f](const OutputImageRegionType & outputRegionForThread) {
180 return this->DynamicThreadedGenerateDataWithFunctor(f, outputRegionForThread);
181 };
182
183 this->Modified();
184 }
185
186
192 void
194 {
195 m_DynamicThreadedGenerateDataFunction = [this, funcPointer](const OutputImageRegionType & outputRegionForThread) {
196 return this->DynamicThreadedGenerateDataWithFunctor(funcPointer, outputRegionForThread);
197 };
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
212
221 template <typename TFunctor>
222 void
223 SetFunctor(const TFunctor & functor)
224 {
225 // the capture creates a copy of the functor
226 m_DynamicThreadedGenerateDataFunction = [this, functor](const OutputImageRegionType & outputRegionForThread) {
227 return this->DynamicThreadedGenerateDataWithFunctor(functor, outputRegionForThread);
228 };
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
262 template <typename TFunctor>
263 void
264 DynamicThreadedGenerateDataWithFunctor(const TFunctor &, const OutputImageRegionType & outputRegionForThread);
265 void
266 DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
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....