From d76305683fba105533f6a4b86e558b042ef220d1 Mon Sep 17 00:00:00 2001 From: John Evans Date: Thu, 13 Mar 2014 18:46:29 -0400 Subject: [PATCH] Added jp2 and jpx cxform tests. jpx fails on i386 linux. --- glymur/test/test_jp2k.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/glymur/test/test_jp2k.py b/glymur/test/test_jp2k.py index 98173a0..3046422 100644 --- a/glymur/test/test_jp2k.py +++ b/glymur/test/test_jp2k.py @@ -95,7 +95,27 @@ class TestJp2k(unittest.TestCase): with self.assertRaises(IOError): Jp2k(filename) - def test_no_cxform_pclr(self): + @unittest.skipIf(OPJ_DATA_ROOT is None, + "OPJ_DATA_ROOT environment variable not set") + def test_no_cxform_pclr_jp2(self): + """Indices for pclr jpxfile if no color transform""" + filename = opj_data_file('input/conformance/file9.jp2') + j = Jp2k(filename) + rgb = j.read() + idx = j.read(no_cxform=True) + self.assertEqual(rgb.shape, (512, 768, 3)) + self.assertEqual(idx.shape, (512, 768)) + + # Should be able to manually reconstruct the RGB image from the palette + # and indices. + palette = j.box[2].box[1].palette + rgb_from_idx = np.zeros(rgb.shape, dtype=np.uint8) + for r in np.arange(rgb.shape[0]): + for c in np.arange(rgb.shape[1]): + rgb_from_idx[r, c] = palette[idx[r, c]] + np.testing.assert_array_equal(rgb, rgb_from_idx) + + def test_no_cxform_pclr_jpx(self): """Indices for pclr jpxfile if no color transform""" j = Jp2k(self.jpxfile) rgb = j.read()