Natural saturation of GPUImage filter and saturation of gpuimage Filter

Source: Internet
Author: User

Natural saturation of GPUImage filter and saturation of gpuimage Filter

Natural saturation is the overall brightness of the image, and saturation is the brightness of the image color.

The "saturation" option works the same as the "saturation" option in the "hue/saturation" command to increase the "saturation" of the entire screen, but if it is adjusted to a higher value, the image will produce excessive color saturation, resulting in image distortion.

Use GPUImageVibranceFilter in GPUImage to adjust the natural saturation of the image.

Segment coloring

    varying highp vec2 textureCoordinate;     uniform sampler2D inputImageTexture;    uniform lowp float vibrance;     void main() {        lowp vec4 color = texture2D(inputImageTexture, textureCoordinate);        lowp float average = (color.r + color.g + color.b) / 3.0;        lowp float mx = max(color.r, max(color.g, color.b));        lowp float amt = (mx - average) * (-vibrance * 3.0);        color.rgb = mix(color.rgb, vec3(mx), amt);        gl_FragColor = color;    }

 

Specific Application

  

+ (UIImage *)changeValueForVibranceFilter:(float)value image:(UIImage *)image{    GPUImageVibranceFilter *filter = [[GPUImageVibranceFilter alloc] init];    filter.vibrance = value;    [filter forceProcessingAtSize:image.size];    GPUImagePicture *pic = [[GPUImagePicture alloc] initWithImage:image];    [pic addTarget:filter];        [pic processImage];    [filter useNextFrameForImageCapture];    return [filter imageFromCurrentFramebuffer];}

 

 

Effect

  

  

 

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.