Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-060

Double Threshold Classification

Problem

Classify pixels with a double threshold.

Return 255 when v > high, 128 when low < v <= high, and 0 when v <= low. Both low and high comparisons are strict on the low side.

Test cases

case 1
in: [[[0,50,100],[150,200,255]],50,150]
expected: [[0,0,128],[128,255,255]]
case 2
in: [[[0,0],[255,255]],100,200]
expected: [[0,0],[255,255]]
case 3
in: [[[50,50]],50,100]
expected: [[0,0]]
case 4
in: [[[100]],50,100]
expected: [[128]]
Starter codePython
def double_threshold(image, low, high):
    # Your code here
    pass

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