jpeg2000 for anaconda installation

268 views
Skip to first unread message

Jonathan Slavin

unread,
May 15, 2015, 2:53:16 PM5/15/15
to su...@googlegroups.com
Hi,

I ran into trouble using sunpy to read in jpeg2000 files.  Looking for the source I ran across the statement on the installation page regarding support for jpeg2000 files and the anaconda distribution - "Currently Glymur / JPEG2000 support is not tested under Anaconda on any platforms. If you require JPEG2000 support either use a different install method, or contact the SunPy mailing list."

Since I'd like to use both my anaconda distribution and sunpy for examining jpeg2000 images, I'd like to see if there's a workaround for this.  When I try:

    from sunpy.io import jp2
    dh = jp2.read(file)

I get a bunch of error messages ending in:

/export/slavin/python/anaconda/lib/python2.7/site-packages/glymur/jp2k.pyc in _populate_dparams(self, rlevel, tile, area)
   1339         # Return raw codestream components instead of "interpolating" the
   1340         # colormap?
-> 1341         dparam.flags |= 1 if self.ignore_pclr_cmap_cdef else 0
   1342 
   1343         dparam.decod_format = self._codec_format

AttributeError: 'DecompressionParametersType' object has no attribute 'flags'

I think this is caused by the version of openjpeg used -- i.e. by the fact that glymur.lib.openjp2.OPENJP2 is None which leads to dparam = opj.DecompressionParametersType() and presumably does not create the attribute flags.  So does anyone know to fix this?  Is it about installing the right version of the openjpeg library?

Thanks for any help,
Jon

Stuart Mumford

unread,
May 19, 2015, 4:25:31 AM5/19/15
to su...@googlegroups.com
Hi,

A few questions:

What platform are you on? What version of openjpeg do you have installed and how did you install it? What version of glymur do you have installed?

Stuart
--
You received this message because you are subscribed to the Google Groups "SunPy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sunpy+un...@googlegroups.com.
To post to this group, send email to su...@googlegroups.com.
Visit this group at http://groups.google.com/group/sunpy.
For more options, visit https://groups.google.com/d/optout.

Slavin, Jonathan

unread,
May 19, 2015, 8:38:54 AM5/19/15
to su...@googlegroups.com
Hi Stuart,

I'm running on CentOS 6.6 Linux.  
Version of openjpeg: 1.3
Glymur version: 0.8.1

I used to be able to do:
image = glymur.Jp2k(file).read()
but now I get that exception I mentioned:
...
/export/slavin/python/anaconda/lib/python2.7/site-packages/glymur/jp2k.pyc in _populate_dparams(self, rlevel, tile, area)
   1339         # Return raw codestream components instead of "interpolating" the
   1340         # colormap?
-> 1341         dparam.flags |= 1 if self.ignore_pclr_cmap_cdef else 0
   1342 
   1343         dparam.decod_format = self._codec_format

AttributeError: 'DecompressionParametersType' object has no attribute 'flags'

Jon

--
You received this message because you are subscribed to a topic in the Google Groups "SunPy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sunpy/_tyX5r0Bc3o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sunpy+un...@googlegroups.com.

To post to this group, send email to su...@googlegroups.com.
Visit this group at http://groups.google.com/group/sunpy.
For more options, visit https://groups.google.com/d/optout.



--
________________________________________________________
Jonathan D. Slavin                 Harvard-Smithsonian CfA
jsl...@cfa.harvard.edu       60 Garden Street, MS 83
phone: (617) 496-7981       Cambridge, MA 02138-1516
fax: (617) 496-7577            USA
________________________________________________________

Jack Ireland

unread,
May 19, 2015, 8:51:01 AM5/19/15
to su...@googlegroups.com
Jon,

It might be worth trying a newer version of openjpeg, as recommended on the glymur documentation page.  Glymur 0.8.2 just came out too.

Even with that, at first blush, the error looks to be one in the glymur library.  I am sure the writer of glymur would like to know about it, since the docs say that glymur will work with openjpeg 1.3.

Jack

Slavin, Jonathan

unread,
May 19, 2015, 9:15:16 AM5/19/15
to su...@googlegroups.com
Hi Jack,

Well I just updated glymur to version 0.8.2 and now I get the message:
"RuntimeError: You must have at least version 1.5.0 of OpenJPEG installed before you can read JPEG2000 images."

I don't have root privileges on my machine, so installation of an updated version of the openjpeg libraries could be a little tricky.  I'll see what I can do.

Jon

Slavin, Jonathan

unread,
May 19, 2015, 10:13:55 AM5/19/15
to su...@googlegroups.com
Okay.  After a couple false starts I was able to install the latest openjpeg library and get glymur to find it.  In case this comes up again, what I did was:
- download openjpeg-2.1.0.tar.gz, untar it (tar xvzf ..., of course)
- in the openjpeg-2.1.0 directory I then did:
- cmake . -DCMAKE_INSTALL_PREFIX='/export/slavin/python/anaconda'
(note the dot after cmake) so setting the install prefix to the root of my anaconda distribution (I found that setting the DESTDIR environment variable to /export/slavin/python/anaconda resulted in an install under /export/slavin/python/anaconda/usr/local). 
- make
- make install
I then needed to create a configuration file for glymur to ensure that it could find the library. So I created a /home/jslavin/.config/glymur directory and a file in it named glymurrc into which I put:
[library]
openjp2:/export/slavin/python/anaconda/lib/libopenjp2.so

and now it works!

Regards,
Jon

DVD PS

unread,
May 19, 2015, 10:39:13 AM5/19/15
to sunpy
Thanks Jon! I'm sure these steps will be useful for a lot of people.


David

Jack Ireland

unread,
May 19, 2015, 12:07:22 PM5/19/15
to su...@googlegroups.com
Should be in the docs for 0.6.
Reply all
Reply to author
Forward
0 new messages