An image processor that produces an image by manipulating one or more input images or by generating new image data.
- iOS 5.0+
- macOS 10.4+
- tvOS 5.0+
CIFilter class produces a
CIImage object as output. Typically, a filter takes one or more images as input. Some filters, however, generate an image based on other types of input parameters. The parameters of a
CIFilter object are set and retrieved through the use of key-value pairs.
You use the
CIFilter object in conjunction with other Core Image classes, such as
CIColor, to take advantage of the built-in Core Image filters when processing images, creating filter generators, or writing custom filters.
CIFilter objects are mutable, and thus cannot be shared safely among threads. Each thread must create its own
CIFilter objects, but you can pass a filter’s immutable input and output
CIImage objects between threads.
To get a quick overview of how to set up and use Core Image filters, see Core Image Programming Guide.
You can subclass
CIFilter in order to create custom filter effects:
By chaining together two or more built-in Core Image filters
By using an image-processing kernel that you write
See Core Image Programming Guide for details.
Methods to Override
Regardless of whether your subclass provides its effect by chaining filters or implementing its own kernel, you should:
CIFilter class automatically manages input parameters when archiving, copying, and deallocating filters. For this reason, your subclass must obey the following guidelines to ensure proper behavior:
Store input parameters in instance variables whose names are prefixed with
Don’t use auto-synthesized instance variables, because their names are automatically prefixed with an underscore. Instead, synthesize the property manually. For example:
If using manual reference counting, don’t release input parameter instance variables in your
deallocmethod implementation. The
deallocimplementation in the
CIFilterclass uses Key-value coding to automatically set the values of all input parameters to