LoginSignup
1
1

More than 5 years have passed since last update.

skimage.io.imreadでどのプラグインが早いのか比べた

Posted at
  • skimage.io.imread()する時に、バックエンドに使うライブラリを指定する事ができる。
  • この時、どのライブラリが高速に読み込みを行えるのか比べてみた。

環境や読み込むファイルの性質によって当然変わってくるはずなので、各自の環境で試してみた方が良い。この記事は測定方法の例示のために書いた。

skimage.io.imreadのpluginオプション

以下のように読み込みで使うプラグインを指定できる。

# matplotlibで読み込む
skimage.io.imread(fname='lenna.png', plugin='matplotlib')

# pilで読み込む
skimage.io.imread(fname='lenna.png', plugin='pil')

plugin : str, optional
Name of plugin to use. By default, the different plugins are tried (starting with the Python Imaging Library) until a suitable candidate is found. If not given and fname is a tiff file, the tifffile plugin will be used.

測定

インストールしていないプラグインは除外して以下のように測定した。

import skimage.io

plugins = skimage.io.find_available_plugins()

for name in plugins:
    # 除外
    if name in ['qt', 'gdal', 'gtk', 'simpleitk', 'fits', 'tifffile']:
        continue

    print(name)

    skimage.io.use_plugin(name)
    %timeit skimage.io.imread(fname='lenna.png', plugin=name)

    print('---')

参考までに私の環境での測定結果を載せておく。

imread
8.88 ms ± 2.08 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)
---
pil
20.1 ms ± 892 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
---
matplotlib
37.8 ms ± 6.65 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
---
imageio
25.1 ms ± 5.67 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)
---
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1