Sharpening of GPUImage filter and gpuimage Filter
The sharpening tool can be used to quickly focus on blurred edges, improve the clarity or focal length of a specific part of the image, and make the color of a specific area of the image clearer. When applying the sharpen tool, if you select the "sample for all layers" check box in the options bar, you can sharpen the images in all visible layers. But it must be moderate. Sharpening is not omnipotent, and it is easy to make things unreal.
Use the GPUImageSharpenFilter class in GPUImage to sharpen the image.
Segment coloring
precision highp float; varying highp vec2 textureCoordinate; varying highp vec2 leftTextureCoordinate; varying highp vec2 rightTextureCoordinate; varying highp vec2 topTextureCoordinate; varying highp vec2 bottomTextureCoordinate; varying highp float centerMultiplier; varying highp float edgeMultiplier; uniform sampler2D inputImageTexture; void main() { mediump vec3 textureColor = texture2D(inputImageTexture, textureCoordinate).rgb; mediump vec3 leftTextureColor = texture2D(inputImageTexture, leftTextureCoordinate).rgb; mediump vec3 rightTextureColor = texture2D(inputImageTexture, rightTextureCoordinate).rgb; mediump vec3 topTextureColor = texture2D(inputImageTexture, topTextureCoordinate).rgb; mediump vec3 bottomTextureColor = texture2D(inputImageTexture, bottomTextureCoordinate).rgb; gl_FragColor = vec4((textureColor * centerMultiplier - (leftTextureColor * edgeMultiplier + rightTextureColor * edgeMultiplier + topTextureColor * edgeMultiplier + bottomTextureColor * edgeMultiplier)), texture2D(inputImageTexture, bottomTextureCoordinate).w); }
Specific Application
+ (UIImage *)changeValueForSharpenilter:(float)value image:(UIImage *)image{ GPUImageSharpenFilter *filter = [[GPUImageSharpenFilter alloc] init]; filter.sharpness = value; [filter forceProcessingAtSize:image.size]; GPUImagePicture *pic = [[GPUImagePicture alloc] initWithImage:image]; [pic addTarget:filter]; [pic processImage]; [filter useNextFrameForImageCapture]; return [filter imageFromCurrentFramebuffer];}
Effect