我正在尝试对图像使用伽玛校正。但我只手动更改伽玛校正的值。有什么方法可以自动计算伽马校正的最佳值吗?例如亮度直方图。
代码:
# import the necessary packages
from __future__ import print_function
import numpy as np
import argparse
import cv2
def adjust_gamma(image, gamma=1.0):
# build a lookup table mapping the pixel values [0, 255] to
# their adjusted gamma values
invGamma = 1.0 / gamma
table = np.array([((i / 255.0) ** invGamma) * 255
for i in np.arange(0, 256)]).astype("uint8")
# apply gamma correction using the lookup table
return cv2.LUT(image, table)
# load the original image
original = cv2.imread('image.jpg')
# loop over …Run Code Online (Sandbox Code Playgroud)