开放式简历Python-图片太大而无法显示 [英] OpenCV & Python - Image too big to display

查看:87
本文介绍了开放式简历Python-图片太大而无法显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的图像是6400××3200,而我的屏幕是1280 x800.因此,该图像需要调整大小以仅用于显示.我正在使用Python和OpenCV 2.4.9. 根据OpenCV文档

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 to OpenCV Documentation,

如果需要显示大于屏幕分辨率的图像,则需要在显示之前调用namedWindow(",WINDOW_NORMAL).

If you need to show an image that is bigger than the screen resolution, you will need to call namedWindow("", WINDOW_NORMAL) before the imshow.

这就是我正在做的,但是图像没有适合屏幕,仅显示了一部分,因为它太大了.我也尝试过使用cv2.resizeWindow,但没有任何区别.

That is what I am doing, but the image is not fitted to the screen, only a portion is shown because it's too big. I've also tried with cv2.resizeWindow, but it doesn't make any difference.

import cv2
cv2.namedWindow("output", cv2.WINDOW_NORMAL)        # Create window with freedom of dimensions
# cv2.resizeWindow("output", 400, 300)              # Resize window to specified dimensions
im = cv2.imread("earth.jpg")                        # Read image
cv2.imshow("output", im)                            # Show image
cv2.waitKey(0)                                      # Display the image infinitely until any keypress

推荐答案

尽管我期望有一个自动解决方案(自动适应屏幕),但调整大小也可以解决该问题.

Although I was expecting an automatic solution (fitting to the screen automatically), resizing solves the problem as well.

import cv2
cv2.namedWindow("output", cv2.WINDOW_NORMAL)        # Create window with freedom of dimensions
im = cv2.imread("earth.jpg")                        # Read image
imS = cv2.resize(im, (960, 540))                    # Resize image
cv2.imshow("output", imS)                            # Show image
cv2.waitKey(0)                                      # Display the image infinitely until any keypress

这篇关于开放式简历Python-图片太大而无法显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆