BradLarson / GPUImage

An open source iOS framework for GPU-based image and video processing
http://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework
BSD 3-Clause "New" or "Revised" License
20.24k stars 4.61k forks source link

Would like to do Split Toning of images, any ideas? #286

Open RichardAltenburg opened 12 years ago

RichardAltenburg commented 12 years ago

In some of my image effects for iOS 5 I need a way to do split toning, which means applying separate colors to the highlights and the shadows in an image. Software like Adobe Lightroom does this with ease, as can be seen here:

http://bwtutorials.blogspot.nl/2011/11/tuto-5-split-toning-with-lightroom.html

On Mac OS X I could use CIFalseColor to emulate this effect, but on iOS I am looking for ideas because CIFalseColor and many other effects are not available. Can you guys give me a direction to solve this issue? Thanks!

BradLarson commented 12 years ago

Would you be happy enough with something that could replace CIFalseColor? The description on that from the Core Image documentation reads:

"Maps luminance to a color ramp of two colors."

which should be pretty easy to achieve with a fragment shader that first converts the image to luminance, then uses the luminance value to control the mix of the two colors. I could create a filter for that pretty quickly.

BradLarson commented 12 years ago

Also, sorry about the close. I fat-fingered that button.

RichardAltenburg commented 12 years ago

It would hurt nobody if you would implement CIFalseColor in GPUImage ;-) but I am not sure it will be the definitive answer to my quest for split toning. I do know from this post that someone has achieved more or less this solution using false color and screen blending (which GPUImage already does):

http://stackoverflow.com/questions/7961929/split-tone-effect-using-core-image-filters/8092453#8092453

To really have it work like Lightroom and the likes, it should be possible to adjust the hue and saturation of both the highlights and the shadows, and I think there is no hue adjustment in your framework just yet.

Thank you for looking into this, I know you must be very busy.

BradLarson commented 12 years ago

OK, there should now be a false color filter in the framework. I'm honestly not much of a color processing guy, so I might need some help in finding the right math to do the rest of what you want.

RichardAltenburg commented 12 years ago

You keep amazing me with all the support you give on this framework, great work!

I came to this page this morning because during breakfast I decided to spit out a list of filters that iOS 5 can actually do, and it turns out it does do CIFalseColor after all, the documentation for Core Image lags behind and did not mention it yet. Now I have a full list of currently available filters on my desk, so this will help in cases where GPUImage is not yet ready.

So I wanted to warn you to not stay up late to create FalseColor for me ;-) but you beat me to it. No worries, I'd rather use your work because it is faster anyway!

I will test your implementation this weekend (I can not rest before this effect works anyway) and will report back what I got. Again, thanks for your help.

(by the way, I am very weak at math, at least I was as a child, maybe it gets better after decades of coding, but as an enthousiast photographer I do need to work a lot with color processing, so that is why I want my effects to become photographer-friendly and I will try to help find the math to do this)

alariccole commented 12 years ago

The easiest solution to this would be to create a CIColorMap replacement, allowing an image to be mapped to a gradient texture (supplied as a texture or created using an input of two colors). This would allow, for instance, a gradient of blue to orange to produce a teal&orange colorization.

BradLarson commented 12 years ago

In that case, I should probably split out the generic color mapping component of the tone curve filter like I've been planning. That's effectively what it does inside, with the tone curve calculations merely being used to generate the mapping texture.

RichardAltenburg commented 12 years ago

I do not understand the last two comments, but you guys seem to know what you are doing so any new components would be appreciated. I tried the solution using FalseColor and ScreenBlendMode as one stackoverflow user suggested, but I can tell you it is nowhere near a split toning like Lightroom and others do.

Currently I need it to replicate a cyanotype effect, but split toning is done in many effects so is still high on my wish list.

brandonscript commented 10 years ago

Hey all, was just looking into this today. The FalseColor methods seem to work OK, but there's no way of controlling the intensity. How tough would it be to add in an intensity control for each of the two colors?