or simply numpy:
assert input.shape == (height, width) # single channel
output = np.zeros((height, width, 3), dtype=np.uint8)
output[(input <= 50)] = (255,0,255)
output[(input > 100) & (input <= 150)] = (255,255,0)
output[(input > 200)] = (0,255,255)
always work through the documentation and tutorials of the technologies you use. numpy is a part of that.