IOS:AutoAdjustRedEye不工作

时间:2017-07-24 05:41:40

标签: ios objective-c cifilter

Before Applying filter Image

After applying Red Eye filter, get bad output image

输出图像每次都不同。 这是我的红眼校正滤镜的代码

    UIImage *img = self.imageInput;
    CIImage *image = [[CIImage alloc]initWithImage:img];
    NSLog(@"after ciimage: %@", kCIImageAutoAdjustEnhance);
    NSDictionary *options = [NSDictionary dictionaryWithObject:@"NO" forKey:kCIImageAutoAdjustEnhance];
    NSLog(@"options: %@", options);
    NSArray *adjustments = [image autoAdjustmentFiltersWithOptions:options];
    NSLog(@"adjustments: %@  ", adjustments);

    for (CIFilter * filter in adjustments)
    {
        [filter setValue:image forKey:kCIInputImageKey];
        image = filter.outputImage;
    }
    CIContext *context = [CIContext contextWithOptions:nil];

    CGImageRef cgImage = [context createCGImage:image fromRect:image.extent];
    UIImage *enhancedImage = [[UIImage alloc] initWithCGImage:cgImage];
    CGImageRelease(cgImage);
    self.imageViewSource.image = enhancedImage;

0 个答案:

没有答案