ITK  4.6.0
Insight Segmentation and Registration Toolkit
itkAdaptImageFilter.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 __itkAdaptImageFilter_h
19 #define __itkAdaptImageFilter_h
20 
22 
23 namespace itk
24 {
25 namespace Functor
26 {
37 template< typename TInput, typename TAccessor >
39 {
40 public:
43  typedef TAccessor AccessorType;
44 
49 
51  typedef typename TAccessor::ExternalType OutputType;
52  inline OutputType operator()(const TInput & A) const
53  {
54  return m_Accessor.Get(A);
55  }
57 
60  {
61  return m_Accessor;
62  }
63 
66  {
67  m_Accessor = functor.m_Accessor;
68  return *this;
69  }
70 
76  void SetAccessor(AccessorType & accessor)
77  {
78  m_Accessor = accessor;
79  }
80 
82  bool operator!=(const Self & functor) const
83  {
84  return ( m_Accessor != functor.m_Accessor );
85  }
86 
87  bool operator==(const Self & other) const
88  {
89  return !( *this != other );
90  }
91 
92 private:
94 };
95 }
96 
124 template< typename TInputImage, typename TOutputImage, typename TAccessor >
126  public UnaryFunctorImageFilter< TInputImage, TOutputImage,
127  Functor::AccessorFunctor< typename TInputImage::PixelType, TAccessor > >
128 {
129 public:
132 
133  typedef UnaryFunctorImageFilter< TInputImage,
134  TOutputImage,
136  typename TInputImage::PixelType,
137  TAccessor > > Superclass;
138 
142 
144  itkNewMacro(Self);
145 
147  typedef TAccessor AccessorType;
148 
151 
153  AccessorType & GetAccessor() { return this->GetFunctor().GetAccessor(); }
154 
156  void SetAccessor(AccessorType & accessor)
157  {
158  FunctorType functor;
159 
160  functor = this->GetFunctor();
161  if ( accessor != functor.GetAccessor() )
162  {
163  functor.SetAccessor(accessor);
164  this->SetFunctor(functor);
165  this->Modified();
166  }
167  }
168 
169 protected:
171  virtual ~AdaptImageFilter() {}
172 
173 private:
174  AdaptImageFilter(const Self &); //purposely not implemented
175  void operator=(const Self &); //purposely not implemented
176 };
177 } // end namespace itk
178 
179 #endif
SmartPointer< const Self > ConstPointer
bool operator!=(const Self &functor) const
TAccessor::ExternalType OutputType
AccessorFunctor & operator=(const AccessorFunctor &functor)
Base class for all process objects that output image data.
AccessorType & GetAccessor()
Convert an accessor to a functor so that it can be used in a UnaryFunctorImageFilter.
void operator=(const Self &)
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::AccessorFunctor< typename TInputImage::PixelType, TAccessor > > Superclass
bool operator==(const Self &other) const
void SetAccessor(AccessorType &accessor)
Superclass::FunctorType FunctorType
virtual void Modified() const
Implements pixel-wise generic operation on one image.
void SetAccessor(AccessorType &accessor)
Convert an image to another pixel type using the specified data accessor.
SmartPointer< Self > Pointer
OutputType operator()(const TInput &A) const