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