SimpleITK  2.0.0
sitkImportImageFilter.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 sitkImportImageFilter_h
19 #define sitkImportImageFilter_h
20 
21 #include "sitkMacro.h"
22 #include "sitkImage.h"
23 #include "sitkImageReaderBase.h"
25 
26 namespace itk {
27  namespace simple {
28 
48  : public ImageReaderBase {
49  public:
51 
52  ~ImportImageFilter() override;
53 
55 
57  std::string ToString() const override;
58 
60  std::string GetName() const override { return std::string("ImportImageFilter"); }
61 
62  SITK_RETURN_SELF_TYPE_HEADER SetSize( const std::vector< unsigned int > &size );
63  const std::vector< unsigned int > &GetSize( ) const;
64 
65  SITK_RETURN_SELF_TYPE_HEADER SetSpacing( const std::vector< double > &spacing );
66  const std::vector< double > &GetSpacing( ) const;
67 
68  SITK_RETURN_SELF_TYPE_HEADER SetOrigin( const std::vector< double > &origin );
69  const std::vector< double > &GetOrigin( ) const;
70 
71  SITK_RETURN_SELF_TYPE_HEADER SetDirection( const std::vector< double > &direction );
72  const std::vector< double > &GetDirection( ) const;
73 
74  SITK_RETURN_SELF_TYPE_HEADER SetBufferAsInt8( int8_t * buffer, unsigned int numberOfComponents = 1 );
75  SITK_RETURN_SELF_TYPE_HEADER SetBufferAsUInt8( uint8_t * buffer, unsigned int numberOfComponents = 1 );
76  SITK_RETURN_SELF_TYPE_HEADER SetBufferAsInt16( int16_t * buffer, unsigned int numberOfComponents = 1 );
77  SITK_RETURN_SELF_TYPE_HEADER SetBufferAsUInt16( uint16_t * buffer, unsigned int numberOfComponents = 1 );
78  SITK_RETURN_SELF_TYPE_HEADER SetBufferAsInt32( int32_t * buffer, unsigned int numberOfComponents = 1 );
79  SITK_RETURN_SELF_TYPE_HEADER SetBufferAsUInt32( uint32_t * buffer, unsigned int numberOfComponents = 1 );
80  SITK_RETURN_SELF_TYPE_HEADER SetBufferAsInt64( int64_t * buffer, unsigned int numberOfComponents = 1 );
81  SITK_RETURN_SELF_TYPE_HEADER SetBufferAsUInt64( uint64_t * buffer, unsigned int numberOfComponents = 1 );
82  SITK_RETURN_SELF_TYPE_HEADER SetBufferAsFloat( float * buffer, unsigned int numberOfComponents = 1 );
83  SITK_RETURN_SELF_TYPE_HEADER SetBufferAsDouble( double * buffer, unsigned int numberOfComponents = 1 );
84 
85  Image Execute() override;
86 
87  protected:
88 
89  // Internal method called by the template dispatch system
90  template <class TImageType> Image ExecuteInternal ( );
91 
92  // If the output image type is a VectorImage then the number of
93  // components per pixel needs to be set, otherwise the method
94  // does not exist. This is done with the enable if idiom.
95  template <class TImageType>
96  typename std::enable_if<!IsVector<TImageType>::Value>::type
97  SetNumberOfComponentsOnImage( TImageType* ) {}
98  template <class TImageType>
99  typename std::enable_if<IsVector<TImageType>::Value>::type
100  SetNumberOfComponentsOnImage( TImageType* );
101 
102  private:
103 
104  // function pointer type
105  typedef Image (Self::*MemberFunctionType)( );
106 
107  // friend to get access to executeInternal member
108  friend struct detail::MemberFunctionAddressor<MemberFunctionType>;
109  std::unique_ptr<detail::MemberFunctionFactory<MemberFunctionType> > m_MemberFactory;
110 
113 
114  std::vector< double > m_Origin;
115  std::vector< double > m_Spacing;
116  std::vector< unsigned int > m_Size;
117  std::vector< double > m_Direction;
118 
119  void * m_Buffer;
120 
121  };
122 
124  int8_t * buffer,
125  const std::vector< unsigned int > &size,
126  const std::vector< double > &spacing = std::vector< double >( 3, 1.0 ),
127  const std::vector< double > &origin = std::vector< double >( 3, 0.0 ),
128  const std::vector< double > &direction = std::vector< double >(),
129  unsigned int numberOfComponents = 1
130  );
131 
133  uint8_t * buffer,
134  const std::vector< unsigned int > &size,
135  const std::vector< double > &spacing = std::vector< double >( 3, 1.0 ),
136  const std::vector< double > &origin = std::vector< double >( 3, 0.0 ),
137  const std::vector< double > &direction = std::vector< double >(),
138  unsigned int numberOfComponents = 1
139  );
140 
142  int16_t * buffer,
143  const std::vector< unsigned int > &size,
144  const std::vector< double > &spacing = std::vector< double >( 3, 1.0 ),
145  const std::vector< double > &origin = std::vector< double >( 3, 0.0 ),
146  const std::vector< double > &direction = std::vector< double >(),
147  unsigned int numberOfComponents = 1
148  );
149 
151  uint16_t * buffer,
152  const std::vector< unsigned int > &size,
153  const std::vector< double > &spacing = std::vector< double >( 3, 1.0 ),
154  const std::vector< double > &origin = std::vector< double >( 3, 0.0 ),
155  const std::vector< double > &direction = std::vector< double >(),
156  unsigned int numberOfComponents = 1
157  );
158 
160  int32_t * buffer,
161  const std::vector< unsigned int > &size,
162  const std::vector< double > &spacing = std::vector< double >( 3, 1.0 ),
163  const std::vector< double > &origin = std::vector< double >( 3, 0.0 ),
164  const std::vector< double > &direction = std::vector< double >(),
165  unsigned int numberOfComponents = 1
166  );
167 
169  uint32_t * buffer,
170  const std::vector< unsigned int > &size,
171  const std::vector< double > &spacing = std::vector< double >( 3, 1.0 ),
172  const std::vector< double > &origin = std::vector< double >( 3, 0.0 ),
173  const std::vector< double > &direction = std::vector< double >(),
174  unsigned int numberOfComponents = 1
175  );
176 
178  int64_t * buffer,
179  const std::vector< unsigned int > &size,
180  const std::vector< double > &spacing = std::vector< double >( 3, 1.0 ),
181  const std::vector< double > &origin = std::vector< double >( 3, 0.0 ),
182  const std::vector< double > &direction = std::vector< double >(),
183  unsigned int numberOfComponents = 1
184  );
185 
187  uint64_t * buffer,
188  const std::vector< unsigned int > &size,
189  const std::vector< double > &spacing = std::vector< double >( 3, 1.0 ),
190  const std::vector< double > &origin = std::vector< double >( 3, 0.0 ),
191  const std::vector< double > &direction = std::vector< double >(),
192  unsigned int numberOfComponents = 1
193  );
194 
196  float * buffer,
197  const std::vector< unsigned int > &size,
198  const std::vector< double > &spacing = std::vector< double >( 3, 1.0 ),
199  const std::vector< double > &origin = std::vector< double >( 3, 0.0 ),
200  const std::vector< double > &direction = std::vector< double >(),
201  unsigned int numberOfComponents = 1
202  );
203 
205  double * buffer,
206  const std::vector< unsigned int > &size,
207  const std::vector< double > &spacing = std::vector< double >( 3, 1.0 ),
208  const std::vector< double > &origin = std::vector< double >( 3, 0.0 ),
209  const std::vector< double > &direction = std::vector< double >(),
210  unsigned int numberOfComponents = 1
211  );
212 
213  }
214 }
215 
216 #endif
itk::simple::Image
The Image class for SimpleITK.
Definition: sitkImage.h:75
itk::simple::ImportImageFilter::m_Spacing
std::vector< double > m_Spacing
Definition: sitkImportImageFilter.h:115
itk::uint8_t
::uint8_t uint8_t
itk::simple::ImportImageFilter::m_Origin
std::vector< double > m_Origin
Definition: sitkImportImageFilter.h:114
itk::simple::ImportAsDouble
Image SITKIO_EXPORT ImportAsDouble(double *buffer, const std::vector< unsigned int > &size, const std::vector< double > &spacing=std::vector< double >(3, 1.0), const std::vector< double > &origin=std::vector< double >(3, 0.0), const std::vector< double > &direction=std::vector< double >(), unsigned int numberOfComponents=1)
itk::int16_t
::int16_t int16_t
itk::simple::detail::MemberFunctionAddressor
Definition: sitkDetail.h:32
itk::simple::ImportImageFilter::GetName
std::string GetName() const override
Definition: sitkImportImageFilter.h:60
SITKIO_EXPORT
#define SITKIO_EXPORT
Definition: sitkIO.h:33
itk::int8_t
::int8_t int8_t
itk::simple::ImportImageFilter::m_Direction
std::vector< double > m_Direction
Definition: sitkImportImageFilter.h:117
sitkImage.h
itk::simple::ImportAsFloat
Image SITKIO_EXPORT ImportAsFloat(float *buffer, const std::vector< unsigned int > &size, const std::vector< double > &spacing=std::vector< double >(3, 1.0), const std::vector< double > &origin=std::vector< double >(3, 0.0), const std::vector< double > &direction=std::vector< double >(), unsigned int numberOfComponents=1)
sitkMemberFunctionFactory.h
itk::simple::ImportImageFilter::SetNumberOfComponentsOnImage
std::enable_if<!IsVector< TImageType >::Value >::type SetNumberOfComponentsOnImage(TImageType *)
Definition: sitkImportImageFilter.h:97
itk::int64_t
::int64_t int64_t
itk::simple::ImportAsInt8
Image SITKIO_EXPORT ImportAsInt8(int8_t *buffer, const std::vector< unsigned int > &size, const std::vector< double > &spacing=std::vector< double >(3, 1.0), const std::vector< double > &origin=std::vector< double >(3, 0.0), const std::vector< double > &direction=std::vector< double >(), unsigned int numberOfComponents=1)
itk::simple::ImportImageFilter::m_PixelIDValue
PixelIDValueType m_PixelIDValue
Definition: sitkImportImageFilter.h:112
itk::simple::ImportAsUInt8
Image SITKIO_EXPORT ImportAsUInt8(uint8_t *buffer, const std::vector< unsigned int > &size, const std::vector< double > &spacing=std::vector< double >(3, 1.0), const std::vector< double > &origin=std::vector< double >(3, 0.0), const std::vector< double > &direction=std::vector< double >(), unsigned int numberOfComponents=1)
itk::uint64_t
::uint64_t uint64_t
sitkMacro.h
itk::simple::ImportAsInt16
Image SITKIO_EXPORT ImportAsInt16(int16_t *buffer, const std::vector< unsigned int > &size, const std::vector< double > &spacing=std::vector< double >(3, 1.0), const std::vector< double > &origin=std::vector< double >(3, 0.0), const std::vector< double > &direction=std::vector< double >(), unsigned int numberOfComponents=1)
itk::simple::ImportImageFilter::m_NumberOfComponentsPerPixel
unsigned int m_NumberOfComponentsPerPixel
Definition: sitkImportImageFilter.h:111
itk::simple::ImportImageFilter
Compose a 2D or 3D image and return a smart pointer to a SimpleITK image.
Definition: sitkImportImageFilter.h:47
sitkImageReaderBase.h
itk::simple::ImportAsInt64
Image SITKIO_EXPORT ImportAsInt64(int64_t *buffer, const std::vector< unsigned int > &size, const std::vector< double > &spacing=std::vector< double >(3, 1.0), const std::vector< double > &origin=std::vector< double >(3, 0.0), const std::vector< double > &direction=std::vector< double >(), unsigned int numberOfComponents=1)
itk::simple::ImportImageFilter::m_MemberFactory
std::unique_ptr< detail::MemberFunctionFactory< MemberFunctionType > > m_MemberFactory
Definition: sitkImportImageFilter.h:109
itk::simple::ImportAsInt32
Image SITKIO_EXPORT ImportAsInt32(int32_t *buffer, const std::vector< unsigned int > &size, const std::vector< double > &spacing=std::vector< double >(3, 1.0), const std::vector< double > &origin=std::vector< double >(3, 0.0), const std::vector< double > &direction=std::vector< double >(), unsigned int numberOfComponents=1)
itk::simple::ImportAsUInt16
Image SITKIO_EXPORT ImportAsUInt16(uint16_t *buffer, const std::vector< unsigned int > &size, const std::vector< double > &spacing=std::vector< double >(3, 1.0), const std::vector< double > &origin=std::vector< double >(3, 0.0), const std::vector< double > &direction=std::vector< double >(), unsigned int numberOfComponents=1)
itk::simple::ImageReaderBase
An abract base class for image readers.
Definition: sitkImageReaderBase.h:39
itk
itk::simple::ImportImageFilter::m_Buffer
void * m_Buffer
Definition: sitkImportImageFilter.h:119
itk::simple::ImportAsUInt32
Image SITKIO_EXPORT ImportAsUInt32(uint32_t *buffer, const std::vector< unsigned int > &size, const std::vector< double > &spacing=std::vector< double >(3, 1.0), const std::vector< double > &origin=std::vector< double >(3, 0.0), const std::vector< double > &direction=std::vector< double >(), unsigned int numberOfComponents=1)
itk::uint16_t
::uint16_t uint16_t
itk::simple::ProcessObject
Base class for SimpleITK classes based on ProcessObject.
Definition: sitkProcessObject.h:51
itk::int32_t
::int32_t int32_t
itk::simple::ImportImageFilter::m_Size
std::vector< unsigned int > m_Size
Definition: sitkImportImageFilter.h:116
itk::uint32_t
::uint32_t uint32_t
itk::simple::ImportAsUInt64
Image SITKIO_EXPORT ImportAsUInt64(uint64_t *buffer, const std::vector< unsigned int > &size, const std::vector< double > &spacing=std::vector< double >(3, 1.0), const std::vector< double > &origin=std::vector< double >(3, 0.0), const std::vector< double > &direction=std::vector< double >(), unsigned int numberOfComponents=1)
itk::simple::PixelIDValueType
int PixelIDValueType
Definition: sitkPixelIDValues.h:32