zoukankan      html  css  js  c++  java
  • GPUImage中饱和度调整的实现——GPUImageSaturationFilter

    饱和度saturation,是指色彩的鲜艳程度,也称色彩的纯度。饱和度取决于该色中含色成分和消色成分(灰色)的比例。含色成分越大,饱和度越大;消色成分越大,饱和度越小。纯的颜色都是高度饱和的,如鲜红,鲜绿。混杂上白色,灰色或其他色调的颜色,是不饱和的颜色,如绛紫,粉红,黄褐等。完全不饱和的颜色根本没有色调,如黑白之间的各种灰色。

    注意区分对比度contrast,对比度是指投影图像最亮和最暗之间的区域之间的比率,比值越大,从黑到白的渐变层次就越多,从而色彩表现越丰富。对比度对视觉效果的影响非常关键,一般来说对比度越大,图像越清晰醒目,色彩也越鲜明艳丽;而对比度小,则会让整个画面都灰蒙蒙的。

    核心代码:

     1  varying highp vec2 textureCoordinate;
     2  
     3  uniform sampler2D inputImageTexture;
     4  uniform lowp float saturation;
     5  
     6  // Values from "Graphics Shaders: Theory and Practice" by Bailey and Cunningham
     7  const mediump vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);
     8  
     9  void main()
    10  {
    11     lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
    12     lowp float luminance = dot(textureColor.rgb, luminanceWeighting);
    13     lowp vec3 greyScaleColor = vec3(luminance);
    14     
    15     gl_FragColor = vec4(mix(greyScaleColor, textureColor.rgb, saturation), textureColor.w);
    16      
    17  }

    其中saturation的取值范围是[0,2]

  • 相关阅读:
    HTML5 开发工具收集
    (转载)flash as滤镜效果总结
    线性表

    AS3 库资源 很多非常有用的类库
    设计模式之简单工厂
    strcpy,strncpy,strcmp,strncmp,strcat,strlen..还有啥?
    设计模式学习之前言
    转CString 用法小结
    String类的构造函数,析构函数,赋值函数
  • 原文地址:https://www.cnblogs.com/calence/p/6829529.html
Copyright © 2011-2022 走看看