MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / test_write_gray_1channel

Method test_write_gray_1channel

tests/data/test_png_rw.py:50–60  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

48 np.testing.assert_allclose(out, img_save_val)
49
50 def test_write_gray_1channel(self):
51 with tempfile.TemporaryDirectory() as out_dir:
52 image_name = os.path.join(out_dir, "test.png")
53 img = np.random.rand(2, 3, 1)
54 img_save_val = (255 * img).astype(np.uint8).squeeze(2)
55 writer_obj = PILWriter(output_dtype=np.uint8, scale=255)
56 writer_obj.set_data_array(img, channel_dim=None)
57 writer_obj.write(image_name, format="PNG")
58 out = np.asarray(Image.open(image_name))
59 out = np.moveaxis(out, 0, 1)
60 np.testing.assert_allclose(out, img_save_val)
61
62 def test_write_rgb(self):
63 """testing default kwargs and obj_kwargs"""

Callers

nothing calls this directly

Calls 4

set_data_arrayMethod · 0.95
writeMethod · 0.95
PILWriterClass · 0.90
astypeMethod · 0.80

Tested by

no test coverage detected