toneCurve()
Alters an image’s tone curve according to a series of data points.
Declaration
class func toneCurve() -> any CIFilter & CIToneCurveReturn Value
The modified image.
Discussion
This method applies the tone curve filter to an image. The effect calculates the adjustment of the tone curve by the sum of the red, green, and blue color values with the point value properties specified.
The tone curve filter uses the following properties:
point0A v
ectorcontaining the position of the first point of the tone curve as a CIVector.point1A v
ectorcontaining the position of the second point of the tone curve as a CIVector.point2A
vectorcontaining the position of the third point of the tone curve as a CIVector.point3A v
ectorcontaining the position of the fourth point of the tone curve as a CIVector.point4A v
ectorcontaining the position of the fifth point of the tone curve as a CIVector.inputImageAn image with the type CIImage.
The following code creates a filter that adds brightness to the input image:
func toneCurve(inputImage: CIImage) -> CIImage {
let toneCurveFilter = CIFilter.toneCurve()
toneCurveFilter.inputImage = inputImage
toneCurveFilter.point0 = CGPoint(x: 0, y: 0)
toneCurveFilter.point1 = CGPoint(x: 0.22, y: 0.25)
toneCurveFilter.point2 = CGPoint(x: 0.4, y: 0.5)
toneCurveFilter.point3 = CGPoint(x: 0.65, y: 0.75)
toneCurveFilter.point4 = CGPoint(x: 1, y: 1)
return toneCurveFilter.outputImage!
}[Image]