MCPcopy Create free account
hub / github.com/SimpleITK/SimpleITK / GetArrayFromImage

Function GetArrayFromImage

Wrapping/Python/SimpleITK/extra.py:271–281  ·  view source on GitHub ↗

Get a NumPy ndarray from a SimpleITK Image. This is a deep copy of the image buffer and is completely safe and without potential side effects.

(image: Image)

Source from the content-addressed store, hash-verified

269
270
271def GetArrayFromImage(image: Image) -> "numpy.ndarray":
272 """Get a NumPy ndarray from a SimpleITK Image.
273
274 This is a deep copy of the image buffer and is completely safe and without potential side effects.
275 """
276
277 if not HAVE_NUMPY:
278 raise ImportError("NumPy not available.")
279
280 # perform deep copy of the image buffer
281 return numpy.array(image, copy=True)
282
283
284def GetImageFromArray(arr: "numpy.ndarray", isVector: Optional[bool] = None) -> Image:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected