Contents

maskedVariableBlur()

Blurs a specified portion of an image.

Declaration

class func maskedVariableBlur() -> any CIFilter & CIMaskedVariableBlur

Mentioned in

Return Value

The blurred image.

Discussion

This method applies the masked variable blur to an image. The effect blurs the image in an area defined by the mask image. The mask image contains shades of grey that define the strength of the blur. Black colors in the mask cause no blurring, and white colors cause maximum blur.

The masked variable blur filter uses the following properties:

radius

A float representing the area of effect as an NSNumber.

mask

An image that masks an area on the input image with the type CIImage.

inputImage

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

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

func maskedVariableBlur(inputImage: CIImage) -> CIImage {
    let filter = CIFilter.maskedVariableBlur()
    filter.inputImage = inputImage
    // Create a mask that goes from white to black vertially.
    let mask = CIFilter.smoothLinearGradient()
    mask.color0 = CIColor.white
    mask.color1 = CIColor.black
    mask.point0 = CGPoint(x: 0, y: 0)
    mask.point1 = CGPoint(x:0, y: inputImage.extent.height)
    filter.mask = mask.outputImage
    filter.radius = 25
    return filter.outputImage!
}

[Image]

See Also

Filters