I am trying to antialias a picture and tried few methods, with open CV and with matplotlib and also with PIL. But still can't get rid of the jerkiness.
This is the picture for antialiasing. The first method I have tried is with 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()
But this seems not to give much improvement.
The second method I have tried with matplotlib but still can't get rid of the jerkiness and the image quality is even worse.
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()
Any suggestions how can I use antialiasing for images to get rid of this sharp transistions in the image? I also tried PIL but still seems no improvements...
Apply a strong Gaussian filter to smooth out the "jaggies", then strongly increase the contrast to reduce the blur by causing saturation. This only works with binary images.
The sharp corners cannot be preserved by this method.