0%
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| import cv2 from cv2 import dnn_superres
img_path = "D:/20210921_78339.png" scale = 4 algorithm = "bicubic"
img = cv2.imread(img_path)
sr = dnn_superres.DnnSuperResImpl_create()
if algorithm == "bilinear": img_new = cv2.resize(img, None, fx=scale, fy=scale, interpolation=cv2.INTER_LINEAR) elif algorithm == "bicubic": img_new = cv2.resize(img, None, fx=scale, fy=scale, interpolation=cv2.INTER_CUBIC)
print("Upsampling succeeded. \n")
cv2.imwrite("saved.jpg", img_new)
|