SimpleITK  1.2.4
sitkImportImageFilter.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 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  virtual ~ImportImageFilter();
53 
55 
57  virtual std::string ToString() const;
58 
60  virtual std::string GetName() const { 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();
86 
87  protected:
88 
89  // Internal method called by the template dispatch system
90  template <class TImageType> Image ExecuteInternal ( void );
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 EnableIf Idiom.
95  template <class TImageType>
97  SetNumberOfComponentsOnImage( TImageType* ) {}
98  template <class TImageType>
100  SetNumberOfComponentsOnImage( TImageType* );
101 
102  private:
103 
104  // function pointer type
105  typedef Image (Self::*MemberFunctionType)( void );
106 
107  // friend to get access to executeInternal member
108  friend struct detail::MemberFunctionAddressor<MemberFunctionType>;
109  nsstd::auto_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
An abract base class for image readers.
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)
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)
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)
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)
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)
virtual std::string GetName() const
::uint8_t uint8_t
nsstd::auto_ptr< detail::MemberFunctionFactory< MemberFunctionType > > m_MemberFactory
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)
std::vector< unsigned int > m_Size
::uint16_t uint16_t
#define SITKIO_EXPORT
Definition: sitkIO.h:33
::uint32_t uint32_t
The Image class for SimpleITK.
Definition: sitkImage.h:78
DisableIf< IsVector< TImageType >::Value >::Type SetNumberOfComponentsOnImage(TImageType *)
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)
::int64_t int64_t
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)
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)
Compose a 2D or 3D image and return a smart pointer to a SimpleITK image.
::int8_t int8_t
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)
::int32_t int32_t
::uint64_t uint64_t
::int16_t int16_t