Monday, July 9, 2018

Non Photorealistic Rendering Software - The Cartoonist

"The Cartoonist" is software to abstract and stylize an input photograph in such a way that the output photograph kinda looks like a cartoon with thick lines and cel shading (toon shading). Details of the methodology can be found in Non Photorealistic Rendering - Image Abstraction by Structure Adaptive Filtering as well as a relatively thorough description of the parameters used by "The Cartoonist". The code comes from a "Processing" implementation by Thomas Lindemeier which I ported to C++ and to which I added support for basic image formats: jpeg, png, and tiff. At some point, I may re-implement the whole thing as I don't particularly like using other people's code.

When you extract thecartoonist-x64.rar, you should see something like this:


The directory "barn1024" shows how to use the software. If you go into "barn1024", you should see something like this:


The file called "thecartoonist.bat" is the one you will double-click to run the software. It tells windows where the executable is. You need to edit the file so that the location of the executable is the correct one for your installation. I use notepad++ to edit text files but I am sure you can use notepad or wordpad with equal success.

The file that controls the input to the software is "thecartoonist_input.txt". It should look like this:

barn1024.jpg
3.
2
4
3.
4.25
1
1.
0.99
3.
2.
3.
8
cartoon_image.png

Line 1: name of the input photograph (here, barn1024.jpg). There should be no spaces in the image name.

Line 2: tensor_sigma (here, 3.)

Line 3: n_e (here, 2)

Line 4: n_a (here, 4)

Line 5: sigma_d (here, 3.)

Line 6: sigma_r (here, 4.25)

Line 7: fdog_n (here, 1)

Line 8: fdog_sigma_e (here, 1.)

Line 9: fdog_tau (here, 0.99)

Line 10: fdog_sigma_m (here, 3.)

Line 11: fdog_phi (here, 2.)

Line 12: phi_q (here, 3.)

Line 13: quant_levels (here, 8)

Line 14: name of the output image (here, cartoon_image.png). There should be no spaces in the image name.

The meaning of the parameters that control the "The Cartoonist" are explained in Non Photorealistic Rendering - Image Abstraction by Structure Adaptive Filtering.

The Cartoonist outputs a bunch of images during to the course of its execution. They are (in alphabetical order):
- abstracted_image_after_oabf.png. This is after the "Separated Orientation Aligned Bilateral Filter" (aka "Separated OABF" or simply OABF) has been applied for n_e iterations to the currently rendered image.
- abstracted_image_after_oabf2.png. This is after the "Separated Orientation Aligned Bilateral Filter" (aka "Separated OABF" or simply OABF) has been applied for n_a-n_e iterations to the currently rendered image (after the edges have been detected).
- abstracted_image_after_quantize.png. This is after the currently rendered image has been color quantized. This is a very important image as it can be used in other software such as "The Watercolorist" as input photograph.
- edges_image.png. This image shows the detected edges by the "Separated Flow-based Difference of Gaussians" (aka "Separated FDoG" or simply FDoG).
- tangent_flow.png. This image shows the local orientation aka the Edge Tangent Flow (ETF). It was obtained using Line Integral Convolution (LIC).


abstracted_image_after_oabf.png


abstracted_image_after_oabf2.png


abstracted_image_after_quantize.png


edges_image.png


tangent_flow.png

Here is the output produced by "The Cartoonist" (cartoon_image.png), a blend of the abstracted image after color quantization and the edges image:


Check out The Cartoonist - Ford GT40 at Le Mans 24 hours race in 1968 for a probably better example of what "The Cartoonist" can do artistically.

"The Cartoonist" is free to download at Painting Software.

Source code: thecartoonist on github.

2 comments:

  1. This is excellent! Thanks for making it available.

    ReplyDelete
  2. In computer science there are people who talk and people who really program, you are one of the latter

    ReplyDelete