[Serialization] [original masterpiece of heijin power community] "LCD driver and GUI basics tutorial"-Chapter 2 color model (III)

Source: Internet
Author: User
Statement: This article is an original work, and the copyright belongs to the power of black gold. Community (Http://www.heijin.org) All, If You Need To reprint, please indicate the source http://www.cnblogs.com/kingst/





Http://www.heijin.org



Http://www.oshcn.com






Chapter 2Color Model



1 Introduction



We all know that the light we call is a part of the electromagnetic wave, which is usually called the visible spectrum. The color model mentioned in this chapter is based on the visible spectrum. The color model can also be called the color space. It is a method for people to parse colors in reality. Different color models are developed from different application fields. Common color models include RGB, CMYK, HSB, YUV, and lab. This chapter focuses on several common color models.



Binary RGB Color Model



1. Introduction to the RGB model



As the name suggests, RGB is the abbreviation of red, green, and blue color channels. The RGB color model adopts the addition mixed color method. The addition mixed color method means various R, G, and B colors. Different components are superimposed to form a colorful color. 2-1.






The most widely used computer is the RGB model. Our monitor is actually made up of dense RGB color blocks, but it is too small to be identified by the naked eye.



As we all know, computers use discrete digital signals to describe data, and the RGB model is no exception. The more discrete points of each color channel, the finer the color description, but this will also bring about a large amount of data. In actual application, the number of colors and the amount of data are weighed, there are several fixed RGB color model formats, including rgb444, rgb555, rgb565, rgb18, rgb24, and rgb32.



2. rgb444 Color Model



Rgb444 is mostly used for embedded system display. The R, G, and B color channels are represented by four bits, 12 bits in total, and 4096 colors can be produced. You may remember that many early mobile phones were 4096 colors. Although it seems that the effect is very poor, it was already very expensive. Figure 2-2 shows the rgb444 color sequence. On the way, we can see that the hops of each color are discontinuous. This is the result of digital quantization. Represent a color with four digits, that is, there are 16 levels of color. You can count them if you are interested.






3. rgb555 Color Model



Rgb555 uses five bits to represent the three color channels of R, G, and B respectively, so that it can reach 32768 colors, namely 32 K colors. In the computer, two bytes are used to represent the color format, indicating the method 2-3, and the highest bit X indicates that the color is not used. This format is currently not used much.






Figure 2-4 shows the rgb555 color level chart. You can see that the level of refinement is better than rgb44, but the human eyes can still tell the steps.



4. rgb565 Color Model



Rgb565 is similar to rgb555. The only difference is that it uses six bits to represent the G color channel, so that it can reach 65536 colors, that is, 64 K colors. This representation method is widely used. We can click the 16bit color in the display attribute of the Windows operating system. This storage format is also used for the evtft series LCD modules and VGA display drivers.









Figure 2-6 shows the level of rgb565, which is more delicate than R and B on both sides, this is the reason that 6 bits are used to represent the G color channel and 5 is used to represent the other two color channels.



From the figure 2-5, we can see that, in the two bytes occupied by rgb565, the R component is in the five-digit height, the G component is in the six-digit middle, and the B component is in the five-digit lower. According to this feature, in the C language, we can use the macro definition below to obtain the values of R, G, and B from the rgb565 data.






Similarly, the following macro definition can be used to synthesize rgb565 data with the values of R, G, and B.






Commonly used rgb565 color definitions.






5. rgb24 and rgb32 color models



Rgb24 uses 24 bits (three bytes) to represent the RGB color channel. Each uses one byte. Most of the data on the computer is represented by this parameter. Each color channel has eight bits (256 levels; the human eye can no longer tell the changes in the color order of each color channel.



Rgb32 uses 24 bits (three bytes) to represent the RGB color channel. Each uses one byte, but uses the last byte to represent the alpha channel. This is the so-called true color 32-bit color. In general, Alpha indicates pixel transparency, 0 indicates full transparency, and 255 indicates opacity. This is a linear change in transparency.



Binary CMYK color model



Like the RGB color model, the CMYK color model is named by letters in the color. Cyan indicates cyan, Magenta indicates the product red, yellow indicates yellow, and black indicates black, in this way, the CMYK name is obtained. Black gets the last letter, because B is easy to misunderstand as blue.






Different from RGB, CMYK is a mixture of reduced colors, which means that cmy elements can obtain the required color by absorbing different spectra. The color reduction model is hard to understand. The following is an example to deepen our understanding.



As we all know, the RGB color model is an active luminous body (think about our display, we can still see the picture displayed in the dark room). Since it is an active luminous body, so for our eyes, an additional light source is equivalent to an additional addition element. In the CMYK color model, we can understand it as a passive luminous body, that is, a light source that reflects other luminous bodies, for example, all kinds of colorful dyes; in the dark room, no matter what color of paint, for us, is a Dark One (they will not take the initiative to shine, all rely on the reflection of other light sources to prove their own existence ). For another example, we can see the yellow dye. Let's take a look at it in two steps: the first step is to apply the white spectrum to the yellow dye, the second step is that the yellow dye absorbs the blue spectrum, so in our eyes, it is yellow. The above paragraph can be expressed using the following formula (if you cannot understand it, you can see Figure 2-1 ):



Because: Red + green + Blue = white



So: white-Blue = red + Green = yellow



With this example, we can easily understand the color model in Figure 2-7 CMYK. In a word, the RGB color model and the CMYK color model are established based on the principle of active light and passive light respectively. It is not hard to come up with the principle that CMYK uses passive light, so this color model is mainly used in printing, dye mixing and other industries. In fact, the fading model is also an addition, but for our eyes, each addition of a cmy element will absorb one more spectral. Therefore, it is called a subtraction hybrid.



Theoretically, cmy three dyes are mixed to absorb all visible spectra, and the mixture is black (that is, non-reflected visible spectra). However, in the actual process, cmy three dyes are mixed, what we get is a dark brown color (we can't always make the ideal raw material), so we need to add a black dye in actual application; that is why we don't need the cmy model, the reason for using CMYK.



HSB Color Model



Whether it's in the sunny suburbs or in the dark evening, under the beautiful neon lights or the dazzling fluorescent lights, human eyes can always skillfully identify a person or an item that they are familiar with. If an RGB color model is used for parsing, their values are absolutely different under the above conditions. So on this basis, we have established a color model that is close to the human senses.



The HSB color model is a color model based on human sensory characteristics. In general, our eyes do not measure the characteristics of objects based on the ratio of RGB primary colors, but are identified by parameters such as the color type, saturation, and brightness. HSB is also called the HSV color model.



The HSB color model divides colors into three parameters: hue, saturation, and brightness (brightness or value). The HSB color model refers to different color channels ~ The phase value of  °. For example, red and green are different colors. saturation indicates the color depth. brightness indicates the color intensity. It indicates the ratio of the reflected light of the object to the absorbed optical fiber.






Because of the features of the HSB (HSV) model, it is often used in image processing and machine vision systems.



Four YUV color model



The YUV color model has a funny process. He is a color model used to ensure compatibility with black and white televisions when a color TV is generated. When a color TV is generated, it was originally intended to use an RGB color model to transmit data, but this will make it unable to be compatible with black and white TVs. The method is always more difficult, and the YUV color model is generated at this time. Y indicates the brightness, and U and V indicate the color and concentration. In this way, we can send YUV video streams through a video channel, while the black and white TV only receives the Y value for compatibility purposes.



The YUV color model is usually used for Video Transmission and image compression. Human eyes are more sensitive to brightness than to color. Therefore, to reduce the bandwidth, the UV ratio of the color component is usually reduced during video transmission, to reduce the bandwidth. The formats of yuv4: 4: 4, yuv4: 2: 2, yuv4: 1: 1, and so on appear. If you are interested in video processing, you can study it in depth. The following describes the Conversion Relationship Between the YUV color model and the RGB color model. Commonly used video decoding chips all contain the hardware implementation of the Conversion Relationship.






The above formula includes floating-point operations. In actual use, if the microprocessor does not contain floating-point units, there is also a formula that does not contain floating-point operations. You can refer to the relevant information.



Summary



Color is the basic element of the GUI, and it is also a learning that we can touch every moment. We spent a chapter to discuss the problem of color models. It is not enough to lay the foundation. This chapter focuses on understanding and understanding the RGB color model. You only need to understand other color models.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.