如何使用Python opencv以100%缩放显示非常小的图像

问题描述 投票:0回答:1

我只想显示一个简单的小图像。

import numpy as np
import cv2
a = np.zeros([64, 64], np.float32)
a[12, 31] = 1
cv2.imshow('test', a)
cv2.waitKey(0)

The resulting image: two dots are here

我只添加一个点,但显示两个点。

问题是由缩放率引起的。我检查了显示图像的尺寸是(71,71)。如何正确显示此图像?

感谢您的智慧。


环境:

Ubuntu 18.04.2 LTS
Python 3.6.8
opencv-python (4.1.0.25)

其他:

The resulting image: two dots are here

当我按下鼠标滚轮时,我会看到消息“缩放:100%”。但是实际上,缩放率不是100%。仍然显示两个点,并且显示的图像尺寸为(71,71)。

cv2.resizeWindow不起作用。

python opencv zoom display
1个回答
0
投票

您总是可以使用cv2.resize()将图像的大小更改为所需的大小。

height = 64
dim = (width, height)

resized = cv2.resize(a, dim, interpolation = cv2.INTER_AREA)
© www.soinside.com 2019 - 2024. All rights reserved.