如何从iPhone中的图像中消除红眼?

时间:2012-11-06 10:25:57

标签: iphone ios ipad image-processing iphone-sdk-3.0

我想删除红眼效果表单照片但是没有任何样本可以帮我处理演示代码或代码片段吗?

感谢。

1 个答案:

答案 0 :(得分:7)

category的{​​{1}}下方使用

UIImage

@interface UIImage (Utitlities)
  -(UIImage*)redEyeCorrection;
@end

用法:下面给出的示例代码

@implementation UIImage (Utitlities)
  -(UIImage*)redEyeCorrection
  {
    CIImage *ciImage = [[CIImage alloc] initWithCGImage:self.CGImage];

    // Get the filters and apply them to the image
    NSArray* filters = [ciImage autoAdjustmentFiltersWithOptions:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:kCIImageAutoAdjustEnhance]];
    for (CIFilter* filter in filters)
    {
      [filter setValue:ciImage forKey:kCIInputImageKey];
      ciImage = filter.outputImage;
    }

    // Create the corrected image
    CIContext* ctx = [CIContext contextWithOptions:nil];
    CGImageRef cgImage = [ctx createCGImage:ciImage fromRect:[ciImage extent]];
    UIImage* final = [UIImage imageWithCGImage:cgImage];
    CGImageRelease(cgImage);
    return final;
  }
@end

参考NYXImagesKit UIImage Enhancing链接