SimpleITK  1.0.1
sitkCastImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 *
3 * Copyright Insight Software Consortium
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<1>
43 {
44 public:
46 
48  SITK_RETURN_SELF_TYPE_HEADER SetOutputPixelType( PixelIDValueEnum pixelID );
49  PixelIDValueEnum GetOutputPixelType( void ) const;
50 
56 
58  std::string GetName() const { return std::string ("CastImageFilter"); }
59 
60  // See super class for doxygen
61  std::string ToString() const;
62 
63  // See super class for doxygen
64  Image Execute ( const Image & );
65 
66 private:
67 
69 
79  template<typename TImageType, typename TOutputImageType>
80  Image ExecuteInternalCast( const Image& inImage );
81 
82  template<typename TImageType, typename TOutputImageType>
83  Image ExecuteInternalToVector( const Image& inImage );
84 
85  template<typename TImageType, typename TOutputImageType>
86  Image ExecuteInternalToLabel( const Image& inImage );
87 
88  template<typename TImageType, typename TOutputImageType>
89  Image ExecuteInternalLabelToImage( const Image& inImage );
92 // SWIG does not appear to process private classes correctly
93 #ifndef SWIG
94 
98  template < class TMemberFunctionPointer >
100  {
101  typedef typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType ObjectType;
102 
103  template< typename TImageType1, typename TImageType2 >
104  TMemberFunctionPointer operator() ( void ) const
105  {
106  return &ObjectType::template ExecuteInternalCast< TImageType1, TImageType2 >;
107  }
108  };
109 
113  template < class TMemberFunctionPointer >
115  {
116  typedef typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType ObjectType;
117 
118  template< typename TImageType1, typename TImageType2 >
119  TMemberFunctionPointer operator() ( void ) const
120  {
121  return &ObjectType::template ExecuteInternalToVector< TImageType1, TImageType2 >;
122  }
123  };
124 
128  template < class TMemberFunctionPointer >
130  {
131  typedef typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType ObjectType;
132 
133  template< typename TImageType1, typename TImageType2 >
134  TMemberFunctionPointer operator() ( void ) const
135  {
136  return &ObjectType::template ExecuteInternalToLabel< TImageType1, TImageType2 >;
137  }
138  };
139 
143  template < class TMemberFunctionPointer >
145  {
146  typedef typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType ObjectType;
147 
148  template< typename TImageType1, typename TImageType2 >
149  TMemberFunctionPointer operator() ( void ) const
150  {
151  return &ObjectType::template ExecuteInternalLabelToImage< TImageType1, TImageType2 >;
152  }
153  };
154 #endif
155 
162  void RegisterMemberFactory2();
163  void RegisterMemberFactory2v();
164  void RegisterMemberFactory2l();
165  void RegisterMemberFactory3();
166  void RegisterMemberFactory3v();
167  void RegisterMemberFactory3l();
170  typedef Image (Self::*MemberFunctionType)( const Image& );
171  nsstd::auto_ptr<detail::DualMemberFunctionFactory<MemberFunctionType> > m_DualMemberFactory;
172 
173 };
174 
175  SITKBasicFilters_EXPORT Image Cast ( const Image& image, PixelIDValueEnum pixelID );
176 
177 }
178 }
179 #endif
#define SITKBasicFilters_EXPORT
::detail::FunctionTraits< TMemberFunctionPointer >::ClassType ObjectType
PixelIDValueEnum
Enumerated values of pixelIDs.
Image Cast(const Image &image, PixelIDValueEnum pixelID)
::detail::FunctionTraits< TMemberFunctionPointer >::ClassType ObjectType
::detail::FunctionTraits< TMemberFunctionPointer >::ClassType ObjectType
The main Image class for SimpleITK.
Definition: sitkImage.h:54
nsstd::auto_ptr< detail::DualMemberFunctionFactory< MemberFunctionType > > m_DualMemberFactory
A hybrid cast image filter to convert images to other types of images.
::detail::FunctionTraits< TMemberFunctionPointer >::ClassType ObjectType
The base interface for SimpleITK filters that take one input image.