vignetteEffect()
Gradually darkens a specified area of an image.
Declaration
class func vignetteEffect() -> any CIFilter & CIVignetteEffectReturn 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:
inputImageAn image with the type CIImage.
intensityA
floatrepresenting the intensity of the vignette effect as an NSNumber.radiusA
floatrepresenting the radius of the effect as an NSNumber.falloffA
floatrepresenting the fall off of brightness toward the edge of the image as an NSNumber.centerA 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]