Contour Output

After the regular image has been computed, a contour output shader can get the contour line segments and use them to for example render a contour image or write a file with contour information. The user can write contour output shaders using the built-in function mi_get_contour_line.

There are three contour output shaders in contour.so. They can generate a contour image, a contour image composited over the regular image, and a PostScript file with black contours. The output shader has to be specified in the camera.

To get a contour image called mycontourimage.rgb in rgb format, write

     output "contour,rgba" "contour_only" ()
     output "rgb" "mycontourimage.rgb"

To get an image called mycontourimage2.rgb (in rgb format) containing contours composited over the regular image, write

     output "contour,rgba" "contour_composite" ()
     output "rgb" "mycontourimage2.rgb"

The contour_composite output shader has two optional Boolean parameters: glow and maxcomp. The glow parameter makes all contours become darker and more transparent near their edges, creating a glow effect. maxcomp specifies that when a contour is over another contour, the maximum of the two colors (in each color band) should be used. If maxcomp is not specified (or set off), normal alpha compositing is used. The contour_only output shader also has the glow and maxcomp parameters, and in addition it has a background parameter which determines the background color (default is black).

To get a PostScript file called mycontourfile.ps with all contours in black, write

     output "contour,rgba" "contour_ps" (
        "paper_size"         4,
        "paper_scale"        1.0,
        "paper_transform_b"  0.0,
        "paper_transform_d"  1.0,
        "title"              on,
        "landscape"          on,
        "ink_stroke_dir"     1.0 1.0 0.0,
        "ink_min_frac"       0.1,
        "file_name"          "mycontourfile.ps"
     ) 

The PostScript file in this example gives A4 paper size with full scale. "paper_size" is an integer, with 0 indicating "letter" size, 1 indicating "executive", 2 indicating "legal", 3-6 indicating "a3", "a4", "a5", "a6", 7-9 indicating "b4", "b5", "b6", and 10 indicating "11x17". The parameter paper_scale scales the PostScript output. Furthermore, the Postscript coordinates are transformed according to the matrix

( b )
d

where b and d are the parameters "paper_transform_b" and "paper_transform_d". This makes it possible to compensate for printers that print out with a slight skew. The Boolean title determines whether a title (consisting of file name and frame number) and a frame around the image are written. The Boolean landscape makes the output be in landscape mode rather than portrait mode. If the parameter ink_stroke_dir is set, each contour segment will have a width that depends on its orientation, giving an ink pen look. For the ink pen look, ink_min_frac specifies the minimum fraction of the original contour thickness (at contour segment orientations perpendicular to the stroke direction). The file_name specifies the name of the file that the contours are written to.

It is also possible to get both the regular image (without contours) and one of the above at the same time. For example, to get the regular image and an image of the contours, write

     output "rgb" "myimage.rgb"
     output "contour,rgba" "contour_only" ()
     output "rgb" "mycontourimage.rgb"

Copyright © 1986-2009 by mental images GmbH