最好使用元组来计算,如果有其他的滤镜公式提供就更好了。使用 Python 元组的话,如何把代码压缩到最短?
import cv2
import math
fileName = 'R-C.jpeg'
save_path = 'after_visit_pix.jpeg'
img = cv2.imread(fileName)
info = img.shape
height = info[0]
width = info[1]
dst = img
for h in range(0, height):
for j in range(0, width):
(b, g, r) = img[h, j]
dst[h, j] = (math.pow(b, 3/2), math.pow(g, 4/5), math.pow(r, 3/2))
cv2.imwrite(save_path, dst)
有帮助的话请给个采纳,谢谢😁