// MARK: - Remove filter from image
func removeFilterFromImage(image: UIImage) -> UIImage {
// Convert UIImage to CIImage
guard let ciInput = CIImage(image: image) else {
return image
}
// Create a neutral filter (e.g., identity filter)
let neutralFilter = CIFilter(name: "CISRGBToneCurveToLinear")
// Set the input image for the filter
neutralFilter?.setValue(ciInput, forKey: kCIInputImageKey)
// Get the output CIImage from the filter
guard let ciOutput = neutralFilter?.outputImage else {
return image
}
// Create a CIContext
let ciContext = CIContext()
// Render the output CIImage as a CGImage
guard let cgImage = ciContext.createCGImage(ciOutput, from: ciOutput.extent) else {
return image
}
// Create a new UIImage from the CGImage
let outputImage = UIImage(cgImage: cgImage)
return outputImage
}
这是我尝试过的,但似乎不起作用。从我读到的来源,这是不可能的,除非有一个反向过滤器,所以应该有反向过滤器的每一个过滤器在这种情况下,如果没有,那么我如何才能删除现有的过滤器从图像例如:高斯模糊
1条答案
按热度按时间ecbunoof1#
将
CIFilter
应用于图像是一种破坏性操作,这意味着它无法恢复以恢复原始图像。