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 1 year has passed since last update.

python、画像の読み込みと表示

Last updated at Posted at 2022-09-18

やること

  • 画像の読み込み
  • 画像の表示

ライブラリ

  • cv2 : python用のOpenCV

コード

import os
import cv2 # cv2のインポート

img_dir = "img_dir" # img_dir:画像データのディレクトリ
img_names = os.listdir(img_dir)

for img_name in img_names:
    img_path = os.path.join(img_dir, img_name)
    
    #画像の読み込み、-1は元画像のチャネルのまま読み込むフラグ
    img = cv2.imread(img_path, -1)
    
    #画像の表示
    cv2.imshow("img_title", img)
    cv2.waitKey(0) # 0の数字を変えると表示のタイミングが変わる。

#画像表示ウィンドウを閉じる
cv2.destroyAllWindows()

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?