Fill This Form To Receive Instant Help
Homework answers / question archive / IV
IV. (10) Write a programme called pgmReduce which takes 3 arguments: 1 . an input file (either ASCII or binary) 2. an integer factor n, and 3 . an output file and reduces the input file by that factor in each dimension. For example, if the invocation is: pgmReduce inputFile 5 outputFile and inputFile is a 13x17 image, then outputFile should be a 2x3 image in which only the pixels with row and column of 0 modulo 5 in the inputFile exist.
(NOTE that this is C program not C++)
I've shared a file containing a C program that takes a .pgm (grayscale images) file as an input which reads the input file and gives the output as the same image. The problem is that the program is very long so we need to create 3 different files;
pgmEcho.c - which contains different functions.
pgmfiles.c - which contains the main function (just takes input from the command line)
pgmMemory.c - which free the allocated memory
(Note: We can make as many header files as we want.)
After making these 3 files you need to compile the code using:
gcc -std=c99 comand
NOTE: When you make the function in pgmEcho.c, you can make as many functions as you like and each function must not exceed 30 lines.
The link to the C program (this program consist of 282 lines of code which you need to break down into functions)
The file name is pgmEcho.c:
This C file can be compiled in terminal now in the following way:
cd to your pgmEcho.c files and command are as follows,
gcc -std=c99 pgmEcho.c (a.out file will be created)
./a.out slice0a.pgm out.pgm
slice0a.pgm - this pgm file is also attatched below (1st argument)
out.pgm - is the output file obtained from the program above (2nd argument)
The link for pgmEcho.c :
https://drive.google.com/file/d/1aLxdonOqsJPPqdFlvzLMgIlP1yQijESi/view?usp=sharing
The link for the grayscale image file slice0a.pgm:
https://drive.google.com/file/d/1mFWHdaGG4mOfwdvPcsX5G22SKeIbBBwA/view?usp=sharing
Instructions for your tutor:
This program is based on more modularity rather than having all the code in the same program