SimpleITK  
sitkCastImageFilter.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 sitkCastImageFilter_h
19 #define sitkCastImageFilter_h
20 
21 #include "sitkImageFilter.h"
22 #include "sitkPixelIDTokens.h"
24 
25 #include <memory>
26 
27 namespace itk::simple
28 {
29 
40 {
41 public:
43 
45  SITK_RETURN_SELF_TYPE_HEADER
46  SetOutputPixelType(PixelIDValueEnum pixelID);
48  GetOutputPixelType() const;
49 
50  ~CastImageFilter() override;
51 
57 
59  std::string
60  GetName() const override
61  {
62  return std::string("CastImageFilter");
63  }
64 
65  // See super class for doxygen
66  std::string
67  ToString() const override;
68 
69  // See super class for doxygen
70  Image
71  Execute(const Image &);
72 
73 private:
75 
85  template <typename TImageType, typename TOutputImageType>
86  Image
87  ExecuteInternalCast(const Image & inImage);
88 
89  template <typename TImageType, typename TOutputImageType>
90  Image
91  ExecuteInternalToVector(const Image & inImage);
92 
93  template <typename TImageType, typename TOutputImageType>
94  Image
95  ExecuteInternalToLabel(const Image & inImage);
96 
97  template <typename TImageType, typename TOutputImageType>
98  Image
99  ExecuteInternalLabelToImage(const Image & inImage);
102 // SWIG does not appear to process private classes correctly
103 #ifndef SWIG
104 
108  template <class TMemberFunctionPointer>
110  {
111  using ObjectType = typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType;
112 
113  template <typename TImageType1, typename TImageType2>
114  TMemberFunctionPointer
115  operator()() const
116  {
117  return &ObjectType::template ExecuteInternalCast<TImageType1, TImageType2>;
118  }
119  };
120 
124  template <class TMemberFunctionPointer>
126  {
127  using ObjectType = typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType;
128 
129  template <typename TImageType1, typename TImageType2>
130  TMemberFunctionPointer
131  operator()() const
132  {
133  return &ObjectType::template ExecuteInternalToVector<TImageType1, TImageType2>;
134  }
135  };
136 
140  template <class TMemberFunctionPointer>
142  {
143  using ObjectType = typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType;
144 
145  template <typename TImageType1, typename TImageType2>
146  TMemberFunctionPointer
147  operator()() const
148  {
149  return &ObjectType::template ExecuteInternalToLabel<TImageType1, TImageType2>;
150  }
151  };
152 
156  template <class TMemberFunctionPointer>
158  {
159  using ObjectType = typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType;
160 
161  template <typename TImageType1, typename TImageType2>
162  TMemberFunctionPointer
163  operator()() const
164  {
165  return &ObjectType::template ExecuteInternalLabelToImage<TImageType1, TImageType2>;
166  }
167  };
168 #endif
169 
176  void
177  RegisterMemberFactory2();
178  void
179  RegisterMemberFactory2v();
180  void
181  RegisterMemberFactory2l();
182  void
183  RegisterMemberFactory3();
184  void
185  RegisterMemberFactory3v();
186  void
187  RegisterMemberFactory3l();
188  void
189  RegisterMemberFactory4();
192  typedef Image (Self::*MemberFunctionType)(const Image &);
193  std::unique_ptr<detail::DualMemberFunctionFactory<MemberFunctionType>> m_DualMemberFactory;
194 };
195 
197 Cast(const Image & image, PixelIDValueEnum pixelID);
198 
199 } // namespace itk::simple
200 #endif
itk::simple::Image
The Image class for SimpleITK.
Definition: sitkImage.h:76
itk::simple::CastImageFilter::ToVectorAddressor::operator()
TMemberFunctionPointer operator()() const
Definition: sitkCastImageFilter.h:131
itk::simple::CastImageFilter::CastAddressor::ObjectType
typename ::detail::FunctionTraits< TMemberFunctionPointer >::ClassType ObjectType
Definition: sitkCastImageFilter.h:111
itk::simple::CastImageFilter::m_OutputPixelType
PixelIDValueEnum m_OutputPixelType
Definition: sitkCastImageFilter.h:74
itk::simple::CastImageFilter::GetName
std::string GetName() const override
Definition: sitkCastImageFilter.h:60
itk::simple::CastImageFilter::CastAddressor
Definition: sitkCastImageFilter.h:109
itk::simple::CastImageFilter::ToVectorAddressor
Definition: sitkCastImageFilter.h:125
itk::simple::CastImageFilter::LabelToAddressor::operator()
TMemberFunctionPointer operator()() const
Definition: sitkCastImageFilter.h:163
itk::simple::PixelIDValueEnum
PixelIDValueEnum
Enumerated values of pixelIDs.
Definition: sitkPixelIDValues.h:100
sitkImageFilter.h
itk::simple::Cast
Image Cast(const Image &image, PixelIDValueEnum pixelID)
itk::simple::CastImageFilter
A hybrid cast image filter to convert images to other types of images.
Definition: sitkCastImageFilter.h:39
sitkDualMemberFunctionFactory.h
itk::simple::CastImageFilter::m_DualMemberFactory
std::unique_ptr< detail::DualMemberFunctionFactory< MemberFunctionType > > m_DualMemberFactory
Definition: sitkCastImageFilter.h:193
SITKBasicFilters_EXPORT
#define SITKBasicFilters_EXPORT
Definition: sitkBasicFilters.h:52
itk::simple::CastImageFilter::ToLabelAddressor
Definition: sitkCastImageFilter.h:141
sitkPixelIDTokens.h
itk::simple::ImageFilter
The base interface for SimpleITK filters that take one input image.
Definition: sitkImageFilter.h:35
itk::simple::CastImageFilter::ToLabelAddressor::operator()
TMemberFunctionPointer operator()() const
Definition: sitkCastImageFilter.h:147
itk::simple::CastImageFilter::ToLabelAddressor::ObjectType
typename ::detail::FunctionTraits< TMemberFunctionPointer >::ClassType ObjectType
Definition: sitkCastImageFilter.h:143
itk::simple::CastImageFilter::CastAddressor::operator()
TMemberFunctionPointer operator()() const
Definition: sitkCastImageFilter.h:115
itk::simple
Definition: sitkAdditionalProcedures.h:28
itk::simple::CastImageFilter::LabelToAddressor
Definition: sitkCastImageFilter.h:157
itk::simple::CastImageFilter::ToVectorAddressor::ObjectType
typename ::detail::FunctionTraits< TMemberFunctionPointer >::ClassType ObjectType
Definition: sitkCastImageFilter.h:127
itk::simple::CastImageFilter::LabelToAddressor::ObjectType
typename ::detail::FunctionTraits< TMemberFunctionPointer >::ClassType ObjectType
Definition: sitkCastImageFilter.h:159