0 votes
1 view
in Python by (11.8k points)

Instructions to get the size of a picture in cv2 wrapper in Python OpenCV (numpy). Is there a right method to do that other than numpy.shape(). How might I get it in these arrangement dimensions: (width, height) list?

1 Answer

0 votes
by (24.6k points)

Here, cv2 utilizes NumPy for manipulating the imager, so the legitimate and most ideal approach to get the size of a picture is utilizing numpy.shape. Expecting you are working with BGR pictures, here is an example: 

>>> import numpy as np

>>> import cv2

>>> img = cv2.imread('foo.jpg')

>>> height, width, channels = img.shape

>>> print height, width, channels

  600 800 3

On the off chance that you were working with binary pictures, IMG will have two measurements, and consequently you should change the code to height, width = img.shape

Are you interested to learn the concepts of Python? Join the python training course fast!

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...