How is the photoshop cutout filter implemented?

前端 未结 9 819
日久生厌
日久生厌 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条回答
  •  梦毁少年i
    2021-02-03 13:39

    Very old question but maybe someone searching for an answer and maybe this helps. Opencv's findcontours and approxPolyDP functions can do this. But we need to prepare the image before main process. First; find most used N colors with k-means. For example find 8 colors.Find contours for each color and then calculate contourArea for all colors one by one (We will have N=8 layers). After that draw filled contours after approxPolyDP for each color from biggest ContourArea to smaller with its pre-calculated color. My another suggestion is eliminate very small contours while calculating contourArea.

    Photoshop cutout effects parameters; Number Of Levels=K-Means-find most used N colors. Edge Simplicity=I guess gaussian blur or other removing noise filters like bilateral filter or meanshift filter with edge preserving will be useful for this step.This step can be executed after K-Means and before finding contours. Edge fidelity=openCV's approxPolyDP epsilon parameter.

提交回复
热议问题