ITK  5.3.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  * 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:
51  JoinFunctor() = default;
52  ~JoinFunctor() = default;
54 
56  using Self = JoinFunctor;
57 
62 
64  static constexpr unsigned int Dimension1 = PixelTraits<TPixel1>::Dimension;
65  static constexpr unsigned int Dimension2 = PixelTraits<TPixel2>::Dimension;
66  static constexpr unsigned int JoinDimension = Dimension1 + Dimension2;
67 
70 
71  bool
72  operator==(const JoinFunctor &) const
73  {
74  return true;
75  }
76 
78 
80  inline JoinType
81  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  {};
103  template <unsigned int VDimension>
105  {};
106 
117  void
118  FirstCopier(JoinType & out, unsigned int idx, const TPixel1 & A) const
119  {
120  FirstCopier(CopierDispatch<Dimension1>(), out, idx, A);
121  }
122 
124  void
125  FirstCopier(CopierDispatchBase, 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  }
133 
135  void FirstCopier(CopierDispatch<1>, JoinType & out, unsigned int idx, const TPixel1 & A) const
136  {
137  out[idx] = static_cast<JoinValueType>(A);
138  }
139 
145  void
146  SecondCopier(JoinType & out, unsigned int idx, const TPixel2 & B) const
147  {
149  }
150 
152  void
153  SecondCopier(CopierDispatchBase, JoinType & out, unsigned int idx, const TPixel2 & B) const
154  {
155  for (unsigned int i = 0; i < Dimension2; i++, idx++)
156  {
157  out[idx] = static_cast<JoinValueType>(B[i]);
158  }
159  }
161 
163  void SecondCopier(CopierDispatch<1>, JoinType & out, unsigned int idx, const TPixel2 & B) const
164  {
165  out[idx] = static_cast<JoinValueType>(B);
166  }
167 }; // class JoinFunction
169 
170 template <typename TImage1, typename TImage2>
171 struct MakeJoin
172 {
175 };
176 } // namespace Functor
177 
208 template <typename TInputImage1, typename TInputImage2>
210  : public BinaryGeneratorImageFilter<TInputImage1,
211  TInputImage2,
212  typename Functor::MakeJoin<TInputImage1, TInputImage2>::ImageType>
213 {
214 public:
215  ITK_DISALLOW_COPY_AND_MOVE(JoinImageFilter);
216 
218  static constexpr unsigned int OutputImageDimension = TInputImage1::ImageDimension;
219 
222 
226  using OutputImagePixelType = typename FunctorType::JoinType;
227 
230 
233 
235  itkNewMacro(Self);
236 
239 
240 #ifdef ITK_USE_CONCEPT_CHECKING
241  // Begin concept checking
244  itkConceptMacro(Input1Input2HasJoinTraitsCheck,
247  // End concept checking
248 #endif
249 
250 protected:
252  ~JoinImageFilter() override = default;
253 };
254 } // end namespace itk
255 
256 #endif
itk::Functor::JoinFunctor::JoinType
Vector< JoinValueType, Self::JoinDimension > JoinType
Definition: itkJoinImageFilter.h:69
itk::JoinImageFilter::OutputImageDimension
static constexpr unsigned int OutputImageDimension
Definition: itkJoinImageFilter.h:218
itk::Functor::JoinFunctor::SecondCopier
void SecondCopier(JoinType &out, unsigned int idx, const TPixel2 &B) const
Definition: itkJoinImageFilter.h:146
itk::Functor::JoinFunctor::FirstCopier
void FirstCopier(CopierDispatchBase, JoinType &out, unsigned int idx, const TPixel1 &A) const
Definition: itkJoinImageFilter.h:125
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:209
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:224
itkPixelTraits.h
itk::Functor::JoinFunctor::ValueType2
typename PixelTraits< TPixel2 >::ValueType ValueType2
Definition: itkJoinImageFilter.h:60
itk::SmartPointer< Self >
itk::Functor::JoinFunctor::JoinValueType
typename JoinTraits< ValueType1, ValueType2 >::ValueType JoinValueType
Definition: itkJoinImageFilter.h:61
itk::Functor::JoinFunctor::operator==
bool operator==(const JoinFunctor &) const
Definition: itkJoinImageFilter.h:72
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:251
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:59
itk::Functor::JoinFunctor::~JoinFunctor
~JoinFunctor()=default
itk::Functor::JoinFunctor::JoinFunctor
JoinFunctor()=default
itk::Functor::JoinFunctor::SecondCopier
void SecondCopier(CopierDispatch< 1 >, JoinType &out, unsigned int idx, const TPixel2 &B) const
Definition: itkJoinImageFilter.h:163
itk::Functor::JoinFunctor::JoinDimension
static constexpr unsigned int JoinDimension
Definition: itkJoinImageFilter.h:66
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:65
itk::Functor::JoinFunctor::ValueType1
typename PixelTraits< TPixel1 >::ValueType ValueType1
Definition: itkJoinImageFilter.h:59
itk::Functor::JoinFunctor::FirstCopier
void FirstCopier(CopierDispatch< 1 >, JoinType &out, unsigned int idx, const TPixel1 &A) const
Definition: itkJoinImageFilter.h:135
itk::JoinTraits::ValueType
TValue1 ValueType
Definition: itkPixelTraits.h:198
itk::JoinImageFilter::OutputImagePixelType
typename FunctorType::JoinType OutputImagePixelType
Definition: itkJoinImageFilter.h:226
itk::JoinImageFilter::OutputImageType
typename Functor::MakeJoin< TInputImage1, TInputImage2 >::ImageType OutputImageType
Definition: itkJoinImageFilter.h:225
itk::PixelTraits::ValueType
typename TPixelType::ValueType ValueType
Definition: itkPixelTraits.h:52
itk::Functor::JoinFunctor::CopierDispatchBase
Definition: itkJoinImageFilter.h:101
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:153
itk::Concept::HasJoinTraits
Definition: itkConceptChecking.h:806
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::Functor::MakeJoin
Definition: itkJoinImageFilter.h:171
itk::Functor::JoinFunctor::FirstCopier
void FirstCopier(JoinType &out, unsigned int idx, const TPixel1 &A) const
Definition: itkJoinImageFilter.h:118
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
itk::Concept::HasPixelTraits
Definition: itkConceptChecking.h:751
itk::Functor::JoinFunctor::operator()
JoinType operator()(const TPixel1 &A, const TPixel2 &B) const
Definition: itkJoinImageFilter.h:81
itk::Functor::JoinFunctor::CopierDispatch
Definition: itkJoinImageFilter.h:104
itk::Functor::JoinFunctor::Dimension1
static constexpr unsigned int Dimension1
Definition: itkJoinImageFilter.h:64
itk::BinaryGeneratorImageFilter::SetFunctor
void SetFunctor(const std::function< ConstRefFunctionType > &f)
Definition: itkBinaryGeneratorImageFilter.h:150