Explore Library
Code QuizIntermediate

Binary Thresholding

A thresholding operation produces an inverted mask by assigning the output values backwards.

Codepython
import numpy as np

# gray is a grayscale image, values 0..255
# Want: pixels brighter than 128 -> white (255), else black (0)
binary = np.where(gray > 128, 0, 255)

What is the bug in this thresholding code?