Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-070

Alpha Blend

Problem

Blend two grayscale images with alpha blending.

For each pixel compute clamp(round(alpha * a + (1 - alpha) * b), 0, 255). Both images have the same shape and alpha is in [0, 1].

Test cases

case 1
in: [[[0,100],[200,255]],[[100,200],[0,255]],0.5]
expected: [[50,150],[100,255]]
case 2
in: [[[10,20]],[[30,40]],1]
expected: [[10,20]]
case 3
in: [[[10,20]],[[30,40]],0]
expected: [[30,40]]
case 4
in: [[[10]],[[20]],0.25]
expected: [[18]]
Starter codePython
def alpha_blend(a, b, alpha):
    # Your code here
    pass

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