2012-11-06 44 views

回答

7

使用下面categoryUIImage的:

@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 

使用:下面

UIImage *redEyeImage = [UIImage imageNamed:@"redEye.jpg"]; 

if (redEyeImage) { 
    UIImage *newRemovedRedEyeImage = [redEyeImage redEyeCorrection]; 
    if (newRemovedRedEyeImage) { 
     imgView.image = newRemovedRedEyeImage; 
    } 
} 

给出的示例代码参见NYXImagesKit UIImage Enhancing链接

+0

它不适用于删除红眼.. –

+0

请提供一些细节,如在哪个版本或在哪种情况下它不工作??? –

+0

它只增强图像,但不是红眼校正.. –