Skip to content

Instantly share code, notes, and snippets.

View longouyang's full-sized avatar

Long Ouyang longouyang

View GitHub Profile
@longouyang
longouyang / simple_cb.py
Last active November 27, 2023 15:13 — forked from DavidYKay/simple_cb.py
Simple color balance algorithm
# 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/
# See also http://web.stanford.edu/~sujason/ColorBalancing/simplestcb.html
import cv2
import math
import numpy as np
import sys
def apply_mask(matrix, mask, fill_value):