Skip to content

Instantly share code, notes, and snippets.

View hobson's full-sized avatar
💭
dev

Hobson Lane hobson

💭
dev
View GitHub Profile
@hobson
hobson / simple_cb.py
Last active April 13, 2018 17:41 — forked from DavidYKay/simple_cb.py
Simple color balance algorithm using Python 2.7.8 and OpenCV 2.4.10. Ported from: http://www.morethantechnical.com/2015/01/14/simplest-color-balance-with-opencv-wcode/
""" White balance (color balance)
Adjust colors to flatten color histogram peaks and broaden color spectrum for better color contrast.
This is also sometimes called white balancing or probability distribution whitening.
References:
- Color balance algorithm in [OpenCV](http://www.morethantechnical.com/2015/01/14/simplest-color-balance-with-opencv-wcode/)
- Ported to python by [DavidYKay](https://github.com/DavidYKay)
- Optimized (`O(N^2)` -> `O(N)`) by @alxrsngartn funded in part by NSF grant number 1722399 to [Aira](http://github.com/aira) (@jmeyers-aira)
- Incorporated into [nlpia](github.com/aira/nlpia) by @hobson