Skip to content
DeepForgeby svx
All problems
HardComputer Visioncv-123

White-Patch Color Balance

Problem

Apply white-patch (max-RGB) color balance to an RGB image.

Find the maximum of each channel, scale every channel value by 255 / max, round to the nearest integer and clamp to [0, 255]. A channel whose maximum is 0 is left unchanged.

Hint

The brightest pixel becomes pure white after scaling.

Test cases

case 1
in: [[[[100,150,50]]]]
expected: [[[255,255,255]]]
case 2
in: [[[[100,50,25],[50,100,25]]]]
expected: [[[255,128,255],[128,255,255]]]
case 3
in: [[[[0,100,100]]]]
expected: [[[0,255,255]]]
Starter codePython
def white_patch(image):
    # Your code here
    pass

3 test cases · run your code against them in the editor