我正在使用以下代码创建图,并将其保存到路径。但是,该图会打开一个新窗口,而无需我明确调用plt.show()。有谁知道如何停止开窗?
arr1 = np.random.rand(150,500)
arr2 = np.random.rand(150,500)
fig = plt.figure()
a=fig.add_subplot(1,2,1)
imgplot = plt.imshow(arr1)
a.set_title('Image 1')
a.xaxis.set_visible(False)
a.yaxis.set_visible(False)
a=fig.add_subplot(2,2,1)
imgplot = plt.imshow(arr2)
a.set_title('Image 2')
a.xaxis.set_visible(False)
a.yaxis.set_visible(False)
plt.savefig('C:/Users/.../fig.png', bbox_inches='tight')
Run Code Online (Sandbox Code Playgroud) 我有一个 512x160 像素的黑白图像,我想使用 OpenCV 将其放大(到 4096x1280)。负值(白色)像素保持负值非常重要。cv2.resize默认情况下似乎会对图像进行抗锯齿处理,从而产生假正像素。有没有办法禁用抗锯齿功能?
编辑:据我所知,这里有插值方法: