#include #include #include const int maxsize=1000; int main() { int image1[maxsize][maxsize]; int image2[maxsize][maxsize]; int rows, cols; int row, col; int maxpixel; int totallines; struct timeval tv; struct timezone tz; long starttimeSec, starttimeMicro; long endtimeSec, endtimeMicro; long totalSec, totalMicro; char *line = NULL; ssize_t inputline; size_t len=0; FILE *infile; FILE *outfile; if ((infile=fopen("ISS-four.pgm", "r")) == NULL) { printf("Could not open file\n"); exit(0); } if ((outfile=fopen("figtestC.pgm", "w")) == NULL) { printf("Could not open file\n"); exit(0); } inputline = getline(&line, &len, infile); // read the format line inputline = getline(&line, &len, infile); // read the comment line fscanf(infile,"%d %d", &cols, &rows); fscanf(infile,"%d", &maxpixel); printf("Rows=%d Cols=%d Max pixel value=%d\n", rows, cols, maxpixel); totallines = rows*cols; printf("Totallines=%d\n", totallines); for(row=0; row 255) image2[row][col] = 255; } gettimeofday(&tv, &tz); endtimeSec = tv.tv_sec; endtimeMicro = tv.tv_usec; printf("End image processing\n"); printf("end (date_and_time): %d sec, %d microsec\n", endtimeSec, endtimeMicro); if (endtimeSec > starttimeSec) { totalSec = endtimeSec-starttimeSec; totalMicro = endtimeMicro + (1000000 - starttimeMicro); } else { totalSec = 0; totalMicro = endtimeMicro - starttimeMicro; } printf("Total time = %d sec, %d microsec\n", totalSec, totalMicro); fprintf(outfile,"P2\n"); fprintf(outfile, "# Test file\n%d %d\n%d\n", cols, rows, maxpixel); for(row = 0; row