博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
GPUImage滤镜之锐化
阅读量:4707 次
发布时间:2019-06-10

本文共 1780 字,大约阅读时间需要 5 分钟。

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

  在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];}

 

  效果

  

 

转载于:https://www.cnblogs.com/salam/p/5120032.html

你可能感兴趣的文章
phpstorm 2018.1.6 和谐版安装方法
查看>>
NFS应用场景及环境搭建
查看>>
让xamarin的Entry绑定时,支持Nullable类型
查看>>
kivy学习三:打包成window可执行文件
查看>>
兄弟连PHP培训教你提升效率的20个要点
查看>>
【快报】基于K2 BPM的新一代协同办公门户实践交流会
查看>>
关于MySQL的行转列的简单应用
查看>>
Queue 队列的用法
查看>>
CDM常用命令
查看>>
游戏开发中常用的设计模式
查看>>
Linux 中/etc/profile、~/.bash_profile 环境变量配置及执行过程
查看>>
JAVA:图形之利用FontMetrics类居中
查看>>
使用rsync同步目录
查看>>
[读码时间] for循环遍历设置所有DIV块元素背景色为红色
查看>>
你会用AngularJS,但你会写AngularJS文档么?
查看>>
ORACLE清除某一字段重复的数据(选取重复数据中另一个字段时期最大值)
查看>>
网页调用迅雷下载文件
查看>>
Python 调用 Shell命令
查看>>
POJ 1159 Palindrome(最长公共子序列)
查看>>
ORM多表操作之多对多查询
查看>>