annotate Meerwald/wm_koch_e.c @ 21:1c4ccd635a68 v0.6

ignore *.swp
author Peter Meerwald-Stadler <pmeerw@pmeerw.net>
date Sat, 28 Jan 2023 23:57:40 +0100
parents 3bdb67e76858
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
1 #include "wm.h"
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
2 #include "dct.h"
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
3 #include "signature.h"
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
4 #include "coord.h"
18
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
5 #include "gray.h"
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
6 #include "pgm.h"
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
7
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
8 char *progname;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
9
18
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
10 double sign(double x) {
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
11 if (x >= 0.0) return 1.0;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
12 else return -1.0;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
13 }
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
14
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
15 double try_modif(gray **image_block, double **dcts, int c1, int c2, double w1, double w2) {
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
16 int i, j;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
17 gray **altered_block;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
18 double **altered_dcts;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
19 double sum;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
20
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
21 altered_block = alloc_grays_8x8();
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
22 altered_dcts = alloc_coeffs_8x8();
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
23
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
24 for (i = 0; i < 8; i++) {
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
25 memcpy(altered_dcts[i], dcts[i], sizeof(double) * 8);
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
26 }
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
27
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
28 // put the changed coefficients back to black
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
29 altered_dcts[c1 / NJPEG][c1 % NJPEG] = w1;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
30 altered_dcts[c2 / NJPEG][c2 % NJPEG] = w2;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
31
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
32 dequantize_8x8(altered_dcts);
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
33
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
34 idct_block_8x8(altered_dcts, altered_block, 0, 0);
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
35
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
36 // compute MSE
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
37 sum = 0.0;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
38 for (i = 0; i < 8; i++) {
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
39 for (j = 0; j < 8; j++) {
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
40 double ib = image_block[i][j];
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
41 double ab = altered_block[i][j];
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
42 sum += (ib - ab) * (ib - ab);
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
43 }
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
44 }
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
45 sum /= 64.0;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
46
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
47 free(altered_block);
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
48 free(altered_dcts);
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
49
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
50 return sum;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
51 }
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
52
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
53 void usage(void) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
54 fprintf(stderr, "usage: %s [-h] [-l n] [-o file] [-q n] [-v n] -s file file\n", progname);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
55 fprintf(stderr, "\t-h\t\tprint usage\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
56 fprintf(stderr, "\t-l n\t\tsignature robustness factor\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
57 fprintf(stderr, "\t-o file\t\toutput (watermarked) file\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
58 fprintf(stderr, "\t-q n\t\tquantization (JPEG quality) factor\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
59 fprintf(stderr, "\t-s file\t\tsignature to embed in input image\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
60 fprintf(stderr, "\t-v n\t\tverbosity level\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
61 exit(0);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
62 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
63
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
64 int main(int argc, char *argv[]) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
65
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
66 FILE *in = stdin;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
67 FILE *out = stdout;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
68 FILE *sig = NULL;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
69
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
70 char signature_name[MAXPATHLEN];
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
71 char input_name[MAXPATHLEN] = "(stdin)";
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
72 char output_name[MAXPATHLEN] = "(stdout)";
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
73
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
74 int c;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
75 int n;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
76
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
77 int seed;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
78 int verbose = 0;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
79
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
80 int rows, cols, format;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
81 gray maxval;
8
f83ef905a63d fixing many warnings
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 0
diff changeset
82 int row;
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
83
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
84 int quantization = 0;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
85 double quality = 0.0;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
86
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
87 struct coords *coords;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
88
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
89 gray **image;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
90 double **dcts;
18
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
91 gray **image_block;
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
92
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
93 progname = argv[0];
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
94
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
95 pgm_init(&argc, argv); wm_init();
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
96
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
97 while ((c = getopt(argc, argv, "h?i:l:o:q:s:v:")) != EOF) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
98 switch (c) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
99 case 'h':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
100 case '?':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
101 usage();
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
102 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
103 case 'l':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
104 quality = atof(optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
105 if (quality <= 0.0) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
106 fprintf(stderr, "%s: signature strength factor %f out of range\n", progname, quality);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
107 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
108 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
109 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
110 case 'o':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
111 if ((out = fopen(optarg, "wb")) == NULL) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
112 fprintf(stderr, "%s: unable to open output file %s\n", progname, optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
113 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
114 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
115 strcpy(output_name, optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
116 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
117 case 'q':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
118 quantization = atoi(optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
119 if (quantization <= 0 || quantization > 100) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
120 fprintf(stderr, "%s: quantization factor %d out of range\n", progname, quantization);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
121 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
122 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
123 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
124 case 's':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
125 if ((sig = fopen(optarg, "r")) == NULL) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
126 fprintf(stderr, "%s: unable to open signature file %s\n", progname, optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
127 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
128 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
129 strcpy(signature_name, optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
130 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
131 case 'v':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
132 verbose = atoi(optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
133 if (verbose < 0) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
134 fprintf(stderr, "%s: verbosity level %d out of range\n", progname, verbose);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
135 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
136 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
137 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
138 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
139 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
140
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
141 argc -= optind;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
142 argv += optind;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
143
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
144 if (argc > 1) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
145 usage();
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
146 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
147 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
148
8
f83ef905a63d fixing many warnings
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 0
diff changeset
149 if (argc == 1 && *argv[0] != '-') {
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
150 if ((in = fopen(argv[0], "rb")) == NULL) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
151 fprintf(stderr, "%s: unable to open input file %s\n", progname, argv[0]);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
152 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
153 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
154 else
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
155 strcpy(input_name, argv[0]);
8
f83ef905a63d fixing many warnings
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 0
diff changeset
156 }
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
157
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
158 if (sig) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
159 char line[128];
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
160 fgets(line, sizeof(line), sig);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
161 if (strspn(line, "KCSG") >= 4) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
162 fscanf(sig, "%d\n", &nbit_signature);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
163 if (quality == 0.0)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
164 fscanf(sig, "%lf\n", &quality);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
165 else
16
4987db85cfae fix another scanf() warning
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 8
diff changeset
166 fscanf(sig, "%*f\n");
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
167 if (quantization == 0)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
168 fscanf(sig, "%d\n", &quantization);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
169 else
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
170 fscanf(sig, "%*d\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
171 fscanf(sig, "%d\n", &seed);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
172 n_signature = NBITSTOBYTES(nbit_signature);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
173 fread(signature, sizeof(char), n_signature, sig);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
174 fscanf(sig, "\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
175 srandom(seed);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
176 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
177 else {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
178 fprintf(stderr, "%s: invalid signature file %s\n", progname, signature_name);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
179 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
180 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
181 fclose(sig);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
182 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
183 else {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
184 fprintf(stderr, "%s: signature file not specified, use -s file option\n", progname);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
185 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
186 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
187
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
188 pgm_readpgminit(in, &cols, &rows, &maxval, &format);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
189
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
190 if (cols % NJPEG) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
191 fprintf(stderr, "%s: image width %d not a multiple of %d\n", progname, cols, NJPEG);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
192 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
193 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
194
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
195 if (rows % NJPEG) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
196 fprintf(stderr, "%s: image height %d not a multiple of %d\n", progname, rows, NJPEG);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
197 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
198 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
199
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
200 if ((cols * rows) / (NJPEG * NJPEG) < nbit_signature) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
201 fprintf(stderr, "%s: image not large enough to embed %d bits of signature\n", progname, nbit_signature);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
202 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
203 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
204
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
205 init_dct_8x8();
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
206 init_quantum_JPEG_lumin(quantization);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
207
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
208 dcts = alloc_coeffs_8x8();
18
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
209 image_block = alloc_grays_8x8();
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
210
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
211 if ((coords = alloc_coords(nbit_signature)) == NULL) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
212 fprintf(stderr, "%s: unable to allocate memory\n", progname);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
213 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
214 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
215
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
216 image = pgm_allocarray(cols, rows);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
217
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
218 for (row = 0; row < rows; row++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
219 pgm_readpgmrow(in, image[row], cols, maxval, format);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
220
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
221 fclose(in);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
222
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
223 // embedding signature bits by modifying two coefficient relationship,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
224 // one bit for each block
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
225 n = 0;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
226 while (n < nbit_signature) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
227 int xb;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
228 int yb;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
229 int c1, c2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
230 double v1, v2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
231 double w1, w2;
18
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
232 double best_w1, best_w2;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
233 double diff;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
234 double mod;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
235 double try;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
236 double best_mse;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
237 int no_mse_opt = 0;
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
238
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
239 // randomly select a block, check to get distinct blocks
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
240 // (don't watermark a block twice)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
241 do {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
242 xb = random() % (cols / NJPEG);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
243 yb = random() % (rows / NJPEG);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
244 } while (add_coord(coords, xb, yb) < 0);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
245
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
246 // do the forward 8x8 DCT of that block
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
247 fdct_block_8x8(image, xb * NJPEG, yb * NJPEG, dcts);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
248
18
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
249 copy_grays_to_block(image_block, image, xb*NJPEG, yb*NJPEG, NJPEG, NJPEG);
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
250
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
251 // randomly select two distinct coefficients from block
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
252 // only accept coefficients in the middle frequency range
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
253 do {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
254 c1 = (random() % (NJPEG * NJPEG - 2)) + 1;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
255 c2 = (random() % (NJPEG * NJPEG - 2)) + 1;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
256 } while (c1 == c2 || !is_middle_frequency_coeff_8x8(c1) || !is_middle_frequency_coeff_8x8(c2));
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
257
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
258 // quantize block according to quantization quality parameter
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
259 quantize_8x8(dcts);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
260
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
261 if (verbose > 0)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
262 fprintf(stderr, "%d: quantized DCT block (x %d/y %d), modifying (x %d/y %d), (x %d/y %d) for %s\n", n, xb * NJPEG, yb * NJPEG, c1 % NJPEG, c1 / NJPEG, c2 % NJPEG, c2 / NJPEG, get_signature_bit(n) ? "HIGH" : "LOW");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
263 if (verbose > 5)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
264 print_coeffs_8x8(dcts);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
265
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
266 v1 = dcts[c1 / NJPEG][c1 % NJPEG];
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
267 v2 = dcts[c2 / NJPEG][c2 % NJPEG];
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
268
18
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
269 best_w1 = DBL_MAX, best_w2 = DBL_MAX;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
270 try = 0.0;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
271 best_mse = DBL_MAX;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
272
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
273 diff = fabs(v1) - fabs(v2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
274
18
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
275 if (get_signature_bit(n))
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
276 mod = fabs(quality - ( fabs(v1) - fabs(v2) ));
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
277 else
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
278 mod = fabs(quality - (fabs(v2) - fabs(v1)));
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
279
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
280 if (verbose > 2)
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
281 fprintf(stderr, "%d / %d: %.2f %.2f %.2f | %d\n", xb, yb, diff, v1, v2, get_signature_bit(n));
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
282
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
283 while (try <= mod) {
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
284 w1 = v1;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
285 w2 = v2;
18
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
286
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
287 // modify coefficient's relationship to embed signature bit
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
288 // using mean square error to minimize error
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
289 if (get_signature_bit(n)) {
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
290 if (diff < quality) {
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
291 // we have to impose the relationship, does not occur naturally
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
292 w1 = sign(v1)*(fabs(v1) + mod - try);
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
293 w2 = sign(v2)*(fabs(v2) - try);
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
294 }
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
295 }
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
296 else {
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
297 if (diff > -quality) {
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
298 // force the relationship
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
299 w2 = sign(v2)*(fabs(v2) + mod - try);
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
300 w1 = sign(v1)*(fabs(v1) - try);
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
301 }
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
302 }
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
303
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
304 double mse = try_modif(image_block, dcts, c1, c2, w1, w2);
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
305 if (mse < best_mse) {
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
306 best_w1 = w1;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
307 best_w2 = w2;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
308 best_mse = mse;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
309 }
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
310
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
311 if (verbose > 2)
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
312 fprintf(stderr, "%d / %d: MSE %.2f %.2f; %.2f: %.2f %.2f\n", xb, yb, mse, best_mse, try, w1, w2);
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
313
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
314 if (fabs(mse) == 1e-3)
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
315 break;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
316
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
317 if (fabs(fabs(w1) - fabs(w2) + quality) > 1e-3)
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
318 break;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
319
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
320 if (no_mse_opt)
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
321 break;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
322
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
323 try += 0.05;
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
324 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
325
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
326 if (verbose > 1)
18
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
327 fprintf(stderr, " %f -> %f, %f -> %f\n", v1, best_w1, v2, best_w2);
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
328
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
329 // put the changed coefficients back to black
18
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
330 dcts[c1 / NJPEG][c1 % NJPEG] = best_w1;
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
331 dcts[c2 / NJPEG][c2 % NJPEG] = best_w2;
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
332
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
333 // the obvious :-)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
334 dequantize_8x8(dcts);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
335
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
336 // do the inverse DCT on the modified 8x8 block
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
337 idct_block_8x8(dcts, image, xb * NJPEG, yb * NJPEG);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
338
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
339 n++;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
340 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
341
18
3bdb67e76858 mse opt.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 17
diff changeset
342 free_grays(image_block);
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
343 free_coeffs(dcts);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
344
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
345 pgm_writepgminit(out, cols, rows, maxval, 0);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
346 for (row = 0; row < rows; row++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
347 pgm_writepgmrow(out, image[row], cols, maxval, 0);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
348
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
349 fclose(out);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
350
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
351 pgm_freearray(image, rows);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
352
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
353 exit(0);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
354 }

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.