Matlab image Processing _ Image white balance algorithm (grey World method)

Source: Internet
Author: User

White balance, that is the so-called white balance.

White balance algorithm has many, here is recorded is the simplest practical white balance algorithm, that is the grey World law!

Gray World algorithm is based on the gray world hypothesis, which assumes that for an image with a large number of color changes, the average value of R, G, and B three components tends to be the same gray K.


The following is the specific algorithm code:

Rgb=imread (' test.jpg '); R = RGB (:,:, 1);      G = RGB (:,:, 2);      B = RGB (:,:, 3); Rx4 = RGB (:,:, 1);  Gx4 = RGB (:,:, 2);  Bx4 = RGB (:,:, 3); Rx4 just made a simple linear brightening, which can be used without reference. Rave = mean (mean (R)); gave = Mean (mean (G)); Bave = mean (mean (B)); Kave = (Rave + gave + bave)/3; R1 = (kave/rave) *r; G1 = (kave/gave) *g; B1 = (kave/bave) *b; R2 = (kave/rave) *rx4; G2 = (kave/gave) *gx4; B2 = (kave/bave) *bx4; Rgb_white = Cat (3, R1, G1, B1); Rgb_whitex4 = Cat (3, R2, G2, B2); Rgb_white_out = Uint8 (rgb_white); rgb_white_outx4 = Uint8 (rgb_whitex4);

Here is the effect of the algorithm:

Original:



After white balance:



Visible, the most primitive algorithm, the effect is good, there is a chance to add some other good algorithm.


Matlab image Processing _ Image white balance algorithm (grey World method)

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.