objective-c - iOS CIFilter对图像进行滤镜处理 为何这么慢
怪我咯
怪我咯 2017-04-17 15:57:16
[iOS讨论组]

我从一个页面跳过去 至少等了3秒 检查踩发现 因为那个页面正在对图像进行滤镜 有什么办法能提高速度

怪我咯
怪我咯

走同样的路,发现不同的人生

全部回复(2)
巴扎黑

GPUImage或许会快一点,以下是我用CIFilter测了一个滤镜处理,用了快2秒。

NSLog(@"start");
CIContext *context = [CIContext contextWithOptions:nil];
CIImage *image = [CIImage imageWithContentsOfURL:[NSURL URLWithString:@"http://127.0.0.1:8000/top1.jpg"]];
CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"];
[filter setValue:image forKey:kCIInputImageKey];
[filter setValue:@10.0f forKey: @"inputRadius"];
CIImage *result = [filter valueForKey:kCIOutputImageKey];
CGImageRef outImage = [context createCGImage: result fromRect:[result extent]];
UIImage * blurImage = [UIImage imageWithCGImage:outImage];

self.backgroundImageView.image=blurImage;

NSLog(@"end");


2015-09-09 16:18:22.703 test[7211:602636] start
2015-09-09 16:18:24.470 test[7211:602636] end
PHP中文网

你可以用OpenGL的Context啊,你不传context默认是CPU的,对高斯模糊这种,CPU弱的时候就很慢了。
点开看OpenGL context

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号