2012-11-06 23 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

它只增強圖像,但不是紅眼校正.. –