ITK  5.4.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 FirstCopier(CopierDispatch<1>, JoinType & out, unsigned int idx, const TPixel1 & A) const
133  {
134  out[idx] = static_cast<JoinValueType>(A);
135  }
136 
142  void
143  SecondCopier(JoinType & out, unsigned int idx, const TPixel2 & B) const
144  {
146  }
147 
149  void
150  SecondCopier(CopierDispatchBase, 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  }
160  void SecondCopier(CopierDispatch<1>, JoinType & out, unsigned int idx, const TPixel2 & B) const
161  {
162  out[idx] = static_cast<JoinValueType>(B);
163  }
164 }; // class JoinFunction
167 template <typename TImage1, typename TImage2>
168 struct MakeJoin
169 {
172 };
173 } // namespace Functor
174 
205 template <typename TInputImage1, typename TInputImage2>
207  : public BinaryGeneratorImageFilter<TInputImage1,
208  TInputImage2,
209  typename Functor::MakeJoin<TInputImage1, TInputImage2>::ImageType>
210 {
211 public:
212  ITK_DISALLOW_COPY_AND_MOVE(JoinImageFilter);
213 
215  static constexpr unsigned int OutputImageDimension = TInputImage1::ImageDimension;
216 
219 
223  using OutputImagePixelType = typename FunctorType::JoinType;
224 
227 
230 
232  itkNewMacro(Self);
233 
235  itkOverrideGetNameOfClassMacro(JoinImageFilter);
236 
237 #ifdef ITK_USE_CONCEPT_CHECKING
238  // Begin concept checking
241  itkConceptMacro(Input1Input2HasJoinTraitsCheck,
244  // End concept checking
245 #endif
246 
247 protected:
249  ~JoinImageFilter() override = default;
250 };
251 } // end namespace itk
252 
253 #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:215
itk::Functor::JoinFunctor::SecondCopier
void SecondCopier(JoinType &out, unsigned int idx, const TPixel2 &B) const
Definition: itkJoinImageFilter.h:143
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:206
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:221
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:248
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:160
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:132
itk::JoinTraits::ValueType
TValue1 ValueType
Definition: itkPixelTraits.h:198
itk::JoinImageFilter::OutputImagePixelType
typename FunctorType::JoinType OutputImagePixelType
Definition: itkJoinImageFilter.h:223
itk::JoinImageFilter::OutputImageType
typename Functor::MakeJoin< TInputImage1, TInputImage2 >::ImageType OutputImageType
Definition: itkJoinImageFilter.h:222
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:150
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:168
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:751
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