为了消除锯齿效果,您可以添加抗锯齿滤波器:
from matplotlib import pyplot
pyplot.imshow(image, cmap="gray", interpolation='hanning')
pyplot.show()
vmin
和vmax
,它将被映射到255。这将导致图像看起来比实际更明亮。import matplotlib.pyplot as plt
import cv2
image = cv2.imread("example2.png")[:,:,0]
fig = plt.figure()
ax1, ax2 = fig.subplots(1,2)
ax1.axis("off")
ax2.axis("off")
ax1.imshow(image, cmap="gray") # rescales value range
ax2.imshow(image, cmap="gray",vmin = 0, vmax = 255) # proper way
plt.show()
文档中已经说明了这里
imshow(image, interpolation='hanning')
来消除它的大部分。 - Jody Klymak