Colorize grayscale image

前端 未结 2 1571
时光说笑
时光说笑 2021-01-16 10:36

I have a grayscale image and a some color, represented in RGB triplet. And i need to colorize grayscale image using this triplet.

2条回答
  •  余生分开走
    2021-01-16 11:14

    Conceptually, you'd take the greyscale value of each pixel in the original image and use that as a percentage of the green value. so if a pixel has greyscale value 87, then the equivalent pixel in the colorized image would be:

    colorized_red = (87 / 255) * red_component(green_shade);
    colorized_green = (87 / 255) * green_component(green_shade);
    colorized_blue = (87 / 255) * blue_component(green_shade);
    

提交回复
热议问题