ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkPyBuffer.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 * https://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"
25
26
27// The python header defines _POSIX_C_SOURCE without a preceding #undef
28#undef _POSIX_C_SOURCE
29#undef _XOPEN_SOURCE
30#include <Python.h>
31
32namespace itk
33{
34
46template <typename TImage>
48{
49public:
51 using Self = PyBuffer;
52
54 using ImageType = TImage;
55 using PixelType = typename ImageType::PixelType;
56 using SizeType = typename ImageType::SizeType;
57 using IndexType = typename ImageType::IndexType;
58 using RegionType = typename ImageType::RegionType;
59 using PointType = typename ImageType::PointType;
60 using SpacingType = typename ImageType::SpacingType;
61 using ImagePointer = typename ImageType::Pointer;
63
65 static constexpr unsigned int ImageDimension = ImageType::ImageDimension;
66
67 using OutputImagePointer = typename TImage::Pointer;
68
72 static PyObject *
74
81};
82
83} // namespace itk
84
85#ifndef ITK_MANUAL_INSTANTIATION
86# include "itkPyBuffer.hxx"
87#endif
88
89#endif // _itkPyBuffer_h
typename PixelType::ComponentType ComponentType
Helper class to get ITK image views into python arrays and back.
Definition itkPyBuffer.h:48
typename DefaultConvertPixelTraits< PixelType >::ComponentType ComponentType
Definition itkPyBuffer.h:62
TImage ImageType
Definition itkPyBuffer.h:54
typename ImageType::IndexType IndexType
Definition itkPyBuffer.h:57
typename ImageType::PointType PointType
Definition itkPyBuffer.h:59
typename ImageType::SizeType SizeType
Definition itkPyBuffer.h:56
static constexpr unsigned int ImageDimension
Definition itkPyBuffer.h:65
typename ImageType::Pointer ImagePointer
Definition itkPyBuffer.h:61
static OutputImagePointer _get_image_view_from_contiguous_array(PyObject *arr, PyObject *shape, PyObject *numOfComponent)
static PyObject * _GetArrayViewFromImage(ImageType *image)
typename ImageType::RegionType RegionType
Definition itkPyBuffer.h:58
typename ImageType::SpacingType SpacingType
Definition itkPyBuffer.h:60
PyBuffer Self
Definition itkPyBuffer.h:51
typename TImage::Pointer OutputImagePointer
Definition itkPyBuffer.h:67
typename ImageType::PixelType PixelType
Definition itkPyBuffer.h:55
struct _object PyObject
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....