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

Function test_image_from_numpy

Modules/Python/test/pytest/test_image_numpy.py:55–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

53
54
55def test_image_from_numpy():
56 array = np.arange(2 * 3 * 4, dtype=np.float32).reshape(4, 3, 2)
57
58 image = mitk.Image.from_numpy(array, spacing=(0.5, 1.0, 2.0), origin=(1.0, 2.0, 3.0))
59 assert image.shape == array.shape
60 assert image.spacing == (0.5, 1.0, 2.0)
61 assert image.origin == (1.0, 2.0, 3.0)
62 np.testing.assert_array_equal(image.as_numpy(), array)
63
64 image_from_ctor = mitk.Image(array, spacing=(0.5, 1.0, 2.0))
65 assert image_from_ctor.shape == array.shape
66 assert image_from_ctor.spacing == (0.5, 1.0, 2.0)
67
68
69def test_image_array_protocol():

Callers

nothing calls this directly

Calls 1

ImageMethod · 0.45

Tested by

no test coverage detected