Image Processing Plug-Ins

Here we describe some details about how to implement the image-processing plug-ins.


Blur - The blur plug-in takesan image as input and produces a blurred version of that image. Blur can be expressed a filtering operation that replaces each pixel in the input image with a weighted average of a set of pixels centered around the original pixel. The kernel of the blur filter is defined as the set of pixels that are averaged together; it has some width and height of N pixels.

Perhaps the simplest blur filter is the box filter, which replaces each pixel with the unweighted average value of the pixels in the blur kernel. You must implement a box filter blur plug-in that allows the kernel size N to vary between 1 and 21, rounding off to the nearest odd integer (It is more difficult to blur with even size box filters, can you explain why?). The kernel size N should be attached to the slider provided by the video-editor.

Template files: Blur.c, BlurSeparable.c

Written questions: Some filters (the box filter) can be written as separable filters, which is a way of expressing them as the composition of two one-dimensional filters, rather than as a single two-dimensional filter. For the box filter, this means that an equivalent filtering operation is to first filter the image horizontally with an N by 1 box filter and then filter that image vertically with an 1 by N box filter.

1. Work out the math and demonstrate that the non-separable and the separable versions of the box filter compute the same result.

2. What is expected number of pixels accessed (which should be proportional to running time) in big-O notation, for the separable versus non-separable version of a filter? Implement both versions of the box filter and run them with wide kernels. In practice, how does the reported running time match up with your prediction?


Compositing - Implement the compositing operators over, out, and xor, as described in the handout Compositing Digital Images by Porter and Duff. Each compositing operator takes two frames containing premultiplied (r,g,b,a) pixels as input and produces one output frame containing premultiplied (r,g,b,a) pixels. The parameter value should be ignored for this plugin.

Template files: Over.c, Out.c, Xor.c

Written question: Assume that the SGI's processor can execute at most one instruction at a time, that add and multiply instructions take 1 clock cycle, and that divides take 20 clock cycles; ignore other effects on performance (e.g. cache misses). How many cycles would you expect the over operator to take when given two 512x512 images when pre-multiplied alpha is used for both source and destination images. What about when pre-multiplied alpha isn't used for source or destination? Implement Over with each assumption; how does the running time reported by the effects program relate to the number of cycles you estimated? (Note: only turn in the version of Over that assumes premultiplied alpha.)


Magnify, Translate, Rotate - The magnify plug-in scales the image up by a factor ranging from 1.0 to 5.0. You should allow a continuous range of scale factors (i.e. floating point values between 1 and 5) and the scale factor should be attached to the slider. One way to magnify an image is to map each output image pixel position its corresponding position in the input image. For example if the magnification factor is 2.25, then the output pixel position Po = (10,23) would map to Pi = Po/s = (10/2.25, 23/2.25) = (4.444,10.222) in the input image. To determine the pixel value at Pi we then bilinearly interpolate the values of the four closest input pixels, which would be the pixels at input image locations (4,10), (4,11), (5,10) and (5,11).

For translation, the plug-in should translate an input frame by some amount (x,y), and as described earlier you should allow the user to set both of these parameters from the keyboard in the pluginStart callback function. Like the magnification scale factor the translation offsets (x,y) should be floating point values and you should use bilinear interpolation to determine the output image pixel values.

For rotation, the user should be able to rotate the input frame by some angle theta; you should scale the slider value to be between 0 and 360 degrees and rotate by this amount. Again, bilinear interpolation should be used to resample the image.

Template files: Magnify.c, Translate.c, Rotate.c


More information on extra credit suggestions

Minify - Scale down an input frame by a scale factor ranging from 1 to 1/5. In this case as for Magnify, the scale factor is a floating point value. With minification each pixel of the output image combines many pixels of the input image. You should average together the input image pixels that correspond to each out image pixel.

Non-Linear Warp - Warp the input frame using some non-linear warp (i.e. resample the image with some f(x, y) that is non-linear (e.g. a sinusoidal function). One of the example images (and videos) is a magnifying glass with fractional alpha values in the interior of the glass; you might use these fractional alphas to select a region of the image and warp it in a way that simulates magnification of the image underneath it.

Impressionistic Painting - Write a plug-in that automatically creates an impressionistic version of the input frame using one of the basic brush types from assignment 1.


CS248: Introduction to Computer Graphics, Pat Hanrahan, Fall 1998