Question: void openInputFiles ( char * name, FILE * input [ ] ) ; The first parameter represents a word passed to main through command line
void openInputFileschar 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 ppm If the parameter name is average
then you will create and open, for reading, files. If the parameter name is median
you will create and open, for reading, files. I will provide you with two sets of ppm
files. One set has the name of averageppm averageppm through
averageppm The other set has the name of medianppm medianppm
through medianppm 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.
imaget removeNoiseAverageimaget img; The parameter represents an array of
imaget that point to dynamically allocated memory for the images used in this
function. This function will use the images called averageppm through
averageppm
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 images
read in You will need to create a local variable of type imatet to store the pixels for
the output image. Dont forget to dynamically allocate the memory for the local
imaget The calculated average should be written to output variable.
Ex For the first pixel of all 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 imaget created for the output. Do this
for all pixels.
imaget removeNoiseMedianimaget image;The parameter represents an array
of imaget that point to dynamically allocated memory for the images used in this
function. This function will use the images called medianppm through
medianppm
Lab
FUN WITH PPM IMAGES
DUE: April Midnight
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
of the images, store these values in an array one array for Red, Green, and Blue. Sort
the values in each array. Create a local variable of type imaget for the output. Write
to the output the median middle RGB values. Dont forget to dynamically allocate the
memory for the local imaget
void sortunsigned int arr, int n; The function described in 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.
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 imaget 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.
imaget readppmFILE; 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 headert you can use the
function you wrote from lab then call allocateMemory. Next you will read the pixel
values and store them. Note that this will be stored in a D pointer, as opposed to the
D pointer that was used in Lab
void writepFILE imaget; This function will call writeheader. Then use a nested
for loop to write the pixels to the output file.
imaget allocateMemoryheadert; This function will allocate the memory for the
entire image imaget this is a local image pointer. Next using the header passed to
the function set the newly allocated image header equal to the headert passed to the
function. Then allocate the memory for the local imagets pixels. This must be a D
allocation. Then return the locally allocated imaget
Other functionsrequirements
You must have a struct called Header typedefed to headert contains all header
information.
You must have a struct called Pixel typedeffed to pixelt contains all information for
the pixels.You must have a struct called Image typedeffed to imaget that will have: a member of
type headert
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
