-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
32 lines (25 loc) · 862 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "pbm.h"
#include "pgm.h"
#include "ppm.h"
#include "sat.h"
int main(void) {
// Read the input image.
PpmImage *image = ReadPpm("../input/lenna.ppm");
// Convert the image to grayscale.
PgmImage *grayscale = PpmToPgm(image, SRgbLuminance);
// Read a threshold map.
PgmImage *map = ReadPgm("../textures/bayer/2x2.pgm");
// Dither the image to 1-bit images.
PbmImage *ditheredBayer = PgmToPbmOrdered(grayscale, map);
PbmImage *ditheredIgn = PgmToPbm(grayscale, IgnThreshold);
// Write the dithered images to a file.
WritePbm(ditheredBayer, "../output/lenna_bayer_2x2.pbm");
WritePbm(ditheredIgn, "../output/lenna_ign.pbm");
// Free the memory used by the images.
FreePbm(ditheredIgn);
FreePbm(ditheredBayer);
FreePgm(map);
FreePgm(grayscale);
FreePpm(image);
return 0;
}