0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Python imageio.imwrite で PNG 保存は遅い

Posted at

背景

imageio, 便利ですよね.

画像処理したデータ(画像)を, 可逆圧縮で 8bit or 16bit で保存したいので PNG で imageio.imwrite で画像保存していたのですが, なぜかスクリプトが重いなーと思ったら, PNG の書き込みが激遅でした.

体感では, 256x256 くらいの画像でも 1 秒くらいかかります. BMP or TIFF で非圧縮だと 0.05 秒くらい.

対処

cv2.imwrite だと速くなるかも...?

あとは最新 imageio(PIL) だと速くなっているかもしれません.

自然画像的なデータだと, 可逆圧縮してもそんなにストレージ減らないので, 圧縮はあきらめて BMP or TIFF(8bit, 16bit, 32bit)にするのが手でしょう.

ちなみに imwrite で 16bit PNG 保存は, PNG-FI オプションをつけないと, 入力画像データが [0, 255] の範囲にある場合は自動的に 8bit にしてしまいますので注意です.

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?