Chris Mueller

Van Gogh

Matt Handley, Chris Mueller, Justin Von Stroh
Fall, 2004

View the source code.

 

Van Gogh is a program we developed to perform basic image manipulation functions. The program reads a PPM image file and is drawn with the OpenGL function glDrawPixels. Using callback functions from the mouse and keyboard, we implemented the following series of features. Images generated can be saved in the PPM format.

Pen tool. The user is able to specify the color of the pen, then can draw on the image using the mouse. When this was first implemented, the pen did not draw a smooth line. Instead, it drew a bunch of scattered dots along the trail of our mouse. This was because the mouse input was not refreshed often enough. To compensate, we implemented the Bresenham line algorithm to draw smooth lines.
Oil paint tool. This brush tool attempts to mimick an oil paintbrush on a canvas of wet paint. Colors from one portion of the image are spread and blurred along the path of the mouse.
Blur. Using a kernel mask (see below), we were able to blur the entire image.
Edge detection. Using kernel masks (see below), we were able to find edges of the image. Variations on the mask produced horizontal or vertical edges.
Grayscale. This converts the image to a grayscale image that includes a user-specified number of gray levels.
Darken.
Lighten.
Auto contrast. This first converts the image to a grayscale image, then finds the maximum and minimum value. Every gray level is then scaled to the associated level between pure black and pure white.
Negative.

 

A special note on the kernel masks and pixel group processing. A good way to run a filter over an entire image is create a "mask" and then apply that mask to every pixel in the image. This mask will take into account pixel values surrounding every pixel, usually performing some sort of combination on the values of a pixel and its neighbors. For example, we could create a 3x3 mask such as the one shown here:

1/9 1/9 1/9
1/9 1/9 1/9
1/9 1/9 1/9

When we apply this mask, we place it on top of the image, then multiply the value in a given position in the mask by the value of the pixel at the corresponding location in the image. We add up all nine of these values, and that sum becomes the new value for the pixel in the middle of the mask (this value is stored in a local copy of the image). We then move the filter to a new position in the image and repeat. Using the mask shown above, we blur the entire image. Other masks used by Van Gogh are shown below.

0 -2 0
-2 8 -2
0 -2 0
General Edge Detection
0 -2 0
0 2 0
0 0 0
Horizontal Edge Detection
0 0 0
-2 2 0
0 0 0
Vertical Edge Detection

 

CG Index Square Fountain Van Gogh Raytracer Computer Vision
© cm