什么是最好的核心图像过滤器,以产生黑白效果? [英] What is the best Core Image filter to produce black and white effects?

查看:226
本文介绍了什么是最好的核心图像过滤器,以产生黑白效果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Core Image并想对所选图片产生黑白效果。

I am using Core Image and would like to produce a black and white effect on the chosen image.

理想情况下,我想要访问Photoshop上可用的相同类型的选项,例如Reds,Cyan,Greens,Blues和Magenta。目标是创建不同类型的黑白效果。

Ideally I would like to have access to the same sort of options that are available on Photoshop i.e. Reds, Cyan, Greens, Blues and Magenta. The goal being to create different types of the black and white effect.

有谁知道什么过滤器最好操纵这些选项?如果没有人知道使用其他过滤器创建黑白效果的好方法?

Does anyone know what filter would be best to manipulate these sort of options? If not does anyone know of a good approach to creating the black and white effect using other filters?

感谢

Oliver

推荐答案

- (UIImage *)imageBlackAndWhite
{
    CIImage *beginImage = [CIImage imageWithCGImage:self.CGImage];

    CIImage *blackAndWhite = [CIFilter filterWithName:@"CIColorControls" keysAndValues:kCIInputImageKey, beginImage, @"inputBrightness", [NSNumber numberWithFloat:0.0], @"inputContrast", [NSNumber numberWithFloat:1.1], @"inputSaturation", [NSNumber numberWithFloat:0.0], nil].outputImage;
    CIImage *output = [CIFilter filterWithName:@"CIExposureAdjust" keysAndValues:kCIInputImageKey, blackAndWhite, @"inputEV", [NSNumber numberWithFloat:0.7], nil].outputImage; 

    CIContext *context = [CIContext contextWithOptions:nil];
    CGImageRef cgiimage = [context createCGImage:output fromRect:output.extent];
    //UIImage *newImage = [UIImage imageWithCGImage:cgiimage];
    UIImage *newImage = [UIImage imageWithCGImage:cgiimage scale:image.scale orientation:image.imageOrientation];
    CGImageRelease(cgiimage);

    return newImage;
}

更新: > iOS6 有 CIColorMonochrome 过滤器,但我玩它,发现它不如我的好。

Upd.: For iOS6 there is CIColorMonochrome filter, but I played with it and found it not so good as mine.

这篇关于什么是最好的核心图像过滤器,以产生黑白效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆