如何对图片进行抗锯齿以消除图像中的抖动

How to antialias picture to get rid of the jerkiness in the image

我正在尝试对图片进行抗锯齿处理,并尝试了几种方法,包括开放式 CV、matplotlib 以及 PIL。却还是摆脱不了生涩。

这是抗锯齿的图片。 我尝试的第一种方法是使用 opencv。

import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt
img = cv.imread('LENS_MODEL.png')
kernel = np.ones((5,5),np.float32)/25
dst = cv.filter2D(img,-1,kernel)
plt.subplot(121),plt.imshow(img),plt.title('Original')
plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(dst),plt.title('Averaging')
plt.xticks([]), plt.yticks([])
plt.show() 

但这似乎并没有带来太大的改善。

第二种方法我用matplotlib试过,还是不能去掉抖动,画质更差

fig, axs = plt.subplots(2, 2, figsize=(5, 6), constrained_layout=True)
axs[0, 0].imshow(img, interpolation='nearest')


for ax, interp in zip(axs.flat[1:],
                             ['nearest', 'antialiased', 'antialiased']):
    ax.imshow(img, interpolation=interp,
              cmap='RdBu_r')
    ax.set_title(f"interpolation='{interp}'")
plt.show()

关于如何对图像使用抗锯齿以消除图像中的这种尖锐过渡,有什么建议吗?我也尝试过 PIL,但似乎仍然没有任何改进...

应用强高斯滤波器来平滑“锯齿”,然后强烈增加对比度以通过引起饱和来减少模糊。这仅适用于二进制图像。

这种方法无法保留尖角。