Project 1: Image Processing
In this assignment you will
create a simple image processing program. Your program will provide a variety of filters
including ones that threshold, brighten, blur, edge detect, dither, and warp.
This assignment will be graded on a 100 point scale. You may use two late day extension on this project. Consult the course web page for the due dates (intermediate and final).
What You Have to Do
Following is a list of features that
you may implement. The number in front of the feature corresponds to its point
value.
The features in bold face are required. The others
are optional. You must implement all required features to
receive any credit for optional ones. All work should be developed with
a partner using pair programming except for those in the "Create an
image" category. For each feature you implement, you need to describe
how you tested it; that typically will involve creation of an
appropriate test image.
-
Simple pixel transformations:
-
(3) Shift Channels: Shift the red, green, and blue channels to, respectively, the green, blue, and red channels.
-
(5) Extract Channel:
Extract a single channel, R, G or B, from a three channel image by
setting the other channels to 0.
-
(3) Gray: Convert a three channel image to gray scale.
-
(3) Threshold: Create a new one bit per channel image
where the color value of a pixel/channel is 1 if the corresponding value in
the input
image exceeds the threshold. Otherwise the color value
is 0.
-
Interpolation/Extrapolation:
-
(5) Interpolation/extrapolation: Write a general purpose
interpolation/extrapolation routine that takes two images,
I1 and I2, and an α value. The routine returns the
image α * I1 + (1-α) * I2 . Use this routine as a basis for the filters below.
-
(3) Brighten: Brighten or darken an image.
-
(3) Contrast: Change the contrast of an image.
-
(3) Saturation: Change the saturation of a three channel image.
-
(3) Invert: Create the negative of an image.
-
Convolution:
-
(5) Convolution: Write a general purpose convolution routine that takes an image,
a convolution kernel, and the size of the kernel. The routine returns the convolved image. Use it
to filter an input image as described below.
-
(3) Edge detect: Detect edges in an image by convolving it with an edge
detection kernel.
-
(3) Blur by Box filter: Blur an image by convolving it with an nxn box
filter (n must be odd).
-
(3) Blur by Gaussian filter: Blur an image by convolving it with an nxn
Gaussian filter (n must be odd).
- Quantize: Requantize an image using the techniques described
below. Note that quantization by rounding is worth 0 points but is
required!
-
(0) Quantize by rounding: Change the number of bits per channel of an
image using simple rounding.
-
(10) Quantize by ordered dither: Change the number of
bits per channel of an image using a 4x4 ordered dithering matrix.
-
(10) Quantize by Floyd-Steinberg dither: Change the
number of bits per channel using dithering with error diffusion.
-
Warp: Warp an image allowing the user a choice of resampling methods.
- Re-sampling methods:
- (1)Nearest neighbor
- (4)Bilinear
- (5)Gaussian
-
(3) Shift: Shift an image right and down by (floats) dx, dy
modulo the width, height. (The pixel at i,j is moved to the pixel at
(i+dx)%width, (j+dy)%height.)
-
(5) Rotate: Rotate an image by a given angle about a given point.
-
(5) Scale: Scale an image in x and y.
-
(5) Fun Warp: Warp an image using a non-linear mapping of your
choice.
Some examples are fisheye, sine, bulge, swirl. (You get 2 pts for any
non-trivial warp. To get 5 points it must be interesting and
well-implemented.)
- Misc. effects: The ip process menu does not include most of these, but it does include a Misc. effect option! You should query the user for necessary input in ip.cpp -- not in control.cpp.
-
(5) Composite: Composite one image with a second image, using a
third image as a matte.
-
(5) Crop: Extract a subimage specified by two corners. (Note: You need to resample as the endpoints may not have integer coordinates.)
-
(5) Gamma correction: See wikipedia gama correction for more information.
-
(5) Median filter: replace the center of n x n window with median value in that window
-
(10) Bilateral filter: see bilateral filter tutorial for details.
-
(5) Sobel operator: implement the sober edge detection algorithm described in class notes
-
(?) Nonphotorealism: Implement any non-trivial painterly filter.
For inspiration, take a look at the effects available in programs like
xv, convert, PhotoShop, and Image Composer (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.
- Create an image (These should be done individually, not with a partner.)
-
(5) Create a composite image of yourself and a famous person. (You get 2 points for something that looks like you tried and 5 points for something that
looks good. You may earn bonus points by winning the composite image contest.)
- (2) Create an interesting image using your image processor and submit it to the art contest. (You get 2 points for something
that looks like you tried and 5 points for something that looks good provided it is not just a simple demonstration of a filter for which you received credit above. You may earn bonus points by winning the art contest.)
-
(10) Create an MPEG movie by varying the parameters to one or more
filters.
By correctly implementing all the required features, you get 65 points.
You can acquire additional points by implementing optional features,
winning the art contest (10 points), winning the composite image contest (10 points) thinking up something new and different
(prior approval is recommended), or reporting a bug (see below).
It is possible to get more than 100 points. However, after 100 points,
each point is divided by two, and after 110 points, each point is divided
by four, etc.
What You Are Provided
To allow you to focus on the
image processing algorithms, we provide skeleton code that includes
a user interface and an image class.
The interface reads the input parameters for most of the filters
but does no error checking. That is your responsibility. In addition,
you must request and read parameters for any filters you design. (Note:
these requests should be
made from ip.cpp, which is described in the next section. )
We also provide a full implementation of the
image processor
that you may find useful to debug and test your own code.
If you find a bug in the code, notes, or documentation for this project,
please notify me immediately. Please be sure to
provide enough information so that I can recreate the problem. You will
acquire (up to) 5 bonus points if you are the first to report the problem.
Getting Started
We provide you
with several files to get you started. The ONLY one you should edit is ip.cpp.
-
main.cpp, main.h: sets up the OpenGL context and handles
window display.
-
common.h: useful definitions and a few common includes.
-
control.cpp, control.h: handles OpenGL menus and user i/o.
-
image.cpp, image.h: class for managing images with functions for getting and
setting individual pixels, as well as reading and writing BMP
files (only one channel 8 bit and 3 channel 24 bit files that are uncompressed).
-
ip.cpp, ip.h: bare bones structure for the image processing routines.
-
win32.cpp, win32.h: definitions for windows applications.
You may download a zipped version of a visual studio project containing these files here.
After you copy these files to your directory, you should
compile the program by using Visual Studio.
Run the executable. Right click in the display window to view
the menu options. At this point only the options under the File submenu are
implemented. Load an image file in bmp format. Be sure it is a 24 bit color image. (Here is a sample.) Gimp is a useful tool for converting file formats.
What and how to submit
You must submit your final project folder, appropriate images and
movies, and a write up that describes what you implemented and evidence
of how you tested it. All materials should be zipped and
uploaded to your sakai dropbox. Note that your submission will differ
from your partner because of the "Create and image" requirements.
-
a zipped version of the complete visual project studio folder including all source files
-
the images (sources, masks, and final) for the composite
feature,
-
the .mpeg movie for the movie feature (optional),
-
the images for the art contest (optional), and
-
an html writeup that describes what you have implemented, the algorithms
you used for any art submissions, and the test images you created to
test each of the features as well as the images your program produces as
output for each.
You should not submit anything else.
Some Rules
Read the following carefully.
-
Your submissions is not considered complete until a writeup is submitted.
-
For images or movies that you submit, you need to provide all sources
images and also describe the
sequence of commands used to created them. (Note: To receive credit
we must be able to reproduce the image/movie!)
- Make sure the source code compiles and runs on the LSC machines.
If not we won't be able to grade it!
- You must write, from scratch, all code you submit beyond that which
we provide.
-
You may use up to 2 late day without incurring a penalty for this assignment.
If you do not
use the late days they will be banked for subsequent assignments.
For each additional late day you will be charged 10 points per day penalty until the
project is submitted.
Notes
-
Check your solutions against those generated by the sample code.
-
See Graphica Obscura for more information on interpolation/extrapolation.
-
Post questions to the course mailing list.
Last Update: Jan. 2013