bokehBlur()
Applies a bokeh effect to an image.
Declaration
class func bokehBlur() -> any CIFilter & CIBokehBlurReturn 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:
radiusA
floatrepresenting the area of effect as an NSNumber.ringSizeA
floatrepresenting the ring size of the bokeh as an NSNumber.ringAmountA
floatrepresenting the emphasis at the ring of the bokeh as an NSNumber.softnessA
floatrepresenting the softness of the bokeh effect as an NSNumber.inputImageA 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]