#author("2017-12-25T20:52:19+09:00","default:Miyashita","Miyashita")
#author("2018-07-25T23:45:03+09:00","default:Miyashita","Miyashita")
*Pythonで画像表示 [#l4459c56]
**OSにあるビューワーで表示 [#b35fcb1b]
単に画像を見たい時しか使わない.
 from PIL import Image
 im = Image.open('example.jpg')
 im.show()
#codeprettify(lang-python){{
from PIL import Image
im = Image.open('example.jpg')
im.show()
}}

**OpenCV2で読んで,OpenCV2で表示 [#h04583d8]
 import cv2
 imgorg = cv2.imread("example.jpg")
 cv2.imshow("Figure 1",imgorg)
 cv2.waitKey(0)
 cv2.destroyAllWindows()
#codeprettify(lang-python){{
import cv2
imgorg = cv2.imread("example.jpg")
cv2.imshow("Figure 1",imgorg)
cv2.waitKey(0)
cv2.destroyAllWindows()
}}
waitKeyは()の中の値×1msの時間だけキーの入力を受け付ける.~
0ではいずれかのキー入力があるまで待つ.~
この場合はキー入力があるまでFigureウィンドウが表示され続ける.
**OpenCV2で読んで,matplotlibで表示 [#gd82fcf9]
目盛りとラベルが不要であればaxis("off")を追加する.
 import cv2
 import matplotlib.pyplot as plt
 imgorg = cv2.imread("example.jpg")
 fig = plt.figure()
 im = plot.imshow(cv2.cvtColor(imgorg,cv2.COLOR_BGR2RGB))
 plt.axis("off")
 plt.show()
#codeprettify(lang-python){{
import cv2
import matplotlib.pyplot as plt
imgorg = cv2.imread("example.jpg")
fig = plt.figure()
im = plot.imshow(cv2.cvtColor(imgorg,cv2.COLOR_BGR2RGB))
plt.axis("off")
plt.show()
}}

Front page   Edit Diff Attach Copy Rename Reload   New List of pages Search Recent changes   Help   RSS of recent changes