I would like to create this cartoon effect from photos just with the command line.
Desired effect examples:
Can you describe the process or give some hints to achieve this cartoon effect?
Info:
- Image 1 source: https://stackoverflow.com/a/1357489/1165509
- Related question (doing the same in GIMP): https://graphicdesign.stackexchange.com/q/63731/7253
I found a bash script for imagemagick to do that by Fred Weinhaus. His scripts are available free of charge for non-commercial use, ONLY.
Command line usage:
(more on the site itself.) What the script does ...
There are samples on his site but those are not near what your examples are. You probabaly will need to play with the settings for it to come out as what your images look like.
As you already may have found out cartoon of posterize filters from various image processing solutions may need quite a bit of tweaking to the original source before we can get results similar to your examples.
Two solutions that operate from the command line may give you results close to your examples, but the results we get still depend much on the source image used.
ImageMagick
Using the
convert
ormogrify
tool we can apply the-paint
filter for a flat-painted cartoon-like styl to our source:Replace
<strength>
with an integer to specify the brush size. The smaller the more details will be preserved. On your example I used a strength of4
for the following result:Trace to vector graphics
Better results than from bitmap operations may be obtained by tracing the bitmap to a vector graphics by using e.g. Inkscape. We could then also add strokes or adapt the resulting colors to better meet our needs.
A command-line tracer can be installed with autotrace (sadly this package is in the repositories for Ubuntu 18.04 or older only).
There are many options to tune the results obtained with using autotrace. Below example was generated with these options: