Sunday, July 8, 2018

Non Photorealistic Rendering Software - The Painter

"The Painter" is software to painterly render a photograph. Details of the methodology can be found in Non Photorealistic Rendering - Stroke-Based Rendering (SBR).

After you have extracted thepainter-x64.rar (windows 64 bit), you should see a directory called "altered_carbon". It contains everything you need to check that the software is running correctly. The file called "thepainter.bat" is the one you 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. If you want to use "The Painter" on your own photograph, create a directory alongside "altered_carbon" (in another words, at the same level as "altered_carbon"), copy "thepainter.bat" and "thepainter_input.txt" from "altered_carbon" to that new directory and double-click "thepainter.bat".

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

01-altered-carbon-104.w1200.h630.jpeg
../texture/canvas01/rgb.png
../texture/canvas01/bumpity.png
4
64 1.0 1.0 10.0 0.5
32 1.0 1.0 10.0 0.5
16 0.5 0.5 10.0 0.5
8 0.5 0.2 20.0 0.5
1
../texture/brush07/opacity.png
../texture/brush07/bumpity.png
0.00001
canvas_rgb_image.png
canvas_bumpity_image.png

Line 1 contains the name of the reference photograph you want to render (here, 01-altered-carbon-104.w1200.h630.jpeg). There should be no spaces in the image name.

Line 2 contains the name of the initial canvas rgb image. I would not worry too much about that one and just use ../texture/canvas01/rgb.png.

Line 3 contains the name of the initial canvas bumpity image. I would not worry too much about that one and just use ../texture/canvas01/bumpity.png.

Line 4 contains the number of brush radii to use (here, 4).

For each brush radius (going from large to small), there should be a line in the following format:
brush_radius opacity_strength bumpity_strength error_threshold grid_size_factor

The brush radius "brush_radius" is the radius of the brush to be used to paint the strokes on the canvas. I usually use the following brush radii: 64, 32, 16, 8, and possibly 4. You don't want to use a brush radius that is too small since the painting is gonna look exactly like the photograph, which is not what you want.

The opacity strength "opacity_strength" is a number from 0.0 to 1.0. The larger the opacity strength, the more opaque the brush strokes are going to be (in the canvas rgb image). More transparent brush strokes lead to a smoother, more blended look.

The bumpity strength "bumpity_strength" is a number from 0.0 to 1.0. The larger the bumpity strength, the more height the brush strokes are going to have (in the canvas bumpity image). In other words, the larger the bumpity strength, the more visible the brush strokes are going to be when the canvas image is bumpmapped by the bumpity map (using the bump map filter in Gimp).

The error threshold "error_threshold" controls how the brush stroke colors should match the reference photo. The larger the error threshold, the coarser the painting will look.

Don't worry too much about the grid size factor "grid_size_factor" and just use 0.5.

Line 9 contains the number of brush textures to be used (here, 1);

For each brush texture, there should be 2 lines telling the program where the opacity image file and the bumpity image file are located.

Line 12 contains the Gaussian blur sigma factor (here, 0.00001) aka f_sigma. The larger the Gaussian blur sigma factor, the more blurring is applied to the reference photo prior to painting the brush strokes.

Line 13 contains the name of the output canvas rgb image (here, canvas_rgb_image.png). There should be no spaces in the image name.

Line 14 contains the name of the output canvas bumpity image (here, canvas_bumpity_image.png). There should be no spaces in the image name.

The brush textures are stored in the "texture" directory. What does a typical brush texture look like? Let's have a look at the brush texture images for brush07.


Brush texture opacity image for brush07.

As you build up layers of paint on the canvas with brush strokes, if the opacity is high (grayscale value is close to white), the paint that's underneath the current brush stroke will not be seen by transparency. If the opacity is low (grayscale value is close to black), the paint that's underneath the current brush stroke will be seen by transparency. The lower the opacity, the more the paint that's underneath will show. If the opacity is pure black, the current brush stroke will not deposit any paint on the canvas.

The opacity value coming from the brush texture opacity image is multiplied by the opacity strength to give the actual opacity value that's gonna be used. So, for example, if the opacity strength is set at 0.5, the opacity that is actually used is half the opacity that's in the brush texture opacity image. This enables to change the opacity quite easily without having to change the brush texture opacity image.


Brush texture bumpity image for brush07.

I am calling the brush height map the brush bumpity map because it rhymes with brush opacity map. It's really a brush bump map which is applied to the canvas bump map (aka canvas height map or canvas bumpity map). The brush bumpity map describes the height of the paint that's deposited by the brush. If the value is middle gray (grayscale value = 128), there is no bump and the paint is laid flat. The white the value, the more height the paint will have when it is deposited by the brush stroke. Here, we are simulating impasto oil painting which is characterized by thick layers of paint.

Just like with opacity, the actual bumpity used is the bumpity in the brush texture bumpity image times the bumpity strength.

Feel free to create your own brush textures! Note that you can use as many brush textures as you want. As a brush stroke is about to be applied, the program randomly assigns a brush texture to the brush stroke among the ones provided in the input file. In this example, I only provide one because I found out that it doesn't make that much of a difference whether you supply one single brush texture or a bunch of them. You really have to experiment with the brush textures to see what you like best.

Now that we have a better idea of what's in "thepainter_input.txt", let's see the what "The Painter" does on that reference photo (the one from the "altered_carbon" directory).


This is the reference photograph.


This is the canvas rgb image produced by "The Painter".


This is the canvas bumpity image produced by "The Painter".

To apply the canvas bumpity map to the canvas rgb image, I use gimp:

- Open as layers the canvas rgb image and the canvas bumpity image
- Activate the layer containing the canvas rgb image and click on Filters->Map->Bump Map
- For the Bump Map, choose the canvas bumpity image
- You may want to adjust the Depth Parameter to adjust the height
- Click OK and then export the bumpmapped image


This is the canvas rgb image bumpmapped.

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

No comments:

Post a Comment