统一两张图片的亮度

Unify Brightness of 2 images

我想要一种方法或步骤来统一 2 个图像的亮度,或者换句话说,使它们的亮度相同但不分配它们。我知道如何使用 PIL 获取图像的亮度,代码如下:

from PIL import Image

imag = Image.open("test.png")
# Convert the image te RGB if it is a .gif for example
imag = imag.convert('RGB')
# coordinates of the pixel
X, Y = 0, 0
# Get RGB
pixelRGB = imag.getpixel((X, Y))
R, G, B = pixelRGB
brightness = sum([R, G, B]) / 3  ##0 is dark (black) and 255 is bright (white)
print(brightness)

有没有人知道如何使两张图像具有相同的亮度。谢谢

您可以使用 Python/OpenCV 中的 mean/standard 偏差颜色转移技术,如 https://www.pyimagesearch.com/2014/06/30/super-fast-color-transfer-images/ 中所述。但是为了不修改颜色而强制它只调整 brightness/contrast,将你的图像转换为 HSV。使用该参考资料中描述的方法仅处理 V 通道。然后组合新的 V 和旧的 S 和 H 通道并将其转换回 BRG。