On Finding Gray Pixels.

Yanlin Qian, Joni-Kristian Kamarainen, Jarno Nikkanen, Jiri Matas

Abstract: We propose a novel grayness index for finding gray pixels and demonstrate its effectiveness and efficiency in illumination estimation. The grayness index, GI in short, is derived using the Dichromatic Reflection Model and is learning-free. GI allows to estimate one or multiple illumination sources in color-biased images. On standard single-illumination and multiple-illumination estimation benchmarks, GI outperforms state-of-the-art statistical methods and many recent deep methods. GI is simple and fast, written in a few dozen lines of code, processing a 1080p image in 0.4 seconds with a non-optimized Matlab code.

Introduction

Color constancy is the computational challenge of determining a scene's true illumination to perform accurate white balancing. If an algorithm can identify which pixels in an image are achromatic (gray), the color of those pixels directly reveals the color of the light source. However, distinguishing between a colored object under white light and a white object under colored light is an ill-posed problem. While deep learning models (CNNs) have achieved high accuracy, they often suffer from dataset bias, failing when applied to cameras with different spectral sensitivities than those used during training.

The Grayness Index (GI)

To address these limitations, we introduce the Grayness Index (GI), a learning-free, camera-agnostic algorithm derived from the Dichromatic Reflection Model (DRM). The DRM models pixel values as a combination of body reflection (object color) and surface reflection (specular highlights).

Overview of the GI pipeline, showing the identification of gray pixels, the resulting GI map, and the estimated global and spatial illumination maps.

The GI algorithm operates through several key steps:

  1. Local Contrast Analysis: Instead of raw intensities, GI analyzes the contrast of red and blue channels relative to total luminance in log space.
  2. Mathematical Formulation: A Laplacian of Gaussian (LoG) filter is applied to the log-difference between color channels and luminance. For a gray pixel, the local contrast in color channels should match the local contrast in luminance.
  3. Index Calculation: The GI value is the $\ell 2$ norm of these contrast residuals; lower values indicate a higher probability that a pixel is gray.
  4. Spatial Refinement: Flat areas lacking spatial cues are discarded, and the GI map is smoothed using a $7 \times 7$ window to reduce noise.

Illumination Estimation

GI can be applied to both single and multiple light source scenarios. For single-light estimation, the algorithm averages the colors of the top $N\%$ "grayest" pixels. For multi-illumination scenes, K-means clustering is applied to these pixels to identify distinct light sources and generate a spatially-varying illumination map.

Step-by-step estimation process: (a) input image, (b) GI map, (c) selected gray pixels, (d-e) estimated illuminations, and (f) final white-balanced result.

Experimental Results

The method was evaluated on the Gehler-Shi, NUS 8-Camera, and MIMO datasets. Key findings include:

  • Generalization: GI significantly outperforms deep learning methods in cross-dataset scenarios where the test camera differs from the training set.
  • Accuracy: On the NUS 8-Camera dataset, GI achieved a mean angular error of 2.91°, surpassing traditional statistical methods like Gray World (4.59°).
  • Efficiency: The algorithm is highly efficient, processing 1080p images in approximately 0.4 seconds in Matlab.

Conclusion

The Grayness Index provides a robust, fast, and mathematically grounded alternative to data-driven color constancy methods. While it faces challenges with "heavy tail" error distributions in rare cases, its simplicity and generalization capabilities make it a powerful tool for real-time applications and a potential preprocessing step for broader computer vision tasks like intrinsic image decomposition.

Summary updated

BibTeX
@inproceedings{qian2019finding,
  author = {Yanlin Qian and Joni-Kristian Kamarainen and Jarno Nikkanen and Jiri Matas},
  title = {{On Finding Gray Pixels.}},
  booktitle = {CVPR},
  year = {2019},
  url = {https://openreview.net/forum?id=HQ4Zazxu6B},
}
Figure