Glymur 0.13.3__py3-none-any.whl → 0.13.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {Glymur-0.13.3.dist-info → Glymur-0.13.5.dist-info}/METADATA +1 -1
- {Glymur-0.13.3.dist-info → Glymur-0.13.5.dist-info}/RECORD +11 -11
- {Glymur-0.13.3.dist-info → Glymur-0.13.5.dist-info}/WHEEL +1 -1
- glymur/codestream.py +84 -3
- glymur/jp2box.py +7 -4
- glymur/jp2k.py +9 -45
- glymur/jp2kr.py +22 -2
- glymur/version.py +1 -1
- {Glymur-0.13.3.dist-info → Glymur-0.13.5.dist-info}/LICENSE.txt +0 -0
- {Glymur-0.13.3.dist-info → Glymur-0.13.5.dist-info}/entry_points.txt +0 -0
- {Glymur-0.13.3.dist-info → Glymur-0.13.5.dist-info}/top_level.txt +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
glymur/__init__.py,sha256=k14IfdaYuTWXSpAIDR3LVDtXt9XKjr-ZSNXCyu8pQko,586
|
|
2
2
|
glymur/_iccprofile.py,sha256=_WfQsT-BqEWQzQVTtuY7tSXqPjOtwvWGW36rKxlLv1s,4148
|
|
3
|
-
glymur/codestream.py,sha256=
|
|
3
|
+
glymur/codestream.py,sha256=nctHzG_bQKhln_gGAmoaxDhH3ndEbsiVVKy3dPqh4JM,62290
|
|
4
4
|
glymur/command_line.py,sha256=jm-6dD2jcU_G7mJAJ0U5sanfG9kRy-j0-G3eSN_Ieek,7476
|
|
5
5
|
glymur/config.py,sha256=ceGulS8TN2OYiTPtq3mAdhXrCCRlxjuLmvN_UG0009Y,4139
|
|
6
6
|
glymur/core.py,sha256=IDkk8FESyukQTB10LHBZ4VQM36NwKE4CXCcuJ407Kzg,3638
|
|
7
|
-
glymur/jp2box.py,sha256
|
|
8
|
-
glymur/jp2k.py,sha256=
|
|
9
|
-
glymur/jp2kr.py,sha256=
|
|
7
|
+
glymur/jp2box.py,sha256=qh1xUGKoGgVrUHq48yRcJAk7miJ__Udua8QHPTxpfQY,112434
|
|
8
|
+
glymur/jp2k.py,sha256=PYrjzhNPsmG2H_tyRUlIheQ-Gx7sXzH7igNAWdVyMXA,53489
|
|
9
|
+
glymur/jp2kr.py,sha256=Qf7ZsSoMkPDvOb0SCP60MARH4ZmkukFiS8oP4T1iYK8,32991
|
|
10
10
|
glymur/options.py,sha256=Y777g4wpxPqRAF8s963goeAIogfLqIe_Dyd9f77MfmU,4428
|
|
11
11
|
glymur/tiff.py,sha256=2uoKfyoyPQWAsdPWB0IxW_npqpP4O10qVADQZf10jXs,41115
|
|
12
|
-
glymur/version.py,sha256=
|
|
12
|
+
glymur/version.py,sha256=Vi8F-2IJL1ETkBrqwEl0xkfDD4yMzTwL08eNmQeLwyI,981
|
|
13
13
|
glymur/data/__init__.py,sha256=n2KZrHV15it7Wu4YCaBLXui1ZleQ30dnZ92dyP6q05k,955
|
|
14
14
|
glymur/data/goodstuff.j2k,sha256=xKQG68KMu33gYjRUDTQvam1Cue2tdio85rNp5J-rYZE,115220
|
|
15
15
|
glymur/data/heliov.jpx,sha256=KXnYdBZgl25jcGLu-m-QfhuP9pqUXV0Hp9HHEdJqr34,1399071
|
|
@@ -17,9 +17,9 @@ glymur/data/nemo.jp2,sha256=yJ1NkTEwU0B_gBtAiA1c5hxtGYSJtJgq6cHC2IHpj70,1132373
|
|
|
17
17
|
glymur/lib/__init__.py,sha256=JnM9oPfcZhBDLKo7_yLS-lIRQ1wXb1N9hKKQ-G7vYVk,127
|
|
18
18
|
glymur/lib/openjp2.py,sha256=VHCy_TnBSDqQ8YlIQHkyFqUXOQ2E5C3jxJoziG73s0I,45052
|
|
19
19
|
glymur/lib/tiff.py,sha256=2o29IzYTsprVR_C6VDNHOzqk_U7aUdCoLQ2fjiyyoaI,50777
|
|
20
|
-
Glymur-0.13.
|
|
21
|
-
Glymur-0.13.
|
|
22
|
-
Glymur-0.13.
|
|
23
|
-
Glymur-0.13.
|
|
24
|
-
Glymur-0.13.
|
|
25
|
-
Glymur-0.13.
|
|
20
|
+
Glymur-0.13.5.dist-info/LICENSE.txt,sha256=G9pvBgkJdPTtZqQmoRyIgAydtic1ZwWtOWBea9VMW7I,1077
|
|
21
|
+
Glymur-0.13.5.dist-info/METADATA,sha256=0fKfzYxRaif1ffjxR_sMXbvThtXWtF3q0IcHDUzbBSc,1020
|
|
22
|
+
Glymur-0.13.5.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
|
|
23
|
+
Glymur-0.13.5.dist-info/entry_points.txt,sha256=inzxpDbDDfIxtdXpCncAHdAdwJfjtXt3xKvIOsuZsG8,93
|
|
24
|
+
Glymur-0.13.5.dist-info/top_level.txt,sha256=D0SvtBUoPxOs40OTRW3l-kjGFHM6VrXS8yZPK5Fx2wY,7
|
|
25
|
+
Glymur-0.13.5.dist-info/RECORD,,
|
glymur/codestream.py
CHANGED
|
@@ -189,7 +189,7 @@ class Codestream(object):
|
|
|
189
189
|
0xff3f: self._parse_reserved_marker,
|
|
190
190
|
|
|
191
191
|
# 0xff4f: SOC (already encountered by the time we get here)
|
|
192
|
-
0xff50: self.
|
|
192
|
+
0xff50: self._parse_cap_segment,
|
|
193
193
|
0xff51: self._parse_siz_segment,
|
|
194
194
|
0xff52: self._parse_cod_segment,
|
|
195
195
|
0xff53: self._parse_coc_segment,
|
|
@@ -713,6 +713,37 @@ class Codestream(object):
|
|
|
713
713
|
|
|
714
714
|
return RGNsegment(crgn, srgn, sprgn, length, offset)
|
|
715
715
|
|
|
716
|
+
@classmethod
|
|
717
|
+
def _parse_cap_segment(cls, fptr):
|
|
718
|
+
"""Parse the SIZ segment.
|
|
719
|
+
|
|
720
|
+
Parameters
|
|
721
|
+
----------
|
|
722
|
+
fptr : file
|
|
723
|
+
Open file object.
|
|
724
|
+
|
|
725
|
+
Returns
|
|
726
|
+
-------
|
|
727
|
+
SIZSegment
|
|
728
|
+
The current SIZ segment.
|
|
729
|
+
"""
|
|
730
|
+
offset = fptr.tell() - 2
|
|
731
|
+
|
|
732
|
+
read_buffer = fptr.read(2)
|
|
733
|
+
length, = struct.unpack('>H', read_buffer)
|
|
734
|
+
read_buffer = fptr.read(length - 2)
|
|
735
|
+
|
|
736
|
+
pcap, = struct.unpack('>I', read_buffer[:4])
|
|
737
|
+
|
|
738
|
+
n = (length - 6) // 2
|
|
739
|
+
ccap = struct.unpack('>' + 'H' * n, read_buffer[4:])
|
|
740
|
+
|
|
741
|
+
segment = CAPsegment(
|
|
742
|
+
pcap=pcap, ccap=ccap, length=length, offset=offset,
|
|
743
|
+
)
|
|
744
|
+
|
|
745
|
+
return segment
|
|
746
|
+
|
|
716
747
|
@classmethod
|
|
717
748
|
def _parse_siz_segment(cls, fptr):
|
|
718
749
|
"""Parse the SIZ segment.
|
|
@@ -736,7 +767,9 @@ class Codestream(object):
|
|
|
736
767
|
data = struct.unpack_from('>HIIIIIIIIH', read_buffer)
|
|
737
768
|
|
|
738
769
|
rsiz = data[0]
|
|
739
|
-
|
|
770
|
+
|
|
771
|
+
# Bit 14 (16384) signifies HTJ2K (JPH)
|
|
772
|
+
if rsiz not in _KNOWN_PROFILES and not np.bitwise_and(rsiz, 16384):
|
|
740
773
|
msg = f"Invalid profile: (Rsiz={rsiz})."
|
|
741
774
|
warnings.warn(msg, UserWarning)
|
|
742
775
|
|
|
@@ -932,6 +965,49 @@ class Segment(object):
|
|
|
932
965
|
return msg
|
|
933
966
|
|
|
934
967
|
|
|
968
|
+
class CAPsegment(Segment):
|
|
969
|
+
"""CAP (Extended Capabilities) segment information.
|
|
970
|
+
|
|
971
|
+
Attributes
|
|
972
|
+
----------
|
|
973
|
+
marker_id : str
|
|
974
|
+
Identifier for the segment.
|
|
975
|
+
offset : int
|
|
976
|
+
Offset of marker segment in bytes from beginning of file.
|
|
977
|
+
length : int
|
|
978
|
+
Length of marker segment in bytes. This number does not include the
|
|
979
|
+
two bytes constituting the marker.
|
|
980
|
+
pcap : 32-bit unsigned int
|
|
981
|
+
bitmask where the kth 1 represents use of capabilities in Part k of
|
|
982
|
+
ISO/IEC 15444-k.
|
|
983
|
+
ccap : 16-bit unsigned int
|
|
984
|
+
The precise meaning depends on the related parts of ISO/IEC 15444-k.
|
|
985
|
+
"""
|
|
986
|
+
def __init__(self, pcap, ccap, length, offset):
|
|
987
|
+
super().__init__(marker_id='CAP')
|
|
988
|
+
self.pcap = pcap
|
|
989
|
+
self.ccap = ccap
|
|
990
|
+
self.length = length
|
|
991
|
+
self.offset = offset
|
|
992
|
+
|
|
993
|
+
def __str__(self):
|
|
994
|
+
msg = Segment.__str__(self)
|
|
995
|
+
|
|
996
|
+
msg += '\n'
|
|
997
|
+
|
|
998
|
+
# have to cast to uint64 because, you know, stupid windows
|
|
999
|
+
parts = [
|
|
1000
|
+
k for k in range(32)
|
|
1001
|
+
if np.bitwise_and(np.uint64(self.pcap), np.uint64(1 << (32 - k)))
|
|
1002
|
+
]
|
|
1003
|
+
|
|
1004
|
+
for b in parts:
|
|
1005
|
+
msg += f' Pcap: Part {b} (ISO/IEC 15444-{b})\n'
|
|
1006
|
+
msg += f' Ccap: {self.ccap}'
|
|
1007
|
+
|
|
1008
|
+
return msg
|
|
1009
|
+
|
|
1010
|
+
|
|
935
1011
|
class COCsegment(Segment):
|
|
936
1012
|
"""COC (Coding style Component) segment information.
|
|
937
1013
|
|
|
@@ -1666,7 +1742,12 @@ class SIZsegment(Segment):
|
|
|
1666
1742
|
try:
|
|
1667
1743
|
profile = _CAPABILITIES_DISPLAY[self.rsiz]
|
|
1668
1744
|
except KeyError:
|
|
1669
|
-
|
|
1745
|
+
if np.bitwise_and(self.rsiz, 16384):
|
|
1746
|
+
# HTJ2K profile that is uninterpreted
|
|
1747
|
+
profile = f'{self.rsiz}'
|
|
1748
|
+
else:
|
|
1749
|
+
# profile unknown
|
|
1750
|
+
profile = f'{self.rsiz} (invalid)'
|
|
1670
1751
|
msg = msg.format(
|
|
1671
1752
|
profile=profile,
|
|
1672
1753
|
height=self.ysiz, width=self.xsiz,
|
glymur/jp2box.py
CHANGED
|
@@ -1259,7 +1259,7 @@ class FileTypeBox(Jp2kBox):
|
|
|
1259
1259
|
"""
|
|
1260
1260
|
box_id = 'ftyp'
|
|
1261
1261
|
longname = 'File Type'
|
|
1262
|
-
_valid_cls = ['jp2 ', 'jpx ', 'jpxb']
|
|
1262
|
+
_valid_cls = ['jp2 ', 'jph ', 'jpx ', 'jpxb']
|
|
1263
1263
|
|
|
1264
1264
|
def __init__(
|
|
1265
1265
|
self, brand='jp2 ', minor_version=0, compatibility_list=None,
|
|
@@ -1304,16 +1304,19 @@ class FileTypeBox(Jp2kBox):
|
|
|
1304
1304
|
return text
|
|
1305
1305
|
|
|
1306
1306
|
def _validate(self, writing=False):
|
|
1307
|
-
"""
|
|
1308
|
-
|
|
1307
|
+
"""
|
|
1308
|
+
Validate the box before writing to file.
|
|
1309
|
+
"""
|
|
1310
|
+
if self.brand not in ['jp2 ', 'jpx ', 'jph ']:
|
|
1309
1311
|
msg = (
|
|
1310
1312
|
f"The file type brand was '{self.brand}'. "
|
|
1311
|
-
f"It should be either 'jp2 ' or '
|
|
1313
|
+
f"It should be either 'jp2 ', 'jpx ', or 'jph '."
|
|
1312
1314
|
)
|
|
1313
1315
|
if writing:
|
|
1314
1316
|
raise InvalidJp2kError(msg)
|
|
1315
1317
|
else:
|
|
1316
1318
|
warnings.warn(msg, UserWarning)
|
|
1319
|
+
|
|
1317
1320
|
for item in self.compatibility_list:
|
|
1318
1321
|
if item not in self._valid_cls:
|
|
1319
1322
|
msg = (
|
glymur/jp2k.py
CHANGED
|
@@ -34,13 +34,12 @@ from .lib import openjp2 as opj2
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
class Jp2k(Jp2kr):
|
|
37
|
-
"""Write JPEG 2000 files.
|
|
37
|
+
"""Write JPEG 2000 files (and optionally read them as well).
|
|
38
38
|
|
|
39
39
|
Parameters
|
|
40
40
|
----------
|
|
41
41
|
filename : str or path
|
|
42
|
-
The path to JPEG 2000 file.
|
|
43
|
-
this is the only argument you need to supply.
|
|
42
|
+
The path to JPEG 2000 file.
|
|
44
43
|
data : np.ndarray, optional
|
|
45
44
|
Image data to be written to file.
|
|
46
45
|
shape : Tuple[int, int, ...], optional
|
|
@@ -105,35 +104,6 @@ class Jp2k(Jp2kr):
|
|
|
105
104
|
verbose : bool, optional
|
|
106
105
|
Print informational messages produced by the OpenJPEG library.
|
|
107
106
|
|
|
108
|
-
Examples
|
|
109
|
-
--------
|
|
110
|
-
>>> jfile = glymur.data.nemo()
|
|
111
|
-
>>> jp2 = glymur.Jp2k(jfile)
|
|
112
|
-
>>> jp2.shape
|
|
113
|
-
(1456, 2592, 3)
|
|
114
|
-
>>> image = jp2[:]
|
|
115
|
-
>>> image.shape
|
|
116
|
-
(1456, 2592, 3)
|
|
117
|
-
|
|
118
|
-
Read a lower resolution thumbnail.
|
|
119
|
-
|
|
120
|
-
>>> thumbnail = jp2[::2, ::2]
|
|
121
|
-
>>> thumbnail.shape
|
|
122
|
-
(728, 1296, 3)
|
|
123
|
-
|
|
124
|
-
Make use of OpenJPEG's thread support
|
|
125
|
-
|
|
126
|
-
>>> import time
|
|
127
|
-
>>> if glymur.version.openjpeg_version >= '2.2.0':
|
|
128
|
-
... jp2file = glymur.data.nemo()
|
|
129
|
-
... jp2 = glymur.Jp2k(jp2file)
|
|
130
|
-
... t0 = time.time(); data = jp2[:]; t1 = time.time()
|
|
131
|
-
... t1 - t0 #doctest: +SKIP
|
|
132
|
-
0.9024193286895752
|
|
133
|
-
... glymur.set_options('lib.num_threads', 4)
|
|
134
|
-
... t0 = time.time(); data = jp2[:]; t1 = time.time()
|
|
135
|
-
... t1 - t0 #doctest: +SKIP
|
|
136
|
-
0.4060473537445068
|
|
137
107
|
"""
|
|
138
108
|
|
|
139
109
|
def __init__(
|
|
@@ -206,13 +176,13 @@ class Jp2k(Jp2kr):
|
|
|
206
176
|
# Must be determined when writing.
|
|
207
177
|
self._shape = None
|
|
208
178
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
179
|
+
if not hasattr(self, '_codec_format'):
|
|
180
|
+
# Only set codec format if the superclass has not done so, i.e.
|
|
181
|
+
# we are writing instead of reading.
|
|
182
|
+
if self.filename[-4:].endswith(('.jp2', '.JP2', '.jpx', 'JPX')):
|
|
183
|
+
self._codec_format = opj2.CODEC_JP2
|
|
184
|
+
else:
|
|
185
|
+
self._codec_format = opj2.CODEC_J2K
|
|
216
186
|
|
|
217
187
|
self._validate_kwargs()
|
|
218
188
|
|
|
@@ -800,12 +770,6 @@ class Jp2k(Jp2kr):
|
|
|
800
770
|
-------
|
|
801
771
|
Jp2k
|
|
802
772
|
Newly wrapped Jp2k object.
|
|
803
|
-
|
|
804
|
-
Examples
|
|
805
|
-
--------
|
|
806
|
-
>>> jfile = glymur.data.goodstuff()
|
|
807
|
-
>>> j2k = glymur.Jp2k(jfile)
|
|
808
|
-
>>> jp2 = j2k.wrap('jp2_from_j2k.jp2')
|
|
809
773
|
"""
|
|
810
774
|
if boxes is None:
|
|
811
775
|
boxes = self._get_default_jp2_boxes()
|
glymur/jp2kr.py
CHANGED
|
@@ -55,6 +55,19 @@ class Jp2kr(Jp2kBox):
|
|
|
55
55
|
>>> thumbnail = jp2[::2, ::2]
|
|
56
56
|
>>> thumbnail.shape
|
|
57
57
|
(728, 1296, 3)
|
|
58
|
+
|
|
59
|
+
Make use of OpenJPEG's thread support
|
|
60
|
+
|
|
61
|
+
>>> import time
|
|
62
|
+
>>> jp2file = glymur.data.nemo()
|
|
63
|
+
>>> jp2 = glymur.Jp2k(jp2file)
|
|
64
|
+
>>> t0 = time.time(); data = jp2[:]; t1 = time.time()
|
|
65
|
+
>>> t1 - t0 #doctest: +SKIP
|
|
66
|
+
0.9024193286895752
|
|
67
|
+
>>> glymur.set_option('lib.num_threads', 4)
|
|
68
|
+
>>> t0 = time.time(); data = jp2[:]; t1 = time.time()
|
|
69
|
+
>>> t1 - t0 #doctest: +SKIP
|
|
70
|
+
0.4060473537445068
|
|
58
71
|
"""
|
|
59
72
|
|
|
60
73
|
def __init__(
|
|
@@ -233,7 +246,7 @@ class Jp2kr(Jp2kBox):
|
|
|
233
246
|
|
|
234
247
|
@property
|
|
235
248
|
def codestream(self):
|
|
236
|
-
"""Metadata for JP2 or J2K codestream
|
|
249
|
+
"""Metadata for JP2 or J2K codestream header."""
|
|
237
250
|
if self._codestream is None:
|
|
238
251
|
self._codestream = self.get_codestream(header_only=True)
|
|
239
252
|
return self._codestream
|
|
@@ -523,6 +536,9 @@ class Jp2kr(Jp2kBox):
|
|
|
523
536
|
def read(self, **kwargs):
|
|
524
537
|
"""Read a JPEG 2000 image.
|
|
525
538
|
|
|
539
|
+
.. deprecated:: 0.13.5
|
|
540
|
+
Use numpy-style slicing instead.
|
|
541
|
+
|
|
526
542
|
Returns
|
|
527
543
|
-------
|
|
528
544
|
img_array : ndarray
|
|
@@ -724,7 +740,7 @@ class Jp2kr(Jp2kBox):
|
|
|
724
740
|
verbose=False, ignore_pclr_cmap_cdef=False):
|
|
725
741
|
"""Read a JPEG 2000 image.
|
|
726
742
|
|
|
727
|
-
The only time you should use this method is when the image has
|
|
743
|
+
The only time you should ever use this method is when the image has
|
|
728
744
|
different subsampling factors across components. Otherwise you should
|
|
729
745
|
use the read method.
|
|
730
746
|
|
|
@@ -870,6 +886,10 @@ class Jp2kr(Jp2kBox):
|
|
|
870
886
|
def get_codestream(self, header_only=True):
|
|
871
887
|
"""Retrieve codestream.
|
|
872
888
|
|
|
889
|
+
This differs from the codestream property in that segment
|
|
890
|
+
metadata that lies past the end of the codestream header
|
|
891
|
+
can be retrieved.
|
|
892
|
+
|
|
873
893
|
Parameters
|
|
874
894
|
----------
|
|
875
895
|
header_only : bool, optional
|
glymur/version.py
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|