Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-071

Color Temperature Shift

Problem

Shift the color temperature of an RGB image with per-channel scaling.

Multiply the red channel by factor, keep green unchanged, and divide blue by factor, rounding to the nearest integer and clamping each channel to [0, 255]. factor is positive.

Test cases

case 1
in: [[[[100,100,100]]],1.2]
expected: [[[120,100,83]]]
case 2
in: [[[[255,0,255]]],0.5]
expected: [[[128,0,255]]]
case 3
in: [[[[10,20,30]]],1]
expected: [[[10,20,30]]]
case 4
in: [[[[10,20,30]]],2]
expected: [[[20,20,15]]]
Starter codePython
def temperature_shift(image, factor):
    # Your code here
    pass

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