繁体   English   中英

如何在 OpenCV 中找到图像的分辨率

[英]How to find resolution of an image in OpenCV

有没有办法在 OpenCV 中找到图像的分辨率。 我不是在寻找宽度和高度,而是在寻找分辨率。

我可以像这样在 ImageMagick 中找到分辨率:

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

上图的分辨率是300

这可能有点晚了,但您可以使用 OpenCV 中任何图像的.shape属性。 所以,这里有一些示例代码来说明 use 如何使用它。

#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)

希望这能回答你的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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