How is the photoshop cutout filter implemented?

fastcall picture fastcall · Oct 26, 2008 · Viewed 11.1k times · Source

Photoshop has a lot of cool artistic filters, and I'd love to understand the underlying algorithms.

One algorithm that's particularly interesting is the Cutout filter (number 2 at the link above).

It has three tunable parameters, Number of Levels, Edge Simplicity, and Edge Fidelity. Number of levels appears to drive a straightforward posterization algorithm, but what the other sliders do technically eludes me.

I would think that they're doing something related to Vornoi diagrams or k-means partitionion, but poking around on wikipedia hasn't resulted in anything that maps obviously to what Photoshop is doing, especially considering how fast the filter renders itself.

Is there any source for technical descriptions of the Photoshop filters? Alternatively, do you have any thoughts about how this particular filter might be implemented?

Answer

Martin Beckett picture Martin Beckett · Oct 26, 2008

Edge detection is usually a Sobel or Canny filter then the edges are joined together with a chain code.
Look at something like the OpenCV library for details