Orfeo Toolbox  4.0
itkJoinImageFilter.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 __itkJoinImageFilter_h
19 #define __itkJoinImageFilter_h
20 
22 #include "itkPixelTraits.h"
23 
24 namespace itk
25 {
26 namespace Functor
27 {
47 template< typename TPixel1, typename TPixel2 >
49 {
50 public:
53 
55  typedef JoinFunctor Self;
56 
61 
63  itkStaticConstMacro(Dimension1, unsigned int,
65  itkStaticConstMacro(Dimension2, unsigned int,
67  itkStaticConstMacro(JoinDimension, unsigned int,
69 
72 
73  bool operator!=(const JoinFunctor &) const
74  {
75  return false;
76  }
77 
78  bool operator==(const JoinFunctor & other) const
79  {
80  return !( *this != other );
81  }
82 
84  inline JoinType operator()(const TPixel1 & A, const TPixel2 & B) const
85  {
86  JoinType out;
87 
88  // Copy A into the output, casting as necessary
89  this->FirstCopier(out, 0, A);
90 
91  // Copy B into the output, starting where A left off,casting as necessary
92  this->SecondCopier(out, Dimension1, B);
93 
94  return out;
95  }
96 
97 private:
105  template< unsigned int VDimension >
107 
118  void FirstCopier(JoinType & out, unsigned int idx, const TPixel1 & A) const
119  {
121  }
122 
125  JoinType & out, unsigned int idx, const TPixel1 & A) const
126  {
127  for ( unsigned int i = 0; i < Dimension1; i++, idx++ )
128  {
129  out[idx] = static_cast< JoinValueType >( A[i] );
130  }
131  }
132 
135  JoinType & out, unsigned int idx, const TPixel1 & A) const
136  { out[idx] = static_cast< JoinValueType >( A ); }
137 
143  void SecondCopier(JoinType & out, unsigned int idx, const TPixel2 & B) const
144  {
146  }
147 
150  JoinType & out, unsigned int idx, const TPixel2 & B) const
151  {
152  for ( unsigned int i = 0; i < Dimension2; i++, idx++ )
153  {
154  out[idx] = static_cast< JoinValueType >( B[i] );
155  }
156  }
157 
160  JoinType & out, unsigned int idx, const TPixel2 & B) const
161  {
162  out[idx] = static_cast< JoinValueType >( B );
163  }
164 }; //class JoinFunction
165 
166 template< typename TImage1, typename TImage2 >
167 struct MakeJoin {
168  typedef JoinFunctor< typename TImage1::PixelType,
169  typename TImage2::PixelType > FunctorType;
170  typedef Image< typename FunctorType::JoinType,
171  TImage1 ::ImageDimension > ImageType;
172 };
173 } //namespace functor
174 
203 template< typename TInputImage1, typename TInputImage2 >
205  public BinaryFunctorImageFilter< TInputImage1,
206  TInputImage2,
207  typename
208  Functor::MakeJoin< TInputImage1,
209  TInputImage2 >::ImageType,
210  typename
211  Functor::MakeJoin< TInputImage1,
212  TInputImage2 >::FunctorType >
213 {
214 public:
216  itkStaticConstMacro(OutputImageDimension, unsigned int,
217  TInputImage1::ImageDimension);
218 
221 
223  typedef typename Functor::MakeJoin< TInputImage1,
224  TInputImage2 >::FunctorType FunctorType;
225  typedef typename Functor::MakeJoin< TInputImage1,
226  TInputImage2 >::ImageType OutputImageType;
228 
230  typedef BinaryFunctorImageFilter< TInputImage1, TInputImage2, OutputImageType,
232 
235 
237  itkNewMacro(Self);
238 
241 
242 #ifdef ITK_USE_CONCEPT_CHECKING
243  // Begin concept checking
244  itkConceptMacro( Input1HasPixelTraitsCheck,
246  itkConceptMacro( Input2HasPixelTraitsCheck,
248  itkConceptMacro( Input1Input2HasJoinTraitsCheck,
251  // End concept checking
252 #endif
253 
254 protected:
256  virtual ~JoinImageFilter() {}
257 
258 private:
259  JoinImageFilter(const Self &); //purposely not implemented
260  void operator=(const Self &); //purposely not implemented
261 };
262 } // end namespace itk
263 
264 #endif

Generated at Sat Mar 8 2014 14:59:50 for Orfeo Toolbox with doxygen 1.8.3.1