ITK  6.0.0
Insight Toolkit
itkJoinImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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:
51 
53  using Self = JoinFunctor;
54 
59 
61  static constexpr unsigned int Dimension1 = PixelTraits<TPixel1>::Dimension;
62  static constexpr unsigned int Dimension2 = PixelTraits<TPixel2>::Dimension;
63  static constexpr unsigned int JoinDimension = Dimension1 + Dimension2;
64 
67 
68  bool
69  operator==(const JoinFunctor &) const
70  {
71  return true;
72  }
73 
75 
77  inline JoinType
78  operator()(const TPixel1 & A, const TPixel2 & B) const
79  {
80  JoinType out;
81 
82  // Copy A into the output, casting as necessary
83  this->FirstCopier(out, 0, A);
84 
85  // Copy B into the output, starting where A left off,casting as necessary
86  this->SecondCopier(out, Dimension1, B);
87 
88  return out;
89  }
90 
91 private:
99  {};
100  template <unsigned int VDimension>
102  {};
103 
114  void
115  FirstCopier(JoinType & out, unsigned int idx, const TPixel1 & A) const
116  {
117  FirstCopier(CopierDispatch<Dimension1>(), out, idx, A);
118  }
119 
121  void
122  FirstCopier(CopierDispatchBase, 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  }
132  void
133  FirstCopier(CopierDispatch<1>, JoinType & out, unsigned int idx, const TPixel1 & A) const
134  {
135  out[idx] = static_cast<JoinValueType>(A);
136  }
137 
143  void
144  SecondCopier(JoinType & out, unsigned int idx, const TPixel2 & B) const
145  {
147  }
148 
150  void
151  SecondCopier(CopierDispatchBase, JoinType & out, unsigned int idx, const TPixel2 & B) const
152  {
153  for (unsigned int i = 0; i < Dimension2; i++, idx++)
154  {
155  out[idx] = static_cast<JoinValueType>(B[i]);
156  }
157  }
161  void
162  SecondCopier(CopierDispatch<1>, JoinType & out, unsigned int idx, const TPixel2 & B) const
163  {
164  out[idx] = static_cast<JoinValueType>(B);
165  }
166 }; // class JoinFunction
169 template <typename TImage1, typename TImage2>
170 struct MakeJoin
171 {
174 };
175 } // namespace Functor
176 
207 template <typename TInputImage1, typename TInputImage2>
209  : public BinaryGeneratorImageFilter<TInputImage1,
210  TInputImage2,
211  typename Functor::MakeJoin<TInputImage1, TInputImage2>::ImageType>
212 {
213 public:
214  ITK_DISALLOW_COPY_AND_MOVE(JoinImageFilter);
215 
217  static constexpr unsigned int OutputImageDimension = TInputImage1::ImageDimension;
218 
221 
225  using OutputImagePixelType = typename FunctorType::JoinType;
226 
229 
232 
234  itkNewMacro(Self);
235 
237  itkOverrideGetNameOfClassMacro(JoinImageFilter);
238 
239 #ifdef ITK_USE_CONCEPT_CHECKING
240  // Begin concept checking
243  itkConceptMacro(Input1Input2HasJoinTraitsCheck,
246  // End concept checking
247 #endif
248 
249 protected:
251  ~JoinImageFilter() override = default;
252 };
253 } // end namespace itk
254 
255 #endif
itk::Functor::JoinFunctor::JoinType
Vector< JoinValueType, Self::JoinDimension > JoinType
Definition: itkJoinImageFilter.h:66
itk::JoinImageFilter::OutputImageDimension
static constexpr unsigned int OutputImageDimension
Definition: itkJoinImageFilter.h:217
itk::Functor::JoinFunctor::SecondCopier
void SecondCopier(JoinType &out, unsigned int idx, const TPixel2 &B) const
Definition: itkJoinImageFilter.h:144
itk::Functor::JoinFunctor::FirstCopier
void FirstCopier(CopierDispatchBase, JoinType &out, unsigned int idx, const TPixel1 &A) const
Definition: itkJoinImageFilter.h:122
itk::Vector
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
itk::JoinImageFilter
Join two images, resulting in an image where each pixel has the components of the first image followe...
Definition: itkJoinImageFilter.h:208
itk::BinaryGeneratorImageFilter
Implements pixel-wise generic operation of two images, or of an image and a constant.
Definition: itkBinaryGeneratorImageFilter.h:56
itk::JoinImageFilter::FunctorType
typename Functor::MakeJoin< TInputImage1, TInputImage2 >::FunctorType FunctorType
Definition: itkJoinImageFilter.h:223
itkPixelTraits.h
itk::Functor::JoinFunctor::ValueType2
typename PixelTraits< TPixel2 >::ValueType ValueType2
Definition: itkJoinImageFilter.h:57
itk::SmartPointer< Self >
itk::Functor::JoinFunctor::JoinValueType
typename JoinTraits< ValueType1, ValueType2 >::ValueType JoinValueType
Definition: itkJoinImageFilter.h:58
itk::Functor::JoinFunctor::operator==
bool operator==(const JoinFunctor &) const
Definition: itkJoinImageFilter.h:69
itk::PixelTraits
Traits for a pixel that define the dimension and component type.
Definition: itkPixelTraits.h:45
itk::JoinImageFilter::~JoinImageFilter
~JoinImageFilter() override=default
itk::JoinImageFilter::JoinImageFilter
JoinImageFilter()
Definition: itkJoinImageFilter.h:250
itkBinaryGeneratorImageFilter.h
itk::Functor::JoinFunctor::ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(JoinFunctor)
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::Functor::JoinFunctor::SecondCopier
void SecondCopier(CopierDispatch< 1 >, JoinType &out, unsigned int idx, const TPixel2 &B) const
Definition: itkJoinImageFilter.h:162
itk::Functor::JoinFunctor::JoinDimension
static constexpr unsigned int JoinDimension
Definition: itkJoinImageFilter.h:63
itk::Functor::JoinFunctor
Join the components of two pixel types into a single pixel type.
Definition: itkJoinImageFilter.h:48
itk::Functor::JoinFunctor::Dimension2
static constexpr unsigned int Dimension2
Definition: itkJoinImageFilter.h:62
itk::Functor::JoinFunctor::ValueType1
typename PixelTraits< TPixel1 >::ValueType ValueType1
Definition: itkJoinImageFilter.h:56
itk::Functor::JoinFunctor::FirstCopier
void FirstCopier(CopierDispatch< 1 >, JoinType &out, unsigned int idx, const TPixel1 &A) const
Definition: itkJoinImageFilter.h:133
itk::JoinTraits::ValueType
TValue1 ValueType
Definition: itkPixelTraits.h:198
itk::JoinImageFilter::OutputImagePixelType
typename FunctorType::JoinType OutputImagePixelType
Definition: itkJoinImageFilter.h:225
itk::JoinImageFilter::OutputImageType
typename Functor::MakeJoin< TInputImage1, TInputImage2 >::ImageType OutputImageType
Definition: itkJoinImageFilter.h:224
itk::PixelTraits::ValueType
typename TPixelType::ValueType ValueType
Definition: itkPixelTraits.h:52
itk::Functor::JoinFunctor::CopierDispatchBase
Definition: itkJoinImageFilter.h:98
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk::Functor::JoinFunctor::SecondCopier
void SecondCopier(CopierDispatchBase, JoinType &out, unsigned int idx, const TPixel2 &B) const
Definition: itkJoinImageFilter.h:151
itk::Concept::HasJoinTraits
Definition: itkConceptChecking.h:809
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::Functor::MakeJoin
Definition: itkJoinImageFilter.h:170
itk::Functor::JoinFunctor::FirstCopier
void FirstCopier(JoinType &out, unsigned int idx, const TPixel1 &A) const
Definition: itkJoinImageFilter.h:115
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
itk::Concept::HasPixelTraits
Definition: itkConceptChecking.h:754
itk::Functor::JoinFunctor::operator()
JoinType operator()(const TPixel1 &A, const TPixel2 &B) const
Definition: itkJoinImageFilter.h:78
itk::Functor::JoinFunctor::CopierDispatch
Definition: itkJoinImageFilter.h:101
itk::Functor::JoinFunctor::Dimension1
static constexpr unsigned int Dimension1
Definition: itkJoinImageFilter.h:61
itk::BinaryGeneratorImageFilter::SetFunctor
void SetFunctor(const std::function< ConstRefFunctionType > &f)
Definition: itkBinaryGeneratorImageFilter.h:150