ITK  4.6.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 >
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);
111  {
112  this->SetConstant2(ct);
113  }
115  {
116  return this->GetConstant2();
117  }
119 
123  virtual const Input2ImagePixelType & GetConstant2() const;
124 
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  // Begin concept checking
167  itkConceptMacro( SameDimensionCheck1,
168  ( Concept::SameDimension< itkGetStaticConstMacro(InputImage1Dimension),
169  itkGetStaticConstMacro(InputImage2Dimension) > ) );
170  itkConceptMacro( SameDimensionCheck2,
171  ( Concept::SameDimension< itkGetStaticConstMacro(InputImage1Dimension),
172  itkGetStaticConstMacro(OutputImageDimension) > ) );
173  // End concept checking
174 #endif
175 
176 protected:
179 
190  void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
191  ThreadIdType threadId);
192 
193  // needed to take the image information from the 2nd input, if the first one is
194  // a simple decorated object
195  virtual void GenerateOutputInformation();
196 
197 private:
198  BinaryFunctorImageFilter(const Self &); //purposely not implemented
199  void operator=(const Self &); //purposely not implemented
200 
202 };
203 } // end namespace itk
204 
205 #ifndef ITK_MANUAL_INSTANTIATION
206 #include "itkBinaryFunctorImageFilter.hxx"
207 #endif
208 
209 #endif
Input2ImageType::RegionType Input2ImageRegionType
OutputImageType::RegionType OutputImageRegionType
void SetFunctor(const FunctorType &functor)
virtual void GenerateOutputInformation()
InPlaceImageFilter< TInputImage1, TOutputImage > Superclass
SimpleDataObjectDecorator< Input1ImagePixelType > DecoratedInput1ImagePixelType
virtual void SetConstant2(const Input2ImagePixelType &input2)
const FunctorType & GetFunctor() const
virtual const Input1ImagePixelType & GetConstant1() const
static const unsigned int InputImage1Dimension
virtual void SetInput2(const TInputImage2 *image2)
Base class for all process objects that output image data.
Input1ImageType::ConstPointer Input1ImagePointer
static const unsigned int OutputImageDimension
OutputImageType::PixelType OutputImagePixelType
void SetConstant(Input2ImagePixelType ct)
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId)
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
static const unsigned int InputImage2Dimension
virtual void SetConstant1(const Input1ImagePixelType &input1)
SimpleDataObjectDecorator< Input2ImagePixelType > DecoratedInput2ImagePixelType
virtual void Modified() const
virtual void SetInput1(const TInputImage1 *image1)
virtual const Input2ImagePixelType & GetConstant2() const
SmartPointer< const Self > ConstPointer
const Input2ImagePixelType & GetConstant() const
void operator=(const Self &)
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.
unsigned int ThreadIdType
Definition: itkIntTypes.h:159