iOS White point/white balance adjustment examples/suggestions

后端 未结 1 749
太阳男子
太阳男子 2020-12-28 11:10

I am trying to change the white point/white balance programmatically. This is what I want to accomplish:
- Choose a (random) pixel from the image
- Get color of that

相关标签:
1条回答
  • 2020-12-28 11:51

    After a lot of experimenting and mathematics I finally got my app to work almost the way I want.
    If anyone else will find themselves facing a similar problem then here is what I did.
    I ended up using CITemperatureAndTint filter supplying a color in Kelvins calculated from the selected pixels RGB value and user suppliable tint value.
    To get to Kelvins I:
    - firstly converted RGB to XYZ using the D65 illuminant (ie Daylight).
    - then converted from XYZ to Yxy. Both of these conversions were made using the algorithms found from EasyRGB.
    - I then calculated Kelvins from Yxy using the McCamry's formula I found in a paper here.

    These steps got the image in the ballpark but not quite there, so I added a UISlider for the user to supply the tint value ranging from -100 to 100.

    With selecting a point that should be white and choosing values from the positive side of the tint scale (all the images I on my phone tend to be more yellow) an image can now be converted to (more) neutral colors. Yey!

    I supplyed the calculated temperature and user chosen tint as inputNeutral vector values.
    6500 (D65 daylight) and 0 as inputTargetNeutral vector values to CITTemperatureAndTint filter.

    0 讨论(0)
提交回复
热议问题