LoginSignup
3
2

More than 5 years have passed since last update.

Python画像処理

Posted at

はじめに

SLP KBIT Advent Calendar 2018の記事です。
期間まで時間がなかったので簡単にできそうな画像処理をしました。
Pythonのライブラリpillowを使いました。

環境

-Python 3.7.1

画像処理

img.py
from PIL import Image 

#画像の名前を入力する
original = input("画像の名前を入れる>>")
#元となる画像
image = Image.open(original)
#画像を8ビット/256階調グレースケールにし、オリジナルの名前+-grayscale.jpgで保存する
image.convert("L").save(original+"-grayscale.jpg")

カラーの画像を256階調の白黒に変更します。

実行する

例に使う画像はイケてる写真


画像の名前を入れる>>イケてる.JPG

これで実行すると

こんな感じで256階調の白黒になる。

最後に

頑張った自分にスタンディングオベーション

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