How is the photoshop cutout filter implemented?

前端 未结 9 832
日久生厌
日久生厌 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:22

    I'm not sure it could be some kind of cell shading, but it also looks like a median filter with a very big kernel size or which was applied several times.

    The edge simplicity/fidelity might be options which help decide whether or not to take in account an adjacent pixel (or one which falls inside the kernel) based on difference of color with the current pixel.

    0 讨论(0)
  • 2021-02-03 13:30

    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

    0 讨论(0)
  • 2021-02-03 13:32

    Did you see this post. It explains how to get the same result using ImageMagic, and IM is opensource.

    0 讨论(0)
  • 2021-02-03 13:32

    The number of levels seems to resemble how cell-shading is done and this is how I'd implement that part in this case: you simply take this histogram of the image and divide it into the "No. of levels" amount of sections then calculate an average for each section. Each color in the histogram will then use that average in stead of their original color.

    The other two parameters require some more thinking but 'Edge simplicity' seems to detonate the number of segments the shapes are build up off. Or rather: the number of refinements applied to some crude Image Segmentation Algorithms. The fidelity slider seems to do something similar; it probably controls some kind of threshold for when the refinements should take place.

    This might help

    0 讨论(0)
  • 2021-02-03 13:34

    I imagine it's probably some thresholding, edge-detection (Sobel/Canny/Roberts/whatever) and posterisation.

    0 讨论(0)
  • 2021-02-03 13:37

    Got a simple solution, which would theoretically produce something similar to that filter. Somehow similar to what Ismael C suggested.

    Edge Simplicity controls window size. Maybe window should be weighted.

    But unlike it happens for regular windowed filters this one would take only a fixed size portion of random pixels from this window. The size of the portion is controlled with Fidelity parameter.

    Set the pixel color to the median of the sample.

    Given we have some posterization algorithm, it is applied afterwards.

    Here we go!

    Please report results if you implement it.

    PS. I really doubt that segmentation is used at all.

    0 讨论(0)
提交回复
热议问题