ITK  4.4.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< class TInputImage1, class TInputImage2,
50  class TOutputImage, class TFunction >
51 class ITK_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 
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);
110  void SetConstant(Input2ImagePixelType ct)
111  {
112  this->SetConstant2(ct);
113  }
114  const Input2ImagePixelType & GetConstant() const
115  {
116  return this->GetConstant2();
117  }
119 
123  virtual const Input2ImagePixelType & GetConstant2() const;
124 
129  FunctorType & GetFunctor() { return m_Functor; }
130 
135  const FunctorType & GetFunctor() const
136  {
137  return m_Functor;
138  }
139 
146  void SetFunctor(const FunctorType & functor)
147  {
148  if ( m_Functor != functor )
149  {
150  m_Functor = functor;
151  this->Modified();
152  }
153  }
155 
157  itkStaticConstMacro(
158  InputImage1Dimension, unsigned int, TInputImage1::ImageDimension);
159  itkStaticConstMacro(
160  InputImage2Dimension, unsigned int, TInputImage2::ImageDimension);
161  itkStaticConstMacro(
162  OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
164 
165 #ifdef ITK_USE_CONCEPT_CHECKING
166 
167  itkConceptMacro( SameDimensionCheck1,
168  ( Concept::SameDimension< itkGetStaticConstMacro(InputImage1Dimension),
169  itkGetStaticConstMacro(InputImage2Dimension) > ) );
170  itkConceptMacro( SameDimensionCheck2,
171  ( Concept::SameDimension< itkGetStaticConstMacro(InputImage1Dimension),
172  itkGetStaticConstMacro(OutputImageDimension) > ) );
173 
175 #endif
176 
177 protected:
180 
191  void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
192  ThreadIdType threadId);
193 
194  // needed to take the image information from the 2nd input, if the first one is
195  // a simple decorated object
196  virtual void GenerateOutputInformation();
197 
198 private:
199  BinaryFunctorImageFilter(const Self &); //purposely not implemented
200  void operator=(const Self &); //purposely not implemented
201 
203 };
204 } // end namespace itk
205 
206 #ifndef ITK_MANUAL_INSTANTIATION
207 #include "itkBinaryFunctorImageFilter.hxx"
208 #endif
209 
210 #endif
211