Compare commits
11 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3db36017c | ||
|
|
3c7205038f | ||
|
|
2ffdf716c0 | ||
|
|
7b1522bb0e | ||
|
|
8cc1155252 | ||
|
|
1bfb2f5fc8 | ||
|
|
4686c40c57 | ||
|
|
05e343b2e4 | ||
|
|
4d680cf90b | ||
|
|
e2465c5c73 | ||
|
|
02ff730784 |
15 changed files with 73 additions and 172 deletions
|
|
@ -1,3 +1,8 @@
|
|||
Jan 10, 2015 - v0.8.0 Reduced number of steps required for writing
|
||||
images. Deprecated old read and write methods in favor of
|
||||
array-style slicing. Added ignore_pclr_cmap_cdef, verbose,
|
||||
shape, codestream, layer properties.
|
||||
|
||||
Oct 06, 2014 - v0.7.2 Added ellipsis support in array-style slicing.
|
||||
|
||||
Oct 02, 2014 - v0.7.1 Fixed README to mention Python 3.4
|
||||
|
|
|
|||
|
|
@ -1,116 +0,0 @@
|
|||
---
|
||||
API
|
||||
---
|
||||
|
||||
Jp2k
|
||||
----
|
||||
.. autoclass:: glymur.Jp2k
|
||||
:members: read, write, wrap, read_bands, get_codestream
|
||||
|
||||
Individual Boxes
|
||||
----------------
|
||||
Jp2kbox
|
||||
'''''''
|
||||
.. autoclass:: glymur.jp2box.Jp2kBox
|
||||
:members:
|
||||
|
||||
AssociationBox
|
||||
''''''''''''''
|
||||
.. autoclass:: glymur.jp2box.AssociationBox
|
||||
:members:
|
||||
|
||||
ColourSpecificationBox
|
||||
''''''''''''''''''''''
|
||||
.. autoclass:: glymur.jp2box.ColourSpecificationBox
|
||||
:members:
|
||||
|
||||
ChannelDefinitionBox
|
||||
''''''''''''''''''''''
|
||||
.. autoclass:: glymur.jp2box.ChannelDefinitionBox
|
||||
:members:
|
||||
|
||||
ComponentMappingBox
|
||||
'''''''''''''''''''
|
||||
.. autoclass:: glymur.jp2box.ComponentMappingBox
|
||||
:members:
|
||||
|
||||
ContiguousCodestreamBox
|
||||
'''''''''''''''''''''''
|
||||
.. autoclass:: glymur.jp2box.ContiguousCodestreamBox
|
||||
:members:
|
||||
|
||||
DataEntryURLBox
|
||||
'''''''''''''''
|
||||
.. autoclass:: glymur.jp2box.DataEntryURLBox
|
||||
:members:
|
||||
|
||||
FileTypeBox
|
||||
'''''''''''
|
||||
.. autoclass:: glymur.jp2box.FileTypeBox
|
||||
:members:
|
||||
|
||||
ImageHeaderBox
|
||||
''''''''''''''
|
||||
.. autoclass:: glymur.jp2box.ImageHeaderBox
|
||||
:members:
|
||||
|
||||
JP2HeaderBox
|
||||
''''''''''''
|
||||
.. autoclass:: glymur.jp2box.JP2HeaderBox
|
||||
:members:
|
||||
|
||||
JPEG2000SignatureBox
|
||||
''''''''''''''''''''
|
||||
.. autoclass:: glymur.jp2box.JPEG2000SignatureBox
|
||||
:members:
|
||||
|
||||
LabelBox
|
||||
''''''''
|
||||
.. autoclass:: glymur.jp2box.LabelBox
|
||||
:members:
|
||||
|
||||
PaletteBox
|
||||
''''''''''
|
||||
.. autoclass:: glymur.jp2box.PaletteBox
|
||||
:members:
|
||||
|
||||
ReaderRequirementsBox
|
||||
'''''''''''''''''''''
|
||||
.. autoclass:: glymur.jp2box.ReaderRequirementsBox
|
||||
:members:
|
||||
|
||||
ResolutionBox
|
||||
'''''''''''''
|
||||
.. autoclass:: glymur.jp2box.ResolutionBox
|
||||
:members:
|
||||
|
||||
CaptureResolutionBox
|
||||
''''''''''''''''''''
|
||||
.. autoclass:: glymur.jp2box.CaptureResolutionBox
|
||||
:members:
|
||||
|
||||
DisplayResolutionBox
|
||||
''''''''''''''''''''
|
||||
.. autoclass:: glymur.jp2box.DisplayResolutionBox
|
||||
:members:
|
||||
|
||||
UUIDBox
|
||||
'''''''
|
||||
.. autoclass:: glymur.jp2box.UUIDBox
|
||||
:members:
|
||||
|
||||
UUIDInfoBox
|
||||
'''''''''''
|
||||
.. autoclass:: glymur.jp2box.UUIDInfoBox
|
||||
:members:
|
||||
|
||||
UUIDListBox
|
||||
'''''''''''
|
||||
.. autoclass:: glymur.jp2box.UUIDListBox
|
||||
:members:
|
||||
|
||||
XMLBox
|
||||
''''''
|
||||
.. autoclass:: glymur.jp2box.XMLBox
|
||||
:members:
|
||||
|
||||
|
|
@ -75,9 +75,9 @@ copyright = u'2013, John Evans'
|
|||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '0.7'
|
||||
version = '0.8'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '0.7.2'
|
||||
release = '0.8.0'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ or if you use windows, then read on.
|
|||
|
||||
Glymur uses ctypes to access the openjp2/openjpeg libraries, and
|
||||
because ctypes accesses libraries in a platform-dependent manner,
|
||||
it is recommended that if you compile and install OpenJPEG into a
|
||||
it is recommended that **if** you compile and install OpenJPEG into a
|
||||
non-standard location, you should then create a configuration file
|
||||
to help Glymur properly find the openjpeg or openjp2 libraries
|
||||
(linux users or macports users don’t need to bother with this if
|
||||
|
|
@ -50,6 +50,9 @@ installed in a non-standard place, i.e. ::
|
|||
[library]
|
||||
openjpeg: /somewhere/lib/libopenjpeg.so
|
||||
|
||||
Once again, you should not have to bother with a configuration file if you use
|
||||
mac or linux and OpenJPEG is provided by your package manager.
|
||||
|
||||
'''''''
|
||||
Testing
|
||||
'''''''
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ It's pretty simple, just supply the image data as the 2nd argument to the Jp2k
|
|||
constructor.
|
||||
|
||||
>>> import glymur, numpy as np
|
||||
>>> data = np.zeros((640, 480), dtype=np.uint8)
|
||||
>>> jp2 = glymur.Jp2k('zeros.jp2', data=data)
|
||||
>>> jp2 = glymur.Jp2k('zeros.jp2', data=np.zeros((640, 480), dtype=np.uint8)
|
||||
|
||||
You should have OpenJPEG version 1.5 or more recent before writing JPEG 2000 images.
|
||||
You must have OpenJPEG version 1.5 or more recent in order to write JPEG 2000
|
||||
images with glymur.
|
||||
|
||||
... display metadata?
|
||||
=====================
|
||||
|
|
@ -442,7 +442,7 @@ following
|
|||
'Google'
|
||||
|
||||
But that would be painful. A better solution is to install the Python XMP
|
||||
Toolkit (make sure it is version 2.0)::
|
||||
Toolkit (make sure it is at least version 2.0)::
|
||||
|
||||
>>> from libxmp import XMPMeta
|
||||
>>> from libxmp.consts import XMP_NS_XMP as NS_XAP
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ Contents:
|
|||
how_do_i
|
||||
whatsnew/index
|
||||
roadmap
|
||||
api
|
||||
|
||||
------------------
|
||||
Indices and tables
|
||||
|
|
|
|||
|
|
@ -7,6 +7,18 @@ Changes in 0.8.0
|
|||
|
||||
* Simplified writing images by moving data and options into the
|
||||
constructor.
|
||||
* The main_header attribute of the ContiguousCodestream class is now called
|
||||
codestream.
|
||||
* Deprecated :py:meth:`read` method in favor of array-style slicing.
|
||||
In order to retain certain functionality, the following parameters
|
||||
to the :py:meth:`read` method have become top-level properties
|
||||
|
||||
* verbose
|
||||
* layer
|
||||
* ignore_pclr_cmap_cdef
|
||||
|
||||
* Two additional properties were introduced.
|
||||
|
||||
* codestream
|
||||
* shape
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1032,7 +1032,7 @@ class ContiguousCodestreamBox(Jp2kBox):
|
|||
with open(self._filename, 'rb') as fptr:
|
||||
fptr.seek(self.main_header_offset)
|
||||
codestream = Codestream(fptr, self._length,
|
||||
header_only=header_only)
|
||||
header_only=header_only)
|
||||
self._codestream = codestream
|
||||
return self._codestream
|
||||
|
||||
|
|
|
|||
|
|
@ -205,28 +205,30 @@ class Jp2k(Jp2kBox):
|
|||
if self._shape is not None:
|
||||
return self._shape
|
||||
|
||||
cstr = self.codestream
|
||||
height = cstr.segment[1].ysiz
|
||||
width = cstr.segment[1].xsiz
|
||||
num_components = len(cstr.segment[1].xrsiz)
|
||||
if self._codec_format == opj2.CODEC_J2K:
|
||||
# get the image size from the codestream
|
||||
cstr = self.codestream
|
||||
height = cstr.segment[1].ysiz
|
||||
width = cstr.segment[1].xsiz
|
||||
num_components = len(cstr.segment[1].xrsiz)
|
||||
else:
|
||||
# try to get the image size from the IHDR box
|
||||
jp2h = [box for box in self.box if box.box_id == 'jp2h'][0]
|
||||
ihdr = [box for box in jp2h.box if box.box_id == 'ihdr'][0]
|
||||
|
||||
# If JP2 and a palette box is present, then determine the shape from
|
||||
# that.
|
||||
if num_components == 1:
|
||||
if self._codec_format == opj2.CODEC_J2K:
|
||||
# There's no palette box or component mapping in a J2K file.
|
||||
# The 3rd component in the shape would then be 1, but we'll
|
||||
# ignore that.
|
||||
self.shape = (height, width)
|
||||
else:
|
||||
jp2h = [box for box in self.box if box.box_id == 'jp2h'][0]
|
||||
height, width = ihdr.height, ihdr.width
|
||||
num_components = ihdr.num_components
|
||||
|
||||
if num_components == 1:
|
||||
# but if there is a PCLR box, then we need to check that as
|
||||
# well, as that turns a single-channel image into a
|
||||
# multi-channel image
|
||||
pclr = [box for box in jp2h.box if box.box_id == 'pclr']
|
||||
if len(pclr) == 0:
|
||||
# No palette box, so just one component, which we will
|
||||
# ignore.
|
||||
self.shape = (height, width)
|
||||
else:
|
||||
self.shape = (height, width, len(pclr[0].signed))
|
||||
if len(pclr) > 0:
|
||||
num_components = len(pclr[0].signed)
|
||||
|
||||
if num_components == 1:
|
||||
self.shape = (height, width)
|
||||
else:
|
||||
self.shape = (height, width, num_components)
|
||||
|
||||
|
|
@ -918,9 +920,11 @@ class Jp2k(Jp2kBox):
|
|||
"""
|
||||
Slicing protocol.
|
||||
"""
|
||||
numrows = self.codestream.segment[1].ysiz
|
||||
numcols = self.codestream.segment[1].xsiz
|
||||
numbands = self.codestream.segment[1].Csiz
|
||||
if len(self.shape) == 2:
|
||||
numrows, numcols = self.shape
|
||||
numbands = 1
|
||||
else:
|
||||
numrows, numcols, numbands = self.shape
|
||||
|
||||
if isinstance(pargs, int):
|
||||
# Not a very good use of this protocol, but technically legal.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
Test fixtures common to more than one test point.
|
||||
"""
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import sys
|
||||
import textwrap
|
||||
|
|
@ -34,14 +33,6 @@ elif re.match('1.[0-6]', six.__version__) is not None:
|
|||
WARNING_INFRASTRUCTURE_ISSUE = True
|
||||
msg = "Cannot run test with version {0} of python-six"
|
||||
WARNING_INFRASTRUCTURE_MSG = msg.format(six.__version__)
|
||||
elif ((re.match('1.8', six.__version__) is not None) and
|
||||
(sys.platform.startswith('linux')) and
|
||||
(platform.linux_distribution() == ('LinuxMint', '17', 'qiana'))):
|
||||
WARNING_INFRASTRUCTURE_ISSUE = True
|
||||
linux_distribution = platform.linux_distribution()
|
||||
msg = "Cannot run test with version {0} of python-six on {1}"
|
||||
WARNING_INFRASTRUCTURE_MSG = msg.format(six.__version__,
|
||||
platform.linux_distribution)
|
||||
|
||||
# Cannot reopen a named temporary file in windows.
|
||||
WINDOWS_TMP_FILE_MSG = "cannot use NamedTemporaryFile like this in windows"
|
||||
|
|
@ -554,7 +545,7 @@ text_gbr_34 = """Colour Specification Box (colr) @ (179, 1339)
|
|||
dump = r'''JPEG 2000 Signature Box (jP ) @ (0, 12)
|
||||
Signature: 0d0a870a
|
||||
File Type Box (ftyp) @ (12, 20)
|
||||
Brand: jp2
|
||||
Brand: jp2
|
||||
Compatibility: ['jp2 ']
|
||||
JP2 Header Box (jp2h) @ (32, 45)
|
||||
Image Header Box (ihdr) @ (40, 22)
|
||||
|
|
@ -678,7 +669,7 @@ Contiguous Codestream Box (jp2c) @ (3223, 1132296)
|
|||
dump = r"""JPEG 2000 Signature Box (jP ) @ (0, 12)
|
||||
Signature: 0d0a870a
|
||||
File Type Box (ftyp) @ (12, 20)
|
||||
Brand: jp2
|
||||
Brand: jp2
|
||||
Compatibility: ['jp2 ']
|
||||
JP2 Header Box (jp2h) @ (32, 45)
|
||||
Image Header Box (ihdr) @ (40, 22)
|
||||
|
|
@ -701,7 +692,7 @@ nemo_dump_no_codestream = dump.format(_indent(nemo_xmp))
|
|||
nemo_dump_no_codestream_no_xml = r"""JPEG 2000 Signature Box (jP ) @ (0, 12)
|
||||
Signature: 0d0a870a
|
||||
File Type Box (ftyp) @ (12, 20)
|
||||
Brand: jp2
|
||||
Brand: jp2
|
||||
Compatibility: ['jp2 ']
|
||||
JP2 Header Box (jp2h) @ (32, 45)
|
||||
Image Header Box (ihdr) @ (40, 22)
|
||||
|
|
|
|||
|
|
@ -27,12 +27,17 @@ from .fixtures import (WARNING_INFRASTRUCTURE_ISSUE,
|
|||
WINDOWS_TMP_FILE_MSG, MetadataBase)
|
||||
|
||||
|
||||
def docTearDown(doctest_obj):
|
||||
glymur.set_parseoptions(full_codestream=False)
|
||||
|
||||
|
||||
def load_tests(loader, tests, ignore):
|
||||
"""Run doc tests as well."""
|
||||
if os.name == "nt":
|
||||
# Can't do it on windows, temporary file issue.
|
||||
return tests
|
||||
tests.addTests(doctest.DocTestSuite('glymur.jp2box'))
|
||||
tests.addTests(doctest.DocTestSuite('glymur.jp2box',
|
||||
tearDown=docTearDown))
|
||||
return tests
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ from . import fixtures
|
|||
def docTearDown(doctest_obj):
|
||||
glymur.set_parseoptions(full_codestream=False)
|
||||
|
||||
|
||||
# Doc tests should be run as well.
|
||||
def load_tests(loader, tests, ignore):
|
||||
"""Should run doc tests as well"""
|
||||
|
|
@ -1079,9 +1080,6 @@ class TestParsing(unittest.TestCase):
|
|||
class TestJp2kOpjDataRootWarnings(unittest.TestCase):
|
||||
"""These tests should be run by just about all configuration."""
|
||||
|
||||
def tearDown(self):
|
||||
glymur.set_parseoptions(full_codestream=False)
|
||||
|
||||
def test_undecodeable_box_id(self):
|
||||
"""Should warn in case of undecodeable box ID but not error out."""
|
||||
filename = opj_data_file('input/nonregression/edf_c2_1013627.jp2')
|
||||
|
|
|
|||
|
|
@ -1065,12 +1065,14 @@ class TestJp2dump(unittest.TestCase):
|
|||
expected = '\n'.join(expected)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(sys.hexversion < 0x03000000, "assertRegex not in 2.7")
|
||||
def test_jp2_codestream_0(self):
|
||||
"""Verify dumping with -c 0, supressing all codestream details."""
|
||||
actual = self.run_jp2dump(['', '-c', '0', self.jp2file])
|
||||
|
||||
expected = fixtures.nemo_dump_no_codestream
|
||||
# shave off the codestream details
|
||||
lines = fixtures.nemo.split('\n')
|
||||
expected = lines[0:105]
|
||||
expected = '\n'.join(expected)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_jp2_codestream_1(self):
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ from .lib import openjpeg as opj, openjp2 as opj2
|
|||
|
||||
# Do not change the format of this next line! Doing so risks breaking
|
||||
# setup.py
|
||||
version = "0.7.2"
|
||||
version = "0.8.0"
|
||||
_sv = LooseVersion(version)
|
||||
version_tuple = _sv.version
|
||||
|
||||
|
|
|
|||
4
setup.py
4
setup.py
|
|
@ -21,12 +21,10 @@ kwargs = {'name': 'Glymur',
|
|||
'test_suite': 'glymur.test'}
|
||||
|
||||
install_requires = ['numpy>=1.7.0', 'lxml>=3.0.0']
|
||||
test_requires = ['six>=1.7.0']
|
||||
if sys.hexversion < 0x03030000:
|
||||
install_requires.append('contextlib2>=0.4')
|
||||
test_requires.append('mock>=1.0.1')
|
||||
install_requires.append('mock>=1.0.1')
|
||||
kwargs['install_requires'] = install_requires
|
||||
kwargs['test_requires'] = test_requires
|
||||
|
||||
clssfrs = ["Programming Language :: Python",
|
||||
"Programming Language :: Python :: 2.7",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue