本文介绍了如何从iPhone中的图像中消除红眼?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想删除红眼效果表单照片但是没有任何样本可以帮助我使用演示代码或代码片段吗?
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?
谢谢。
推荐答案
使用以下类别
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;
}
}
参考链接
这篇关于如何从iPhone中的图像中消除红眼?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!