Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am given a project in C language that reads the images in ppm format and i need to write a program that manipulates the

I am given a project in C language that reads the images in ppm format and i need to write a program that manipulates the picture in certain ways (listed on 1st page)

Main.c and ppm.h is already worked out (last attached pic) and all I need is to complete is ppm.c which consists of several functions.

Here is ppm.c skeleton

#include  #include  #include  #include "ppm.h" ppmPic *readPic(char *fileName) { return NULL; } void writePic(ppmPic *myPic, char *fileName) { return; } ppmPic *rotateLeft(ppmPic *thePic) { return NULL; } ppmPic *rotateRight(ppmPic *thePic) { return NULL; } ppmPic *flipHorizontal(ppmPic *thePic) { return NULL; } ppmPic *flipVertical(ppmPic *thePic) { return NULL; } ppmPic *invert(ppmPic *thePic) { return NULL; } ppmPic *duplicate(ppmPic *thePic) { return NULL; } 

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

verview: This program manipulates pictures (image files). Specifically, it takes an existing image and creates a new image. This new image can be flipped or rotated or inverted or a simple copy of the original image. Ba Pictures can be stored in many formats. You've probably heard of the more common ones, such as jpeg (from the Joint Photographic Experts Group) and gif (Graphics Interchange Format). The vast majority of these formats store the image data in a binary file. There is one format, ppm (portable pixmap) that uses ASCII files to store an image. These ppm files consist of header information and then a long string of numbers representing the red, green and blue components of each pixel in the image. It is not widely used. Since the images are stored in ASCII, they are much larger than other (binary) formats. However, as these files are (readable) ASClI data, they are a good format for an introductory programming class in Th e ppm format that is used for this project is shown at the right. The very first line is always P3 After that, you have three px-2-1-red pixel-2-1-green pixel-2-1-blue pixel-2-2-red pixel-2-2-green pixel-2-2-blue.. values (width, height, colors) that can be on a P3 width-in-pixels height-in-pixels maximum-color-value pixel-1-1-red pixel-1-1-green pixel-1-1-blue pixel-1-2-red pixel-1-2-green pixel-1-2-blue.. pixel N-1-red pixel-N-1-green pixel-N-1-blue pixel-N-2-red pixel-N-2-green pixel-N-2-blue gle line or separate lines. Finally, you have the actual RGB values (three integers) for each pixel in the image. A very tiny ppm file that is four pixels wide and six pixels tall, with the top two rows the color red, the middle two rows the color green, and the bottom two rows the color blue, is shown at the right below sin will be manipulating ppm image fil In order to see if your4 6 255 This program program is working properly, you need to be able to view these images Your system might (or might not) have a viewer that supports ppm images 255 00 25500 255 00 255 00 If not, then download the free program GIMP (GNU Image Manipulation0255 0 0255 0 0 25s 00255o Program). Download GIMP at http://www.gimp.org/downloads 255 00 255 00 255 00 25500 0255 0 00255 00255 0 2550 00 255 00 255 0255 0 00 255 00 255 0255 0 00 255 00 255 You can use GIMP to convert additional pictures into ppm format for testing if you wish. Simply load an exis and then select the "Export As" option and a file type of PPM image. Make sure to click ASCII when asked how to export. When you use ppm to convert an image into a ppm file, it puts a comment on the second line. You need to delete that comment line, as our program does not h ting image that you have into GIMP andle comments in ppm files. 3. Project Details: As mentioned previously, this project manipulates image files. The specific manipulations implemented are: 1. duplicate (duplicates/copies an image) 2. invert (negate the image) 3. flipHorizontal (flip the image from left to right) 4. flipVertical (flip the image from top to bo 5. rotateleft (rotate the image counter-clockwise by 90 degrees) 6. rotateRight (rotate the image clockwise by 90 degrees) verview: This program manipulates pictures (image files). Specifically, it takes an existing image and creates a new image. This new image can be flipped or rotated or inverted or a simple copy of the original image. Ba Pictures can be stored in many formats. You've probably heard of the more common ones, such as jpeg (from the Joint Photographic Experts Group) and gif (Graphics Interchange Format). The vast majority of these formats store the image data in a binary file. There is one format, ppm (portable pixmap) that uses ASCII files to store an image. These ppm files consist of header information and then a long string of numbers representing the red, green and blue components of each pixel in the image. It is not widely used. Since the images are stored in ASCII, they are much larger than other (binary) formats. However, as these files are (readable) ASClI data, they are a good format for an introductory programming class in Th e ppm format that is used for this project is shown at the right. The very first line is always P3 After that, you have three px-2-1-red pixel-2-1-green pixel-2-1-blue pixel-2-2-red pixel-2-2-green pixel-2-2-blue.. values (width, height, colors) that can be on a P3 width-in-pixels height-in-pixels maximum-color-value pixel-1-1-red pixel-1-1-green pixel-1-1-blue pixel-1-2-red pixel-1-2-green pixel-1-2-blue.. pixel N-1-red pixel-N-1-green pixel-N-1-blue pixel-N-2-red pixel-N-2-green pixel-N-2-blue gle line or separate lines. Finally, you have the actual RGB values (three integers) for each pixel in the image. A very tiny ppm file that is four pixels wide and six pixels tall, with the top two rows the color red, the middle two rows the color green, and the bottom two rows the color blue, is shown at the right below sin will be manipulating ppm image fil In order to see if your4 6 255 This program program is working properly, you need to be able to view these images Your system might (or might not) have a viewer that supports ppm images 255 00 25500 255 00 255 00 If not, then download the free program GIMP (GNU Image Manipulation0255 0 0255 0 0 25s 00255o Program). Download GIMP at http://www.gimp.org/downloads 255 00 255 00 255 00 25500 0255 0 00255 00255 0 2550 00 255 00 255 0255 0 00 255 00 255 0255 0 00 255 00 255 You can use GIMP to convert additional pictures into ppm format for testing if you wish. Simply load an exis and then select the "Export As" option and a file type of PPM image. Make sure to click ASCII when asked how to export. When you use ppm to convert an image into a ppm file, it puts a comment on the second line. You need to delete that comment line, as our program does not h ting image that you have into GIMP andle comments in ppm files. 3. Project Details: As mentioned previously, this project manipulates image files. The specific manipulations implemented are: 1. duplicate (duplicates/copies an image) 2. invert (negate the image) 3. flipHorizontal (flip the image from left to right) 4. flipVertical (flip the image from top to bo 5. rotateleft (rotate the image counter-clockwise by 90 degrees) 6. rotateRight (rotate the image clockwise by 90 degrees)

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

Students also viewed these Databases questions

Question

b. Why were these values considered important?

Answered: 1 week ago