Contents

bokehBlur()

Applies a bokeh effect to an image.

Declaration

class func bokehBlur() -> any CIFilter & CIBokehBlur

Return Value

The blurred image.

Discussion

This method applies the bokeh blur filter to an image. The effect targets a circular area of pixels defined by the radius and blurs the area. The filter adds smaller intense blur rings.

The bokeh blur filter uses the following properties:

radius

A float representing the area of effect as an NSNumber.

ringSize

A float representing the ring size of the bokeh as an NSNumber.

ringAmount

A float representing the emphasis at the ring of the bokeh as an NSNumber.

softness

A float representing the softness of the bokeh effect as an NSNumber.

inputImage

A CIImage representing the input image to apply the filter to.

The following code creates a filter that adds a softer blur to the input image:

    func bokehBlur(inputImage: CIImage) -> CIImage? {

        let bokehBlurFilter = CIFilter.bokehBlur()
        bokehBlurFilter.inputImage = inputImage
        bokehBlurFilter.ringSize = 0.1
        bokehBlurFilter.ringAmount = 0
        bokehBlurFilter.softness = 1
        bokehBlurFilter.radius = 20
        return bokehBlurFilter.outputImage
    }

[Image]

See Also

Filters