Tolerance in a perceptual space
A tolerance slider is a promise that one number means one thing. Measured as a distance in RGB it does not, and the picture where it fails is the ordinary one: a coloured object with a lit side and a shaded side.
The number that is not a number
Every colour-replacement tool has a slider marked tolerance, and almost all of them compute it the same way: take the colour you sampled, take each pixel, treat both as points in a cube whose axes are red, green and blue, and measure the straight-line distance between them. It is a reasonable-looking definition. It is also the reason those tools feel unreliable, and the failure is not subtle once you know where to look for it.
sRGB is a storage encoding. Its three axes were chosen so that eight bits per channel covers the range a display can produce without visible banding, and the transfer function that squeezes them is a compression curve, not a model of the eye. A step of thirty counts near black crosses a very large perceptual gap; the same thirty counts near white crosses almost nothing. So a tolerance of thirty is two settings at once — a tight one in the highlights and a loose one in the shadows — and in a photograph those two regions are the same object.
| Sampled value | Same value plus 30 | Roughly how different they look |
|---|---|---|
| a dark grey near 20 | near 50 | obviously two different greys |
| a mid grey near 120 | near 150 | a clear step |
| a light grey near 210 | near 240 | barely separable |
The consequence in practice is a mask that grabs half the shadow side of an object and none of its lit side, or one that selects the object correctly and also the whole of a dark background. Widening the slider fixes one end and ruins the other, which is what makes the control feel like it is fighting you.