简体   繁体   中英

How to display very small image with 100% zoom with Python opencv

I just wanted to display a small simple image.

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

结果图像:这里有两个点

I just add one dot, but two dots are shown.

The problem is caused by the zoom rate. I checked the display image size is (71, 71). How can I display this image correctly?

Thank you for your wisdom.


Environment:

Ubuntu 18.04.2 LTS
Python 3.6.8
opencv-python (4.1.0.25)

additional:

结果图像:这里有两个点

When I pull down my mouse's wheel, I can see the message that 'Zoom:100%'. But actually, the zoom rate is not 100%. TWO DOTS are still shown and the displayed image size is (71, 71).

cv2.resizeWindow doesn't work.


addition:

结果图像:这里有两个点

When I ran same code on Windows 10, I could see correct display. It is exact 100% zoom rate.

You can always use cv2.resize() to change the size of the image to what you want.

height = 64
dim = (width, height)

resized = cv2.resize(a, dim, interpolation = cv2.INTER_AREA)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM