All problems
Ordered Dithering 2x2 Bayer
Problem
Apply 2x2 ordered dithering with the Bayer matrix [[0, 2], [3, 1]].
A pixel becomes 255 when its value is strictly greater than 255 * (m + 0.5) / 4, where m is the matrix entry at (i mod 2, j mod 2); otherwise the pixel becomes 0.
Test cases
case 1
in: [[[32,96],[160,224]]]
expected: [[255,0],[0,255]]
case 2
in: [[[32,160],[224,96]]]
expected: [[255,255],[255,255]]
case 3
in: [[[0,0],[0,0]]]
expected: [[0,0],[0,0]]
case 4
in: [[[255,255],[255,255]]]
expected: [[255,255],[255,255]]
Starter codePython
def bayer_dither(image):
# Your code here
pass4 test cases · run your code against them in the editor