ITK  5.2.0
Insight Toolkit
itkBinaryFunctorImageFilter.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 itkBinaryFunctorImageFilter_h
19 #define itkBinaryFunctorImageFilter_h
20 
21 #include "itkInPlaceImageFilter.h"
23 
24 namespace itk
25 {
52 template <typename TInputImage1, typename TInputImage2, typename TOutputImage, typename TFunction>
53 class ITK_TEMPLATE_EXPORT BinaryFunctorImageFilter : public InPlaceImageFilter<TInputImage1, TOutputImage>
54 {
55 public:
56  ITK_DISALLOW_COPY_AND_MOVE(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
91  SetInput1(const TInputImage1 * image1);
92  virtual void
93  SetInput1(const DecoratedInput1ImagePixelType * input1);
94  virtual void
95  SetInput1(const Input1ImagePixelType & input1);
97 
99  virtual void
100  SetConstant1(const Input1ImagePixelType & input1);
101 
104  virtual const Input1ImagePixelType &
105  GetConstant1() const;
106 
108  virtual void
109  SetInput2(const TInputImage2 * image2);
110  virtual void
111  SetInput2(const DecoratedInput2ImagePixelType * input2);
112  virtual void
113  SetInput2(const Input2ImagePixelType & input2);
115 
117  virtual void
118  SetConstant2(const Input2ImagePixelType & input2);
119  void
121  {
122  this->SetConstant2(ct);
123  }
124  const Input2ImagePixelType &
125  GetConstant() const
126  {
127  return this->GetConstant2();
128  }
130 
133  virtual const Input2ImagePixelType &
134  GetConstant2() const;
135 
140  FunctorType &
142  {
143  return m_Functor;
144  }
145 
150  const FunctorType &
151  GetFunctor() const
152  {
153  return m_Functor;
154  }
155 
162  void
163  SetFunctor(const FunctorType & functor)
164  {
165  if (m_Functor != functor)
166  {
167  m_Functor = functor;
168  this->Modified();
169  }
170  }
172 
174  static constexpr unsigned int InputImage1Dimension = TInputImage1::ImageDimension;
175  static constexpr unsigned int InputImage2Dimension = TInputImage2::ImageDimension;
176  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
177 
178 #ifdef ITK_USE_CONCEPT_CHECKING
179  // Begin concept checking
180  itkConceptMacro(SameDimensionCheck1,
182  itkConceptMacro(SameDimensionCheck2,
184  // End concept checking
185 #endif
186 
187 protected:
189  ~BinaryFunctorImageFilter() override = default;
190 
201  void
202  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
203 
204 
205  // Needed to take the image information from the 2nd input, if the first one is
206  // a simple decorated object.
207  void
208  GenerateOutputInformation() override;
209 
210 private:
212 };
213 } // end namespace itk
214 
215 #ifndef ITK_MANUAL_INSTANTIATION
216 # include "itkBinaryFunctorImageFilter.hxx"
217 #endif
218 
219 #endif
itk::BinaryFunctorImageFilter::Input2ImageType
TInputImage2 Input2ImageType
Definition: itkBinaryFunctorImageFilter.h:78
itk::BinaryFunctorImageFilter::m_Functor
FunctorType m_Functor
Definition: itkBinaryFunctorImageFilter.h:211
itk::SimpleDataObjectDecorator
Decorates any "simple" data type (data types without smart pointers) with a DataObject API.
Definition: itkSimpleDataObjectDecorator.h:66
itk::BinaryFunctorImageFilter::Input2ImageRegionType
typename Input2ImageType::RegionType Input2ImageRegionType
Definition: itkBinaryFunctorImageFilter.h:80
itk::BinaryFunctorImageFilter::SetFunctor
void SetFunctor(const FunctorType &functor)
Definition: itkBinaryFunctorImageFilter.h:163
itk::BinaryFunctorImageFilter::Input1ImagePixelType
typename Input1ImageType::PixelType Input1ImagePixelType
Definition: itkBinaryFunctorImageFilter.h:75
itk::ImageSource::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::BinaryFunctorImageFilter::Input2ImagePointer
typename Input2ImageType::ConstPointer Input2ImagePointer
Definition: itkBinaryFunctorImageFilter.h:79
itk::BinaryFunctorImageFilter
Implements pixel-wise generic operation of two images, or of an image and a constant.
Definition: itkBinaryFunctorImageFilter.h:53
itk::SmartPointer< Self >
itk::BinaryFunctorImageFilter::Input1ImageType
TInputImage1 Input1ImageType
Definition: itkBinaryFunctorImageFilter.h:72
itk::Concept::SameDimension
Definition: itkConceptChecking.h:694
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::BinaryFunctorImageFilter::FunctorType
TFunction FunctorType
Definition: itkBinaryFunctorImageFilter.h:71
itk::BinaryFunctorImageFilter::GetFunctor
FunctorType & GetFunctor()
Definition: itkBinaryFunctorImageFilter.h:141
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::BinaryFunctorImageFilter::Input1ImageRegionType
typename Input1ImageType::RegionType Input1ImageRegionType
Definition: itkBinaryFunctorImageFilter.h:74
itk::BinaryFunctorImageFilter::GetFunctor
const FunctorType & GetFunctor() const
Definition: itkBinaryFunctorImageFilter.h:151
itk::BinaryFunctorImageFilter::Input2ImagePixelType
typename Input2ImageType::PixelType Input2ImagePixelType
Definition: itkBinaryFunctorImageFilter.h:81
itk::BinaryFunctorImageFilter::SetConstant
void SetConstant(Input2ImagePixelType ct)
Definition: itkBinaryFunctorImageFilter.h:120
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itkInPlaceImageFilter.h
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::ImageSource::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkImageSource.h:93
itk::BinaryFunctorImageFilter::GetConstant
const Input2ImagePixelType & GetConstant() const
Definition: itkBinaryFunctorImageFilter.h:125
itkSimpleDataObjectDecorator.h
itk::BinaryFunctorImageFilter::Input1ImagePointer
typename Input1ImageType::ConstPointer Input1ImagePointer
Definition: itkBinaryFunctorImageFilter.h:73
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90