ITK  6.0.0
Insight Toolkit
itkPyImageFilter.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 itkPyImageFilter_h
20#define itkPyImageFilter_h
21
23
24// The python header defines _POSIX_C_SOURCE without a preceding #undef
25#undef _POSIX_C_SOURCE
26#undef _XOPEN_SOURCE
27#include "Python.h"
28
29namespace itk
30{
31
41template <class TInputImage, class TOutputImage>
42class ITK_TEMPLATE_EXPORT PyImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
43{
44public:
45 ITK_DISALLOW_COPY_AND_MOVE(PyImageFilter);
46
52
54 itkNewMacro(Self);
55
57 itkOverrideGetNameOfClassMacro(PyImageFilter);
58
60 using InputImageType = TInputImage;
63 using InputImagePixelType = typename InputImageType::PixelType;
64 using OutputImageType = TOutputImage;
67 using OutputImagePixelType = typename OutputImageType::PixelType;
68
70 static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
71 static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
72
76 void
78
82 void
84
88 void
90
94 void
95 SetPyGenerateData(PyObject * obj);
96
98 void
99 _SetSelf(PyObject * self)
100 {
101 this->m_Self = self;
102 }
103
104protected:
106 ~PyImageFilter() override;
107
108 void
110
111 void
113
114 void
116
117 void
118 GenerateData() override;
119
120private:
121 PyObject * m_Self;
122 PyObject * m_GenerateInputRequestedRegionCallable{ nullptr };
123 PyObject * m_GenerateOutputInformationCallable{ nullptr };
124 PyObject * m_EnlargeOutputRequestedRegionCallable{ nullptr };
125 PyObject * m_GenerateDataCallable{ nullptr };
126};
127
128} // end namespace itk
129
130
131#ifndef ITK_MANUAL_INSTANTIATION
132# include "itkPyImageFilter.hxx"
133#endif
134
135#endif // _itkPyImageFilter_h
Base class for all data objects in ITK.
Base class for all process objects that output image data.
typename OutputImageType::PixelType OutputImagePixelType
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
typename OutputImageType::Pointer OutputImagePointer
Base class for filters that take an image as input and produce an image as output.
typename InputImageType::Pointer InputImagePointer
typename InputImageType::PixelType InputImagePixelType
typename InputImageType::RegionType InputImageRegionType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
ImageToImageFilter subclass that calls a Python callable object, e.g. a Python function or a class wi...
void SetPyGenerateOutputInformation(PyObject *obj)
void _SetSelf(PyObject *self)
void SetPyGenerateData(PyObject *obj)
void SetPyEnlargeOutputRequestedRegion(PyObject *obj)
void SetPyGenerateInputRequestedRegion(PyObject *obj)
void EnlargeOutputRequestedRegion(DataObject *dataObject) override
void GenerateOutputInformation() override
~PyImageFilter() override
void GenerateInputRequestedRegion() override
void GenerateData() override
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....