All problems
Gray-World Color Balance
Problem
Balance the colors of an RGB image with the gray-world assumption.
Compute the per-channel means, let target be their average, then scale each channel by target / mean, rounding to integers and clamping to [0, 255]. A channel whose mean is 0 is left unchanged.
Hint
Scale each channel so that all three channel means become equal.
Test cases
case 1
in: [[[[100,150,50]]]]
expected: [[[100,100,100]]]
case 2
in: [[[[200,100,0]]]]
expected: [[[100,100,0]]]
case 3
in: [[[[128,128,128]]]]
expected: [[[128,128,128]]]
Starter codePython
def gray_world(image):
# Your code here
pass3 test cases · run your code against them in the editor