SimpleITK  2.0.0
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
28 {
29 namespace simple
30 {
31 
42  : public ImageFilter
43 {
44 public:
46 
48  SITK_RETURN_SELF_TYPE_HEADER SetOutputPixelType( PixelIDValueEnum pixelID );
49  PixelIDValueEnum GetOutputPixelType( ) const;
50 
51  ~CastImageFilter() override;
52 
58 
60  std::string GetName() const override { return std::string ("CastImageFilter"); }
61 
62  // See super class for doxygen
63  std::string ToString() const override;
64 
65  // See super class for doxygen
66  Image Execute ( const Image & );
67 
68 private:
69 
71 
81  template<typename TImageType, typename TOutputImageType>
82  Image ExecuteInternalCast( const Image& inImage );
83 
84  template<typename TImageType, typename TOutputImageType>
85  Image ExecuteInternalToVector( const Image& inImage );
86 
87  template<typename TImageType, typename TOutputImageType>
88  Image ExecuteInternalToLabel( const Image& inImage );
89 
90  template<typename TImageType, typename TOutputImageType>
91  Image ExecuteInternalLabelToImage( const Image& inImage );
94 // SWIG does not appear to process private classes correctly
95 #ifndef SWIG
96 
100  template < class TMemberFunctionPointer >
102  {
103  using ObjectType = typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType;
104 
105  template< typename TImageType1, typename TImageType2 >
106  TMemberFunctionPointer operator() ( ) const
107  {
108  return &ObjectType::template ExecuteInternalCast< TImageType1, TImageType2 >;
109  }
110  };
111 
115  template < class TMemberFunctionPointer >
117  {
118  using ObjectType = typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType;
119 
120  template< typename TImageType1, typename TImageType2 >
121  TMemberFunctionPointer operator() ( ) const
122  {
123  return &ObjectType::template ExecuteInternalToVector< TImageType1, TImageType2 >;
124  }
125  };
126 
130  template < class TMemberFunctionPointer >
132  {
133  using ObjectType = typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType;
134 
135  template< typename TImageType1, typename TImageType2 >
136  TMemberFunctionPointer operator() ( ) const
137  {
138  return &ObjectType::template ExecuteInternalToLabel< TImageType1, TImageType2 >;
139  }
140  };
141 
145  template < class TMemberFunctionPointer >
147  {
148  using ObjectType = typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType;
149 
150  template< typename TImageType1, typename TImageType2 >
151  TMemberFunctionPointer operator() ( ) const
152  {
153  return &ObjectType::template ExecuteInternalLabelToImage< TImageType1, TImageType2 >;
154  }
155  };
156 #endif
157 
164  void RegisterMemberFactory2();
165  void RegisterMemberFactory2v();
166  void RegisterMemberFactory2l();
167  void RegisterMemberFactory3();
168  void RegisterMemberFactory3v();
169  void RegisterMemberFactory3l();
172  typedef Image (Self::*MemberFunctionType)( const Image& );
173  std::unique_ptr<detail::DualMemberFunctionFactory<MemberFunctionType> > m_DualMemberFactory;
174 
175 };
176 
177  SITKBasicFilters_EXPORT Image Cast ( const Image& image, PixelIDValueEnum pixelID );
178 
179 }
180 }
181 #endif
itk::simple::Image
The Image class for SimpleITK.
Definition: sitkImage.h:75
itk::simple::CastImageFilter::CastAddressor::ObjectType
typename ::detail::FunctionTraits< TMemberFunctionPointer >::ClassType ObjectType
Definition: sitkCastImageFilter.h:103
itk::simple::CastImageFilter::m_OutputPixelType
PixelIDValueEnum m_OutputPixelType
Definition: sitkCastImageFilter.h:70
itk::simple::CastImageFilter::GetName
std::string GetName() const override
Definition: sitkCastImageFilter.h:60
itk::simple::CastImageFilter::CastAddressor
Definition: sitkCastImageFilter.h:101
itk::simple::CastImageFilter::ToVectorAddressor
Definition: sitkCastImageFilter.h:116
itk::simple::PixelIDValueEnum
PixelIDValueEnum
Enumerated values of pixelIDs.
Definition: sitkPixelIDValues.h:90
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:41
sitkDualMemberFunctionFactory.h
itk::simple::CastImageFilter::m_DualMemberFactory
std::unique_ptr< detail::DualMemberFunctionFactory< MemberFunctionType > > m_DualMemberFactory
Definition: sitkCastImageFilter.h:173
SITKBasicFilters_EXPORT
#define SITKBasicFilters_EXPORT
Definition: sitkBasicFilters.h:52
itk::simple::CastImageFilter::ToLabelAddressor
Definition: sitkCastImageFilter.h:131
sitkPixelIDTokens.h
itk
itk::simple::ImageFilter
The base interface for SimpleITK filters that take one input image.
Definition: sitkImageFilter.h:36
itk::simple::CastImageFilter::ToLabelAddressor::ObjectType
typename ::detail::FunctionTraits< TMemberFunctionPointer >::ClassType ObjectType
Definition: sitkCastImageFilter.h:133
itk::simple::CastImageFilter::LabelToAddressor
Definition: sitkCastImageFilter.h:146
itk::simple::CastImageFilter::ToVectorAddressor::ObjectType
typename ::detail::FunctionTraits< TMemberFunctionPointer >::ClassType ObjectType
Definition: sitkCastImageFilter.h:118
itk::simple::CastImageFilter::LabelToAddressor::ObjectType
typename ::detail::FunctionTraits< TMemberFunctionPointer >::ClassType ObjectType
Definition: sitkCastImageFilter.h:148