Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that reads in a .ppm image and stores the pixels from the image in a linked list of pixels. Once the image

Write a program that reads in a .ppm image and stores the pixels from the image in a linked list of pixels. Once the image is read in, a menu is presented to the user with choices of printing out the original image or some other manipulation. However, none of the manipulations will be implemented your program should only reproduce the image from the linked list of pixels. The manipulations could be used in a future assignment.

Your program will consist of multiple source files, a header file, and a makefile. You should have the following files

with the specified functions (along with any other additional helper functions that you may want to also create):

mainDriver.c

-

contains the main()function, where:

1. declares and initializes a list_t pointer called image which will point to the image

2. opens input file specified at the command line

3. calls parseHeader()function to get the width and height

4. calls getImage() function sending width and height and image pointer and gets the pixel data and creates linked list

5. then calls printMenu() function for choices:

original image

mirror image

upside down

gray scale

rotate to the right 90 degrees

(*** only the original image will be implemented with this assignment)

6. when menu choice #1 is chosen:

6a. calls printHeader() function

6b. then calls printImage() function

7. when other menu choices are chosen:

7a. prints message to user

7b. lets user choose another menu option, unless

7c. choice #6 which will quit the program

menu.c

-

contains the printMenu() function, which will present the menu to the user and return the chosen value; valid input from 1-6 is forced within this function

parse.c

-

contains the parseHeader() and getImage() functions

print.c

contains the printHeader() and printImage() functions

// mirror.c

-

contains the mirror() function (*** not required)

// flipHoriz.c

-

contains the flipHoriz() function (*** not required)

// gray.c

-

contains the grayScale() function (*** not required)

// rotate.c

-

contains the rotate() function (*** not required)

transform.h

provided to you

This files contents are located below.

makefile

should have 3 targets: one to compile, one to run, and a clean target to remove the executable and any other files that are not needed. Notice from above, only one function returns something

The printMenu() function returns an int; the other functions do not return anything. Also, printMenu() doesnt require any arguments. The only functions that need the file pointer as one of the arguments are the parseHeader() and getImage() functions. The other functions need at the very least, the rows and columns, and most also need pointer to the image.

Your program will use command line arguments (to specify the input image file) as well as redirection (for the newly created image). When run, a menu will be presented to the user to choose which manipulation to perform. An example of what it should look like when run is below:

[00:00:00] user@access1: [101] ./transform twoTigers.ppm > newImage.ppm

1. original image

2. mirror image

3. upside down image

4. gray scale image

5. rotate image to the right

6. quit program

MENU CHOICE: 2

mirror not implemented yet

1. original image

2. mirror image

3. upside down image

4. gray scale image

5. rotate image to the right

6. quit program

MENU CHOICE: 5

rotate to the right not implemented yet

1. original image

2. mirror image

3. upside down image

4. gray scale image

5. rotate image to the right

6. quit program

MENU CHOICE: 7

1. original image

2. mirror image

3. upside down image

4. gray scale image

5. rotate image to the right

6. quit program

MENU CHOICE: 1

1. original image

2. mirror image

3. upside down image

4. gray scale image

5. rotate image to the right

6. quit program

MENU CHOICE: 6

[00:00:00] user@access1: [102]

After menu choice 1 was chosen, a new image file called newImage.ppm (according to the example output above),

should have been created. You can then download and view that image with an image viewer/editor, such as gimp.

If your program does not work as specified, you will lose points accordingly. If your program does not compile, you will lose all points associated with functionality.

-

The header file, transform.h, is given and has contents as follows:

#include

#include

#include

typedef struct pixel {

unsigned char r, g, b;

struct pixel * next;

} pixel_t;

//

typedef struct list {

pixel_t * head;

pixel_t * tail;

} list_t;

//

void parseHeader( FILE *input, int *cols, int *rows);

void getImage( FILE *input, int rows, int cols, list_t * theImage );

//

int printMenu();

//

void printHeader( int rows, int cols );

void printImage( int rows, int cols, list_t * theImage );

All other function prototypes (mirror, flipHoriz, grayScale, rotate) would be included here but are not required/necessary for this program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2016 Riva Del Garda Italy September 19 23 2016 Proceedings Part 1 Lnai 9851

Authors: Paolo Frasconi ,Niels Landwehr ,Giuseppe Manco ,Jilles Vreeken

1st Edition

3319461273, 978-3319461274

More Books

Students also viewed these Databases questions

Question

a. Describe the encounter. What made it intercultural?

Answered: 1 week ago