我正在尝试使用CIFilter和GPUImage滤镜对图像应用各种效果(亮度、对比度、饱和度等),但我遇到了困难,需要像下面展示的那样进行增强:
增强前滤镜
增强后滤镜
我尝试的CIFilter代码:
![Before Enhancement filter:](https://istack.dev59.com/sYpC5.webp)
![After Enhancement filter](https://istack.dev59.com/bugqy.webp)
NSDictionary *options = @{ CIDetectorImageOrientation :
[[resultImage properties] valueForKey:kCGImagePropertyOrientation] };
NSArray *adjustments = [resultImage autoAdjustmentFiltersWithOptions:options];
for (CIFilter *filter in adjustments) {
[filter setValue:resultImage forKey:kCIInputImageKey];
resultImage = filter.outputImage;
}
GPUImage滤镜:
UIImage *inputImage = [UIImage imageNamed:@"Msource.png"];
GPUImageAdaptiveThresholdFilter *stillImageFilter = [[GPUImageAdaptiveThresholdFilter alloc] init];
stillImageFilter.blurRadiusInPixels = 10.0;// adjust this to tweak the blur radius of the filter, defaults to 4.0
UIImage *filteredImage = [stillImageFilter imageByFilteringImage:inputImage];