简体   繁体   中英

How to find resolution of an image in OpenCV

Is there a way to find a resolution for an image in OpenCV. I'm not looking for width and height, but the resolution.

I can find the resolution in ImageMagick like this:

identify -format "%wx %h %xx %y" mypic.jpg 4175 x 4175 300 x 300%

The resolution for the above image is 300

This might be a bit late, but you can use the .shape property of any image in OpenCV. So, here's some sample code to illustrate how use can use this.

#importing the module cv2
import cv2
#reading the image whose dimensions are to be found using imread() function
image = cv2.imread('input.jpg')
#using shape property to get the dimensions of the image
dimensions = image.shape
print(dimensions)

Hope this answers your question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM