CITemperatureAndTint用于iOS中的图像 [英] CITemperatureAndTint for image in iOS

查看:130
本文介绍了CITemperatureAndTint用于iOS中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有CITemperatureAndTint的示例代码或示例?我已经阅读了它的文档,但是我需要一些示例来实现它。

Is there any sample code or example for CITemperatureAndTint? I have read its documentation but i need some example to implement it.

推荐答案

CIFilter *yourFilter = [CIFilter filterWithName:@"CITemperatureAndTint"];
[yourFilter setValue:yourInputImage forKey:@"inputImage"];
[yourFilter setValue:[CIVector vectorWithX:6500 Y:500] forKey:@"inputNeutral"]; // Default value: [6500, 0] Identity: [6500, 0]
[yourFilter setValue:[CIVector vectorWithX:1000 Y:630] forKey:@"inputTargetNeutral"]; // Default value: [6500, 0] Identity: [6500, 0]
CIImage *resultImage = [yourFilter valueForKey: @"outputImage"];
UIImage *resultOutputImage = [UIImage imageWithCGImage:[context createCGImage:resultImage fromRect:resultImage.extent]];    

您可以在此Wikipedia链接

参考

CITemperatureAndTint具有三个输入参数:图像,中性和TargetNeutral。 Neutral和TargetNeutral均为2D CIVector类型,在这两种情况下,请注意,第一维是温度,第二维是色调。 CITemperatureAndTint过滤器的基本作用是计算一个矩阵,该矩阵将RGB值从中性定义的源白点(srcTemperature,srcTint)调整到由目标中性定义的目标白点(dstTemperature,dstTint),然后将此矩阵应用于输入图像(使用CIColorMatrix过滤器)。如果中性和目标中性具有相同的值,则应用此滤镜后图像将不会改变。我不知道有关iPhoto的实现细节,但是我认为两个滑动条给出了要添加到源图像中的Temperature和Tint更改(即源和目标Temperature和Tint值之间的差异)。

CITemperatureAndTint has three input parameters: Image, Neutral and TargetNeutral. Neutral and TargetNeutral are of 2D CIVector type, and in both of them, note that the first dimension refers to Temperature and the second dimension refers to Tint. What the CITemperatureAndTint filter basically does is computing a matrix that adapts RGB values from the source white point defined by Neutral (srcTemperature, srcTint) to the target white point defined by TargetNeutral (dstTemperature, dstTint), and then applying this matrix on the input image (using the CIColorMatrix filter). If Neutral and TargetNeutral are of the same values, then the image will not change after applying this filter. I don't know the implementation details about iPhoto, but I think the two slide bars give the Temperature and Tint changes (i.e. differences between source and target Temperature and Tint values already) that you want to add to the source image.

这篇关于CITemperatureAndTint用于iOS中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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