How to apply Cool and warm tone CIFilter in iOS?
Asked Answered
D

2

-1

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).

enter image description here

enter image description here

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.

Downhaul answered 15/3, 2019 at 6:47 Comment(0)
D
5

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")
Downhaul answered 15/3, 2019 at 11:56 Comment(0)
U
2

It seems like the CITemperatureAndTint filter is what you are looking for. I frankly don't know exactly how the parameters work, but maybe you can check out this or this related question.

Unrivaled answered 15/3, 2019 at 7:40 Comment(8)
Thanks @Frank Schlegel for your response, I tried using CITemperatureAndTint filter but no difference in preview. Looks similar to original video :(Downhaul
Did you play around with the inputNeutral and inputTargetNeutral parameters?Unrivaled
No I don't. Can you help me on the same?Downhaul
As I understood it, inputNeutral defines the color temperate and tint of the reference point, and inputTargetNeutral the same for the target point. So maybe pick some reference point in the middle (or keep the default of 6500K) and move the taget to warmer or colder colors (like 1000K).Unrivaled
Maybe try this for a start: [filter setValue:[CIVector vectorWithX:1000 Y:0] forKey:@"inputTargetNeutral"];Unrivaled
Thanks a lot @Frank Schlegel for directing me to CITemperatureAndTint Filter. I can able to get Warm by setting filter.setValue(CIVector(x: 1000, y: 0), forKey: "inputNeutral") filter.setValue(CIVector(x: 1000, y: 0), forKey: "inputTargetNeutral"). But can you help me to get parameters for Cool?Downhaul
Check out the color temperature map from Wikipedia: en.wikipedia.org/wiki/Color_temperature. Values around 12000K should yield nice cold colors.Unrivaled
Let us continue this discussion in chat.Downhaul

© 2022 - 2024 — McMap. All rights reserved.