A partial python reproduction of the journal paper "Edge-Based Color Constancy", including Shades of Grey, Grey-Edge, and 2nd order Grey-Edge.
- python3
- dependence package
- numpy
- scipy
- opencv-python
from IllumEst_EdgeBased_Scipy import EBCCIMG
import numpy as np
import cv2
# import RAW IMAGE (float, uint8, uint16...)
img_RAW = cv2.imread('./input/Canon1DsMkIII_0199.PNG',1)
img_RAW = cv2.cvtColor(img_RAW, cv2.COLOR_BGR2RGB)
# different illuminant estimation methods
WP_GW = EBCCIMG(img_RAW,mode='GW')
WP_mRGB = EBCCIMG(img_RAW,mode='maxRGB')
WP_SoG = EBCCIMG(img_RAW,mode='SoG')
WP_GGW = EBCCIMG(img_RAW,mode='GGW', p=9, sigma=9)
WP_GE1 = EBCCIMG(img_RAW,mode='GE1', p=7, sigma=4)
WP_GE2 = EBCCIMG(img_RAW,mode='GE2', p=7, sigma=5)
illumEst_EdgeBased_Scipy.py is mainly based on scipy. More details are shown in it. All estimated illuminants are L2 normalized.
- In the folder
./input,Canon1DsMkIII_0199.PNGis one demosaicked raw image without white balance from NUS-8. Canon1DsMkIII_0199.jsonis the metadata extracted by dcraw.
These images are done with white balance and gamma correction in raw color space. The leftmost applies daylight multiplier in Canon1DsMkIII_0199.json. The others shows the variation of different illuminant estimation methods in Ref. [1].

[1] J. van de Weijer, T. Gevers and A. Gijsenij, "Edge-Based Color Constancy," in IEEE Transactions on Image Processing, vol. 16, no. 9, pp. 2207-2214, Sept. 2007.