簡體   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