ITK  5.3.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  * 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 itkTernaryGeneratorImageFilter_h
19 #define itkTernaryGeneratorImageFilter_h
20 
21 #include "itkInPlaceImageFilter.h"
24 
25 #include <functional>
26 
27 namespace itk
28 {
53 template <typename TInputImage1, typename TInputImage2, typename TInputImage3, typename TOutputImage>
54 class ITK_TEMPLATE_EXPORT TernaryGeneratorImageFilter : public InPlaceImageFilter<TInputImage1, TOutputImage>
55 {
56 public:
57  ITK_DISALLOW_COPY_AND_MOVE(TernaryGeneratorImageFilter);
58 
64 
66  itkNewMacro(Self);
67 
70 
72  using Input1ImageType = TInputImage1;
73  using Input1ImagePointer = typename Input1ImageType::ConstPointer;
75  using Input1ImagePixelType = typename Input1ImageType::PixelType;
77 
78  using Input2ImageType = TInputImage2;
79  using Input2ImagePointer = typename Input2ImageType::ConstPointer;
81  using Input2ImagePixelType = typename Input2ImageType::PixelType;
83 
84  using Input3ImageType = TInputImage3;
85  using Input3ImagePointer = typename Input3ImageType::ConstPointer;
87  using Input3ImagePixelType = typename Input3ImageType::PixelType;
89 
90  using OutputImageType = TOutputImage;
91  using OutputImagePointer = typename OutputImageType::Pointer;
93  using OutputImagePixelType = typename OutputImageType::PixelType;
94 
95 
97  const Input2ImagePixelType &,
99 
101  const Input2ImagePixelType &,
104 
106  void
107  SetInput1(const TInputImage1 * image1);
108  virtual void
109  SetInput1(const DecoratedInput1ImagePixelType * input1);
110  virtual void
111  SetInput1(const Input1ImagePixelType & input1);
113 
115  virtual void
116  SetConstant1(const Input1ImagePixelType & input1);
117 
120  virtual const Input1ImagePixelType &
121  GetConstant1() const;
122 
124  void
125  SetInput2(const TInputImage2 * image2);
126  virtual void
127  SetInput2(const DecoratedInput2ImagePixelType * input2);
128  virtual void
129  SetInput2(const Input2ImagePixelType & input2);
131 
133  virtual void
134  SetConstant2(const Input2ImagePixelType & input2);
135 
138  virtual const Input2ImagePixelType &
139  GetConstant2() const;
140 
142  void
143  SetInput3(const TInputImage3 * image3);
144  virtual void
145  SetInput3(const DecoratedInput3ImagePixelType * input3);
146  virtual void
147  SetInput3(const Input3ImagePixelType & input3);
149 
151  virtual void
152  SetConstant3(const Input3ImagePixelType & input3);
153 
156  virtual const Input3ImagePixelType &
157  GetConstant3() const;
158 
159 
160 #if !defined(ITK_WRAPPING_PARSER)
161 
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 
240 #ifdef ITK_USE_CONCEPT_CHECKING
241  // Begin concept checking
245  // End concept checking
246 #endif
247 
248 protected:
250  ~TernaryGeneratorImageFilter() override = default;
251 
252  void
253  GenerateOutputInformation() override;
254 
265  template <typename TFunctor>
266  void
267  DynamicThreadedGenerateDataWithFunctor(const TFunctor &, const OutputImageRegionType & outputRegionForThread);
268  void
269  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
271 
272 
273 private:
275 };
276 } // end namespace itk
277 
278 #ifndef ITK_MANUAL_INSTANTIATION
279 # include "itkTernaryGeneratorImageFilter.hxx"
280 #endif
281 
282 #endif
itk::TernaryGeneratorImageFilter::SetFunctor
void SetFunctor(const std::function< ValueFunctionType > &f)
Definition: itkTernaryGeneratorImageFilter.h:177
itk::SimpleDataObjectDecorator
Decorates any "simple" data type (data types without smart pointers) with a DataObject API.
Definition: itkSimpleDataObjectDecorator.h:66
itk::ImageSource< TImage >::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itk::InPlaceImageFilter
Base class for filters that take an image as input and overwrite that image as the output.
Definition: itkInPlaceImageFilter.h:77
itk::TernaryGeneratorImageFilter::m_DynamicThreadedGenerateDataFunction
std::function< void(const OutputImageRegionType &)> m_DynamicThreadedGenerateDataFunction
Definition: itkTernaryGeneratorImageFilter.h:274
itk::TernaryGeneratorImageFilter< TMask, TImage, TImage, TImage >::Input3ImagePixelType
typename Input3ImageType::PixelType Input3ImagePixelType
Definition: itkTernaryGeneratorImageFilter.h:87
itk::SmartPointer< Self >
itkImageRegionIteratorWithIndex.h
itk::TernaryGeneratorImageFilter< TMask, TImage, TImage, TImage >::FunctionType
OutputImagePixelType(*)(const Input1ImagePixelType &, const Input2ImagePixelType &, const Input3ImagePixelType &) FunctionType
Definition: itkTernaryGeneratorImageFilter.h:98
itk::TernaryGeneratorImageFilter< TMask, TImage, TImage, TImage >::Input3ImageType
TImage Input3ImageType
Definition: itkTernaryGeneratorImageFilter.h:84
itk::TernaryGeneratorImageFilter< TMask, TImage, TImage, TImage >::Input3ImageRegionType
typename Input3ImageType::RegionType Input3ImageRegionType
Definition: itkTernaryGeneratorImageFilter.h:86
itk::Concept::SameDimension
Definition: itkConceptChecking.h:694
itk::TernaryGeneratorImageFilter< TMask, TImage, TImage, TImage >::ValueFunctionType
OutputImagePixelType(Input1ImagePixelType, Input2ImagePixelType, Input3ImagePixelType) ValueFunctionType
Definition: itkTernaryGeneratorImageFilter.h:103
itk::TernaryGeneratorImageFilter< TMask, TImage, TImage, TImage >::Input2ImageRegionType
typename Input2ImageType::RegionType Input2ImageRegionType
Definition: itkTernaryGeneratorImageFilter.h:80
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::TernaryGeneratorImageFilter
Implements pixel-wise generic operation of three images or images with constants.
Definition: itkTernaryGeneratorImageFilter.h:54
itk::TernaryGeneratorImageFilter< TMask, TImage, TImage, TImage >::ConstRefFunctionType
OutputImagePixelType(const Input1ImagePixelType &, const Input2ImagePixelType &, const Input3ImagePixelType &) ConstRefFunctionType
Definition: itkTernaryGeneratorImageFilter.h:102
itk::TernaryGeneratorImageFilter::SetFunctor
void SetFunctor(const TFunctor &functor)
Definition: itkTernaryGeneratorImageFilter.h:222
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::TernaryGeneratorImageFilter::SetFunctor
void SetFunctor(const std::function< ConstRefFunctionType > &f)
Definition: itkTernaryGeneratorImageFilter.h:166
itk::TernaryGeneratorImageFilter< TMask, TImage, TImage, TImage >::Input2ImageType
TImage Input2ImageType
Definition: itkTernaryGeneratorImageFilter.h:78
itk::TernaryGeneratorImageFilter< TMask, TImage, TImage, TImage >::Input1ImageType
TMask Input1ImageType
Definition: itkTernaryGeneratorImageFilter.h:72
itk::TernaryGeneratorImageFilter< TMask, TImage, TImage, TImage >::Input1ImagePointer
typename Input1ImageType::ConstPointer Input1ImagePointer
Definition: itkTernaryGeneratorImageFilter.h:73
itk::TernaryGeneratorImageFilter< TMask, TImage, TImage, TImage >::Input2ImagePixelType
typename Input2ImageType::PixelType Input2ImagePixelType
Definition: itkTernaryGeneratorImageFilter.h:81
itk::ImageSource< TImage >::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk::TernaryGeneratorImageFilter< TMask, TImage, TImage, TImage >::Input3ImagePointer
typename Input3ImageType::ConstPointer Input3ImagePointer
Definition: itkTernaryGeneratorImageFilter.h:85
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk::TernaryGeneratorImageFilter< TMask, TImage, TImage, TImage >::Input1ImagePixelType
typename Input1ImageType::PixelType Input1ImagePixelType
Definition: itkTernaryGeneratorImageFilter.h:75
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::TernaryGeneratorImageFilter< TMask, TImage, TImage, TImage >::Input2ImagePointer
typename Input2ImageType::ConstPointer Input2ImagePointer
Definition: itkTernaryGeneratorImageFilter.h:79
itkInPlaceImageFilter.h
itk::ImageSource< TImage >::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkImageSource.h:93
itk::TernaryGeneratorImageFilter::SetFunctor
void SetFunctor(ConstRefFunctionType *funcPointer)
Definition: itkTernaryGeneratorImageFilter.h:192
itkSimpleDataObjectDecorator.h
itk::TernaryGeneratorImageFilter::SetFunctor
void SetFunctor(ValueFunctionType *funcPointer)
Definition: itkTernaryGeneratorImageFilter.h:202
itk::TernaryGeneratorImageFilter< TMask, TImage, TImage, TImage >::Input1ImageRegionType
typename Input1ImageType::RegionType Input1ImageRegionType
Definition: itkTernaryGeneratorImageFilter.h:74
itk::ImageSource< TImage >::OutputImageType
TImage OutputImageType
Definition: itkImageSource.h:90