Changing name to "ignore_pclr_cmap_cdef". #179
This commit is contained in:
parent
d483e2cd4b
commit
1be7c4ec50
3 changed files with 24 additions and 19 deletions
|
|
@ -695,8 +695,9 @@ class Jp2k(Jp2kBox):
|
||||||
(first_row, first_col, last_row, last_col)
|
(first_row, first_col, last_row, last_col)
|
||||||
tile : int, optional
|
tile : int, optional
|
||||||
Number of tile to decode.
|
Number of tile to decode.
|
||||||
no_cxform : bool
|
ignore_pclr_cmap_cdef : bool
|
||||||
Whether or not to apply intended color transforms.
|
Whether or not to ignore the pclr, cmap, or cdef boxes during any
|
||||||
|
color transformation. Defaults to False.
|
||||||
verbose : bool, optional
|
verbose : bool, optional
|
||||||
Print informational messages produced by the OpenJPEG library.
|
Print informational messages produced by the OpenJPEG library.
|
||||||
|
|
||||||
|
|
@ -751,7 +752,7 @@ class Jp2k(Jp2kBox):
|
||||||
msg += "the read_bands method instead."
|
msg += "the read_bands method instead."
|
||||||
raise RuntimeError(msg)
|
raise RuntimeError(msg)
|
||||||
|
|
||||||
def _read_openjpeg(self, rlevel=0, no_cxform=False, verbose=False):
|
def _read_openjpeg(self, rlevel=0, ignore_pclr_cmap_cdef=False, verbose=False):
|
||||||
"""Read a JPEG 2000 image using libopenjpeg.
|
"""Read a JPEG 2000 image using libopenjpeg.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
|
@ -759,8 +760,9 @@ class Jp2k(Jp2kBox):
|
||||||
rlevel : int, optional
|
rlevel : int, optional
|
||||||
Factor by which to rlevel output resolution. Use -1 to get the
|
Factor by which to rlevel output resolution. Use -1 to get the
|
||||||
lowest resolution thumbnail.
|
lowest resolution thumbnail.
|
||||||
no_cxform : bool
|
ignore_pclr_cmap_cdef : bool
|
||||||
Whether or not to apply intended color transforms.
|
Whether or not to ignore the pclr, cmap, or cdef boxes during any
|
||||||
|
color transformation. Defaults to False.
|
||||||
verbose : bool, optional
|
verbose : bool, optional
|
||||||
Print informational messages produced by the OpenJPEG library.
|
Print informational messages produced by the OpenJPEG library.
|
||||||
|
|
||||||
|
|
@ -796,7 +798,7 @@ class Jp2k(Jp2kBox):
|
||||||
dparameters = opj.DecompressionParametersType()
|
dparameters = opj.DecompressionParametersType()
|
||||||
opj.set_default_decoder_parameters(ctypes.byref(dparameters))
|
opj.set_default_decoder_parameters(ctypes.byref(dparameters))
|
||||||
|
|
||||||
if no_cxform is True:
|
if ignore_pclr_cmap_cdef is True:
|
||||||
# Return raw codestream components.
|
# Return raw codestream components.
|
||||||
dparameters.flags |= 1
|
dparameters.flags |= 1
|
||||||
|
|
||||||
|
|
@ -844,7 +846,7 @@ class Jp2k(Jp2kBox):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _read_openjp2(self, rlevel=0, layer=0, area=None, tile=None,
|
def _read_openjp2(self, rlevel=0, layer=0, area=None, tile=None,
|
||||||
verbose=False, no_cxform=False):
|
verbose=False, ignore_pclr_cmap_cdef=False):
|
||||||
"""Read a JPEG 2000 image using libopenjp2.
|
"""Read a JPEG 2000 image using libopenjp2.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
|
@ -874,7 +876,8 @@ class Jp2k(Jp2kBox):
|
||||||
"""
|
"""
|
||||||
self._subsampling_sanity_check()
|
self._subsampling_sanity_check()
|
||||||
|
|
||||||
dparam = self._populate_dparam(layer, rlevel, area, tile, no_cxform)
|
dparam = self._populate_dparam(layer, rlevel, area, tile,
|
||||||
|
ignore_pclr_cmap_cdef)
|
||||||
|
|
||||||
with ExitStack() as stack:
|
with ExitStack() as stack:
|
||||||
if hasattr(opj2.OPENJP2,
|
if hasattr(opj2.OPENJP2,
|
||||||
|
|
@ -918,7 +921,7 @@ class Jp2k(Jp2kBox):
|
||||||
|
|
||||||
return img_array
|
return img_array
|
||||||
|
|
||||||
def _populate_dparam(self, layer, rlevel, area, tile, no_cxform):
|
def _populate_dparam(self, layer, rlevel, area, tile, ignore_pclr_cmap_cdef):
|
||||||
"""Populate decompression structure with appropriate input parameters.
|
"""Populate decompression structure with appropriate input parameters.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
|
@ -932,8 +935,9 @@ class Jp2k(Jp2kBox):
|
||||||
(first_row, first_col, last_row, last_col)
|
(first_row, first_col, last_row, last_col)
|
||||||
tile : int
|
tile : int
|
||||||
Number of tile to decode.
|
Number of tile to decode.
|
||||||
no_cxform : bool
|
ignore_pclr_cmap_cdef : bool
|
||||||
Whether or not to apply intended color transforms.
|
Whether or not to ignore the pclr, cmap, or cdef boxes during any
|
||||||
|
color transformation. Defaults to False.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
|
|
@ -971,14 +975,14 @@ class Jp2k(Jp2kBox):
|
||||||
dparam.tile_index = tile
|
dparam.tile_index = tile
|
||||||
dparam.nb_tile_to_decode = 1
|
dparam.nb_tile_to_decode = 1
|
||||||
|
|
||||||
if no_cxform is True:
|
if ignore_pclr_cmap_cdef is True:
|
||||||
# Return raw codestream components.
|
# Return raw codestream components.
|
||||||
dparam.flags |= 1
|
dparam.flags |= 1
|
||||||
|
|
||||||
return dparam
|
return dparam
|
||||||
|
|
||||||
def read_bands(self, rlevel=0, layer=0, area=None, tile=None,
|
def read_bands(self, rlevel=0, layer=0, area=None, tile=None,
|
||||||
verbose=False, no_cxform=False):
|
verbose=False, ignore_pclr_cmap_cdef=False):
|
||||||
"""Read a JPEG 2000 image.
|
"""Read a JPEG 2000 image.
|
||||||
|
|
||||||
The only time you should use this method is when the image has
|
The only time you should use this method is when the image has
|
||||||
|
|
@ -996,8 +1000,9 @@ class Jp2k(Jp2kBox):
|
||||||
(first_row, first_col, last_row, last_col)
|
(first_row, first_col, last_row, last_col)
|
||||||
tile : int, optional
|
tile : int, optional
|
||||||
Number of tile to decode.
|
Number of tile to decode.
|
||||||
no_cxform : bool
|
ignore_pclr_cmap_cdef : bool
|
||||||
Whether or not to apply intended color transforms.
|
Whether or not to ignore the pclr, cmap, or cdef boxes during any
|
||||||
|
color transformation. Defaults to False.
|
||||||
verbose : bool, optional
|
verbose : bool, optional
|
||||||
Print informational messages produced by the OpenJPEG library.
|
Print informational messages produced by the OpenJPEG library.
|
||||||
|
|
||||||
|
|
@ -1027,7 +1032,7 @@ class Jp2k(Jp2kBox):
|
||||||
"of OpenJP2 installed before using "
|
"of OpenJP2 installed before using "
|
||||||
"this functionality.")
|
"this functionality.")
|
||||||
|
|
||||||
dparam = self._populate_dparam(layer, rlevel, area, tile, no_cxform)
|
dparam = self._populate_dparam(layer, rlevel, area, tile, ignore_pclr_cmap_cdef)
|
||||||
|
|
||||||
with ExitStack() as stack:
|
with ExitStack() as stack:
|
||||||
if hasattr(opj2.OPENJP2,
|
if hasattr(opj2.OPENJP2,
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ class TestJp2k(unittest.TestCase):
|
||||||
"""Indices for pclr jpxfile if no color transform"""
|
"""Indices for pclr jpxfile if no color transform"""
|
||||||
j = Jp2k(self.jpxfile)
|
j = Jp2k(self.jpxfile)
|
||||||
rgb = j.read()
|
rgb = j.read()
|
||||||
idx = j.read(no_cxform=True)
|
idx = j.read(ignore_pclr_cmap_cdef=True)
|
||||||
self.assertEqual(rgb.shape, (1024, 1024, 3))
|
self.assertEqual(rgb.shape, (1024, 1024, 3))
|
||||||
self.assertEqual(idx.shape, (1024, 1024))
|
self.assertEqual(idx.shape, (1024, 1024))
|
||||||
|
|
||||||
|
|
@ -119,7 +119,7 @@ class TestJp2k(unittest.TestCase):
|
||||||
filename = opj_data_file('input/conformance/file2.jp2')
|
filename = opj_data_file('input/conformance/file2.jp2')
|
||||||
j = Jp2k(filename)
|
j = Jp2k(filename)
|
||||||
ycbcr = j.read()
|
ycbcr = j.read()
|
||||||
crcby = j.read(no_cxform=True)
|
crcby = j.read(ignore_pclr_cmap_cdef=True)
|
||||||
|
|
||||||
expected = np.zeros(ycbcr.shape, ycbcr.dtype)
|
expected = np.zeros(ycbcr.shape, ycbcr.dtype)
|
||||||
for k in range(crcby.shape[2]):
|
for k in range(crcby.shape[2]):
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,7 @@ class TestSuiteWriteCinema(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
@unittest.skipIf(re.match(r"""2\.0""", glymur.version.openjpeg_version),
|
@unittest.skipIf(not re.match(r"""(1.5|2.0)""", glymur.version.openjpeg_version),
|
||||||
"Functionality implemented for 2.1")
|
"Functionality implemented for 2.1")
|
||||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||||
"OPJ_OPJ_DATA_ROOT environment variable not set")
|
"OPJ_OPJ_DATA_ROOT environment variable not set")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue