ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkBinaryFunctorImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 itkBinaryFunctorImageFilter_h
19 #define itkBinaryFunctorImageFilter_h
20 
21 #include "itkInPlaceImageFilter.h"
23 
24 namespace itk
25 {
50 template< typename TInputImage1, typename TInputImage2,
51  typename TOutputImage, typename TFunction >
52 class ITK_TEMPLATE_EXPORT BinaryFunctorImageFilter:
53  public InPlaceImageFilter< TInputImage1, TOutputImage >
54 {
55 public:
56  ITK_DISALLOW_COPY_AND_ASSIGN(BinaryFunctorImageFilter);
57 
63 
65  itkNewMacro(Self);
66 
69 
71  using FunctorType = TFunction;
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 OutputImageType = TOutputImage;
85  using OutputImagePointer = typename OutputImageType::Pointer;
87  using OutputImagePixelType = typename OutputImageType::PixelType;
88 
90  virtual void SetInput1(const TInputImage1 *image1);
91  virtual void SetInput1(const DecoratedInput1ImagePixelType *input1);
92  virtual void SetInput1(const Input1ImagePixelType &input1);
94 
96  virtual void SetConstant1(const Input1ImagePixelType &input1);
97 
100  virtual const Input1ImagePixelType & GetConstant1() const;
101 
103  virtual void SetInput2(const TInputImage2 *image2);
104  virtual void SetInput2(const DecoratedInput2ImagePixelType *input2);
105  virtual void SetInput2(const Input2ImagePixelType &input2);
107 
109  virtual void SetConstant2(const Input2ImagePixelType &input2);
111  {
112  this->SetConstant2(ct);
113  }
115  {
116  return this->GetConstant2();
117  }
119 
122  virtual const Input2ImagePixelType & GetConstant2() const;
123 
128  FunctorType & GetFunctor() { return m_Functor; }
129 
134  const FunctorType & GetFunctor() const
135  {
136  return m_Functor;
137  }
138 
145  void SetFunctor(const FunctorType & functor)
146  {
147  if ( m_Functor != functor )
148  {
149  m_Functor = functor;
150  this->Modified();
151  }
152  }
154 
156  static constexpr unsigned int InputImage1Dimension = TInputImage1::ImageDimension;
157  static constexpr unsigned int InputImage2Dimension = TInputImage2::ImageDimension;
158  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
159 
160 #ifdef ITK_USE_CONCEPT_CHECKING
161  // Begin concept checking
162  itkConceptMacro( SameDimensionCheck1,
163  ( Concept::SameDimension< Self::InputImage1Dimension,
164  Self::InputImage2Dimension > ) );
165  itkConceptMacro( SameDimensionCheck2,
166  ( Concept::SameDimension< Self::InputImage1Dimension,
167  Self::OutputImageDimension > ) );
168  // End concept checking
169 #endif
170 
171 protected:
173  ~BinaryFunctorImageFilter() override = default;
174 
185  void DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
186 
187 
188  // Needed to take the image information from the 2nd input, if the first one is
189  // a simple decorated object.
190  void GenerateOutputInformation() override;
191 
192 private:
194 };
195 } // end namespace itk
196 
197 #ifndef ITK_MANUAL_INSTANTIATION
198 #include "itkBinaryFunctorImageFilter.hxx"
199 #endif
200 
201 #endif
void SetFunctor(const FunctorType &functor)
typename OutputImageType::Pointer OutputImagePointer
typename Input1ImageType::RegionType Input1ImageRegionType
const FunctorType & GetFunctor() const
typename Input2ImageType::ConstPointer Input2ImagePointer
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
typename Input2ImageType::PixelType Input2ImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
void SetConstant(Input2ImagePixelType ct)
typename Input1ImageType::ConstPointer Input1ImagePointer
Decorates any &quot;simple&quot; data type (data types without smart pointers) with a DataObject API...
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
typename Input1ImageType::PixelType Input1ImagePixelType
const Input2ImagePixelType & GetConstant() const
Base class for filters that take an image as input and overwrite that image as the output...
#define itkConceptMacro(name, concept)
typename Input2ImageType::RegionType Input2ImageRegionType
Implements pixel-wise generic operation of two images, or of an image and a constant.