| 53 | |
| 54 | |
| 55 | def 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 | |
| 69 | def test_image_array_protocol(): |