progress
This commit is contained in:
parent
5e8a66c38e
commit
3f7c08739c
9 changed files with 117 additions and 185 deletions
|
|
@ -25,16 +25,14 @@ 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 +352,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 +462,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.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue