Image size (Python, OpenCV)

Andrea Diaz picture Andrea Diaz · Oct 23, 2012 · Viewed 207.1k times · Source

I would like to get the Image size in python,as I do it with c++.

int w = src->width;
printf("%d", 'w');

Answer

cowhi picture cowhi · Apr 22, 2014

Using openCV and numpy it is as easy as this:

import cv2

img = cv2.imread('path/to/img',0)
height, width = img.shape[:2]