Alpha hybrid Formula

Source: Internet
Author: User

Alpha mixing: there are too many articles about the combination of two translucent colors. I am not talking about any new and better algorithms, these alpha-mixing articles are based on a specific practical application: overlays a translucent color on the background color. Openpainter has more general requirements: mixing two translucent colors. That is to say, the original color is transparent.
For this reason, I first tried a lot of experiments with PS, and tried to export the Alpha mixture formula. In fact, some simple experiments and some logical reasoning have successfully found the Alpha hybrid method. Here, for the convenience of calculation, the value range of all color component values is 0 ~ 1.
The first is the calculation of the transparency value. In essence, color is the product of light. If transparency is understood as the light transmittance of glass, everything becomes very simple. For example, an alpha = 0.2 color can be imagined as a colored glass with a light transmittance of 80%. We can see from this glass that 80% of the light passes through, so there is only 20% left in color, that is, the so-called 0.2 Alpha. Now let's make a mix: overlay the colors where Alpha is 0.2 and 0.6. At this time, we had two pieces of glass, one with a light transmittance of 80% and the other with a transmittance of 40%. When a beam passes through a glass with a light transmittance of 80%, the remaining light intensity is 80%. when it passes through a glass with a light transmittance of 40%, the light is further weakened, with only 80% x 40% = 32%. This means that there is 32% transparency, that is, alpha = 0.68.
To sum up the above algorithm, we can conclude that:

The next step is to calculate the color components of each channel based on the existing transparency. In fact, it is easier to use mathematical derivation methods. We already know how to overlay the translucent color on the background color. The calculation method of the RGB color component is as follows:

Then, we can calculate the formula by adding two different translucent colors to the background color. First, stack the first translucent color on the background color, and then stack the second translucent color on the stacked result. Second, fold the two translucent colors first, mix with the background color. That is:

The results of the two mixed methods should be exactly the same.

Sort, get

This is the Alpha hybrid formula in RGB mode. Similar to CMYK.

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.