ITK  5.4.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 * 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 itkBinaryFunctorImageFilter_h
19#define itkBinaryFunctorImageFilter_h
20
23
24namespace itk
25{
52template <typename TInputImage1, typename TInputImage2, typename TOutputImage, typename TFunction>
53class ITK_TEMPLATE_EXPORT BinaryFunctorImageFilter : public InPlaceImageFilter<TInputImage1, TOutputImage>
54{
55public:
56 ITK_DISALLOW_COPY_AND_MOVE(BinaryFunctorImageFilter);
65 itkNewMacro(Self);
68 itkOverrideGetNameOfClassMacro(BinaryFunctorImageFilter);
71 using FunctorType = TFunction;
72 using Input1ImageType = TInputImage1;
75 using Input1ImagePixelType = typename Input1ImageType::PixelType;
78 using Input2ImageType = TInputImage2;
81 using Input2ImagePixelType = typename Input2ImageType::PixelType;
84 using OutputImageType = TOutputImage;
87 using OutputImagePixelType = typename OutputImageType::PixelType;
88
90 virtual void
91 SetInput1(const TInputImage1 * image1);
92 virtual void
94 virtual void
95 SetInput1(const Input1ImagePixelType & input1);
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
112 virtual void
113 SetInput2(const Input2ImagePixelType & input2);
117 virtual void
118 SetConstant2(const Input2ImagePixelType & input2);
119 void
120 SetConstant(Input2ImagePixelType ct)
121 {
122 this->SetConstant2(ct);
124 const Input2ImagePixelType &
125 GetConstant() const
126 {
127 return this->GetConstant2();
128 }
133 virtual const Input2ImagePixelType &
134 GetConstant2() const;
135
141 GetFunctor()
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 }
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
187protected:
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;
210private:
211 FunctorType m_Functor{};
212};
213} // end namespace itk
214
215#ifndef ITK_MANUAL_INSTANTIATION
216# include "itkBinaryFunctorImageFilter.hxx"
217#endif
218
219#endif
Implements pixel-wise generic operation of two images, or of an image and a constant.
virtual void SetInput1(const Input1ImagePixelType &input1)
typename Input1ImageType::RegionType Input1ImageRegionType
virtual void SetInput1(const DecoratedInput1ImagePixelType *input1)
typename Input1ImageType::ConstPointer Input1ImagePointer
typename Input1ImageType::PixelType Input1ImagePixelType
typename Input2ImageType::ConstPointer Input2ImagePointer
virtual void SetInput2(const DecoratedInput2ImagePixelType *input2)
typename Input2ImageType::RegionType Input2ImageRegionType
virtual void SetInput2(const Input2ImagePixelType &input2)
typename Input2ImageType::PixelType Input2ImagePixelType
Base class for all process objects that output image data.
typename OutputImageType::PixelType OutputImagePixelType
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
typename OutputImageType::Pointer OutputImagePointer
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.
Functor::Add2< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > FunctorType
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....