如何在iOS中应用冷色调和暖色调CIFilter? [英] How to apply Cool and warm tone CIFilter in iOS?

查看:285
本文介绍了如何在iOS中应用冷色调和暖色调CIFilter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Swift iOS 视频应用程序 c>。我在哪里使用 AVPlayer 播放视频并设置 CIFilters 视频上使用 AVVideoComposition 。我必须在视频上应用冷暖色调滤镜效果(请参见下图)。







有人可以工作吗? d就一样吗?请建议我。

解决方案

感谢@Frank Schlegel将我定向到 CITemperatureAndTint 使用 inputNeutral inputTargetNeutral 进行过滤。请参阅下面的核心图像滤镜参数以获取暖色调和冷色调效果:

  filter = CIFilter(name: CITemperatureAndTint) ! 

//冷

  filter.setValue(CIVector(x:16000,y:1000),forKey: inputNeutral)
filter.setValue(CIVector(x:1000,y:500),forKey: inputTargetNeutral )

// warm

  filter.setValue(CIVector(x:6500,y:500),forKey: inputNeutral)
filter.setValue(CIVector(x:1000,y:630),forKey: inputTargetNeutral)


I am working on Video based Application in Swift iOS. Where I am using AVPlayer to play the Video and setting CIFilters on Video using AVVideoComposition. I have to apply Cool and warm tone filter effects on my Videos (please see the below images).

I have tried all the Core Image Filters mentioned in below Apple doc, but none of them looks like Cool and warm tone filter effect.

https://developer.apple.com/library/archive/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html

Can anyone have worked on the same? Please suggest me.

解决方案

Thanks @Frank Schlegel for direct me to CITemperatureAndTint Filter with inputNeutral and inputTargetNeutral. Please see the below Core Image Filter Parameter to get Warm and Cold tone effect :

filter = CIFilter(name: "CITemperatureAndTint")!

//cold

filter.setValue(CIVector(x: 16000, y: 1000), forKey: "inputNeutral")
filter.setValue(CIVector(x: 1000, y: 500), forKey: "inputTargetNeutral")

//warm

filter.setValue(CIVector(x: 6500, y: 500), forKey: "inputNeutral")
filter.setValue(CIVector(x: 1000, y: 630), forKey: "inputTargetNeutral")

这篇关于如何在iOS中应用冷色调和暖色调CIFilter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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