The first few times I 've told you how to implement some simple filter effects by operating pixels.
This time, I would like to tell you how to adjust the color space of an image using a grayscale histogram.
First, I would like to introduce some color tips.
In terms of computer color, the color is composed of three colors: Right Red, green, and blue.
In the most easy 24-bit color, red, green, and blue are represented by one byte each. One byte has eight bits, so the combination is exactly 24 bits. Since computers cannot use continuous simulated values to represent a natural volume, they can only be divided into segments for display. The more shares, the closer they are to nature. 1 byte is 2 ^ 8 = 256, so in the 24-bit color, each monochrome has 256 different intensity. The three colors are mixed according to different intensity, you can get 2 ^ 24 colors. About 16.77 million colors can be expressed, which is no different from natural colors for human eyes.
If we use PHOTOSHOP to open an image and select the LEVEL tool, we can see the color distribution of the image.
Source image:
Grayscale channel: red channel:
Green Channel: blue channel:
From the above four channels, we can find that the color of this image is dominated by low brightness, and the red, green, and blue colors are rarely distributed in High Brightness areas, the grayscale channel also indicates that the brightness of the entire image is very low.
In the previous article, I have already told you that human eyes are most sensitive to gray scale (brightness. Therefore, if we can improve the gray scale of the image in this chapter, it will be better in our vision.
Some friends may say that they only need to increase the brightness of the image, isn't it? Yes. by increasing the brightness of all colors, you can transfer the colors that were originally in the bright area to the moderate or high brightness area. But as you know, in the algorithm, adding brightness is simply adding an Offset after the R, G, and B values: NewRed = OldRed + Offset, NewGreen = OldGreen + Offset, NewBlue + Offset, however, this method only "roughly" moves the entire color space to a position without changing its distribution. Please refer to the following. I added a brightness of 120 points to this image: Then you can see the color distribution at this time and you will know why I say it is "rude ".
Grayscale channel: red channel:
Green Channel: blue channel:
We can see that the color information of the High Brightness part on the source image is lost, while the low brightness part (0-120) is blank,