Step by step filter (1) Basic Color knowledge, step by step filter

Source: Internet
Author: User
Tags color representation emit

Step by step filter (1) Basic Color knowledge, step by step filter

I declare in advance that my goal is to write a filter function by myself, instead of using open source filters or system filters. I think those filters are good but cannot be customized, if your software wants to integrate its own filter function, simply using system filters or third-party filter modules will have no special features and will not stand out from the numerous filter software in China, it is better not to add this function, because no one else is doing well.

 

To use filters, you must first learn from the basics of color and then start from the ground up. Otherwise, you cannot write proper functions.

 

1. The first is the color addition and subtraction theory.

First, people define red (R), Green (G), and blue (B) as the three primary colors of luminous colors. The colors visible to the human eye can all be represented by these three colors, this is the RGB Color Representation commonly used by electronic devices. This theory can be demonstrated in the PS tool. You only need to define three layers. The RGB values of the layers are set to red (, 0, 0) green (0,255, 0), blue (255,), partially overlay the three color layers, and then set the layer blending mode of the three layers to "filter color ", the stack effect is as follows:

 

From the figure, we can see that the color overlapping parts are yellow, green, and pinghong, and the three overlapping color values can be measured by the color Acquisition Tool of PS respectively as yellow (255,255, 0), Green (0,255,255), and magenta (255,). Please see their values. We can see that the color is superimposed in the RGB representation, but it is simply a numerical superposition of the corresponding positions.

Therefore, we have a formula as follows:

 

Red (R 0,255, 0) + Green (G 255,255, 0) = yellow (Y, 0)

Green (G 0,255, 0) + blue (B 255, 0,255,255) = green (C)

Blue (B 255, 255) + red (R, 0, 0) = Magenta (M)

 

The above formula is called the coloring method ..

According to the above theory, color superposition can be calculated by mathematical expressions.

Because the white RGB color is (255,255,255), the following formula can be obtained based on the color numerical superposition principle obtained above:

 

Red (R 0,255,255, 0, 0) + Green (C 255,255,255) = white)

Green (G 0,255, 0) + Magenta (M 255, 255,255,255) = white)

Blue (B 255, 255,255) + yellow (Y 255,255,255, 0) = white)

 

Therefore, the complementary color theory is formed.

 

Red to green

Green complementary colors are red

Blue to yellow

 

Here we need to introduce two concepts:Spontaneous light colorAndReflective light color. As the name suggests, spontaneous light color is the color of an object that emits light on its own, such as various light colors from LED lights. The reflective light color is the color that we can see by reflecting the light of a shining object, for example, a painting.

Color theory sets red, green, and blueSelf-luminous primary colors. Set "green", "Red", and "yellow"Three primary colors of reflected light. The color adding system we mentioned above is based on the three primary color system of red, green, and blue.

The following figure shows the color superposition theory of reflected light.

 

In the reflected light system, the following formula is true:

Red (C 255, 255,255) + yellow (Y, 0) = red (R, 0)

Yellow (Y 255,255, 0) + Green (C 0,255,255) = green (G 0,255, 0)

Blue (C 0,255,255) + Magenta (C 255, 255) = blue (B)

Green () + red + yellow = Black (0, 0)

The above theory is called the fading method.

 

 

 

 

 

 

 

How to get a non-color image?

When R = G = B, the image is a gray image, that is, a non-color image. If you need to process an image into a black-and-white image, you only need to set the R, G, and B of each pixel in the image to (R + G + B)/3 at the same time, this image is converted into a black image and a black image.

 

2. RGB and CMYK color system

RGB colors are mainly used for display, neon lights, and other color devices. They are called self-luminous colors. That is to say, the color system theory can only be applied to the color superposition of self-luminous objects.

CMYK colors represent C (green), M (Magenta or magenta), Y (yellow), and K (black) respectively. CMYK colors are mainly used in printing and painting, and therefore become reflective colors, that is to say, the application of this color system theory can only be seen through the reflection of the object color superposition.

What are the differences and connections between the two color systems?

The colors C (green), M (red), and Y (yellow) appear in the color coloring and fading theory we mentioned above. By the way, it means that the RGB color system can be converted to the CMYK system. We can also see that in the RGB representation method, after the three primary colors are simultaneously superimposed, the color block in the middle is displayed as white, which is a feature of RGB, but in the CMYK color system, after the CMY color is superimposed, it is displayed as black, this is the feature of CMYK color representation. The colors that do not emit light are displayed in black, while those that do not emit light are displayed in white.

 

3. RGB and HSL color Systems

Is another color representation, color (H), saturation (S), brightness (L), the value range of each channel is still 0-255, this is very similar to RGB, however, the values of the same color vary greatly in the HSL representation and RGB representation.

 

The next article describes how to implement simulated functions for some operations in PS.

 

The above are non-professional comments I have obtained based on the summary. Please correct them by professionals,Do not spray. 

Related Article

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.