|
COS 426 - Computer Graphics
|
Spring 2012
|
Assignment 1: Image Processing
Due Thursday, Feb. 23, 11:59 PM
In this assignment you will create a simple image processing program. The operations
that you implement will mostly be filters that take an input image, process the
image, and produce an output image.
Getting Started
Download the following skeleton code: cos426_assignment1.zip.
Read over 00README.txt to learn the functions of the different files and
directories.
How the Program Works
The user interface for this assignment was kept as simple as possible, so you
can concentrate on the image processing issues. The program runs on the command
line. It reads an image from a file (the first program argument) and writes an image
to a file (the second program argument). In between, it processes the image using
the filters specified by subsequent command line arguments. For example, to increase
the brightness of the image in.jpg by 10%, and save the result in the
image out.jpg, you would type:
% imgpro in.jpg out.jpg -brightness 1.1
For each available image filter there may be one or more optional parameters
(e.g., brightness takes a factor). To see the complete list of filters and their
parameters, type:
% imgpro -help
If you specify more than one filter on the command line, they are applied in
the order that they are found. For example,
% imgpro in.jpg out.jpg -contrast 0.8 -scale 0.5 0.5
would first decrease the contrast of the input image by 20%, and then scale down
the result by 50% in both x and y directions. Of course, you are welcome
to create your own filters and add program arguments for them by editing imgpro.cpp.
However, please do not change the program arguments for the filters already provided.
What You Have to Do
The assignment is worth 20 points. The following is a list of features that you
may implement (listed roughly from easiest to hardest). The number in front of the
feature corresponds to how many points the feature is worth. The features in bold
face are required. The other ones are optional. Refer to the
examples web page
for more details on the implementation of each filter and example output images.
- Per-pixel Operations
- (1/2) Black & White: Convert to gray levels by replacing each
pixel with its luminance.
- (1/2) Gamma: Apply a
gamma correction
to the image.
- (1/3) Saturation: Change the saturation of an image. See
Graphica Obscura.
- (1/3) Contrast: Change the contrast of an image. See
Graphica Obscura.
- (1/3) Extract Channel: Leave specified channel intact and set all others
to zero.
- Linear Filtering Operations
Note: Since all the filters below are
intended to operate on linear pixel values, be sure to undo the image
gamma (by raising values to the power of 2.2) before processing, and
re-apply gamma (by raising values to the power of 1/2.2) afterwards. Use
good coding practices (modularity) and don't re-implement gamma
correction, given that you already implemented it, as specified above.
- (1) Gaussian Blur: Blur an image by convolving it with a Gaussian
low-pass filter.
- (1/3) Sharpen: Apply a linear sharpening filter to the image.
- (1/3) Edge detect: Detect edges in an image by convolving it with an
edge detection kernel.
- (1/3) Motion Blur: Apply a left-right motion blur to the image.
- Non-Linear Filtering Operations
- (1) Median Filter: Remove speckle noise using a median filter of given
width
- (2) Bilateral Filter: Smooth while preserving sharp edges in
the original. See
here.
- Resampling Operations
Note: You must provide code for point, linear, and Gaussian sampling
Clarification: You must implement three sampling methods (point,
bilinear, and Gaussian), which can be controlled by the -sampling
option prior to -scale, -rotate, or -fun.
For Gaussian sampling, choose sensible Gaussian filter dimensionss. For
scaling, this requires adapting the extent of the Gaussian, for rotation
and fun, you may use a fixed size of your choosing.
- (2) Scale: Scale an image up or down by a real valued factor.
- (2) Rotate: Rotate an image by a given angle.
- (2) Fun: Warp an image using a non-linear mapping of your choice
(examples are fisheye, sine, bulge, swirl).
- Dithering Operations
- (1/3) Quantize: Change the number of bits per channel of an image, using
simple rounding.
- (2/3) Random dither: Convert an image to a given number of bits per
channel, using a random threshold.
- (2) Ordered dither: Convert an image to a given number of bits per channel,
using a 4x4 ordered dithering matrix.
- (2) Floyd-Steinberg dither: Convert an image to a given number
of bits per channel, using dithering with error diffusion.
- Miscellaneous
- (1) Composite: Compose one image with a second image using the
over operator, with a third image as a matte (alpha).
- (3) Morph: Use pairs of corresponding lines to morph a source
image into a target image using a morph parameter t. See [Beier92].
Use the provided line correspondence editor
to define the line correspondences.
- (up to 3) Nonphotorealism: Implement any non-trivial painterly filter.
For inspiration, take a look at the effects available in programs like
xv, PhotoShop, and Image Composer, or
GIMP (e.g., impressionist, charcoal,
stained glass, etc.). The points awarded for this feature will depend on
the creativity and difficulty of the filter. At most one such filter will
receive points.
- (up to 3) Anything else: Implement any non-trivial image processing
algorithm of your own choosing, and we will give you points according to
the difficulty.
By implementing all the required features, you get 14 points. There are many
ways to get more points:
- implementing the optional features listed above;
- (1) submitting one or more images or movies for the art contest (movies
should be in
.mpeg, .mov or .avi format,
animating the results of one or more filters with continuously varying parameters,
e.g. the morph);
- (2) winning the art contest.
It is possible to get more than 20 points. However, implementing more than 6
points worth of non-required features incurs diminishing returns: each successive
point is worth 3/4 as much as the previous one. Thus, the adjusted extra credit
score is computed according to the following formula:
extra credit = 3 * (1 - pow(0.75, points - 6))
Extra credit points cannot replace the required features (bold items). Your final
score will be calculated by adding your score on the required features (up to 14
points) to your score on the optional features (up to 9 points, with diminishing
returns past 6).
Submitting
This assignment is due Thursday, February 23, 2012 at 11:59 PM. Please see the
general notes on submitting your assignments,
or the same notes explained in slides,
as well as the late policy and the
collaboration policy.
Please submit a single .zip file named [your NetID]_cos426_assignment1.zip
containing
- your writeup.html, containing links to all result images and a
description of your implementation;
- your complete output/ and modified src/ directory trees.
Please submit images in .jpg format, and remove binaries and object
files from the source tree (i.e., leaving only source code). To do this, run
make clean or execute "Clean Solution" from the build menu in Visual
Studio.
The Dropbox link to submit your assignment is
here.
writeup.html should be an HTML document demonstrating the effects
of the features you have implemented. For some features (e.g., black & white), you
can simply show the input and output of your program. However, for features that
take an input parameter (e.g., blur), you should provide a series of images showing
at least three settings of the input parameter to demonstrate that your code is
working properly. You can start from the skeleton writeup.html provided
with the distribution as a template -- simply add sections to that HTML file for
the features you implement in the following format:
- the name of the feature on the top line,
- the input image and output image(s) on a second line,
- text listing the command(s) used to generate the output images on the following
lines, and
- (optionally) comments about what to look for in your output (including possible
problems in the implementation).
We remind you that you are expected to use good programming style at all times,
including meaningful variable names, a comment or three describing what the code
is doing, etc. We will test your code by running make in your src/
subdirectory, followed by make in the main assignment directory to create
the output images. Please ensure that your code builds/runs in this way.
Last update
9-Feb-2012 11:44:58
smr at princeton edu