How is the photoshop cutout filter implemented?

前端 未结 9 838
日久生厌
日久生厌 2021-02-03 13:21

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

9条回答
  •  悲&欢浪女
    2021-02-03 13:46

    From tinkering with it I've found out that:

    • it's deterministic
    • it doesn't do any kind of pixel based posterization to achieve final effect
    • it probably doesn't use any kind of pixel based edge detection, it seems to work rather with areas then edges.
    • it calculates the shapes closed polygons to draw (some of the polygon edges might overlap with image edges).
    • when the edges of polygons are known then color of each area enclosed in edges (not necessarily belonging to one polygon) is colored with average color of pixels of original image that area covers.
    • edge of polygon can intersect with itself. Especially visible for high edge simplicity.
    • as 'line simplicity' drops, the number of polygon edges increases, but also number of polygons increases.
    • edge fidelity influences line polygon edge count but does not influence polygon count
    • high edge fidelity (=3) causes single polygon to have very long and very short edges at the same time, low fidelity (=1) causes single polygon to have all edges roughly the similar length
    • high edge simplicity and low edge fidelity seem to prefer polygons anchored at edges of image, even at cost of sanity.

    Altogether it looks like simplified version of Live Trace algorithm from Adobe Illustrator that uses polygons instead of curves.

    ... or maybe not.

提交回复
热议问题