Color model talks (four)

zhaozj2021-02-11  189

Third, intuitive color model

The color model of the previous explanation is based on three-color color model, now let's look at a more intuitive color model. Maybe everyone painted oil painting or water? Remember how we made a color? We always choose a color we need from the pigment, and then if we need to have a little black, add some points to the inside, add a white. Obviously, this method is more intuitive, and we can also use this intuitive model to describe the color than the three basins.

HSV color model

The parameters of the color in this model are: Color (H), Purity (S), Ming (V).

The three-dimensional representation of the HSV model is evolved from the RGB cube. It is envisaged from the white vertex of the RGB along the cube diagonal to the black vertex, you can see the hexagonal shape of the cube. The hexagonal boundary represents the color, the horizontal axis represents a purity, and the brightness is measured along the vertical axis. See below:

HSV hexagle

The h parameter represents the color information, that is, the position of the spectrum color. This parameter is represented by a angular measure, red, green, and blue respectively separated 120 degrees. Complementary color is 180 degrees respectively. The purity S is a ratio value, which ranges from 0 to 1, which represents the purity of the selected color and the ratio between the maximum purity of the color. When s = 0, only grayscale. V represents the brightness of the color, ranging from 0 to 1. One thing to pay attention to: There is no direct connection between it and the light intensity.

RGB conversion to HSV algorithm

MAX = max (r, g, b) min = min (r, g, b) IF r = max, h = (gb) / (max-min) IF g = max, h = 2 (br) / ( Max-min) IF b = max, h = 4 (rg) / (max-min) h = h * 60 if h <0, h = h 360 V = max (r, g, b) s = ( Max-min) / MaxHSV algorithm for transforming to RGB

IF s = 0 r = g = b = v else h / = 60; i = integer (h) f = h - i a = v * (1 - s) b = v * (1 - s * f) c = V * (1 - s * (1 - f)) Switch (i) case 0: r = v; g = c; b = a; case 1: r = b; g = v; b = a; case 2: R = a; g = v; b = C; case 3: r = a; g = b; b = v; case 4: r = c; g = a; b = v; case 5: r = v; g = a; b = B;

HSV is an intuitive color model for users. We can start from a pure color, ie specified color angle h, and let V = S = 1, then we can get the color we need by adding black and white to it. Increasing black can reduce V and S is constant, and the same increase in white can reduce S and V is constant. For example, to get dark blue, V = 0.4 s = 1 h = 240 degrees. To get light blue, V = 1 s = 0.4 h = 240 degrees.

Generally speaking, the human eye can distinguish 128 different colors, 130 color saturation, 23 species clear. If we use 16bit to reply to HSV, you can use 7-bit to store H, 4-bit storage S, 5-bit storage V, that is, 745 or 655 can meet our needs. Since HSV is a relatively intuitive color model, it is relatively wide in many image editing tools, such as Photoshop (called HSB in Photoshop), but this also determines that it is not suitable for use in light models, many light The mixed operation, the light intensity operation, etc. cannot be implemented directly using the HSV.

By the way, another intuitive color model is an HSL model, the first two parameters and HSV in the model, while L represents the brightness. Its 3D is expressed as a pair of prism. Because there are not many, it will not be detailed here.

转载请注明原文地址:https://www.9cbs.com/read-3797.html

New Post(0)