Reading .jp2 in skimage

415 views
Skip to first unread message

Jaidev Deshpande

unread,
Oct 29, 2012, 5:53:59 PM10/29/12
to scikit...@googlegroups.com
Hello,

Are jpeg 2000 images supported in skimage? I tried looking for it in
the docs but didn't find anything.

Thanks

--
JD

Tony Yu

unread,
Oct 29, 2012, 6:09:24 PM10/29/12
to scikit...@googlegroups.com
Hey JD,

skimage doesn't implement image readers, but instead, uses other i/o libraries as plugins (so there's no good way to list image format support). For me, `skimage.io.imread` doesn't read jp2 by default (my default plugin is 'PIL'), but I can set the plugin to 'freeimage' to read jp2 images; e.g.

    from skimage import io
    io.imread('some_image.jp2', plugin='freeimage')

which uses freeimage just for that one call or

    io.use_plugin('freeimage')
    io.imread('some_image.jp2')

which changes your default io plugin to freeimage. You'd need to have the freeimage library installed on your system to use this plugin:


There may be other skimage plugins that support jp2, but I'm not sure.

Best,
-Tony

Jaidev Deshpande

unread,
Oct 29, 2012, 6:23:34 PM10/29/12
to scikit...@googlegroups.com
On Tue, Oct 30, 2012 at 3:39 AM, Tony Yu <tsy...@gmail.com> wrote:
>
>
> On Mon, Oct 29, 2012 at 5:53 PM, Jaidev Deshpande
> <deshpand...@gmail.com> wrote:
>>
>> Hello,
>>
>> Are jpeg 2000 images supported in skimage? I tried looking for it in
>> the docs but didn't find anything.
>>
>> Thanks
>>
>> --
>> JD
>>
>
> Hey JD,
>
> skimage doesn't implement image readers, but instead, uses other i/o
> libraries as plugins (so there's no good way to list image format support).

Out of curiosity, does matplotlib's imread do the same, using other plugins?

> For me, `skimage.io.imread` doesn't read jp2 by default (my default plugin
> is 'PIL'), but I can set the plugin to 'freeimage' to read jp2 images; e.g.
>
> from skimage import io
> io.imread('some_image.jp2', plugin='freeimage')
>
> which uses freeimage just for that one call or
>
> io.use_plugin('freeimage')
> io.imread('some_image.jp2')
>
> which changes your default io plugin to freeimage. You'd need to have the
> freeimage library installed on your system to use this plugin:
>
> http://freeimage.sourceforge.net/

Thanks! That did it.

>
> There may be other skimage plugins that support jp2, but I'm not sure.
>
> Best,
> -Tony
>
> --
>
>



--
JD

Tony Yu

unread,
Oct 29, 2012, 6:39:45 PM10/29/12
to scikit...@googlegroups.com
On Mon, Oct 29, 2012 at 6:23 PM, Jaidev Deshpande <deshpand...@gmail.com> wrote:
On Tue, Oct 30, 2012 at 3:39 AM, Tony Yu <tsy...@gmail.com> wrote:
>
>
> On Mon, Oct 29, 2012 at 5:53 PM, Jaidev Deshpande
> <deshpand...@gmail.com> wrote:
>>


<snip>
 
>
> skimage doesn't implement image readers, but instead, uses other i/o
> libraries as plugins (so there's no good way to list image format support).

Out of curiosity, does matplotlib's imread do the same, using other plugins?

I think Matplotlib uses libpng for PNGs and then PIL for everything else. I tried loading a jp2 image with the matplotlib plugin and it raises a PIL error.

> For me, `skimage.io.imread` doesn't read jp2 by default (my default plugin
> is 'PIL'), but I can set the plugin to 'freeimage' to read jp2 images; e.g.
>
>     from skimage import io
>     io.imread('some_image.jp2', plugin='freeimage')
>
> which uses freeimage just for that one call or
>
>     io.use_plugin('freeimage')
>     io.imread('some_image.jp2')
>
> which changes your default io plugin to freeimage. You'd need to have the
> freeimage library installed on your system to use this plugin:
>
>     http://freeimage.sourceforge.net/

Thanks! That did it.

Great! We should probably update info in the docs about what plugins we support. Freeimage is already listed in our install page, but there are actually a few others that aren't:


Reply all
Reply to author
Forward
0 new messages