Contents

vignetteEffect()

Gradually darkens a specified area of an image.

Declaration

class func vignetteEffect() -> any CIFilter & CIVignetteEffect

Return Value

The modified image.

Discussion

This method applies the vignette effect filter to an image. This effect reduces brightness of the image at the periphery of a specified region.

The vignette effect filter uses the following properties:

inputImage

An image with the type CIImage.

intensity

A float representing the intensity of the vignette effect as an NSNumber.

radius

A float representing the radius of the effect as an NSNumber.

falloff

A float representing the fall off of brightness toward the edge of the image as an NSNumber.

center

A CGPoint representing the center of the image.

The following code creates a filter that darkens the edges of an area on the input image:

func vignetteEffect(inputImage: CIImage ) -> CIImage {
    let vignetteFilter = CIFilter.vignetteEffect()
    vignetteFilter.inputImage = inputImage
    vignetteFilter.intensity = 1
    vignetteFilter.radius = 650
    vignetteFilter.falloff = 0.5
    vignetteFilter.center = CGPoint(x: 1024, y: 768)
    return vignetteFilter.outputImage!
}

[Image]

See Also

Color Effect Filters