문제

I want to remove red eye effect form photo but not get any sample can any one help me with working demo code or code snippet?

Thanks.

도움이 되었습니까?

해결책

Use below category of 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

Usage: Sample code given below

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

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

Refer NYXImagesKit UIImage Enhancing link

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top