How is the cartoon image programmatically?

My application works with photos and videos of people who I want to multimonize. Therefore, I need an algorithm for this manually (we use C ++ / Qt for our product, which has image manipulation classes) or, perhaps, some CLI program that will do this for me, which I can call and use from our own application.

+61
algorithm command-line-interface image-manipulation
Aug 31 '09 at 13:11
source share
8 answers

Here are some algorithms to play with:

  • Median or repeating drawer blur filter to get a cartoony color palette
    • Edit: Two-way filtering should better suit your needs.
  • Minimum filter (zero percentile) to improve some types of edges.
  • Segmentation of a color image using either a small subcube or sphere in the RGB color cube
  • Improving the overall edge of a segmented image using edge detection such as Sobel kernels or 8-sided border tracing
  • Blurred / Medium Composite Image with Extended Ribs

These are pretty simple and very easy to implement. Keep in mind that median and fuzzy filters can be implemented with linear time complexity wrt core radius.

Additional changes:

Once you get the idea of ​​the Huang algorithm, the implementation of the box blur filter is a delicious piece of cake.

Reading material:

  • Fast median and two-way filtering (get PDF)
  • Median Filtering Constant time (get PDF) Note: I have an implementation of this in C # using Mono / SIMD to speed up the merging of histograms, however it seems better than the O (r) algorithm when the diameter exceeds ~ 60 pixels due to comparable the number of additional / auxiliary instructions (break-even point), the C ++ implementation is probably much better suited for using SIMD.

Other reading materials include Gonzalez and Woods image processing (this seems to be an older edition) for segmenting and tracing borders. An 8-sided edge tracing can be very difficult to tilt your head (choosing between pixels in pixels or between pixels and how to snap on edges). I would be happy to share some code, but the hundred-liners here do not fit exactly.

+47
Aug 31 '09 at 13:39
source share

You can try rotoscopy, for example toonyphotos.com :

rotoscopy example

+22
Aug 31 '09 at 13:32
source share

You might want to check out Freestyle , an open source project (even Google Summer of Code, even) to implement a non-photorealistic render for Blender . Here is an example of its output, in animated mode: alt text
(source: sourceforge.net )

+12
Aug 31 '09 at 14:31
source share

If there is a set of parameters that achieve the desired effect in the GIMP Cartoon Filter (or some other combination of filters), it can be launched in batch processing mode.

+7
Aug 31 '09 at 14:09
source share

I didn’t do this myself, but I thought about two steps that could give the image a cartoony look.

  • Finding edges and superimposing on them a rather fairly thick line (a few pixels).

  • Reduce the number of colors in your image.

+6
Aug 31 '09 at 13:18
source share

Not sure if this will help, but this Photoshop tutorial suggests the following:

  • Open an image in Photoshop
  • Filter> Blur> Gaussian Blur. Set a radius of 3.0 or higher to try.
  • Edit> Reject Gaussian Blur. A window appears., Set the dimming mode. You may also need to reduce the opacity.

Here is the result.

enter image description here

I guess you could do something similar in your program.

+5
Aug 31 '09 at 13:22
source share

This is relatively easy to do. Here are the steps:

  • two-sided filtering to simplify / abstract the photo. You can separate the two-way filter so that it works faster. Perform a 1-sided filter at 1d along the gradient and then normal to the gradient.

  • detect the edges. For example, using the differential of the Gaussian algorithm. You can use DoG in the direction of the gradient and smooth it along the flow lines. To get the streamlines, you need to get the Edge Tangent Flow (ETF), which you can get through the structure tensor.

  • quantize colors. In fact, you quantize brightness to simulate cel or toon shading shading.

  • mix the abstract image after quantization and the edges that you find.

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

I have made several free programs (for win64) that do just that at: http://3dstereophoto.blogspot.com/p/painting-software.html

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

These are links to my blog, which is mainly devoted to three-dimensional photography (depth maps, photogrammetry, etc.).

+3
Jul 10 '18 at 14:50
source share

I don’t actually know the tool, but you can look at osg (openSceneGraph)

there is an osgFX library, and there is a cartoony effect ... maybe you can inspire this library ...




maybe (I don’t know) imagemagick has many functions, maybe it has such a function, but I don’t know ...

+1
Aug 31 '09 at 13:15
source share



All Articles