E186 Project 1 (due Feb. 7)


  1. Obtain two images (either from a digital camera, a scanner, or ftped from some site in the network, or simply some of the image files in /home/adder/classes/e186/imagedata/) and display them on an HP station (using XV), or whatever platform you choose to use.

  2. Use the sample template program /home/adder/classes/e186/programs/processing.c to find the negative of these images and display the results on the screen. The program will also produce a histogram of the input image stored as a disk file called "imagename.hist" where "imagename" should be replaced by the actual file name of the image. You can view the histogram with "xv imagename.hist". No need to turn in any of your results up to this point.

  3. Modify the sample program processing.c to generate an image of size N by N (e.g., N=512) so that its ith row (i=0, ..., N-1) is a sinusoidal function of frequency f(i)=i*fo, or angular frequency 2*Pi*f(i)=2*Pi*i*fo, where Pi=3.14, fo=1/N:
    f(x) = sin[2*Pi*f(i)*x] = sin[6.28*i*x/N]
    As digital images are discrete, we can only show the N pixels of this function as:
    f(j) = sin[2*Pi*f(i)*j] = sin[6.28*i*j/N] for (j=0, ..., N-1)
    Moreover, to make sure the pixel values are within the range of [0,...,255], we redefine the function as:
    f(j) = 128 + 127*sin[6.28*i*j/N]
    Submit your image as image 0 (Remember to attach your last name in front. For example, if your last name is Smith, you should submit this image as smith_0.pgm.) What do you expect to see in the image so generated? Do you expect to see more and more alternations between black and white sections in each row as you go down the image row by row? If what you see is not quite what you expected, explain why the discrepancy. Submit your explanation in a text file your_last_name.tex.

  4. Modify the sample program processing.c and do the following for the image /home/adder/classes/e186/imagedata/paolina.pgm.

    (a) Use bilinear interpolation discussed in class to resize the image so that it is 0.75 times narrower (horizontally) and 1.5 times taller (vertically). Submit the result as image 1.

    (b) Linearly stretch the contrast of paolina.pgm so that its histogram covers the entire dynamic range 0--255. Use 3% cut-off point at both the low and high ends of the histogram to do the stretching. Submit the linearly stretched image as image 2, and its histogram as images 3. (The unix command for changing filename is "mv oldname newname".)

  5. Find an image with an object and its background which can be approximately separated in the histogram (two humps) (cup.pgm, bucket.pgm, teapot.pgm, etc. are good candidates), and do the following:

    (a) Do a 3-point piecewise linear mapping to stretch the object and suppress the background. Submit the images before and after the linear mapping as 4 and 5, and the corresponding histograms as 6 and 7.

    (b) Do a background clipping on the original images (stretching the grey levels of the object and compress the background to a single grey level). Submit the resultant image and its histogram as 8 and 9.

    (c) Now threshold the images used so that the object is white and the background is black. Submit the result as 10.

  6. Submit a text file named "your_last_name.tex" to summarize (concise and to the point) what you did for each processing method, explain how the parameters were chosen, and what effects were achieved, and any additional comments you think helpful.
Hint: it is always a good idea to develop your programs in a modular fashion. Always write the code for a stand-alone operation as a function which can be invoked many times later. For example, for this project, you need to write three functions, the first one for enlarging or reducing the size of a given image, the second one for linear stretching (with variable cut-off percentage), and the third one for piecewise linear mapping which can also be used to do thresholding. Moreover, you may want to write a function for 2D convolution with variable sizes for both the 2D kernel and the image. This function will be very useful in the future.