From 83755cef0a5a4ef70a126bc8eb6e6572c6ca3ff1 Mon Sep 17 00:00:00 2001 From: jevans Date: Sun, 25 May 2014 21:44:08 -0400 Subject: [PATCH] Added another irreversible test to not use OPJ_TEST_SUITE. #238 --- glymur/test/test_jp2k.py | 33 ++++++++++++++--------------- glymur/test/test_opj_suite_write.py | 15 +++++++++++++ 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/glymur/test/test_jp2k.py b/glymur/test/test_jp2k.py index 49a491e..6e328e0 100644 --- a/glymur/test/test_jp2k.py +++ b/glymur/test/test_jp2k.py @@ -63,6 +63,22 @@ class TestJp2k(unittest.TestCase): def tearDown(self): pass + def test_irreversible(self): + """Irreversible""" + j = Jp2k(self.jp2file) + expdata = j.read() + with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile: + j2 = Jp2k(tfile.name, 'wb') + j2.write(expdata, irreversible=True) + + codestream = j2.get_codestream() + self.assertEqual(codestream.segment[2].spcod[8], + glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE) + + actdata = j2.read() + self.assertTrue(fixtures.mse(actdata[0], expdata[0]) < 0.38) + + def test_no_cxform_pclr_jpx(self): """Indices for pclr jpxfile if no color transform""" j = Jp2k(self.jpxfile) @@ -401,23 +417,6 @@ class TestJp2k_write(unittest.TestCase): def tearDown(self): pass - def test_irreversible(self): - """Irreversible""" - filename = opj_data_file('input/nonregression/issue141.rawl') - expdata = np.fromfile(filename, dtype=np.uint16) - expdata.resize((2816, 2048)) - with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile: - j = Jp2k(tfile.name, 'wb') - j.write(expdata, irreversible=True) - - codestream = j.get_codestream() - self.assertEqual(codestream.segment[2].spcod[8], - glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE) - - actdata = j.read() - self.assertTrue(fixtures.mse(actdata, expdata) < 250) - - def test_cblkh_different_than_width(self): """Verify that we can set a code block size where height does not equal width. diff --git a/glymur/test/test_opj_suite_write.py b/glymur/test/test_opj_suite_write.py index 77ef262..5fdc0ca 100644 --- a/glymur/test/test_opj_suite_write.py +++ b/glymur/test/test_opj_suite_write.py @@ -13,6 +13,8 @@ import tempfile import unittest import warnings +import numpy as np + try: import skimage.io skimage.io.use_plugin('freeimage', 'imread') @@ -271,6 +273,19 @@ class TestSuiteWrite(unittest.TestCase): def tearDown(self): pass + def test_NR_ENC_issue141_rawl_23_encode(self): + filename = opj_data_file('input/nonregression/issue141.rawl') + expdata = np.fromfile(filename, dtype=np.uint16) + expdata.resize((2816, 2048)) + with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile: + j = Jp2k(tfile.name, 'wb') + j.write(expdata, irreversible=True) + + codestream = j.get_codestream() + self.assertEqual(codestream.segment[2].spcod[8], + glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE) + + def test_NR_ENC_Bretagne1_ppm_1_encode(self): """NR-ENC-Bretagne1.ppm-1-encode""" infile = opj_data_file('input/nonregression/Bretagne1.ppm')