Algorithms: Basic Functions for PGM

The following four C functions are for loading PGM files into memory and writing them to a file. You should copy the two source files with these functions,  imageio.h and  imageio.c, to your account. In addition, you may download the program threshold.c, which illustrates the use of the basic functions, and compile it using the command "gcc -o threshold threshold.c imageio.c".
 
allocate_image Dynamically allocate memory for an image, with a specified number of rows an columns. 
free_image Free the memory of a specified image, which has been allocated by allocate_image.
read_pgm_image Read a PGM image from a specified file, and determine the number of rows and columns.
write_pgm_image Write a specified image to a specified file, using the PGM format.
Back to the Projects page