LoginSignup
23
16

More than 5 years have passed since last update.

Python + OpenCVでの画像サイズ取得方法

Last updated at Posted at 2019-02-17

読み込んだ画像のサイズを取得する方法

test.py
import sys,cv2

# 対象画像読み込み
img = cv2.imread("testImg.png",cv2.IMREAD_COLOR)

# 画像の大きさを取得
height, width, channels = img.shape[:3]
print("width: " + str(width))
print("height: " + str(height))

上記を実行すると、以下のように画像の幅と高さが出力される

width: 240
height: 240
23
16
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
23
16