From 2c8e30e320411926fff60cb49b63d5d20771eebf Mon Sep 17 00:00:00 2001 From: jevans Date: Tue, 9 Sep 2014 19:10:31 -0400 Subject: [PATCH] Documentation for slicing. --- docs/source/how_do_i.rst | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/docs/source/how_do_i.rst b/docs/source/how_do_i.rst index ebe7a31..a24c1ef 100644 --- a/docs/source/how_do_i.rst +++ b/docs/source/how_do_i.rst @@ -3,17 +3,24 @@ How do I...? ------------ -... read the lowest resolution thumbnail? -========================================= -Printing the Jp2k object should reveal the number of resolutions -(look in the COD segment section of the codestream), but you can -take a shortcut by supplying -1 as the -resolution level. :: +... read the lower resolution images? +===================================== +Jp2k implements slicing via the :py:meth:`__getitem__` method so +any lower resolution images in a JPEG 2000 file can easily be +accessed, for example here's how to retrieve the first sub-image :: >>> import glymur >>> jp2file = glymur.data.nemo() >>> jp2 = glymur.Jp2k(jp2file) - >>> thumbnail = jp2.read(rlevel=-1) + >>> fullres = jp2[:] + >>> print(fullres.shape) + (1456, 2592, 3) + >>> thumbnail = jp2[::2, ::2] + >>> print(thumbnail.shape) + (728, 1296, 3) + +The :py:meth:`read` method gives many more options for other JPEG 2000 features +such as quality layers. ... display metadata? =====================