Orfeo Toolbox  3.16
itkJoinImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkJoinImageFilter.h,v $
5  Language: C++
6  Date: $Date: 2009-04-01 14:36:26 $
7  Version: $Revision: 1.18 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkJoinImageFilter_h
18 #define __itkJoinImageFilter_h
19 
21 #include "itkPixelTraits.h"
22 
23 namespace itk
24 {
25 
26 namespace Functor {
45 template <class TPixel1, class TPixel2>
47 {
48 public:
51 
53  typedef JoinFunctor Self;
54 
56  typedef typename PixelTraits<TPixel1>::ValueType ValueType1;
57  typedef typename PixelTraits<TPixel2>::ValueType ValueType2;
58  typedef typename JoinTraits<ValueType1, ValueType2>::ValueType JoinValueType;
59 
61  itkStaticConstMacro(Dimension1, unsigned int,
62  PixelTraits<TPixel1>::Dimension);
63  itkStaticConstMacro(Dimension2, unsigned int,
64  PixelTraits<TPixel2>::Dimension);
65  itkStaticConstMacro(JoinDimension, unsigned int,
67 
70 
71  bool operator!=( const JoinFunctor & ) const
72  {
73  return false;
74  }
75  bool operator==( const JoinFunctor & other ) const
76  {
77  return !(*this != other);
78  }
79 
81  inline JoinType operator() ( const TPixel1 & A, const TPixel2 & B) const
82  {
83  JoinType out;
84 
85  // Copy A into the output, casting as necessary
86  this->FirstCopier(out, 0, A);
87 
88  // Copy B into the output, starting where A left off,casting as necessary
89  this->SecondCopier(out, Dimension1, B);
90 
91  return out;
92  }
93 
94 private:
102  template<unsigned int VDimension>
103  struct CopierDispatch : public CopierDispatchBase {};
104 
115  void FirstCopier(JoinType& out, unsigned int idx, const TPixel1& A) const
116  {
117  FirstCopier(CopierDispatch<Dimension1>(), out, idx, A);
118  }
119 
122  JoinType& out, unsigned int idx, const TPixel1& A) const
123  {
124  for (unsigned int i=0; i < Dimension1; i++, idx++)
125  {
126  out[idx] = static_cast<JoinValueType>(A[i]);
127  }
128  }
129 
132  JoinType& out, unsigned int idx, const TPixel1& A) const
133  { out[idx] = static_cast<JoinValueType>(A); }
134 
140  void SecondCopier(JoinType& out, unsigned int idx, const TPixel2& B) const
141  {
143  }
144 
147  JoinType& out, unsigned int idx, const TPixel2& B) const
148  {
149  for (unsigned int i=0; i < Dimension2; i++, idx++)
150  {
151  out[idx] = static_cast<JoinValueType>(B[i]);
152  }
153  }
154 
157  JoinType& out, unsigned int idx, const TPixel2& B) const
158  {
159  out[idx] = static_cast<JoinValueType>(B);
160  }
161 }; //class JoinFunction
162 
163 template <typename TImage1, typename TImage2>
164 struct MakeJoin
165 {
166  typedef JoinFunctor<typename TImage1::PixelType,
167  typename TImage2::PixelType> FunctorType;
168  typedef Image<typename FunctorType::JoinType,
170 };
171 
172 } //namespace functor
173 
197 template <class TInputImage1, class TInputImage2>
199  public BinaryFunctorImageFilter<TInputImage1,
200  TInputImage2,
201  ITK_TYPENAME
202  Functor::MakeJoin<TInputImage1,
203  TInputImage2>::ImageType,
204  ITK_TYPENAME
205  Functor::MakeJoin<TInputImage1,
206  TInputImage2>::FunctorType>
207 {
208 public:
210  itkStaticConstMacro(OutputImageDimension, unsigned int,
211  TInputImage1::ImageDimension);
212 
215 
217  typedef typename Functor::MakeJoin<TInputImage1,
219  typedef typename Functor::MakeJoin<TInputImage1,
220  TInputImage2>::ImageType OutputImageType;
222 
224  typedef BinaryFunctorImageFilter<TInputImage1,TInputImage2, OutputImageType,
228 
230  itkNewMacro(Self);
231 
234 
235 #ifdef ITK_USE_CONCEPT_CHECKING
236 
237  itkConceptMacro(Input1HasPixelTraitsCheck,
239  itkConceptMacro(Input2HasPixelTraitsCheck,
241  itkConceptMacro(Input1Input2HasJoinTraitsCheck,
242  (Concept::HasJoinTraits<typename PixelTraits<typename TInputImage1::PixelType>::ValueType,
243  typename PixelTraits<typename TInputImage2::PixelType>::ValueType>));
245 #endif
246 
247 protected:
249  virtual ~JoinImageFilter() {}
250 
251 private:
252  JoinImageFilter(const Self&); //purposely not implemented
253  void operator=(const Self&); //purposely not implemented
254 
255 };
256 
257 
258 } // end namespace itk
259 
260 #endif

Generated at Sat Feb 2 2013 23:47:00 for Orfeo Toolbox with doxygen 1.8.1.1