Gray World Algorithm, grayalgorithm

Source: Internet
Author: User

Gray World Algorithm, grayalgorithm

Human Visual systems are color-constant and can be used to obtain the surface color of an object from the changing lighting environment and imaging conditions. However, imaging devices do not have such adjustment functions,

Different Lighting environments may cause a certain degree of deviation between the color of the collected image and the actual color. You need to select an appropriate color balancing (Correction) algorithm to eliminate the effect of different lighting environments on the face.

Color effect. Grayscale global algorithms are the most common balancing algorithms.

I. grayscale world Algorithm

The gray world algorithm is based on the gray world Assumption. This assumption assumes that for an image with a large number of color changes, the average values of the three components tend to be the same gray.

Degree value. Physically speaking, the gray world method assumes that the average reflection of natural scenery on light is a fixed value in general, which is approximately "gray ".

Color ". The color balancing algorithm forcibly applies this assumption to the image to be processed, which can eliminate the effect of ambient light from the image and obtain the original scene image.

Algorithm Execution steps:

(1) There are two methods to determine:

Either take a fixed value (such as half of the brightest gray value, or 128 If the eight digits are displayed );

You can either calculate the average value of the three channels of the image and obtain the value;

(2) Calculate the gain coefficient of the three channels :;;;

(3) Based on the Von Kries diagonal model, adjust the component components of each pixel in the image:

This algorithm is simple and fast. However, when the color of the image scene is not rich, especially when a large monochrome object occurs, this algorithm often fails.

Note: Von Kries proposed that a diagonal matrix transformation can be used to describe the relationship between colors of the same object surface under two illumination conditions. It is assumed that the sensor is under illumination

The following object values are obtained:


This theory converts different light sources.

Ii. Matlab implementation

function Test()I=imread('test.jpg');y=GrayWorld(I);y=uint8(y);figure(1);imshow(I);figure(2);imshow(y);function y=GrayWorld(Image)r=Image(:,:,1);g=Image(:,:,2);b=Image(:,:,3);avgR = mean(mean(r));avgG = mean(mean(g));avgB = mean(mean(b));avgRGB = [avgR avgG avgB];grayValue = (avgR + avgG + avgB)/3scaleValue = grayValue./avgRGB;newI(:,:,1) = scaleValue(1) * r;newI(:,:,2) = scaleValue(2) * g;newI(:,:,3) = scaleValue(3) * b;y=newI;


Test results:




Refer:

Http://www.cnblogs.com/Imageshop/archive/2013/04/20/3032062.html

Http://scien.stanford.edu/pages/labsite/1999/psych221/projects/99/jchiang/intro2.html

Http://scien.stanford.edu/pages/labsite/2000/psych221/projects/00/trek/GWimages.html

[1] Xu Xiaozhao, Cai xiaoheng, Liu Xiaomin, Liu Changjiang, and Shen lanmiao. improved the gray world color correction algorithm [J]. journal of photon, 2010, 39 (3): 559 ~ 564




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.