LoginSignup
1
1

More than 3 years have passed since last update.

【python】画像処理その1 ~画像を読み込んで表示~

Last updated at Posted at 2019-10-23

必要なライブラリをインポート


from PIL import Image
import numpy as np
from matplotlib import pylab as plt
from scipy import ndimage

画像を表示するだけなら下の3つは要らないようですが,
今後いろいろいじりたいのでインポートしてます.

画像ファイルを開く

img = np.array(Image.open('表示したい画像のパス'))

Image.openで画像を読み込んでnp.arrayndarrayにしますです.

画像を表示

plt.imshow(img)

plt.show()

この二行はどっちがかけても表示されないので気を付けてください.

ここまでの全体のコード

from PIL import Image
import numpy as np
from matplotlib import pylab as plt
from scipy import ndimage

img = np.array(Image.open('表示したい画像のパス'))

plt.imshow(img)

plt.show()

表示結果

image-processing-1.PNG

参考

Matplotlibで画像を表示
Python, NumPyで画像処理(読み込み、演算、保存)

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