Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python PIL和x27之间的区别是什么;s和OpenCV';s调整大小_Python_Python Imaging Library_Image Resizing_Opencv Python - Fatal编程技术网

Python PIL和x27之间的区别是什么;s和OpenCV';s调整大小

Python PIL和x27之间的区别是什么;s和OpenCV';s调整大小,python,python-imaging-library,image-resizing,opencv-python,Python,Python Imaging Library,Image Resizing,Opencv Python,我讨论了以下问题:这两个库的resize函数的行为不同。下面是一个小测试: import numpy as np import PIL import cv2 from matplotlib import pyplot as plt img = np.random.randn(10, 10, 3) SIZE = (5, 5) img -= img.min() img /= img.max() img = (img*255).astype(np.uint8) # Display the init

我讨论了以下问题:这两个库的resize函数的行为不同。下面是一个小测试:

import numpy as np
import PIL
import cv2
from matplotlib import pyplot as plt

img = np.random.randn(10, 10, 3)
SIZE = (5, 5)
img -= img.min()
img /= img.max()
img = (img*255).astype(np.uint8)

# Display the initial image
plt.figure(figsize=(16,9))
plt.imshow(img)
plt.show()
plt.close()

# resize the image in two different ways
img_cv2 = cv2.resize(img, dsize=SIZE, interpolation=cv2.INTER_LINEAR)
img_pil = PIL.Image.fromarray(img).resize(SIZE, resample=PIL.Image.BILINEAR)

# get the difference image and normalize it
diff = np.abs(img_cv2.astype(np.float32) - img_pil)
diff /= diff.max() or 1

# display results
fig, axs = plt.subplots(1, 3, figsize=(16, 9))
axs[0].imshow(img_cv2)
axs[1].imshow(img_pil)
axs[2].imshow(diff)
plt.show()
plt.close()
我现在的问题是:为什么会发生这种情况?是实现上的差异(我还没有检查PIL或OpenCV中的代码)还是我以错误的方式使用了这些函数


以下是一些示例输出:和。

您的链接似乎不起作用。它们对我有效:-/(一秒钟前测试)我在GitHub上发现了一个问题:您的链接似乎不起作用。它们对我有效:-/(一秒钟前测试)我在GitHub上发现了一个问题: