pinchDistortion()
Distorts an image by creating a pinch effect with stronger distortion in the center.
Declaration
class func pinchDistortion() -> any CIFilter & CIPinchDistortionReturn Value
The distorted image.
Discussion
This method applies the pinch distortion filter to an image. This effect creates a rectangular area that pinches source pixels inward, distorting those pixels closest to the rectangle the most.
The pinch distortion filter uses the following properties:
inputImageAn image with the type CIImage.
centerA set of coordinates marking the center of the image as a CGPoint.
scaleA float representing the amount of pinching effect as an NSNumber.
radiusA float representing the amount of pixels used to create the distortion as an NSNumber.
The following code creates a filter that results in a distorted image from the center of the photo:
func pinch(inputImage: CIImage) -> CIImage {
let filter = CIFilter.pinchDistortion()
filter.inputImage = inputImage
filter.radius = 400
filter.scale = 0.5
filter.center = CGPoint(x: 1791, y: 1344)
return filter.outputImage!
}[Image]