Search code examples
pythonimage-processingscikit-image

Is there a way to automatically correct the color balance?


I'm looking for a solution to automatically adjust the color balance?
I would like to use the pictures for color analysis and comparison, therefore color balance is important.
I was hoping a feature such as histogram equalization with scikit-image to correct and balance the colors. The result doesn't have to look good or natural, it must just always be the same.

Does anyone have a solution ?


Solution

  • There is a good article on color balancing at Illuminant Estimation: Simplest Color Balance. The code is in MATLAB but a guy named Roy ported it to C++ using OpenCV here: Simplest Color Balance with OpenCV [w/code].

    David Young-Chan Kay took that same code and ported it to Python 2.7.8 and OpenCV 2.4.10 here: https://gist.github.com/DavidYKay/9dad6c4ab0d8d7dbf3dc

    Below is an original image like that in your reference, and below it is the output of the algorithm. enter image description here enter image description here