[英]OpenCV nearest neighbour interpolation creates pixels not present in original image
I have an image A. The goal is to downsize it to an image, such that the dimensions of the image are smaller, but no pixel in the new image contains a value not present in the original. 我有一个图像A。目标是将其缩小为图像,以使图像的尺寸较小,但新图像中没有像素包含原始图像中不存在的值。 In other words, if $p \\in A'$ then $p \\in A$.
换句话说,如果$ p \\ in A'$,则$ p \\ in A $。
I tried doing this in python as follows: 我尝试在python中这样做,如下所示:
resized = cv2.resize(old_img, (1024, 1024), 0, 0, cv2.INTER_NEAREST)
However, when the input is a binary image (old_img contains only black and white pixels), the resulting image contains grey values (values not equal to 0 or 255). 但是,当输入为二进制图像(old_img仅包含黑白像素)时,结果图像将包含灰度值(值不等于0或255)。
Is this a bug in the implementation? 这是实现中的错误吗? It's a hard requirement for me that no pixel ends up with a non original value.
对我来说,没有一个像素具有非原始值是很困难的要求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.