Averaging is the wrong algorithm
The intuitive approach — add up every pixel and divide — fails on anything colourful, and it fails in a specific way: it always returns a desaturated brown or grey. That colour is the centre of the image's colour cloud, and in a picture with several hues the centre is empty space.
Median cut works differently. All the pixels start in one box; the box with the widest spread of colour is cut in half along its widest axis; repeat. Each final box holds pixels that are genuinely similar, and its average is a colour that actually appears in the image.
Coverage, not saturation
The results are ordered by how much of the image each colour occupies. That matters: the most eye-catching colour in a photograph is often a small bright accent, while the colour the image reads as is the large quiet one behind it.
Practical uses
- A background that sits under a photograph without a visible seam
- A placeholder tint shown while an image loads
- Checking a set of product shots for a consistent look before publishing
Questions
Why not just average all the pixels?+
Because averaging a picture with more than one hue gives brown. Red and blue in equal measure average to grey-purple, a colour that appears nowhere in the image. Median cut splits the colour space instead, so distinct hues stay distinct.
Why does it show three colours rather than one?+
Because "dominant" is rarely a single answer. The first is what covers the most area, but the second and third are usually what makes the image recognisable. They are ordered by coverage, so the top one is the answer if you only want one.
How is this different from the palette extractor?+
Same engine, fewer colours. [The palette extractor](/t/palette-extractor) is for building a scheme from an image; this is for the single question of what colour something is.
What is it useful for?+
Background colours behind a hero image, placeholder tints while a photograph loads, category colours derived from artwork, and checking whether a set of product photos shares a consistent look.