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

Function GetArrayViewFromImage

Wrapping/Python/SimpleITK/extra.py:258–268  ·  view source on GitHub ↗

Get a NumPy ndarray view of a SimpleITK Image. Returns a a read-only view of the image buffer. The behavior of modifying the underlying SimpleITK image while the NumPy array view exists is undefined.

(image: Image)

Source from the content-addressed store, hash-verified

256
257
258def GetArrayViewFromImage(image: Image) -> "numpy.ndarray":
259 """Get a NumPy ndarray view of a SimpleITK Image.
260
261 Returns a a read-only view of the image buffer. The behavior of modifying the underlying
262 SimpleITK image while the NumPy array view exists is undefined.
263 """
264
265 if not HAVE_NUMPY:
266 raise ImportError("NumPy not available.")
267
268 return numpy.asarray(image, copy=False)
269
270
271def GetArrayFromImage(image: Image) -> "numpy.ndarray":

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected