我正在尝试使图像看起来好像已使用彩色扫描仪扫描过)。第一张图片是我通过使用以下过滤器生成的。第二张图片就是我想要的照片外观。任何人都可以建议使用CIFilter或其组合以获得此扫描效果吗?
我正在使用的过滤器:
let context = CIContext.init()
let sharpenCimage = self.sharpen(inputImage: ciimage, inputRadius: 2.5, inputIntensity: 1.0)
let colorControlCimage = self.colorControl(input: sharpenCimage!, contrast: 2.4, saturation: 0.6, brightness: 0.2)
let CIColorMatrix = self.CIColorMatrix(inputImage: colorControlCimage!)
func colorControl(input: CIImage, contrast: Float, saturation: Float, brightness: Float) -> CIImage? {
let filter = CIFilter(name: "CIColorControls")
filter?.setValue(input, forKey: kCIInputImageKey)
//filter?.setValue(contrast, forKey: kCIInputContrastKey)
//filter?.setValue(saturation, forKey: kCIInputSaturationKey)
//filter?.setValue(brightness, forKey: kCIInputBrightnessKey)
filter?.setDefaults()
return filter?.outputImage
}
func sharpen(inputImage: CIImage, inputRadius: Float, inputIntensity: Float) -> CIImage? {
let filter = CIFilter(name: "CIUnsharpMask")
filter?.setValue(inputImage, forKey: kCIInputImageKey)
filter?.setValue(inputRadius, forKey: kCIInputRadiusKey)
filter?.setValue(inputIntensity, forKey: kCIInputIntensityKey)
return filter?.outputImage
}
func CIColorMatrix(inputImage: CIImage) -> CIImage? {
let filter = CIFilter(name: "CIColorMatrix")
filter?.setValue(inputImage, forKey: kCIInputImageKey)
filter?.setDefaults()
return filter?.outputImage
}
我希望它看起来像什么