ITK  4.13.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 {
49 template< typename TInputImage1, typename TInputImage2,
50  typename TOutputImage, typename TFunction >
51 class ITK_TEMPLATE_EXPORT BinaryFunctorImageFilter:
52  public InPlaceImageFilter< TInputImage1, TOutputImage >
53 {
54 public:
60 
62  itkNewMacro(Self);
63 
66 
68  typedef TFunction FunctorType;
69  typedef TInputImage1 Input1ImageType;
70  typedef typename Input1ImageType::ConstPointer Input1ImagePointer;
71  typedef typename Input1ImageType::RegionType Input1ImageRegionType;
72  typedef typename Input1ImageType::PixelType Input1ImagePixelType;
75 
76  typedef TInputImage2 Input2ImageType;
77  typedef typename Input2ImageType::ConstPointer Input2ImagePointer;
78  typedef typename Input2ImageType::RegionType Input2ImageRegionType;
79  typedef typename Input2ImageType::PixelType Input2ImagePixelType;
82 
83  typedef TOutputImage OutputImageType;
84  typedef typename OutputImageType::Pointer OutputImagePointer;
85  typedef typename OutputImageType::RegionType OutputImageRegionType;
86  typedef typename OutputImageType::PixelType OutputImagePixelType;
87 
89  virtual void SetInput1(const TInputImage1 *image1);
90  virtual void SetInput1(const DecoratedInput1ImagePixelType *input1);
91  virtual void SetInput1(const Input1ImagePixelType &input1);
93 
95  virtual void SetConstant1(const Input1ImagePixelType &input1);
96 
99  virtual const Input1ImagePixelType & GetConstant1() const;
100 
102  virtual void SetInput2(const TInputImage2 *image2);
103  virtual void SetInput2(const DecoratedInput2ImagePixelType *input2);
104  virtual void SetInput2(const Input2ImagePixelType &input2);
106 
108  virtual void SetConstant2(const Input2ImagePixelType &input2);
110  {
111  this->SetConstant2(ct);
112  }
114  {
115  return this->GetConstant2();
116  }
118 
121  virtual const Input2ImagePixelType & GetConstant2() const;
122 
127  FunctorType & GetFunctor() { return m_Functor; }
128 
133  const FunctorType & GetFunctor() const
134  {
135  return m_Functor;
136  }
137 
144  void SetFunctor(const FunctorType & functor)
145  {
146  if ( m_Functor != functor )
147  {
148  m_Functor = functor;
149  this->Modified();
150  }
151  }
153 
155  itkStaticConstMacro(
156  InputImage1Dimension, unsigned int, TInputImage1::ImageDimension);
157  itkStaticConstMacro(
158  InputImage2Dimension, unsigned int, TInputImage2::ImageDimension);
159  itkStaticConstMacro(
160  OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
162 
163 #ifdef ITK_USE_CONCEPT_CHECKING
164  // Begin concept checking
165  itkConceptMacro( SameDimensionCheck1,
166  ( Concept::SameDimension< itkGetStaticConstMacro(InputImage1Dimension),
167  itkGetStaticConstMacro(InputImage2Dimension) > ) );
168  itkConceptMacro( SameDimensionCheck2,
169  ( Concept::SameDimension< itkGetStaticConstMacro(InputImage1Dimension),
170  itkGetStaticConstMacro(OutputImageDimension) > ) );
171  // End concept checking
172 #endif
173 
174 protected:
176  virtual ~BinaryFunctorImageFilter() ITK_OVERRIDE {}
177 
188  void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
189  ThreadIdType threadId) ITK_OVERRIDE;
190 
191  // Needed to take the image information from the 2nd input, if the first one is
192  // a simple decorated object.
193  virtual void GenerateOutputInformation() ITK_OVERRIDE;
194 
195 private:
196  ITK_DISALLOW_COPY_AND_ASSIGN(BinaryFunctorImageFilter);
197 
198  FunctorType m_Functor;
199 };
200 } // end namespace itk
201 
202 #ifndef ITK_MANUAL_INSTANTIATION
203 #include "itkBinaryFunctorImageFilter.hxx"
204 #endif
205 
206 #endif
Input2ImageType::RegionType Input2ImageRegionType
OutputImageType::RegionType OutputImageRegionType
void SetFunctor(const FunctorType &functor)
InPlaceImageFilter< TInputImage1, TOutputImage > Superclass
SimpleDataObjectDecorator< Input1ImagePixelType > DecoratedInput1ImagePixelType
const FunctorType & GetFunctor() const
Base class for all process objects that output image data.
Input1ImageType::ConstPointer Input1ImagePointer
OutputImageType::PixelType OutputImagePixelType
void SetConstant(Input2ImagePixelType ct)
Input1ImageType::RegionType Input1ImageRegionType
Decorates any &quot;simple&quot; data type (data types without smart pointers) with a DataObject API...
OutputImageType::Pointer OutputImagePointer
Input2ImageType::PixelType Input2ImagePixelType
Input1ImageType::PixelType Input1ImagePixelType
SimpleDataObjectDecorator< Input2ImagePixelType > DecoratedInput2ImagePixelType
SmartPointer< const Self > ConstPointer
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
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)
Input2ImageType::ConstPointer Input2ImagePointer
Implements pixel-wise generic operation of two images, or of an image and a constant.