Skip to content

Instantly share code, notes, and snippets.

View Diyago's full-sized avatar
🎯
Focusing

Insaf Ashrapov Diyago

🎯
Focusing
View GitHub Profile
@DavidYKay
DavidYKay / simple_cb.py
Last active September 9, 2024 00:14
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/
import cv2
import math
import numpy as np
import sys
def apply_mask(matrix, mask, fill_value):
masked = np.ma.array(matrix, mask=mask, fill_value=fill_value)
return masked.filled()
def apply_threshold(matrix, low_value, high_value):