在OS X上使用核心图像的令人费解的滤镜效果

时间:2015-05-04 15:39:45

标签: macos filter core-image

核心图像内置过滤器中有一个名为“CILineOverlay”的草图过滤器。在示例中,apple显示的结果效果如下:enter image description here

然而,苹果没有显示应该为参数设置什么细节值。

我尝试了许多价值,但我无法得到苹果展示的效果。我的效果看起来像这样: enter image description here

这是我的代码` - (IBAction)lineImg:(NSButton *)sender {

NSString * path=[[NSBundle mainBundle] pathForResource:@"yingBW" ofType:@"png" inDirectory:@"Cresources"];
NSImage * image=[[NSImage alloc] initWithContentsOfFile:path];


NSData * imageData = [image TIFFRepresentation];

CIImage * sourceImage = [CIImage imageWithData:imageData];

CIFilter * lineFilter = [CIFilter filterWithName:@"CILineOverlay"
                                   keysAndValues:kCIInputImageKey,sourceImage,
                         @"inputNRNoiseLevel",self.noiseLevel, //0.07, 0~0.1
                         @"inputNRSharpness",self.sharpness,//0.71 ,0~2
                         @"inputEdgeIntensity",self.edgeIntensity,//1.0 ,0.0~20
                         @"inputThreshold",self.threshold,//0.1 ,0~1
                         @"inputContrast",self.contrast,// 50 ,0.25~200
                         nil];

CIImage * resultimg=[lineFilter valueForKey:kCIOutputImageKey];


NSBitmapImageRep* rep = [[NSBitmapImageRep alloc] initWithCIImage:resultimg];

NSData *pngdata = [rep representationUsingType:NSPNGFileType properties:nil];
self.imgView.image=[[NSImage alloc] initWithData:pngdata];

} `

是否有人可以像苹果一样提供相同的效果?

0 个答案:

没有答案