Search code examples
pythonsimplecv

SimpleCV colour correction for under or overexposed photos


Was wondering whether anyone know how to do the following in SimpleCV. I would like to colour correct a photo, so that if it's under or over exposed it is corrected. I believe cameras do this by taking an average of the colours and then adjusting the colours to turn the average into a 50% grey. This simple method should work ok for my scenario.

If anyone has some example Python code to do this or something more complex it would be much appreciated.

Thanks


Solution

  • There is a function built into SimpleCV:

    balanced_img = Image('myphoto.jpg').whiteBalance('GrayWorld') # 'Simple' or 'GrayWorld'
    

    You can read about the white balance methods from links in the SimpleCV docs for whiteBalance

    This does what you described you wanted - adjust the average to a gray-scale. The 'Simple' method basically stretches the color range for each channel from 0 - 255 after clipping some of the outliers.

    You can also do color correction with functions like applyRGBCurve.