Take a black and white image as input and apply a 4 elements palette on it.
Move the cursor along the X-axis to set the treshold value. Press the mouse button to activate/deactivate a sort of "tuning mode" that allow to modify image colors starting from initial elements of the palette (defined at the beginning) according to the Y coordinate of the mouse cursor. Press 's' to save the output image.