Image filter
An image filter is one rule applied to every pixel of a picture in the same way. Grayscale, sepia and invert are filters of this kind. Each takes a pixel's red, green and blue values and works out new ones from them, without looking at where the pixel sits or what it shows.
Most changes to a picture depend on what is in it: remove this person, lighten that face, blur those numbers. A filter does not. It is a rule that turns one pixel’s colour into another, applied identically to every pixel.
How the common filters work
Each pixel holds a red, a green and a blue value, usually from 0 to 255. Grayscale replaces all three with one weighted average, giving green the most weight because the eye is most sensitive to it. Sepia mixes the three channels with a different set of weights, so that the result leans towards brown. Invert subtracts each value from 255, so black becomes white and blue becomes yellow.
Because each rule is a fixed table of weights, these filters are often written as a colour matrix. The W3C Filter Effects specification, which browsers follow for the CSS filters, gives the exact numbers for grayscale and sepia.
What a filter keeps
A filter changes colour, not shape. The size, the sharpness and the position of everything in the picture stay the same, and so does transparency if the filter leaves the alpha channel alone, as these do.
What it can lose is information. Grayscale throws away hue for good, so it cannot be undone, while invert can be reversed exactly. Saving as JPEG after any filter adds its own small losses.
When to use one
Filters suit jobs where every picture should change the same way: a set of product shots toned to match, scans turned grayscale to shrink them, or a dark screenshot inverted for printing. Where only part of a picture needs work, an editor is the better tool.
Frequently asked questions
Is a filter the same as editing a photo?
No. Editing usually changes part of a picture, such as a blemish or a background. A filter treats every pixel alike, which is why it can be applied to a whole batch of photos in one pass.
Does inverting twice give back the original?
Yes. Inverting replaces each value with 255 minus itself, so doing it again returns the starting value exactly, as long as the file was saved without lossy compression in between.
Why does a sepia photo look different in two programs?
Because sepia is a family of looks, not one rule. Programs use different colour weights, and some also add contrast or grain. The CSS sepia filter publishes its weights, which makes its result repeatable.