Question: void openInputFiles ( char * name, FILE * input [ ] ) ; The first parameter represents a word passed to main through command line

void openInputFiles(char* name, FILE* input[]); The first parameter represents a word
passed to main through command line arguments. The second parameter represents an
array of FILE pointers.
This function will create and then open, for reading, the input files. You will use the
function sprintf to create a set of ppm file names. Each of these files should be opened
for reading and stored in the array of file pointers passed to the function. You cannot
hard code these file names. You must generate the file names using sprintf. The file
names will be in the form of _001.ppm. If the parameter (name) is average
then you will create and open, for reading, 10 files. If the parameter (name) is median
you will create and open, for reading, 9 files. I will provide you with two sets of ppm
files. One set has the name of average_001.ppm, average_002.ppm through
average_010.ppm. The other set has the name of median_001.ppm, median_002.ppm
through median_009.ppm. When opening the files, you must check that the file open
successfully. You can use assert or a function that you create. If you choose to write a
function, if a file does not successfully open you must print an error message and exit
the program.
2. image_t* removeNoiseAverage(image_t* img[]); The parameter represents an array of
image_t* that point to dynamically allocated memory for the images used in this
function. This function will use the images called average_001.ppm through
average_010.ppm.
This function will remove the noise or graininess in photos taking by the hubble space
telescope. For each pixel calculate an average of the RGB channels of the 10 images
read in. You will need to create a local variable of type imate_t * to store the pixels for
the output image. (Dont forget to dynamically allocate the memory for the local
image_t*.) The calculated average should be written to output variable.
Ex. For the first pixel of all 10 images, you will read the red values and average them,
the green values and average them, and the blue values and average them. Then save
the average values in the first pixel of the local image_t* created for the output. Do this
for all pixels.
3. image_t* removeNoiseMedian(image_t* image[]);The parameter represents an array
of image_t* that point to dynamically allocated memory for the images used in this
function. This function will use the images called median_001.ppm through
median_009.ppm.
Lab 10
FUN WITH PPM IMAGES
DUE: April 15,2024, Midnight
3
To remove an unwanted object in a series of images you can use a method similar to
that used in removeNoiseAverage function. Rather than calculating the average you
determine the median. This will involve, for each pixel, reading the RGB values for all 9
of the images, store these values in an array one array for Red, Green, and Blue. Sort
the 9 values in each array. Create a local variable of type image_t* for the output. Write
to the output the median (middle) RGB values. (Dont forget to dynamically allocate the
memory for the local image_t*.)
4. void sort(unsigned int* arr, int n); The function described in 3 above requires you sort
the values in the array passed to the function. This is what the sort function will be used
for. You can choose what flavor of sort you want to use.
5. You are to write a driver called main.c; The driver should have two variables of type
FILE* arrays one for the pointers to the average ppm files and one for the pointers to
the median ppm files. It should also have two variables of type image_t* arrays one
for the pointers to the average images and one for the pointers to the median images.
You should open the appropriate files, read the ppm files, call either
removeNoiseAverage or removeNoiseMedian.
6. image_t* read_ppm(FILE*); This function will read the pixel values and store them. This
means you will need to read the header and store it in a local header_t (you can use the
function you wrote from lab7) then call allocateMemory. Next you will read the pixel
values and store them. Note that this will be stored in a 2D pointer, as opposed to the
1D pointer that was used in Lab 7.
7. void write_p6(FILE*, image_t*); This function will call write_header. Then use a nested
for loop to write the pixels to the output file.
8. image_t* allocateMemory(header_t*); This function will allocate the memory for the
entire image (image_t*), this is a local image pointer. Next using the header passed to
the function set the newly allocated image header equal to the header_t passed to the
function. Then allocate the memory for the local image_ts pixels. This must be a 2D
allocation. Then return the locally allocated image_t.
Other functions/requirements.
You must have a struct called Header typedefed to header_t contains all header
information.
You must have a struct called Pixel typedeffed to pixel_t contains all information for
the pixels.You must have a struct called Image typedeffed to image_t that will have: a member of
type header_t,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!