Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Using Core Image Filters for special effects

Duncan CDuncan C Posts: 9,112Tutorial Authors, Registered Users @ @ @ @ @ @ @
edited April 2014 in iPhone SDK Tutorials
Apple added support for Core Image in iOS 5. One of the most versatile features of Core Image is support for Core Image filters (Members of the CIImage class). Core Image filters let you create a variety of effects, most of which alter one or more input images. Apple added filters in iOS 6, and then more in in iOS 7. There are now 118 different Core Image filters, as described in the Core Image Filter reference, available in Xcode and on Apple's website.

The documentation on CI filters is pretty sparse however. It can be hard to figure out what the filters do based on the limited info available.

Core image filters are grouped by category.

However, the API is fairly self-documenting. You can ask Core Image for a list of filters by category, and then you can ask a filter for it's attributes. The attributes for a filter is a dictionary that lists it's input settings, their types, valid range, and default value, and the output values (The only output value I've ever seen is an output image.)

I wrote a program that interrogates Core Image for a list of filters and presents them in a table view grouped by filter category. When the user selects a filter it asks Core Image for the attributes, and then displays UI elements for the more common types of settings:
  • a segmented control that lets you pick a center point, used for some effects
  • up to 5 float values that are controlled by sliders
  • up to 2 color wells

The program makes it pretty easy to explore the different available filters and see what they do.

The UI for selecting settings takes a fair amount of screen real-estate, so I decided to make the program iPad only. CI filters are VERY slow on the simulator, so you really want to run the program on an actual iPad.

The program is on github at https://github.com/DuncanMC/CIFilterTest
Post edited by Duncan C on
Regards,
Duncan C
WareTo

widehead.gif
Animated GIF created with Face Dancer, available for free in the app store.

I'm available for one-on-one help at CodeMentor

Replies

Sign In or Register to comment.