OpenCV & Python - Image too big to display

后端 未结 7 2021
猫巷女王i
猫巷女王i 2020-12-04 23:33

I have an image that is 6400 × 3200, while my screen is 1280 x 800. Therefore, the image needs to be resized for display only. I am using Python and OpenCV 2.4.9. According

7条回答
  •  不思量自难忘°
    2020-12-04 23:47

    In opencv, cv.namedWindow() just creates a window object as you determine, but not resizing the original image. You can use cv2.resize(img, resolution) to solve the problem.

    Here's what it displays, a 740 * 411 resolution image.

    image = cv2.imread("740*411.jpg")
    cv2.imshow("image", image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
    

    Here, it displays a 100 * 200 resolution image after resizing. Remember the resolution parameter use column first then is row.

    image = cv2.imread("740*411.jpg")
    image = cv2.resize(image, (200, 100))
    cv2.imshow("image", image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
    

提交回复
热议问题