How to cartoon-ify an image programmatically?

前端 未结 8 697
粉色の甜心
粉色の甜心 2020-11-28 17:37

My app works with photos and videos of people, which I want to cartoonify. So I need an algorithm to do it manually (we use c++/Qt for our product, which has image manipulat

相关标签:
8条回答
  • 2020-11-28 18:16

    It's relatively easy to do. Here are the steps:

    • bilateral filtering to simplify/abstract the photo. You may want to separate the bilateral filter so that it's faster. Perform the bilateral filter in 1d along the gradient and then along the normal to the gradient.

    • detect the edges. For instance, using a Difference of Gaussians algo. You may want to use the DoG in the gradient direction and smooth it following the flow lines. To get the flow lines, you would need to get the Edge Tangent Flow (ETF) which you can get via structure tensor.

    • quantize the colors. Actually, you quantize the luminance to simulate cel shading aka toon shading.

    • blend the abstracted image afer quantize and the edges you detected.

    This will give you a rendered image that looks like a cel shaded cartoon.

    I made some free software (for win64) that does exactly this at: http://3dstereophoto.blogspot.com/p/painting-software.html

    The name of the software is "The Cartoonist" and you can see it in action here: http://3dstereophoto.blogspot.com/2018/07/non-photorealistic-rendering-software_9.html

    Those are links to my blog which primarily deals with 3d photography (depth maps, photogrammetry, etc).

    0 讨论(0)
  • 2020-11-28 18:22

    actually i dont know a tool but you can look to osg (openSceneGraph)

    there is a osgFX library and there is cartoon effect... maybe you can inspire from that library...


    maybe (i dont know) imagemagick has many features, maybe it has a feature like that but i dont know...

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