Principle and realization of common shader (i.) grayscale

Source: Internet
Author: User

Gray image is a special color image with the same three components of R, G and B. So grayscale is the process of calculating the gray value, here only the most commonly used weighted average method.

The color image of the YUV space, the physical meaning of its Y component is the luminance of the pixel, which reflects the brightness level, so it can be based on the variation relationship between RGB and YUV color space to establish the corresponding three color components of brightness Y and R, G and B: y=0.3r+0.59g+0.11b, The grayscale value of the image is expressed with this luminance value.

Fragment Shader
Assume that the output value previously computed is color
float grayvalue= Dot (Color.rgb, VEC3 (0.30.590.11 1.0);

Principle and realization of common shader (i.) grayscale

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.