Methods and Protocols for Filter Creation

Create Core Image filters that expose their attributes as properties.


Core Image provides methods that create type-safe CIFilter instances. Use these filters to avoid run-time errors that can occur when relying on Core Image's string-based API.

To use the type-safe API, import CoreImage.CIFilterBuiltins:

import CoreImage
import CoreImage.CIFilterBuiltins

The type-safe approach returns a non-optional filter. Because the returned filter conforms to the relevant protocol—for example, CIFalseColor in the case of falseColorFilter—the parameters are available as properties. The following creates and applies a false color filter:

func falseColor(inputImage: CIImage) -> CIImage? {
    let falseColorFilter = CIFilter.falseColor()
    falseColorFilter.color0 = CIColor(red: 1, green: 1, blue: 0)
    falseColorFilter.color1 = CIColor(red: 0, green: 0, blue: 1)
    falseColorFilter.inputImage = inputImage
    return falseColorFilter.outputImage

The false color filter maps luminance to a color ramp of two colors:

Two photographs showing a flower. The image on the left shows the original version of the flower. The image on the right shows the false color version of the flower.




The properties you use to configure a Core Image filter.

Filter Categories

Blur Filters

Apply blurs, simulate motion and zoom effects, reduce noise, and erode and dilate image regions.

Color Adjustment Filters

Apply color transformations, including exposure, hue, and tint adjustments.

Color Effect Filters

Apply color effects, including photo effects, dithering, and color maps.

Composite Operations

Composite images by using a range of blend modes and compositing operators.

Convolution Filters

Convolve images to produce effects including sharpening, blurring, and embossing.

Generator Filters

Generate barcode, geometric, and special-effect images.

Geometry Adjustment Filters

Translate, scale, and rotate images in 2D and 3D.

Gradient Filters

Generate linear and radial gradients.

Halftone Effect Filters

Simulate monochrome and CMYK halftone screens.

Sharpening Filters

Apply sharpening to images.

Stylizing Filters

Create stylized versions of images by applying effects including pixellation and line overlays.

Tile Effect Filters

Produce tiled images from source images.

Transition Filters

Transition between two images by using effects including page curl and swipe.