The saturation of meitu xiuxiu filter and the filter saturation of xiuxiu Filter
Saturation refers to the brightness of the color, also known as the purity of the color. The saturation is determined by the ratio of the color-containing component and the color-removing component (Gray) in the color. The greater the color composition, the greater the saturation. The greater the color composition, the smaller the saturation. Pure colors are highly saturated, such as bright red and fresh green. Mixed with white, gray, or other colors, is not saturated color, such as purple, pink, Yellow Brown. Completely unsaturated colors have no tones at all, such as various gray colors between black and white.
Use the GPUImageSaturationFilter class in GPUImage to adjust the image saturation.
Segment coloring
varying highp vec2 textureCoordinate; uniform sampler2D inputImageTexture; uniform lowp float saturation; // Values from "Graphics Shaders: Theory and Practice" by Bailey and Cunningham const mediump vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721); void main() { lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate); lowp float luminance = dot(textureColor.rgb, luminanceWeighting); lowp vec3 greyScaleColor = vec3(luminance); gl_FragColor = vec4(mix(greyScaleColor, textureColor.rgb, saturation), textureColor.w); }
Specific Application
+ (UIImage *)changeValueForSaturationFilter:(float)value image:(UIImage *)image;{ GPUImageSaturationFilter *filter = [[GPUImageSaturationFilter alloc] init]; filter.saturation = value; [filter forceProcessingAtSize:image.size]; GPUImagePicture *pic = [[GPUImagePicture alloc] initWithImage:image]; [pic addTarget:filter]; [pic processImage]; [filter useNextFrameForImageCapture]; return [filter imageFromCurrentFramebuffer];}
Effect
High saturation and low saturation [black and white]