LoginSignup
2
3

More than 5 years have passed since last update.

アルファチャネル付きの画像をnumpy用に読みとるには

Last updated at Posted at 2018-05-24

アルファチャネル付きの画像ファイルをPythonで読み取るには

cv2.imread(filename, cv2.IMREAD_UNCHANGED)

BGRAの画像をcv2.imwrite()で書くのは問題がない。
修正後:cv2.imread(filename, cv2.IMREAD_UNCHANGED)のように記載すれば、アルファチャネル付きの画像をきちんと読み込めました。
(間違った理解に対して、ご指摘を感謝します。)

 BGRAの画像をファイルを読み込んだ時にBGR画像となってしまう場合がある。
 私が使っている??のバージョンでは、まだ解決していない。 

PIL.Image.open(filename)

 PIL.Imageの画像形式はnumpy.array()とは相互変換をする必要がある。
 若干めんどうに感じます。

skimage.io.imread()

http://scikit-image.org/docs/dev/api/skimage.io.html
 BGRAの画像をすんなり読むことができます。

Input/Output with Mahotas

2
3
2

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
2
3