我正在使用CI过滤器,但在降噪方面遇到了麻烦。基本上我从这里得到一张空白图片。
我确信我错过了一些简单的事情。
这是我的代码:
CGImageRef imageRef = [self.iv.image CGImage];
CIContext *context = [CIContext contextWithOptions:nil]; // 1
CIImage *ciImage = [CIImage imageWithCGImage:imageRef]; // 2
CIFilter *filter = [CIFilter filterWithName:@"CINoiseReduction" ];
[filter setDefaults];
[filter setValue:ciImage forKey:@"inputImage"]; // 3
CIImage *ciResult = [filter valueForKey:kCIOutputImageKey]; // 4
CGImageRef cgImage = [context createCGImage:ciResult fromRect:[ciResult extent]];
UIImage *img = [UIImage imageWithCGImage:cgImage];
self.iv.image = img;
答案 0 :(得分:2)
Aaaaaa ...这是因为iOS上没有这个过滤器,所以行:
CIFilter *filter = [CIFilter filterWithName:@"CINoiseReduction" ];
...返回null。因为,你知道,这可能是你真正想要的东西:)
Here's the list of CI filters, along with notes on availability