swiftcifilterbrightness

CIColorControls wrong brightness


I am change brightness value of the image to negative value and trying to compare result image with apple photo editor.

Original

Original image

Edited by me

Me

Edited by Apple Photo Editor

Apple

As you can see, my CIFilter change brightness of white part of the image too. Apple Editor changes brightness of person only.

My code is simple:

filter.setValue(NSNumber(value: -0.4), forKey: kCIInputBrightnessKey)

It makes no difference whether I increase the brightness or decrease it. The brightness of the entire image changes. Apple Editor changes only part of the image


Solution

  • The "Brightness" slider in Photos is not mapped to the "traditional" brightness value (that is used in CIColorControls). Apple uses more sophisticated algorithms under the hood that, among others, take the image's content into account. I'm afraid there's no single core image filter that can reproduce that result. But it looks like Photos also increased the contrast when reducing the brightness, so you could try that.