0% found this document useful (0 votes)
8 views8 pages

Computer Vision HW1

The document outlines a homework assignment on white balance techniques in computer vision, specifically focusing on the grey world and robust white patch algorithms implemented in MATLAB. It includes code snippets for both algorithms, criteria for their effectiveness, and results from applying them to various images. The analysis discusses when each algorithm performs better and the conditions under which both algorithms fail, emphasizing the importance of color balance and lighting in image processing.

Uploaded by

zahraaalfaeq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views8 pages

Computer Vision HW1

The document outlines a homework assignment on white balance techniques in computer vision, specifically focusing on the grey world and robust white patch algorithms implemented in MATLAB. It includes code snippets for both algorithms, criteria for their effectiveness, and results from applying them to various images. The analysis discusses when each algorithm performs better and the conditions under which both algorithms fail, emphasizing the importance of color balance and lighting in image processing.

Uploaded by

zahraaalfaeq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Computer Vision

Homework 1:
White Balance

Pesented by:
Zahraa muhaned mohammed faeq
MSc stg 1
HW1: White Balance

1. Implement the grey world and the robust white patch algorithms using MATLAB.

a. grey_world

imread('C:\Users\ahmed\Pictures\257531\‫صور‬.jpg');
image = im2double(image);

% average
avg_r = mean2(image(:,:,1));
avg_g = mean2(image(:,:,2));
avg_b = mean2(image(:,:,3));

fprintf('Grey Point (R, G, B): %.2f, %.2f, %.2f\n',


avg_r, avg_g, avg_b);

avg_grey = (avg_r + avg_g + avg_b) / 3;


scale_r = avg_grey / avg_r;
scale_g = avg_grey / avg_g;
scale_b = avg_grey / avg_b;

fprintf('correction factor (R, G, B): %.2f, %.2f,


%.2f\n', scale_r , scale_g, scale_b);

imshow(balanced_image);
b. robust_white_patch

image = imread('C:\Users\ahmed\Pictures\ph\3.jpg');
image = im2double(image);

max_r = max(max(image(:,:,1)));
max_g = max(max(image(:,:,2)));
max_b = max(max(image(:,:,3)));

scale_r = 1 / max_r;
scale_g = 1 / max_g;
scale_b = 1 / max_b;

balanced_image = image;
balanced_image(:,:,1) = image(:,:,1) * scale_r;
balanced_image(:,:,2) = image(:,:,2) * scale_g;
balanced_image(:,:,3) = image(:,:,3) * scale_b;

fprintf('White Point (R, G, B): %.2f, %.2f, %.2f\n',


max_r , max_g, max_b);

fprintf('correction factor (R, G, B): %.2f, %.2f, %.2f\n',


scale_r , scale_g, scale_b);

balanced_image = min(max(balanced_image, 0), 1);


imshow(balanced_image);
2. Look for images where the grey world algorithm gives better result than the other algorithm. What
criteria make the grey world algorithm more suitable for these images. Report the grey point (the average
intensities of the R, G, and B channels) for each image.

 Comparing the gray world and the strong white patch :

In grey world algorithm In robust white patch algorithm.

Analyze the Criteria


1. Grey World better
o Because the image contains statistically balanced colors (sky, clouds,...).
o There are no dominant colors (e.g., one color overwhelming the image).
o The lighting is balanced.

2. Record the results:


o Grey World:

GreyPoint
Grey Point(R,
(R,G,G,B):B):55.67,
0.47,54.35,
0.51,56.76
0.42

Grey Point:
correction 0.4676
factor (R, G, B): 1.00, 1.02, 0.98

o White Patch Algorithm.

White Point (R, G, B): 0.69, 0.69, 0.73

correction factor (R, G, B): 1.44, 1.45, 1.38

o Grey World gave better results because the colors look balanced and the details
are preserved.
3.Repeat step 2 for the robust white patch algorithm. This time report the white point (the 1
percentiles of the R, G, and B channels) for each image.

 Comparing the gray world and the strong white patch :

In robust white patch algorithm In grey world algorithm

Analyze the Criteria


1. Robust White Patch better :
o Because the image contains bright points (white) as a reference
o The Robust White Patch algorithm relies on these bright points to adjust the color
balance.
o Grey World fails in this case because it relies on the global average, which may
not reflect strong lighting.
2. Record the results:
o Robust white patch algorithm :

White Point (R, G, B): 1.00, 1.00, 1.00

correction factor (R, G, B): 1.00, 1.00, 1.00

o grey world algorithm :

Grey Point (R, G, B): 66.04, 70.98, 70.39

Correction factor (R, G, B): 1.05, 0.97, 0.98

o Robust White Patch gave better results because it utilized the bright points
in the image.
4.Look for images where both algorithms fail. What criteria do they haveor lack?

Original

Grey World Robust White Patch

 Apply Grey World:


o Result: The colors appear washed out, and the blue sky loses its color.

 Apply Robust White Patch:


o Result: The colors appear overexposed, and the white clouds lose their details.

 Analysis:
o Both algorithms fail because the image contains a dominant color (blue sky) and
uneven lighting.
Original

Grey World Robust White Patch

the colors changed Here the colors became light


5. Try to imitate the criteria in step 4 using your phone camera, then check how successful each
algorithms is.

Grey world Robust White Patch

change the colors (failed) The colors almost didn't change.)successful)

You might also like