什么是色调?

色调,在画面上表现思想、感情所使用的色彩和色彩的浓淡。分为暖色调和冷色调。

图像处理------调整色调-LMLPHP

from cv2 import destroyAllWindows, imread, imshow, waitKey

 #创建棕褐色色调
def make_sepia(img, factor: int):
    pixel_h, pixel_v = img.shape[0], img.shape[1]

    #创建像素的灰度表示
    def to_grayscale(blue, green, red):  
        return 0.2126 * red + 0.587 * green + 0.114 * blue

    #规范化 R/G/B 值,如果值> 255,则返回 255
    def normalize(value):
        return min(value, 255)

    for i in range(pixel_h):
        for j in range(pixel_v):
            greyscale = int(to_grayscale(*img[i][j]))
            img[i][j] = [
                normalize(greyscale),
                normalize(greyscale + factor),
                normalize(greyscale + 2 * factor),
            ]

    return img


if __name__ == "__main__":
    #读取原始图像
    images = {
        percentage: imread("image_data/test.jpg", 1) for percentage in (10, 20, 30, 40)
    }

    for percentage, img in images.items():
        make_sepia(img, percentage)

    for percentage, img in images.items():
        imshow(f"Original image with sepia (factor: {percentage})", img)

    waitKey(0)
    destroyAllWindows()

图像处理前:

图像处理------调整色调-LMLPHP

图像处理后:

图像处理------调整色调-LMLPHP

图像处理------调整色调-LMLPHP

图像处理------调整色调-LMLPHP

图像处理------调整色调-LMLPHP

图像处理------调整色调-LMLPHP

图像处理------调整色调-LMLPHP

 

01-26 09:26