merge branch 'issue275' into devel
This commit is contained in:
commit
6572fd8772
2 changed files with 26 additions and 18 deletions
|
|
@ -214,9 +214,9 @@ making use of the :py:meth:`set_printoptions` function::
|
||||||
UUID: be7acfcb-97a9-42e8-9c71-999491e3afac (XMP)
|
UUID: be7acfcb-97a9-42e8-9c71-999491e3afac (XMP)
|
||||||
Contiguous Codestream Box (jp2c) @ (3223, 1132296)
|
Contiguous Codestream Box (jp2c) @ (3223, 1132296)
|
||||||
|
|
||||||
It is possible to print all the gory codestream details as well, i.e. ::
|
It is possible to easily print the codestream header details as well, i.e. ::
|
||||||
|
|
||||||
>>> print(j.get_codestream()) # details not shown
|
>>> print(j.codestream) # details not show
|
||||||
|
|
||||||
... add XML metadata?
|
... add XML metadata?
|
||||||
=====================
|
=====================
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,8 @@ class Jp2k(Jp2kBox):
|
||||||
verbose : bool
|
verbose : bool
|
||||||
whether or not to print informational messages produced by the
|
whether or not to print informational messages produced by the
|
||||||
OpenJPEG library, defaults to false
|
OpenJPEG library, defaults to false
|
||||||
|
codestream : object
|
||||||
|
JP2 or J2K codestream object
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
--------
|
--------
|
||||||
|
|
@ -145,6 +147,7 @@ class Jp2k(Jp2kBox):
|
||||||
self._codec_format = None
|
self._codec_format = None
|
||||||
self._colorspace = None
|
self._colorspace = None
|
||||||
self._layer = 0
|
self._layer = 0
|
||||||
|
self._codestream = None
|
||||||
if data is not None:
|
if data is not None:
|
||||||
self._shape = data.shape
|
self._shape = data.shape
|
||||||
else:
|
else:
|
||||||
|
|
@ -179,6 +182,16 @@ class Jp2k(Jp2kBox):
|
||||||
raise RuntimeError(msg)
|
raise RuntimeError(msg)
|
||||||
self._layer = layer
|
self._layer = layer
|
||||||
|
|
||||||
|
@property
|
||||||
|
def codestream(self):
|
||||||
|
if self._codestream is None:
|
||||||
|
self._codestream = self.get_codestream(header_only=True)
|
||||||
|
return self._codestream
|
||||||
|
|
||||||
|
@codestream.setter
|
||||||
|
def codestream(self, the_codestream):
|
||||||
|
self._codestream = the_codestream
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def verbose(self):
|
def verbose(self):
|
||||||
return self._verbose
|
return self._verbose
|
||||||
|
|
@ -192,7 +205,7 @@ class Jp2k(Jp2kBox):
|
||||||
if self._shape is not None:
|
if self._shape is not None:
|
||||||
return self._shape
|
return self._shape
|
||||||
|
|
||||||
cstr = self.get_codestream(header_only=True)
|
cstr = self.codestream
|
||||||
height = cstr.segment[1].ysiz
|
height = cstr.segment[1].ysiz
|
||||||
width = cstr.segment[1].xsiz
|
width = cstr.segment[1].xsiz
|
||||||
num_components = len(cstr.segment[1].xrsiz)
|
num_components = len(cstr.segment[1].xrsiz)
|
||||||
|
|
@ -233,8 +246,7 @@ class Jp2k(Jp2kBox):
|
||||||
for box in self.box:
|
for box in self.box:
|
||||||
metadata.append(str(box))
|
metadata.append(str(box))
|
||||||
else:
|
else:
|
||||||
codestream = self.get_codestream()
|
metadata.append(str(self.codestream))
|
||||||
metadata.append(str(codestream))
|
|
||||||
return '\n'.join(metadata)
|
return '\n'.join(metadata)
|
||||||
|
|
||||||
def parse(self):
|
def parse(self):
|
||||||
|
|
@ -865,10 +877,9 @@ class Jp2k(Jp2kBox):
|
||||||
FileTypeBox(),
|
FileTypeBox(),
|
||||||
JP2HeaderBox(),
|
JP2HeaderBox(),
|
||||||
ContiguousCodestreamBox()]
|
ContiguousCodestreamBox()]
|
||||||
codestream = self.get_codestream()
|
height = self.codestream.segment[1].ysiz
|
||||||
height = codestream.segment[1].ysiz
|
width = self.codestream.segment[1].xsiz
|
||||||
width = codestream.segment[1].xsiz
|
num_components = len(self.codestream.segment[1].xrsiz)
|
||||||
num_components = len(codestream.segment[1].xrsiz)
|
|
||||||
if num_components < 3:
|
if num_components < 3:
|
||||||
colorspace = core.GREYSCALE
|
colorspace = core.GREYSCALE
|
||||||
else:
|
else:
|
||||||
|
|
@ -907,10 +918,9 @@ class Jp2k(Jp2kBox):
|
||||||
"""
|
"""
|
||||||
Slicing protocol.
|
Slicing protocol.
|
||||||
"""
|
"""
|
||||||
codestream = self.get_codestream(header_only=True)
|
numrows = self.codestream.segment[1].ysiz
|
||||||
numrows = codestream.segment[1].ysiz
|
numcols = self.codestream.segment[1].xsiz
|
||||||
numcols = codestream.segment[1].xsiz
|
numbands = self.codestream.segment[1].Csiz
|
||||||
numbands = codestream.segment[1].Csiz
|
|
||||||
|
|
||||||
if isinstance(pargs, int):
|
if isinstance(pargs, int):
|
||||||
# Not a very good use of this protocol, but technically legal.
|
# Not a very good use of this protocol, but technically legal.
|
||||||
|
|
@ -1072,9 +1082,8 @@ class Jp2k(Jp2kBox):
|
||||||
def _subsampling_sanity_check(self):
|
def _subsampling_sanity_check(self):
|
||||||
"""Check for differing subsample factors.
|
"""Check for differing subsample factors.
|
||||||
"""
|
"""
|
||||||
codestream = self.get_codestream(header_only=True)
|
dxs = np.array(self.codestream.segment[1].xrsiz)
|
||||||
dxs = np.array(codestream.segment[1].xrsiz)
|
dys = np.array(self.codestream.segment[1].yrsiz)
|
||||||
dys = np.array(codestream.segment[1].yrsiz)
|
|
||||||
if np.any(dxs - dxs[0]) or np.any(dys - dys[0]):
|
if np.any(dxs - dxs[0]) or np.any(dys - dys[0]):
|
||||||
msg = "Components must all have the same subsampling factors "
|
msg = "Components must all have the same subsampling factors "
|
||||||
msg += "to use this method. Please consider using OPENJP2 and "
|
msg += "to use this method. Please consider using OPENJP2 and "
|
||||||
|
|
@ -1277,8 +1286,7 @@ class Jp2k(Jp2kBox):
|
||||||
# Must check the specified rlevel against the maximum.
|
# Must check the specified rlevel against the maximum.
|
||||||
if rlevel != 0:
|
if rlevel != 0:
|
||||||
# Must check the specified rlevel against the maximum.
|
# Must check the specified rlevel against the maximum.
|
||||||
codestream = self.get_codestream()
|
max_rlevel = self.codestream.segment[2].spcod[4]
|
||||||
max_rlevel = codestream.segment[2].spcod[4]
|
|
||||||
if rlevel == -1:
|
if rlevel == -1:
|
||||||
# -1 is shorthand for the largest rlevel
|
# -1 is shorthand for the largest rlevel
|
||||||
rlevel = max_rlevel
|
rlevel = max_rlevel
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue