CS790 – Master of Engineering Project
Curvature-based Pen and Ink Drawings from 3-D Polygonal Objects
 
By
 
Glen Chang
Department of Computer Science
Cornell University
 
Advisor: Bruce Land

 

Abstract

The goal of this project is to develop a Win32 application for rendering 3-D polygonal objects as black and white line drawings. Using OpenGL as the rendering 3-D graphic API, we can extract the depth buffer information (Z-buffer). We can compute the mean curvature, Gaussian curvature, and Laplacian operations from the depth information. The results of the computations are then thresholded to produce a black and white image. This black and white image is easier for the viewer to perceive the surface structure than the original image especially when generating black and white only hard-copies.
 

Introduction

Pen and ink based drawings have a certain quality that makes them more perceptible for human than photo-realistic pictures or renderings. Cartoon and comic book style drawings have always used line drawings to help the reader infer shapes and objects. We would like to use the same technique perfected by cartoon and comic book artists to aid researchers in the area of scientific visualization.

Since we are interested in speed and simplicity while performing the rendering, we will only consider polygonal objects. We use object files exported by IBM Visualization Data Explorer™ and stripping the data down to only the vertex list, vertex normals list, and the face list. Using OpenGL API for rendering the polygonal object, we can extract the depth information. We then perform three different computations on the depth information. They are mean curvature, Gaussian curvature, and Laplacian convolution.
 

Method

We first construct the polygonal object from the vertex, normal, and face lists. After the image is rendered, the depth information is then extracted and stored in a buffer. Three additional buffers are allocated for storing the results for the three different computations. Since the mean curvature, Gaussian curvature, and Laplacian convolution calculations are only dependent on the depth information, they can be calculated all at the same process in parallel.

To calculate mean curvature and Gaussian curvature, we first derive five different derivatives: fx, fy, fxx, fyy, fxy. The equations are listed (1) through (5) in Equations 1.

Equation 1 – Derivatives
Equation 2 – Mean curvature
 
The equation for calculating mean curvature is listed in Equation 2. H is nonzero only near the edges of polygons and is proportional to the dihedral angle between them.
Equation 3 – Gaussian curvature
 
The Gaussian curvature equation is listed in Equation 3. It does not highlight objects as well as mean curvature since the result is often zero.

Laplacian convolution is a simple filtering/masking operation on the depth buffer. It multiplies the value of the pixel by 8 and inverse (multiply by –1) the value of its 8 neighboring pixels. Sum up the 9 values gives us the Laplacian convolution. This operator provides us a good edge-detection.

After all the measurements have been done, we will construct the composite output image which is user-defined. The user can select a combination of the three different computations or just the depth buffer. The user can also select a threshold value for each of the measurements. The threshold value is scaled logarithmically to fit within the minimum and maximum of the measurement. Once the user is satisfied with the image, he or she can elect to save it to a file.
 

The Code - RenderBW.zip

The program was written in C/C++ on the Win32 platform. The program requires OpenGL libraries be installed in the operating system for the rendering of the 3-D object. This program does not use Microsoft Foundation Class libraries.

The main concern with the program is speed. The two biggest speed bottlenecks are rendering and calculating the three different measurements. Parsing a large 3-D object file takes up considerable time also, but it does not require much optimization since it is a one shot deal.

OpenGL has a feature to compile OpenGL objects into lists. The list can be played back during repaint instead of redrawing every polygon of the object. The performance gain was not measured, but it was significant and observable to the user.

Calculating the three different measurements can be quite time consuming, therefore, we tried to minimize the frequency of this operation. We only perform this operation every thousandth of a second by setting a timer for the output window. Also, the operation would only be performed if certain user actions have caused the main window scene to change which results in the modification of the depth buffer, such as resizing window, zooming, rotating, and moving.

By separating the calculation of the measurements and the composition of the output view, the user can fine tune the output view smoothly without irritating pauses related to the calculations. Changes in the threshold dialog boxes or the combination used for output do not require recalculations.

A problem can occur while the user resizes the main window which can be difficult to resolve. The difficulty is due to resizing requires recalculating and reallocating buffers. Since calculations take a long time relatively, subsequent resize messages would be received and processed while the calculations for the previous resize message is still processing. One way around the problem would be to combine the process of calculations with the window resize messages, but this would severely impair the program’s performance.

 

The Application - RenderBW.exe

Figure 1a - Main Window Figure                                        1b - Output View Window

Figure 1a and 1b shows the two windows associated with the program. There is some basic user-interface for manipulating the object in the main window.

<arrow key> = Rotate the object

<shift> + <arrow key> = Move the object

Z = Zoom in

X = Zoom out
 

Menus and Dialog box

                                    Figure 2a - File menu                    Figure 2b - Option menu                    Figure 2c - Output menu

The size of the main window determines the image size both for viewing and storing the rendered line drawing output. The output view window displays the rendered image scaled proportionally to fit within the window.

Figure 2a through 2c shows the menus available for the user to select. To import an object to display, use the "File – Open" menu. The program currently only imports Data Explorer object file with only vertex, normal, and face information. To adjust the threshold controls use the "Option – Thresholds" menu. A dialog box will then pop up which will be explained later. To select the different measurements for output, use the "Output" menu. If "Z buffer" menu item is checked, only the depth information will be displayed. If it’s unchecked, the following three menu items will determine the composite output. To save the image of the output view, select "Output – Save Output" and a standard save dialog box will appear. Currently, the application can only save in the PGM file format.

Figure 3 – Thresholds dialog box

The thresholds dialog box (see Figure 3) allows the user to refine the output of the rendered image. There are three sets of controls corresponding to the following measurements: mean curvature, Gaussian curvature, Laplacian operator. The user can use the scrollbar(s) to adjust the threshold levels for any of the measurements. The output window is updated as the user makes changes. To accept the changes, the user should click "OK", and to undo the changes, the user would need to click "Cancel".
 

Examples

Figures 4a – 4d shows different output generated by the program rendered from the object from Figure 1a. This particular example has about 18,000 triangles making up the model. Figure 5 shows another example output of the program.
 

Figure 4a – Positive mean curvature                                               Figure 4b – Gaussian curvature
Figure 4c – Laplacian convolution                                             Figure 4d – Combination of 4a-4c
Figure 5 – Example output

 
Bugs !!!

There is currently a problem with the program when the user resizes the main window. The output window sometimes is distorted or the application could crash.
 

Future Work