Project 1 Commands

In all cases, it is important that your program is robust in the face of bad inputs. It should never crash.

Some operations are required of all programs. Other operations are optional, but doing more optional parts is what gets you a better grade.

It is important to describe all optional things that you've done in your documentation!

R: Required; O: Optional

Basic Commands R/O Points Explanation
read V filename R 0 Read filename into variable V. Filename must end in .tga. Warning: spaces in filenames don't work (since we break words at spaces)!
write V filename R 0 Write filename from variable V. Filename must in in .tga. Warning: spaces in filenames don't work (since we break words at spaces)!
blank V w h R 0 Create a blank image of size w (width) by h (height) pixels (w and h are integers). The image should be black with alpha value of 255 (100%). The new image is stored in variable V.
fill V x1 y1 x2 y2 r g b a R 3

x1,y1,x2,y2,r,g,b,a are all integers. Fills a rectangular region of the image in variable V with the color (r,g,b,a).

(x1,y1) (x2,y2) specifies a rectangular image INCLUSIVE of the values. so the command:

fill 10 10 20 20 0 0 0 255

does change the pixel (20,20). If part of the specified region is outside the image boundary, your program should fill the part that's within the image.

copy V U R 2 Make a copy of the image in variable V and place it into variable U.
Image Adjustment R/O Points Explanation
darken V a R 0 Multiply the colors of V by floating point number a.
rgb2grey V U R 3 Convert an RGB image V to a grey scale image U, using this formula brightness = 0.3 R + 0.59 G + 0.11 B
desaturate V a R 5

Desaturate the colors of image V by the amount floating point number a between 0 and 1. Desaturating by 1 (100%) means totally removing the color (it should give a grayscale image). Desaturating by 0 doesn't change the image. .5 (50%) is halfway inbetween. In desaturation, the luminance (or brightness) of each pixel should remain (approximately) the same.

You can use the above formula to compute the brightness.

Image Filtering R/O Points Explanation
blur V k R 5 Blur image V by repeatedly applying the kernel

(1/16 [1 2 1; 2 4 2; 1 2 1])

k times.

sharpen V (params) O 5 Sharpen image V using some sharpening methods that you learned about on the web, for example, this website.  We discussed this idea in the class as well. Since we don't know what method you'll implement, we don't know what parameters your command will take. Be sure to explain what you did in your documentation.
Image Resampling R/O Points Explanation
resize V sa sb R 8

Resizes image V by scale factor sa/sb (where sa and sb are integers). We express the scaling as a ratio of integers to allow you to exactly specify things like 1/3.

You can vary the difficulty (and get optional points) by implementing better sampling and reconstruction.

The basic version of this would implement point sampling (pixel replication for upscaling, dropping every Nth pixel for down sampling) for integer scale factors.

In your documentation you must describe the sampling and reconstruction methods that you use.

stretch V xa xb ya yb O 10 Do a resize where the image is scaled by xa/xb in the X direction and ya/yb in the Y direction.
rotate V t R 8 Rotate image V by angle t around the center of the image, where t is a floating point number giving a number of degrees to rotate counter-clockwise. Your program should not change the size of the image (so some parts of the image may get chopped off, and other parts of the result may be empty - you should fill them with black).

The basic version of this command can rotate by 90 degree increments. More advanced versions of the command can rotate by arbitrary amounts. The best implementations will use good sampling to avoid aliasing.

nlwarp V U O 15

You can implement different non-linear warping functions to warp V and save it in U. You can pick any warps that you want - swirls, ripples, fisheye effects, etc.

Optional points can be earned by implementing better resampling methods, and for creating more complex types of warps (such as ones where you specify how a grid of points move).

Because every kind of warp may need different parameters, the exact syntax of your command is up to you. You'll get to show off your warps when you demo your program.

You should make sure that your warps show off your sampling methods. Since your warp compresses the image in some places and stretches it in others, ideally, you should use different sampling kernel at different places, as described in Paul Heckbert's master thesis here. We did not cover in the class.

Your documentation should make clear what the warping functions are and what sampling methods that you have done.

Nonphotorealistic Rendering R/O Points Explanation
paint1 V R 40 Apply a simplified version of Aaron Hertzmann's painterly rendering algorithm from the 1998 SIGGRAPH Paper Painterly Rendering with Curved Brush Strokes of Multiple Sizes. You need only implement the multiple (circular) brush size version from section 2.1 of this paper.

Your implementation should use the brush size radii of 7, 3 and 1. When calling the Gaussian-blur function, use the filter constructed using the binomial coefficients with a filter size of

2 × radius + 1
The fg parameter should be set to 1, and the threshold parameter T should be set to 25.

The difference function in Hertzmann's pseudo-code is simply Euclidean distance (as specified in the text below the paintLayer figure), so you'll need to compute and store these distances on a per-pixel basis.
paint2 V O 15 It's high recommended that you try other stroke types and parameters, for example, in last semester's project. Also, try to make the strokes be adapted to the input image structures, like the edges. Try to implement additional features in Hertzmann's paper.
Image Compositing R/O Points Explanation
chromakey V r g b R 3

Change the alpha values in an image V such that any pixel with its color equal to (r,g,b) gets its alpha value set to zero. You can assume that initially V has alpha = 255 for every pixel.

Note that this is a very simple way to make a mask - you'll only encounter exactly perfect colors in images that you make by hand. If you want to try to do something fancier...

composite A over B x y R 3 A and B are image variables and x and y are integers. Giving a position in image B, this command updates image B by compositing image A "over" it, positioned such that the upper left corner of A is at x,y. That is, pixel (0,0) of A is composited over pixel (x,y) of B (and (1,0) is over (x+1,y), etc).
matte V (params) O open Do something that tries to compute the matte (alpha values) from the given image V. Doing this well is really hard. Its surprising how hard it is!
Other Things R/O Points Explanation
  O open

While there are a lot of commands here, they are only a small subset of the things that are possible. (Have a look at the menus in Photoshop).

If there's something you want to try implementing, go ahead! We'll probably give you some points for doing it, and you'll learn something. In general, you'll get more points (for the same amount of effort) doing the things described in the assignment. But if your goal is to do cool stuff and learn...

Fell free to send a note to the instructor about something you want to try. I'll be able to give you some ideas as to how hard it will be, where to start, and how much it might be worth towards your grade.

Total required: 80

Total optional: 45+

But remember: do the required parts first. They are most important for your grade.