annotate Fotopoulos-dir/test-sub.c @ 25:5a57a145bccb default tip

Added tag v0.7 for changeset 9f20bce6184e
author Peter Meerwald-Stadler <pmeerw@pmeerw.net>
date Fri, 20 Dec 2024 13:32:15 +0100
parents 9f20bce6184e
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 /* Watermarking program - Subband DCT Transform based */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
2 /* Module : Testing */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
3 /* Author : Vassilis Fotopoulos */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
4 /* Date : 25/4/2000 */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
5 /* Revision : 6.0 */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
6 /* Developed at : ELLAB */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
7 /* Electronics Laboratory */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
8 /* Department of Physics */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
9 /* University of Patras - GREECE */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
10 /* Copyleft (c) 1999 */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
11 /*------------------------------------------------------*/
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
12 /* pseudorandom noise generator's code is */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
13 /* taken from "Numerical Recipes in C" */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
14 /* FCT implementation from University of Bath */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
15 /*------------------------------------------------------*/
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
16 #include <stdio.h>
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
17 #include <stdlib.h>
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
18 #include <string.h>
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
19 #include <math.h>
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
20 #include <float.h>
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
21 #include <getopt.h>
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
22 #include "common.h"
24
9f20bce6184e move directories, support netpbm 11
Peter Meerwald-Stadler <pmeerw@pmeerw.net>
parents: 13
diff changeset
23 #include "netpbm/pgm.h"
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
24
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
25 //--------------------------------------------------------
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
26 void add_hor_add_ver(double **in, int N, double **out);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
27 void add_hor_sub_ver(double **in, int N, double **out);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
28 void sub_hor_add_ver(double **in, int N, double **out);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
29 void sub_hor_sub_ver(double **in, int N, double **out);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
30 double detect_mark(double *i, int N, long key, long int L, long int M, double a);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
31
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
32 //--------------------------------------------------------
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
33 double cu[1024];
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
34 double cv[1024];
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
35 int height, width;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
36 //--------------------------------------------------------
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
37 void add_hor_add_ver(double **in, int N, double **out)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
38 {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
39 double **temp;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
40 int r, c;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
41 temp = dmatrix(N, N);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
42 for (r = 0; r < N; r++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
43 for (c = 0; c < N / 2; c++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
44 temp[r][c] = (in[r][2 * c] + in[r][2 * c + 1]) / 2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
45 for (c = 0; c < N / 2; c++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
46 for (r = 0; r < N / 2; r++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
47 out[r][c] = (temp[2 * r][c] + temp[2 * r + 1][c]) / 2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
48 freematrix_d(temp, N);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
49 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
50 //--------------------------------------------------------
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
51 void add_hor_sub_ver(double **in, int N, double **out)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
52 {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
53 double **temp;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
54 int r, c;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
55 temp = dmatrix(N, N);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
56 for (r = 0; r < N; r++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
57 for (c = 0; c < N / 2; c++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
58 temp[r][c] = (in[r][2 * c] + in[r][2 * c + 1]) / 2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
59 for (c = 0; c < N / 2; c++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
60 for (r = 0; r < N / 2; r++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
61 out[r][c] = (temp[2 * r][c] - temp[2 * r + 1][c]) / 2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
62 freematrix_d(temp, N);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
63 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
64 //--------------------------------------------------------
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
65 void sub_hor_add_ver(double **in, int N, double **out)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
66 {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
67 double **temp;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
68 int r, c;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
69 temp = dmatrix(N, N);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
70 for (r = 0; r < N; r++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
71 for (c = 0; c < N / 2; c++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
72 temp[r][c] = (in[r][2 * c] - in[r][2 * c + 1]) / 2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
73 for (c = 0; c < N / 2; c++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
74 for (r = 0; r < N / 2; r++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
75 out[r][c] = (temp[2 * r][c] + temp[2 * r + 1][c]) / 2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
76 freematrix_d(temp, N);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
77 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
78 //--------------------------------------------------------
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
79 void sub_hor_sub_ver(double **in, int N, double **out)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
80 {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
81 double **temp;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
82 int r, c;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
83 temp = dmatrix(N, N);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
84 for (r = 0; r < N; r++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
85 for (c = 0; c < N / 2; c++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
86 temp[r][c] = (in[r][2 * c] - in[r][2 * c + 1]) / 2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
87 for (c = 0; c < N / 2; c++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
88 for (r = 0; r < N / 2; r++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
89 out[r][c] = (temp[2 * r][c] - temp[2 * r + 1][c]) / 2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
90 freematrix_d(temp, N);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
91 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
92
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
93 //---------------------------------------------------------
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
94 double detect_mark(double *i, int N, long key, long int L, long int M, double a)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
95 {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
96 int row, col, count;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
97 long int elem, temp, seed;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
98 double z;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
99
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
100
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
101 seed = key;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
102 z = 0.0;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
103 count = 0;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
104 elem = 0;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
105 row = 2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
106 col = -1;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
107 do {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
108 do {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
109 row--;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
110 col++;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
111 elem++;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
112 if (col < N) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
113 if (elem > M) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
114 temp = row * N + col;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
115 z += i[temp] * gasdev(&seed);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
116 count++;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
117 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
118 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
119 } while (row > 0);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
120 row = 2 + col;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
121 col = -1;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
122 } while (count < L);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
123
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
124 return (z / L);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
125 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
126
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
127 int main(int argc, char* argv[])
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
128 {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
129 double **i;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
130 FILE *in;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
131 int N;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
132 long int key, M1, L1, M2, L2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
133 double **ll, **lh, **hl, **hh;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
134 double *v1, *v2, *v3, *v99;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
135 double m1, m2, m3, detect_value, m99;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
136 int ** image_i;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
137 int c;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
138 int wm_length_1 = 10000, wm_length_ll = 10000, coeff_start_1 = 3000, coeff_start_ll = 3000;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
139 double a_ll = 0.1, a_other = 0.2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
140
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
141 pgm_init(&argc, argv); wm_init2();
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
142
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
143 while ((c = getopt(argc, argv, "a:b:t:m:s:l:")) != EOF) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
144 switch (c) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
145 case 'a':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
146 a_ll = atof(optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
147 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
148 case 'b':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
149 a_other = atof(optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
150 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
151 case 't':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
152 coeff_start_1 = atoi(optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
153 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
154 case 'm':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
155 wm_length_1 = atoi(optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
156 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
157 case 's':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
158 coeff_start_ll = atoi(optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
159 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
160 case 'l':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
161 wm_length_ll = atoi(optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
162 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
163 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
164 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
165 argc -= optind;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
166 argv += optind;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
167
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
168 in = stdin;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
169 open_image(in, &width, &height);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
170 image_i = imatrix(height, width);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
171 load_image(image_i, in, width, height);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
172
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
173 if (height == width)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
174 N = height;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
175 else {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
176 fprintf(stderr, "Cannot Proccess non-square images!\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
177 exit( -11);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
178 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
179 // starting coeff. for 1st level decomp.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
180 M1 = coeff_start_1;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
181 // number of coeffs to alter
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
182 L1 = wm_length_1;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
183 // alpha parameter
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
184
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
185 // now the LL band
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
186 M2 = coeff_start_ll;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
187 L2 = wm_length_ll;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
188
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
189
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
190 i = dmatrix(N, N);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
191 ll = dmatrix(N / 2, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
192 lh = dmatrix(N / 2, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
193 hl = dmatrix(N / 2, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
194 hh = dmatrix(N / 2, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
195 v1 = dvector(N * N / 4);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
196 v2 = dvector(N * N / 4);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
197 v3 = dvector(N * N / 4);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
198 v99 = dvector(N * N / 4);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
199
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
200 matrix_i2d(image_i, i, N);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
201
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
202 //---------------------1o decomposition-------------------
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
203 add_hor_add_ver(i, N, ll);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
204 add_hor_sub_ver(i, N, lh);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
205 sub_hor_add_ver(i, N, hl);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
206 sub_hor_sub_ver(i, N, hh);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
207 //---------------------Detect Watermark from all bands----
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
208 put_matrix_2_vector(lh, v1, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
209 put_matrix_2_vector(hl, v2, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
210 put_matrix_2_vector(hh, v3, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
211 put_matrix_2_vector(ll, v99, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
212 fct2d(v1, N / 2, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
213 fct2d(v2, N / 2, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
214 fct2d(v3, N / 2, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
215 fct2d(v99, N / 2, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
216 for (key = 1; key <= 1000; key++) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
217 m1 = detect_mark(v1, N / 2, key, L1, M1, a_other);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
218 m2 = detect_mark(v2, N / 2, key, L1, M1, a_other);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
219 m3 = detect_mark(v3, N / 2, key, L1, M1, a_other);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
220 m99 = detect_mark(v99, N / 2, key, L2, M2, a_ll);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
221 detect_value = (m1 + m2 + m3 + m99) / 4;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
222 printf("%ld\t%f\t%f\t%f\t%f\t%f\n", key, m1, m2, m3, m99, detect_value);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
223 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
224 //--------------------------------------------------------
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
225 free(v1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
226 free(v2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
227 free(v3);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
228 free(v99);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
229 freematrix_d(ll, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
230 freematrix_d(hl, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
231 freematrix_d(lh, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
232 freematrix_d(hh, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
233 fclose(in);
13
cbecc570129d cleanup warnings
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 0
diff changeset
234
cbecc570129d cleanup warnings
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 0
diff changeset
235 exit(EXIT_SUCCESS);
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
236 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
237
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
238
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
239
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
240

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