From fc2519ca753b9f5b10106c9285806e4fc9e5f825 Mon Sep 17 00:00:00 2001 From: jevans Date: Thu, 25 Sep 2014 18:57:13 -0400 Subject: [PATCH 1/7] more doc updates --- docs/source/detailed_installation.rst | 8 +++--- docs/source/how_do_i.rst | 37 +++++++++++++++++++-------- docs/source/introduction.rst | 3 +-- docs/source/roadmap.rst | 2 +- 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/docs/source/detailed_installation.rst b/docs/source/detailed_installation.rst index ecf0632..1a9281c 100644 --- a/docs/source/detailed_installation.rst +++ b/docs/source/detailed_installation.rst @@ -24,11 +24,11 @@ configuration format is the same as used by Python’s configparser module, i.e. :: [library] - openjp2: /opt/openjp2-svn/lib/libopenjp2.so + openjp2: /somewhere/lib/libopenjp2.so This assumes, of course, that you've installed OpenJPEG into -/opt/openjp2-svn on a linux system. The location of the configuration file -can vary as well (of course). If you use either linux or mac, the path +/opt/openjpeg on a linux system. The location of the configuration file +can vary as well. If you use either linux or mac, the path to the configuration file would normally be :: $HOME/.config/glymur/glymurrc @@ -48,7 +48,7 @@ You may also include a line for the version 1.x openjpeg library if you have it installed in a non-standard place, i.e. :: [library] - openjpeg: /not/the/usual/location/lib/libopenjpeg.so + openjpeg: /somewhere/lib/libopenjpeg.so ''''''' Testing diff --git a/docs/source/how_do_i.rst b/docs/source/how_do_i.rst index 3e0c3ee..5d11d67 100644 --- a/docs/source/how_do_i.rst +++ b/docs/source/how_do_i.rst @@ -7,11 +7,11 @@ How do I...? ================ Jp2k implements slicing via the :py:meth:`__getitem__` method, meaning that multiple resolution imagery in a JPEG 2000 file can -easily be accessed. For example here's how to retrieve a full resolution and -first lower-resolution image :: +easily be accessed via array-style slicing. For example here's how to +retrieve a full resolution and first lower-resolution image :: >>> import glymur - >>> jp2file = glymur.data.nemo() + >>> jp2file = glymur.data.nemo() # just a path to a JPEG2000 file >>> jp2 = glymur.Jp2k(jp2file) >>> fullres = jp2[:] >>> print(fullres.shape) @@ -20,8 +20,21 @@ first lower-resolution image :: >>> print(thumbnail.shape) (728, 1296, 3) -The :py:meth:`read` method gives many more options for other JPEG 2000 features -such as quality layers. +The :py:meth:`read` method exposes many more options for other JPEG 2000 +features such as quality layers. + +... write images? +================= +So long as the image data can fit entirely into memory, array-style slicing may +also be used to write JPEG 2000 files. + + >>> import glymur, numpy as np + >>> jp2 = glymur.Jp2k('zeros.jp2', mode='wb') + >>> jp2[:] = np.zeros((640, 480), dtype=np.uint8) + +The :py:meth:`write` method exposes many more options for other JPEG 2000 +features. You should have OpenJPEG version 1.5 or more recent before writing +JPEG 2000 images. ... display metadata? ===================== @@ -328,10 +341,10 @@ is currently limited to XML and UUID boxes. ... create an image with an alpha layer? ======================================== -OpenJPEG can create JP2 files with more than 3 components (requires -the development version of OpenJPEG), but by default, any extra components are -not described as such. In order to do so, we need to rewrap such -an image in a set of boxes that includes a channel definition box. +OpenJPEG can create JP2 files with more than 3 components (use version 2.1.0+ +for this), but by default, any extra components are not described +as such. In order to do so, we need to rewrap such an image in a +set of boxes that includes a channel definition box. This example is based on SciPy example code found at http://scipy-lectures.github.io/advanced/image_processing/#basic-manipulations . @@ -389,7 +402,11 @@ Here's how the Preview application on the mac shows the RGBA image. ... work with XMP UUIDs? ======================== -XMP is metadata on steroids. +`Wikipedia `_ states +that "The Extensible Metadata Platform (XMP) is an ISO standard, +originally created by Adobe Systems Inc., for the creation, processing +and interchange of standardized and custom metadata for all kinds +of resources." The example JP2 file shipped with glymur has an XMP UUID. :: diff --git a/docs/source/introduction.rst b/docs/source/introduction.rst index 54681f7..ae6d6ab 100644 --- a/docs/source/introduction.rst +++ b/docs/source/introduction.rst @@ -10,12 +10,11 @@ JPEG 2000 images is currently limited to images that can fit in memory. but it is strongly recommended to use version 2.1.0, which is the most recently released version of OpenJPEG at this time. - In regards to metadata, most JP2 boxes are properly interpreted. Certain optional JP2 boxes can also be written, including XML boxes and XMP UUIDs. There is incomplete support for reading JPX metadata. -Glymur 0.6 works on Python versions 2.7, 3.3 and 3.4. If you have Python 2.6, +Glymur works on Python versions 2.7, 3.3 and 3.4. If you have Python 2.6, you should use the 0.5 series of Glymur. For more information about OpenJPEG, please consult http://www.openjpeg.org. diff --git a/docs/source/roadmap.rst b/docs/source/roadmap.rst index 47ccfd1..df629ac 100644 --- a/docs/source/roadmap.rst +++ b/docs/source/roadmap.rst @@ -2,7 +2,7 @@ Platforms Tested (0.7.0 release only) ------------------------------------- * Linux Mint 17 / Python 3.4.0 and 2.7.6 / OpenJPEG 2.1.0 and 1.3.0 - * MacOS 10.6.8 / MacPorts / Python 3.4.1 + * MacOS 10.6.8 / MacPorts / Python 3.4.1, 3.3.5,and 2.7.8 * CentOS 6.5 / Anaconda Python 3.4.1 / OpenJPEG 1.3.0 ------------ From e2661ee7f40595ac67aa24e9564244e95257c759 Mon Sep 17 00:00:00 2001 From: John Evans Date: Thu, 25 Sep 2014 19:33:03 -0400 Subject: [PATCH 2/7] doc mods --- docs/source/roadmap.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/source/roadmap.rst b/docs/source/roadmap.rst index df629ac..1ebcd04 100644 --- a/docs/source/roadmap.rst +++ b/docs/source/roadmap.rst @@ -2,8 +2,9 @@ Platforms Tested (0.7.0 release only) ------------------------------------- * Linux Mint 17 / Python 3.4.0 and 2.7.6 / OpenJPEG 2.1.0 and 1.3.0 - * MacOS 10.6.8 / MacPorts / Python 3.4.1, 3.3.5,and 2.7.8 + * MacOS 10.6.8 / MacPorts Python 3.4.1, 3.3.5,and 2.7.8 / OpenJPEG 2.1.0 * CentOS 6.5 / Anaconda Python 3.4.1 / OpenJPEG 1.3.0 + * Fedora 20 i386 / Python 2.7.5 and 3.3.2 / OpenJPEG 1.5.1 ------------ Known Issues From 1341a15f7bf3ce96ff90332e0182eb1f74790e1a Mon Sep 17 00:00:00 2001 From: John Evans Date: Fri, 26 Sep 2014 16:00:42 -0400 Subject: [PATCH 3/7] force step=>rlevel computation to result in integer For whatever stupid reason, np.log2(x) cannot be relied upon to be an integer when x is a power of 2 ON WIN32!!! All hail win32! --- glymur/jp2k.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/glymur/jp2k.py b/glymur/jp2k.py index 734ed60..f1b9818 100644 --- a/glymur/jp2k.py +++ b/glymur/jp2k.py @@ -832,9 +832,11 @@ class Jp2k(Jp2kBox): # one of them. step = rows_step - if np.log2(step) != np.floor(np.log2(step)): + # Check if the step size is a power of 2. + if np.abs(np.log2(step) - np.floor(np.log2(step))) > 1e-6: msg = "Row and column strides must be powers of 2." raise IndexError(msg) + rlevel = np.int(np.round(np.log2(step))) if rows.start is None: rows_start = 0 @@ -857,7 +859,7 @@ class Jp2k(Jp2kBox): cols_stop = cols.stop area = (rows_start, cols_start, rows_stop, cols_stop) - data = self.read(area=area, rlevel=np.int(np.log2(step))) + data = self.read(area=area, rlevel=rlevel) if len(pargs) == 2: return data From 56042efd981ce7d3e0815055e6ee3b64b08034fb Mon Sep 17 00:00:00 2001 From: John Evans Date: Sun, 28 Sep 2014 12:43:57 -0400 Subject: [PATCH 4/7] use round rather than floor --- glymur/jp2k.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glymur/jp2k.py b/glymur/jp2k.py index f1b9818..b721742 100644 --- a/glymur/jp2k.py +++ b/glymur/jp2k.py @@ -833,7 +833,7 @@ class Jp2k(Jp2kBox): step = rows_step # Check if the step size is a power of 2. - if np.abs(np.log2(step) - np.floor(np.log2(step))) > 1e-6: + if np.abs(np.log2(step) - np.round(np.log2(step))) > 1e-6: msg = "Row and column strides must be powers of 2." raise IndexError(msg) rlevel = np.int(np.round(np.log2(step))) From 1b0f60298dd6eb8a8de019637c1b22700adbf030 Mon Sep 17 00:00:00 2001 From: John Evans Date: Sun, 28 Sep 2014 12:44:55 -0400 Subject: [PATCH 5/7] skip test on windows uses namedtemporaryfile --- glymur/test/test_config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/glymur/test/test_config.py b/glymur/test/test_config.py index 7196d35..f908272 100644 --- a/glymur/test/test_config.py +++ b/glymur/test/test_config.py @@ -71,6 +71,7 @@ class TestSuite(unittest.TestCase): Jp2k(self.jp2file) @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) + @unittest.skipIf(os.name == "nt", 'named temporary file issue on windows') def test_xdg_env_config_file_is_bad(self): """A non-existant library location should be rejected.""" with tempfile.TemporaryDirectory() as tdir: From 760da6bade416c5115341ec91216facc668449ed Mon Sep 17 00:00:00 2001 From: jevans Date: Mon, 29 Sep 2014 07:37:17 -0400 Subject: [PATCH 6/7] better error message if array-style slice other than [:] --- glymur/jp2k.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glymur/jp2k.py b/glymur/jp2k.py index b721742..87028e1 100644 --- a/glymur/jp2k.py +++ b/glymur/jp2k.py @@ -772,7 +772,7 @@ class Jp2k(Jp2kBox): # Should have a slice object where start = stop = step = None self.write(data) else: - msg = "Images currently must be written entirely at once." + msg = "Partial write operations are currently not allowed." raise TypeError(msg) def __getitem__(self, pargs): From 83eaded7789fb950224a0c9bcab3a3ca9577e4f0 Mon Sep 17 00:00:00 2001 From: jevans Date: Mon, 29 Sep 2014 07:42:50 -0400 Subject: [PATCH 7/7] added mention of testing on windows --- docs/source/roadmap.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/roadmap.rst b/docs/source/roadmap.rst index 1ebcd04..503fbc4 100644 --- a/docs/source/roadmap.rst +++ b/docs/source/roadmap.rst @@ -5,6 +5,7 @@ Platforms Tested (0.7.0 release only) * MacOS 10.6.8 / MacPorts Python 3.4.1, 3.3.5,and 2.7.8 / OpenJPEG 2.1.0 * CentOS 6.5 / Anaconda Python 3.4.1 / OpenJPEG 1.3.0 * Fedora 20 i386 / Python 2.7.5 and 3.3.2 / OpenJPEG 1.5.1 + * Windows 7 32bit / Anaconda Python 2.7.6 and 3.4.1 / OpenJPEG 2.1.0 ------------ Known Issues