1

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 "%w x %h %x x %y" mypic.jpg 4175 x 4175 300 x 300%

The resolution for the above image is 300

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
Anthony
  • 33,838
  • 42
  • 169
  • 278
  • possible duplicate of http://stackoverflow.com/questions/19098104/python-opencv2-cv2-wrapper-get-image-size – Balaji R Mar 01 '16 at 03:28
  • 1
    there is no way to do that with opencv. and resolution is a dtp thing, it's irrelevant in computer-vision. – berak Mar 01 '16 at 06:15
  • As @berak says, the resolution is largely irrelevant until you actually come to lay down the pixels on a piece of paper or a screen. In computer vision, you just have so many pixels by so many pixels - and more is better (unless you are in a hurry) and that's what you've got. – Mark Setchell Mar 01 '16 at 09:16

1 Answers1

0

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.

ottlite
  • 1
  • 2