ITK  4.11.0
Insight Segmentation and Registration Toolkit
itkPyBuffer.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 
19 #ifndef itkPyBuffer_h
20 #define itkPyBuffer_h
21 
22 #include "itkObject.h"
23 #include "itkObjectFactory.h"
24 #include "itkImportImageFilter.h"
26 
27 
28 // The python header defines _POSIX_C_SOURCE without a preceding #undef
29 #undef _POSIX_C_SOURCE
30 #include <Python.h>
31 
32 namespace itk
33 {
34 
45 template <typename TImage>
46 class PyBuffer
47 {
48 public:
50  typedef PyBuffer Self;
51 
53  typedef TImage ImageType;
54  typedef typename ImageType::PixelType PixelType;
55  typedef typename ImageType::SizeType SizeType;
56  typedef typename ImageType::IndexType IndexType;
57  typedef typename ImageType::RegionType RegionType;
58  typedef typename ImageType::PointType PointType;
59  typedef typename ImageType::SpacingType SpacingType;
60  typedef typename ImageType::Pointer ImagePointer;
62 
64  itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
65 
67 
71  static PyObject * _GetArrayFromImage( ImageType * image);
72 
76  static const OutputImagePointer _GetImageFromArray( PyObject *arr, PyObject *shape, PyObject *numOfComponent);
77 
78 protected:
79 
80 private:
81  PyBuffer(const Self&); // Purposely not implemented.
82  void operator=(const Self&); // Purposely not implemented.
83 };
84 
85 } // namespace itk
86 
87 #ifndef ITK_MANUAL_INSTANTIATION
88 #include "itkPyBuffer.hxx"
89 #endif
90 
91 #endif // _itkPyBuffer_h
void operator=(const Self &)
ImageType::RegionType RegionType
Definition: itkPyBuffer.h:57
ImageType::PointType PointType
Definition: itkPyBuffer.h:58
PyBuffer(const Self &)
PyBuffer Self
Definition: itkPyBuffer.h:50
DefaultConvertPixelTraits< PixelType >::ComponentType ComponentType
Definition: itkPyBuffer.h:61
static const unsigned int ImageDimension
Definition: itkPyBuffer.h:64
TImage ImageType
Definition: itkPyBuffer.h:53
ImageType::SizeType SizeType
Definition: itkPyBuffer.h:55
static PyObject * _GetArrayFromImage(ImageType *image)
Helper class for converting C buffers into python arrays.
Definition: itkPyBuffer.h:46
static const OutputImagePointer _GetImageFromArray(PyObject *arr, PyObject *shape, PyObject *numOfComponent)
ImageType::Pointer ImagePointer
Definition: itkPyBuffer.h:60
ImageType::PixelType PixelType
Definition: itkPyBuffer.h:54
Image< ComponentType, ImageDimension >::Pointer OutputImagePointer
Definition: itkPyBuffer.h:66
ImageType::IndexType IndexType
Definition: itkPyBuffer.h:56
ImageType::SpacingType SpacingType
Definition: itkPyBuffer.h:59