« Older: Trains « Older
Newer: Move UIButton with CALayer »Newer »
Tool to apply CIKernel
I’ve been having a look at the CoreImage Kernels on OS X recently. They are a powerful tool, and you can quickly write a small kernel to edit an image in a very specific way. You can then use Quartz Composer to test that your kernel does what you thought it should. Unfortunately once you have done this there is no apparent way to save the output of Quartz Composer. To solve this issue I have written a small command line program which takes a path to your kernel, a series of inputs, and an output file path, and applies the kernel. The source code for this is here.
So I have a CIKernel file that I have tested with Quartz composer like this:
This removes the high saturation values from the image leaving only the grey scale colours. To apply this to an image I write:
This applies the CIKernel removeSat.cikernel
with an Image
arguement and a floating point argument, and writes the result
to the path ~/Desktop/output.png. The arguments must match the
arguments of your CIKernel (samplers replaced with images). It
doesn’t parse the kernel definition to work out what types it
should take so you need to tell it the types.
So in this example the input image looked like this:
and the output looks like this:
In this case the colour is replaced by a clear colour, so you can see background of the website through the person.
The program doesn’t handle relative paths (but it will handle tildes).