{{FULL_COURSE}} Homework 1 - Image Processing


0. Goal

Create a toolbox of image transformations and filters, with a programming emphasis on C pointers.

1. Supplied Code

Start from the ppm_example.c code on the syllabus page, or from your modified version from class exercises. You should add all your new code and functions to this file, because you will not be allowed to submit any additional files. This restriction simplifies the submission process.

You code must be written in pure C—no C++ or Qt is allowed. You are welcome to use C99 and C11 constructs, especially declaring variables anywhere in the function body and in for loop initializers.

2. Help Log

Maintain a log of all help you receive and resources you use. Make sure the date and time, the names of everyone you work with or get help from, including in office hours, and every URL you use, except as noted in the collaboration policy. Also briefly log your question, bug or the topic you were looking up/discussing. Ideally, you should also the answer to your question or solution to your bug. This will help you learn and provide a useful reference for future assignments and exams. This also helps us know if there is a topic that people are finding difficult. You will submit this as a plain text file.

4. Code Requirements

You must adhere to the guidelines below. In addition, you must implement all the features from section 4 and a selection of features from section 5.

5. Required Features

Your program must implement the all the following features. You will probably want to write a separate function for each of these, that main will call if the correct argument is supplied. It is up to you what arguments those functions should take, and what (if anything) they should return.

  1. -grayscale: convert the image to grayscale using the formula Y == .299R + .587G + .114B.
  2. -flip: Mirror the image left-to-right. You should not need to allocate or free any memory to perform this operation.
  3. -flop: Mirror the image top-to-bottom. You should not need to allocate or free any memory to perform this operation.
  4. -transpose: Transpose the image like a matrix, i.e. flip it along the diagonal axis from top-left to bottom-right. You will probably need to malloc additional memory to do this.
  5. -boxblur n: Perform a box blur of radius n. A box blur slides a square with sides of length 2n + 1 across the image, and replaces the center pixel with the average of all pixels in the box. You will need to store the blurred pixels in a new image so they don't interfere with blurring subsequent pixels. Round the resulting value to the nearest integer, and clamp to the range 0..255. Replace any pixels that are within n pixels of the image boundary with bright green (0, 255, 0). (In practice, there are different ways of handling pixels that are too close to the boundary to every be at the center of the square. Replacing them with bright green makes it easy for you and the TAs to see that you are handling them as a special case.)
  6. -median n: Perform a median filter of radius n. This works like the box blur, but it replaces the center pixel with the median pixel value rather than the average. Replace pixels too close to the boundary with bright green.
  7. -gaussian n s: Perform a Gaussian convolution of radius n and standard deviation s. This is slightly more involved than a box blur, but is a more typical blurring function. It is also a canonical example of a convolution filter.

5. Additional

Implement at least two of the following transformations, which are listed in roughly increasing order of difficulty. If you implement more than two, or additional transformations of your own, you will receive extra credit. List all transformations you implemented in your readme file, including the appropriate command-line options for any that are not listed below. (Your own transformations will receive extra credit based on the complexity of pointer manipulation and memory management as well as the complexity of the transformation.)

6. Submission

Download and complete this readme_filters.txt template in a text editor (NOT Windows Notepad, Mac TextEdit, or Word because they will mangle the file). Submit the readme, your helplog (also as a plain text file), and your code through the Dashboard. You may submit as often as you like, but only your last submission will be graded. You only need to resubmit files that have changed since your previous submission.