I tried to convert above pseudo-code into real code but not getting desired result. any idea on where I am doing wrong ?
import cv2
import numpy as np
def gammaCorrection(src, gamma):
invGamma = 1 / gamma
table = [((i / 255) ** invGamma) * 255 for i in range(256)]
table = np.array(table, np.uint8)
return cv2.LUT(src, table)
image = cv2.imread(r'C:\Users\test\Desktop\test.jpg')
gammaCorrectedImage = gammaCorrection(image, 3.0) #Or whatever power works for you
ksize = (40, 40)
bokeh = cv2.blur(gammaCorrectedImage, ksize) #discBlur(gammaCorrectedImage)
bokeh = gammaCorrection(bokeh, 0.33) #To get back the original gamma.
blurImage = cv2.blur(image, ksize) #discBlur(image)
finalImage = cv2.max(bokeh, blurImage)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.