The contrast of the meitu filter and the contrast of the filter

Source: Internet
Author: User

The contrast of the meitu filter and the contrast of the filter

Contrast refers to the measurement of different brightness levels between the brightest white and the darkest black areas in an image, that is, the gray contrast size of an image.

Use GPUImageContrastFilter in GPUImage to implement

Fragment shader

 varying highp vec2 textureCoordinate;  uniform sampler2D inputImageTexture; uniform lowp float contrast;  void main() {     lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);          gl_FragColor = vec4(((textureColor.rgb - vec3(0.5)) * contrast + vec3(0.5)), textureColor.w); }

 

The RGB value of each pixel is-0.5 multiplied by the contrast value and then + 0.5 is used to generate a new Pixel RGB

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

 

 

 

Effect

  

Low Contrast, high contrast

 

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.