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