Same CIGaussianBlur effect archives two highly different results depending on the background

34 Views Asked by At

I am trying to achieve a the same gaussian blur as Photoshop does but it's seems the CIFilter in Core Image is very biased on the background of the image. I am not talking about the blurred edges, please look closer at the blue intensity between white and dark background of the CIFilter blurred version and Photoshop.

Input images:

enter image description here

enter image description here

Core Image result:

enter image description here enter image description here

Photoshop result:

enter image description here enter image description here

You can clearly see CIGaussianBlur outputs a very different image.

This is the code used to generate the images on iOS:

let imageURL = Bundle.main.url(forResource: "1", withExtension: "png")!
let ciImage = CIImage(contentsOf: imageURL)!
let extent = CGRect(origin: .zero, size: ciImage.extent.size)
let blurredImage = CIFilter.gaussianBlur()
blurredImage.radius = 64
blurredImage.inputImage = ciImage

let outputURL = try! FileService.shared.getNewFileURL(type: "jpeg")
let context = CIContext()
try! context.writeJPEGRepresentation(of: blurredImage.outputImage!.cropped(to: extent), to: outputURL, colorSpace: colorSpace)
0

There are 0 best solutions below