A colour is not yet a shape
The previous stage decided, pixel by pixel, which of a small set of inks each pixel most resembles. That decision has no notion of shape at all. It does not know that a lone stray pixel is noise rather than a shape of its own. It does not know that a thin ribbon of in-between colour running along a boundary is only the blur of anti-aliasing, not a third ink. It does not know that two blobs of identical colour on opposite sides of the picture are two different objects. And it cannot tell, on its own, whether two shapes that touch at a single pixel corner are one connected mark or two shapes that happen to kiss.
This stage answers each of those questions in turn, and hands the next stage a set of connected, single-ink regions it can trust.
The sliver problem
Every soft edge between two inks is, in the label map, a thin ribbon of pixels that were each assigned to whichever palette colour they happened to sit nearest — often neither of the two inks actually forming the edge, but some third colour that happens to sit nearby in colour space. Left alone, that ribbon becomes its own skinny region: a sliver, with its own boundary on both sides, running the whole length of every edge in the picture. On one 36-cell test mosaic, leaving slivers unabsorbed turned a scene with a true count of 37 flat regions into 128 separate faces.
The fix is not to erase the ribbon, but to ask what mixture of real inks would explain its colour, and give each sliver pixel back to the ink that mixture says it mostly is. A pixel that reads as seventy percent dark outline and thirty percent mid-brown is, physically, an outline pixel — even though, measured by plain colour distance, it might sit nearer the brown.
Each candidate sliver is tested against up to three neighbouring inks at once, because a ribbon sitting at a three-way junction, or under a shape that pokes out slightly from beneath another, is a mixture of three colours, not two. A component is only absorbed once at least four fifths of its pixels fit that mixture within a tolerance set from the picture's own measured noise. A second, pixel-by-pixel pass catches the slivers that slip past even this — the case where anti-aliasing between two cells happens to land on a third cell's own colour and fuses into a large region with it, too big to look like a thin ribbon at all.
Same colour, different objects
Colour alone cannot tell two separate shapes of the same ink apart. Two dots of identical red on opposite sides of a logo are, to a colour label, indistinguishable — but they are two different marks, and treating them as one region has real consequences beyond tidiness. A region drawn from several disconnected pieces has no single flat colour and no single sensible fill shape; asked to explain the left-over difference between its pieces, the fitting stage further downstream will happily invent a gradient to cover a difference that was never a gradient at all — it was simply two unrelated objects sharing a palette entry.
This stage separates every region into its actually-connected pieces before anything else is decided about its fill. Two same-coloured shapes that do not touch become two independent regions, each free to be measured, edited, and filled on its own terms.
The one true ambiguity: four pixels at a corner
There is exactly one situation a pixel grid cannot settle by itself. Picture four pixels meeting at a single shared corner, arranged so the two pixels on one diagonal are one ink and the two on the other diagonal are a second ink — a chequerboard corner. Read one way, the two same-coloured pixels are corners of one connected shape that happens to pinch down to nothing at that single point, like an hourglass. Read the other way, they are two separate shapes that simply touch at a point. Nothing in the four pixels themselves says which is true — both readings explain the same four colours equally well.
This stage resolves the ambiguity by going back to the picture itself, not the label map, and asking how much of each of the two inks actually covers each of the four pixels. Those four coverage fractions are combined into a single estimate of which ink genuinely owns the exact corner point, together with an honest measure of how uncertain that estimate is — carried through from the same pixel noise used throughout the tracer. Only when the reading clears a firm statistical margin is the corner actually merged one way or the other; below that margin, the two readings are indistinguishable and the corner is left exactly as found, neither welded nor split.
That caution matters concretely on a real chequerboard pattern — a QR code, a chequered flag — whose corners genuinely sit exactly on the boundary between the two readings, because the two squares really do meet at a single point and neither reading is truer than the other. Forcing a decision there on nothing more than rounding noise was measured to cost real accuracy on one icon on its own.
What this stage hands forward
The output is a face per connected, single-ink shape: speckle gone, anti-aliasing folded into whichever ink it actually belongs to, disconnected same-coloured shapes told apart, and every four-way corner either resolved with real statistical confidence or left honestly undecided. Everything from here on — fitting a gradient to a region, tracing its boundary, deciding where curves bend — works on this set of faces, not on the raw colour labels underneath it.