0
2

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.

matplotlibでpng画像表示

Posted at

pythonで画像表示

恥ずかしながら今までプログラミング言語でプログラムして画像表示というものをしたことがなかった。
pythonのmatplotlibを用いると簡単にできたので、ある種感動したのでその記録。

showpng.py
# !/usr/bin/env python3

import matplotlib.pyplot as plt
import matplotlib.image as mpimg

img = mpimg.imread("m2.png") # png形式の画像データをnumpyのndarray形式の配列に変換
plt.imshow(img) # imshowは配列を引数に取ることができる。
plt.show() # 読み込んだ配列形式のデータを画像形式として表示

実行結果

m2.png

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?