Professional basic knowledge of image (1) color space

RGB is the color space we are most exposed to. An image is represented by three channels, namely red (R), green (G) and blue (B). Different combinations of these three colors can form almost any other color.

1. RGB 

RGB is the color space we are most exposed to. An image is represented by three channels, namely red (R), green (G) and blue (B). Different combinations of these three colors can form almost any other color.

The RGB color space is the most basic, most commonly used, and hardware-oriented color space in image processing, and it is relatively easy to understand.

The RGB color space uses a linear combination of three color components to represent a color. Any color is related to these three components, and these three components are highly correlated, so it is not intuitive to continuously change colors. Adjustment requires changing these three components.

Images acquired in natural environments are easily affected by natural lighting, occlusion, and shadows, that is, they are more sensitive to brightness. The three components of the RGB color space are closely related to brightness, that is, as long as the brightness changes, the three components will change accordingly, and there is no more intuitive way to express it.

  • However, the sensitivity of the human eye to these three color components is different. In monochrome, the human eye is the least sensitive to red and the most sensitive to blue, so the RGB color space is a color space with poor uniformity. If the similarity of colors is directly measured by Euclidean distance, the result will have a large deviation from human vision. For a certain color, it is difficult for us to speculate on the more accurate three-component numerical representation.

Therefore, the RGB color space is suitable for display systems, but not for image processing.

Commonly used color RGB values:

color R G B
black 0 0 0
White 255 255 255
grey 192         192 192
yellow 255 255 0
Purple 0 255 255
brown 128 128 0
Fuchsia 255 0 255

2. HSV

It is closer to people's perception of color than RGB. It is very intuitive to express the hue, vividness and lightness of the color, which is convenient for color comparison.

In the HSV color space, it is easier to track objects of a certain color than BGR, and is often used to segment objects of a specified color.

The way HSV expresses color images consists of three parts:

  • Hue (hue, hue, chroma)       

Chromaticity (Hue)

Use angle measurement, ranging from 0°~360° (counterclockwise), such as 0°/360° for red, 120° for green, and 240° for blue.

  • Saturation (saturation, color purity)
  • Value (brightness)

In GRB, the color is determined by three values. For example, yellow is (255,255,0); in HSV, yellow is determined by only one value, Hue=60.

Half side cross section of HSV cylinder (Hue=60):

In the case of a certain Hue, the saturation is reduced, that is, white is added to the spectral color, and the proportion of the spectral color is also reduced. The saturation is reduced to 0, which means that the proportion of the spectral color is zero, resulting in the entire color Appears white.

When the lightness decreases, black is added to the spectral color, and the proportion of the spectral color is also reduced. When the lightness is reduced to 0, it means that the proportion of the spectral color is zero, causing the entire color to appear black.

HSV is a more intuitive color model for users. We can easily get a single color, that is, specify the color angle H, and let V=S=1, and then get the color we need by adding black and white to it. Increasing black decreases V without changing S, and increasing white decreases S without changing V. 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.

The stretch contrast enhancement of HSV is to normalize the two components of S and V (min-max normalize), and H remains unchanged.

The RGB color space is more industry-oriented, while HSV is more user-oriented. Most people who do image recognition will use the HSV color space, because the HSV color space is more intuitive to express!

When extracting white objects, it is more convenient to use HLS, because there is no white in Hue in HSV, and white needs to be determined by S and V (S=0, V=100). In HLS, white is only determined by the brightness L component. So it is more accurate to use HSL color space when detecting white.

3. HLS

  • hue (hue)
  • saturation
  • lightness

HLS and HSV are similar, so we will introduce them together here. HLS also has three components, hue (hue), saturation (saturation), lightness (brightness).

The difference between HLS and HSV is that the last component is different, HLS is light (brightness), HSV is value (brightness). You can try it out on this  page  .

The L component in HLS is lightness, the lightness is 100, it means white, the lightness is 0, it means black; the V component in HSV is lightness, the lightness is 100, it means spectral color, the lightness is 0, it means black.

Guess you like

Origin blog.csdn.net/weixin_46267139/article/details/131111497