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 5 years have passed since last update.

Python Pillow 画像読み込み

Last updated at Posted at 2019-10-03

背景

画像処理のソフトウェアは大きく分けて2つある。
・OpneCV (C++, Python)
・Pillow (Python)

てっきり、Pillowにも画像読み込み方は種類があると思っていた。
Pillowでグラースケール画像をRGB画像で読み込みたかった。

下記の方法で回避することにする。

参考コード

pillow_RGB_to_GRAY.py
# Pillowの画像読み込みモジュールImage
from PIL import Image

# 入力画像 (グレースケール)
img = 'image.jpg'

# Pillowで画像の読み込み
img_GRAY = Image.open(img)

# 画像形式をチェック
print("img_GRAY.mode", img_GRAY.mode)

# グラースケールをRGBに変換
img_RGB = img_GRAY.convert('RGB')

# 画像形式をチェック
print("img_RGB.mode", img_RGB.mode)

参考文献

Pillow (PIL) - 画像の情報を取得する方法
Pillow (PIL) - 画像のチャンネル、画素値を操作する方法

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?