Added test for reversed components and cdef box. #179

This commit is contained in:
John Evans 2014-03-13 07:15:07 -04:00
commit 78351219e9
2 changed files with 19 additions and 2 deletions

View file

@ -695,6 +695,8 @@ class Jp2k(Jp2kBox):
(first_row, first_col, last_row, last_col)
tile : int, optional
Number of tile to decode.
no_cxform : bool
Whether or not to apply intended color transforms.
verbose : bool, optional
Print informational messages produced by the OpenJPEG library.

View file

@ -95,8 +95,8 @@ class TestJp2k(unittest.TestCase):
with self.assertRaises(IOError):
Jp2k(filename)
def test_no_cxform(self):
"""Indices for jpxfile if no color transform"""
def test_no_cxform_pclr(self):
"""Indices for pclr jpxfile if no color transform"""
j = Jp2k(self.jpxfile)
rgb = j.read()
idx = j.read(no_cxform=True)
@ -112,6 +112,21 @@ class TestJp2k(unittest.TestCase):
rgb_from_idx[r, c] = palette[idx[r, c]]
np.testing.assert_array_equal(rgb, rgb_from_idx)
def test_no_cxform_cmap(self):
"""Bands as physically ordered, not as physically intended"""
# This file has the components physically reversed. The cmap box
# tells the decoder how to order them, but this flag prevents that.
filename = opj_data_file('input/conformance/file2.jp2')
j = Jp2k(filename)
ycbcr = j.read()
crcby = j.read(no_cxform=True)
expected = np.zeros(ycbcr.shape, ycbcr.dtype)
for k in range(crcby.shape[2]):
expected[:,:,crcby.shape[2] - k - 1] = crcby[:,:,k]
np.testing.assert_array_equal(ycbcr, expected)
def test_file_not_present(self):
"""Should error out if reading from a file that does not exist"""
# Verify that we error out appropriately if not given an existing file