MCPcopy Create free account
hub / github.com/MITK/MITK / AsNumpyDirect

Function AsNumpyDirect

Wrapping/Python/mitk/Image.cpp:160–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160py::array AsNumpyDirect(Image& img, bool writeable, mitk::TimeStepType time_step)
161{
162 void* data = img.GetData(static_cast<int>(time_step));
163
164 if (data == nullptr)
165 mitkThrow() << "Could not access image data at time step " << time_step;
166
167 // Pin the Image::Pointer in the capsule so the buffer outlives the
168 // numpy array regardless of who else holds a reference to the image.
169 auto* pin = new Image::Pointer(&img);
170 auto capsule = py::capsule(pin, "mitk.ImagePin", &DeleteImagePinCapsule);
171
172 return BuildNumpyArray(img, data, writeable, std::move(capsule));
173}
174
175py::array AsNumpyAccessor(Image& img, bool writeable)
176{

Callers 1

InitImageFunction · 0.85

Calls 2

BuildNumpyArrayFunction · 0.85
GetDataMethod · 0.45

Tested by

no test coverage detected