ECE 1620 - Assignment #10 - Due: 22 April 2022


To process PPM (Portable Pixel Map) images in VECR, start with a copy of ppm_copy.c which copies an image from standard input to standard output. It uses a ppm structure and routines declared in ppm.h and defined in ppm.c

Look at ppm.h to see the description of the ppm structure and functions.

The RGB arrays in the ppm structure are declared using pointer notation because they are dynamically sized and allocated -- but they behave and are used just like regular two-dimensional arrays. So, for example, the red color data for a ppm structure a is in array elements a.r[i][j], i=0...(a.rows-1), j=0...(a.cols-1)

Three sample images are provided: test.ppm, Flowers.ppm, and baby.ppm


  1. a10/p1.c - image color swap

    Write a C program which reads a PPM image from standard input, swaps the red and green pixel values, and then writes the modified image to standard output.

    Test your program using the image view icon with one of the sample images as input:

                    args:

    Sample results: original test image, swapped; original Flowers image, swapped


  2. a10/p2.c - image transpose

    Write a C program which transposes an image, i.e. reflects it about the diagonal.

    To do this, after reading a PPM image, create a new image of the appropriate size; copy the pixels from positions [j][i] of the original image to positions [i][j] of the new image; then write the new image to standard output.

    Sample results: original test image, transposed; original baby image, transposed


  3. a10/p3.c - digital image forensics

    The suspect in a bank fraud investigation has hidden a 6-digit account number in the green color plane of an image p3.ppm

    Your job, as a digital image forensics specialist, is to extract the account number and submit it to the FBI to recover the stolen funds.

    The account number image is encoded in the least-significant bits of the green pixel values. To decode the number: for each green pixel, if it is odd set it to 255, if it is even set it to 0. Then view the resulting image.

    Sample results: input, output

    Check results - view the log entries for your image number submission


  4. a10/p4.c - image create

    Write a program to generate an image which contains a range of color values 0...255 for each color plane and/or makes some interesting pattern.

    Example images: shades, rainbow, zig-zag


Optional/Extra