documentEnhancer()
Adjusts an image’s shadows and contrast.
Declaration
class func documentEnhancer() -> any CIFilter & CIDocumentEnhancerReturn Value
The modified image.
Discussion
This method applies the document enhancer filter to an image. The effect removes unwanted shadows while whitening the background and enhancing contrast. The filter is commonly used to enhance scanned documents.
The document enhancer filter uses the following properties:
inputImageAn image with the type CIImage.
amountA
floatrepresenting the desired strength of the effect as an NSNumber.
The following code creates a filter that adds brightness to the input image:
func documentEnhancer(inputImage: CIImage) -> CIImage {
let documentEnhancerFilter = CIFilter.documentEnhancer()
documentEnhancerFilter.inputImage = inputImage
documentEnhancerFilter.amount = 4
return documentEnhancerFilter.outputImage!
}[Image]