ITK  5.4.0
Insight Toolkit
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;
75 using Input1ImagePixelType = typename Input1ImageType::PixelType;
77
78 using Input2ImageType = TInputImage2;
81 using Input2ImagePixelType = typename Input2ImageType::PixelType;
83
84 using Input3ImageType = TInputImage3;
87 using Input3ImagePixelType = typename Input3ImageType::PixelType;
89
90 using OutputImageType = TOutputImage;
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
115 virtual void
117
120 virtual const Input1ImagePixelType &
122
124 void
125 SetInput2(const TInputImage2 * image2);
126 virtual void
128 virtual void
133 virtual void
135
138 virtual const Input2ImagePixelType &
140
142 void
143 SetInput3(const TInputImage3 * image3);
144 virtual void
146 virtual void
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 };
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 };
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 };
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
240#ifdef ITK_USE_CONCEPT_CHECKING
241 // Begin concept checking
245 // End concept checking
246#endif
247
248protected:
250 ~TernaryGeneratorImageFilter() override = default;
251
252 void
254
265 template <typename TFunctor>
266 void
267 DynamicThreadedGenerateDataWithFunctor(const TFunctor &, const OutputImageRegionType & outputRegionForThread);
268 void
269 DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
273private:
274 std::function<void(const OutputImageRegionType &)> m_DynamicThreadedGenerateDataFunction{};
275};
276} // end namespace itk
277
278#ifndef ITK_MANUAL_INSTANTIATION
279# include "itkTernaryGeneratorImageFilter.hxx"
280#endif
281
282#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
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...
Decorates any "simple" data type (data types without smart pointers) with a DataObject API.
Implements pixel-wise generic operation of three images or images with constants.
void SetInput3(const TInputImage3 *image3)
virtual void SetInput3(const Input3ImagePixelType &input3)
virtual void SetConstant3(const Input3ImagePixelType &input3)
virtual void SetInput2(const DecoratedInput2ImagePixelType *input2)
~TernaryGeneratorImageFilter() override=default
typename Input3ImageType::RegionType Input3ImageRegionType
OutputImagePixelType(const Input1ImagePixelType &, const Input2ImagePixelType &, const Input3ImagePixelType &) ConstRefFunctionType
void GenerateOutputInformation() override
typename Input3ImageType::ConstPointer Input3ImagePointer
void SetFunctor(ValueFunctionType *funcPointer)
typename Input2ImageType::PixelType Input2ImagePixelType
virtual void SetInput1(const Input1ImagePixelType &input1)
typename Input2ImageType::ConstPointer Input2ImagePointer
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
OutputImagePixelType(*)(const Input1ImagePixelType &, const Input2ImagePixelType &, const Input3ImagePixelType &) FunctionType
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
virtual void SetInput3(const DecoratedInput3ImagePixelType *input3)
void SetFunctor(const std::function< ValueFunctionType > &f)
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....