GPUImage滤镜之锐化

  应用锐化工具可以快速聚焦模糊边缘,提高图像中某一部位的清晰度或者焦距程度,使图像特定区域的色彩更加鲜明。 在应用锐化工具时,若勾选器选项栏中的“对所有图层取样”复选框,则可对所有可见图层中的图像进行锐化。但一定要适度。锐化不是万能的,很容易使东西不真实。

  在GPUImage中使用GPUImageSharpenFilter类来实现图像的锐化效果

  片段着色

 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);
 }

  具体应用

  

+ (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];
}

  效果

  

时间: 2024-08-03 15:31:17

GPUImage滤镜之锐化的相关文章

GPUImage 滤镜头文件

#import "GLProgram.h" // Base classes #import "GPUImageOpenGLESContext.h" #import "GPUImageOutput.h" #import "GPUImageView.h" #import "GPUImageVideoCamera.h" #import "GPUImageStillCamera.h" #impo

PS 图像滤镜— — USM 锐化

这个算法的原理很简单,就是先用高斯模糊获取图像的低频信息,然后用原图减去高斯模糊之后的图,得到图像的高频信息,再将原图与高频信息融合,进一步增强原图的高频信息,看起来,图像的边缘显得特别的sharp. clc; clear all; close all; addpath('E:\Visual Effects\PS Algorithm'); Image=imread('4.jpg'); Image=double(Image); Image1=Image; Half_size=3; F_size=2

基于GPUImage的多滤镜rtmp直播推流

之前做过开源videocore的推流改进:1)加入了美颜滤镜; 2) 加入了librtmp替换原来过于简单的rtmpclient: 后来听朋友说,在videocore上面进行opengl修改,加入新的滤镜比较麻烦,IOS的滤镜最好的要算GPUImage了. 自己就决定将多滤镜开源GPUImage来实现rtmp的直播推流: 实现的方案: 1,GPUImageMovieWriter进行rgba视频数据的输出. 通过重写GPUImageMovieWriter,实现一个代理协议pixelBufferde

FFMpeg ver 20160219-git-98a0053 滤镜中英文对照 2016.02.21 by 1CM

FFMpeg ver 20160219-git-98a0053 滤镜中英文对照 2016.02.21 by 1CM T.. = Timeline support 支持时间轴 .S. = Slice threading 分段线程 ..C = Command support 支持命令传送 A = Audio input/output 音频 输入/输出 V = Video input/output 视频 输入/输出 N = Dynamic number and/or type of input/out

FFMpeg 滤镜中英文对照

FFMpeg ver 20160213-git-588e2e3 滤镜中英文对照 2016.02.17 by 1CM T.. = Timeline support 支持时间轴 .S. = Slice threading 分段线程 ..C = Command support 支持命令传送 A = Audio input/output 音频 输入/输出 V = Video input/output 视频 输入/输出 N = Dynamic number and/or type of input/out

2015最新iOS学习线路图

iOS是由苹果公司开发的移动操作系统,以xcode为主要开发工具,具有简单易用的界面.令人惊叹的功能,以及超强的稳定性,已经成为iPhone.iPad 和iPod touch 的强大基础:iOS 内置的众多技术和功能让 Apple设备始终保持着遥遥领先的地位. iOS学习路线:http://www.mobiletrain.org/page/ios.html 课程分  类 课程模块 模块介绍 课程内容 Part1C语言 C语言和Objective-C语言 C语言 Mac系统及常用工具.进制:C数据

Android项目用到的一些开源项目

大家空闲的时候可以学习下,一些项目还是经常能用到的. 1.      对图片的剪裁cropimage-master http://stackoverflow.com/questions/18013406/is-com-android-camera-action-crop-not-available-for-android-jelly-bean-4-3 2.      ImageLoader  异步加载更加流畅,可以显示大量图片,在拖动ListView的时候不会出现卡的现象 https://git

iOS常用第三方

名称 作用 说明 AFNetworking 基于HTTP协议联网   SDWebImage 图片缓存和异步加载   YYWebImage 图片缓存和异步加载   Ono XML解析   RaptureXML XML解析   KissXML XML解析   YYModel JSON-模型对象转换(非侵入性) 国内90后程序员郭燿源神作 MJExtesion JSON-模型对象转换(非侵入性)   JSONModel JSON-模型对象转换(侵入性)   FMDB SQLite数据库操作   pop

开源分享

1.1 UIImageCagegory图片处理 1.2 UIImageCagegoryGif动画图片处理 1.3 GIF动画 1.4 Base64编解码 1.5 科大讯飞语音识别 1.6 mp3/mp4播放 1.7 Reachability使用 1.8 AMR音频转码 1.9 JsonKit使用 1.10 MBProgressHUD 1.11 RTLabel 1.12 OC方便框架 1.13 OpenURL打电话-发短信-上网-邮件 1.14 群发短信API接口 1.15 OHAttribute