Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 核心图像过滤器应用_Iphone_Objective C_Ios_Ios5_Core Image - Fatal编程技术网

Iphone 核心图像过滤器应用

Iphone 核心图像过滤器应用,iphone,objective-c,ios,ios5,core-image,Iphone,Objective C,Ios,Ios5,Core Image,如何应用我应用的CIToneCurve过滤器 filter= [CIFilter filterWithName:@"CIScreenBlendMode"]; [filter setValue:beginImage1 forKey:kCIInputImageKey]; [filter setValue:beginImage forKey:@"inputBackgroundImage"]; 使用这种方法的不同过滤器现在我想应用CIToneCurve如何应用这些参数 inpu

如何应用我应用的CIToneCurve过滤器

  filter= [CIFilter filterWithName:@"CIScreenBlendMode"];
     [filter setValue:beginImage1 forKey:kCIInputImageKey];
     [filter setValue:beginImage forKey:@"inputBackgroundImage"];
使用这种方法的不同过滤器现在我想应用CIToneCurve如何应用这些参数

inputImage
显示名称为Image的CIImage类

inputPoint0
一个CIVector类,其属性类型为CIAttributeTypeOffset,显示名称为点1。默认值:[0,0]标识:[0,0]

inputPoint1
一个CIVector类,其属性类型为CIAttributeTypeOffset,显示名称为Point 2l。默认值:[0.25,0.25]标识:[0.25,0.25]

inputPoint2
一个CIVector类,其属性类型为CIAttributeTypeOffset,显示名称为Point 3l。默认值:[0.5,0.5]标识:[0.5,0.5]

inputPoint3
一个CIVector类,其属性类型为CIAttributeTypeOffset,显示名称为点4。默认值:[0.75,0.75]标识:[0.75,0.75]

inputPoint4
一个CIVector类,其属性类型为CIAttributeTypeOffset,显示名称为Point 5。默认值:[1,1]标识:[1,1]


我写了这些,但我的应用程序崩溃了,没有给出任何错误

每个过滤器都接受不同类型的参数,但一旦你习惯了它们,就相当容易了。 您没有发布您将遇到的错误,但这对我很有用:

- (void)doCIToneCurveFilter
{
    // Set an appropriate image. A bit dark so we see the results clearer
    // This image is being taken from http://photo.tutsplus.com/tutorials/post-processing/adobe-camera-raw-for-beginners-tone-curve/
    imageView.image = [UIImage imageNamed:@"turtles"];
    imageView.frame = CGRectMake(0, 0, imageView.image.size.width*0.7, imageView.image.size.height*0.7); // shrank this a bit 2 images fit on screen

    // Make the input image recipe
    CIImage *inputImage = [CIImage imageWithCGImage:imageView.image.CGImage];

    // Make tone filter filter
    // See mentioned link for visual reference
    CIFilter *toneCurveFilter = [CIFilter filterWithName:@"CIToneCurve"];
    [toneCurveFilter setDefaults];
    [toneCurveFilter setValue:inputImage forKey:kCIInputImageKey];
    [toneCurveFilter setValue:[CIVector vectorWithX:0.0  Y:0.0] forKey:@"inputPoint0"]; // default
    [toneCurveFilter setValue:[CIVector vectorWithX:0.27 Y:0.26] forKey:@"inputPoint1"]; 
    [toneCurveFilter setValue:[CIVector vectorWithX:0.5  Y:0.80] forKey:@"inputPoint2"];
    [toneCurveFilter setValue:[CIVector vectorWithX:0.7  Y:1.0] forKey:@"inputPoint3"];
    [toneCurveFilter setValue:[CIVector vectorWithX:1.0  Y:1.0] forKey:@"inputPoint4"]; // default

    // Get the output image recipe
    CIImage *outputImage = [toneCurveFilter outputImage];

    // Create the context and instruct CoreImage to draw the output image recipe into a CGImage
    CIContext *context = [CIContext contextWithOptions:nil];
    CGImageRef cgimg = [context createCGImage:outputImage fromRect:[outputImage extent]];

    // Draw the image in screen
    UIImageView *imageView2 = [[UIImageView alloc] initWithImage:[UIImage imageWithCGImage:cgimg]];
    CGRect f = imageView2.frame;
    f.origin.y = CGRectGetMaxY(imageView.frame);
    f.size.width = imageView.frame.size.width;
    f.size.height = imageView.frame.size.height;
    imageView2.frame = f;

    [self.view addSubview:imageView2];
}
这就是结果:

我使用的图像是从那里拍摄的,在这个例子中,你可以找到我近似的曲线:

PS:如果你想知道为什么我的结果图像看起来与它的结果不完全相同,那是因为我的图像是部分图像,颜色分布不同。相似但不完全相同。因此,应用完全相同的曲线不会得到完全相同的结果

我希望有帮助