Type Method

bokehBlur()

Applies a bokeh effect to an image.

Declaration

class func bokehBlur() -> 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
    }
Two photographs of a beach at sunset with multiple palm trees. The photo on the left is clear and crisp. In the photo on the right, a bokeh blur filter has been applied and the image is softer and looks slightly fuzzy or hazy.

See Also

Filters

class func boxBlur() -> CIFilter & CIBoxBlur

Applies a square-shaped blur to an area of an image.

class func discBlur() -> CIFilter & CIDiscBlur

Applies a circle-shaped blur to an area of an image.

class func gaussianBlur() -> CIFilter & CIGaussianBlur

Blurs an image with a Gaussian distribution pattern.

class func median() -> CIFilter & CIMedian

Calculates the median of an image to refine detail.

class func morphologyMaximum() -> CIFilter & CIMorphologyMaximum

Blurs a circular area by enlarging contrasting pixels.

class func morphologyMinimum() -> CIFilter & CIMorphologyMinimum

Blurs a circular area by reducing contrasting pixels.

class func morphologyRectangleMaximum() -> CIFilter & CIMorphologyRectangleMaximum

Blurs a rectangular area by enlarging contrasting pixels.

class func morphologyRectangleMinimum() -> CIFilter & CIMorphologyRectangleMinimum

Blurs a rectangular area by reducing contrasting pixels.

class func noiseReduction() -> CIFilter & CINoiseReduction

Reduces noise by sharpening the edges of objects.

class func zoomBlur() -> CIFilter & CIZoomBlur

Creates a zoom blur centered around a single point on the image.