deprecated read method, removed write method, closes #299

use array-style slicing instead.  Many former read methods are now
properties.  Many former write method parameters are now moved into the
constructor.
This commit is contained in:
John Evans 2014-11-11 10:46:59 -05:00
commit 03cb19d22b
16 changed files with 1132 additions and 1188 deletions

View file

@ -14,27 +14,22 @@ retrieve a full resolution and first lower-resolution image ::
>>> jp2file = glymur.data.nemo() # just a path to a JPEG2000 file
>>> jp2 = glymur.Jp2k(jp2file)
>>> fullres = jp2[:]
>>> print(fullres.shape)
>>> fullres.shape
(1456, 2592, 3)
>>> thumbnail = jp2[::2, ::2]
>>> print(thumbnail.shape)
>>> thumbnail.shape
(728, 1296, 3)
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.
It's pretty simple, just supply the image data as the 2nd argument to the Jp2k
constructor.
>>> import glymur, numpy as np
>>> jp2 = glymur.Jp2k('zeros.jp2', mode='wb')
>>> jp2[:] = np.zeros((640, 480), dtype=np.uint8)
>>> data = np.zeros((640, 480), dtype=np.uint8)
>>> jp2 = glymur.Jp2k('zeros.jp2', data=data)
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.
You should have OpenJPEG version 1.5 or more recent before writing JPEG 2000 images.
... display metadata?
=====================
@ -354,15 +349,14 @@ image isn't square. ::
>>> import numpy as np
>>> import glymur
>>> from glymur import Jp2k
>>> rgb = Jp2k(glymur.data.goodstuff()).read()
>>> rgb = Jp2k(glymur.data.goodstuff())[:]
>>> lx, ly = rgb.shape[0:2]
>>> X, Y = np.ogrid[0:lx, 0:ly]
>>> mask = ly**2*(X - lx / 2) ** 2 + lx**2*(Y - ly / 2) ** 2 > (lx * ly / 2)**2
>>> alpha = 255 * np.ones((lx, ly, 1), dtype=np.uint8)
>>> alpha[mask] = 0
>>> rgba = np.concatenate((rgb, alpha), axis=2)
>>> jp2 = Jp2k('tmp.jp2', 'wb')
>>> jp2[:] = rgba
>>> jp2 = Jp2k('tmp.jp2', data=rgba)
Next we need to specify what types of channels we have.
The first three channels are color channels, but we identify the fourth as
@ -465,8 +459,7 @@ http://photojournal.jpl.nasa.gov/tiff/PIA17145.tif info JPEG 2000::
>>> import skimage.io
>>> image = skimage.io.imread('PIA17145.tif')
>>> from glymur import Jp2k
>>> jp2 = Jp2k('PIA17145.jp2', 'wb')
>>> jp2[:] = image
>>> jp2 = Jp2k('PIA17145.jp2', data=image)
Next you can extract the XMP metadata.

View file

@ -1,12 +1,3 @@
-------------------------------------
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 / 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
------------

View file

@ -2,10 +2,26 @@
Changes in glymur 0.7
=====================
Changes in 0.7.3
=================
* added read support back for metadata only when the OpenJPEG library is
not installed
Changes in 0.7.2
=================
* added ellipsis support in array-style slicing
Changes in 0.7.1
=================
* fixed release notes regarding Python 3.4
Changes in 0.7.0
=================
* implemented :py:meth:`__getitem__`, :py:meth:`__setitem__` support
* added back windows support
* box_id and longname are class attributes now instead of instance
attributes (see issue 248)
attributes

View file

@ -0,0 +1,10 @@
=====================
Changes in glymur 0.8
=====================
Changes in 0.8.0
=================
* Simplified writing images by moving data and options into the
constructor. This is backwards-incompatible with 0.7.x.
* Deprecated :py:meth:`read` method in favor of array-style slicing.

View file

@ -8,6 +8,7 @@ These document the changes between minor (or major) versions of glymur.
.. toctree::
0.5
0.6
0.8
0.7
0.6
0.5