annotate Fotopoulos/test-sub.c @ 3:acb6967ee76d

update to 0.5
author Peter Meerwald <pmeerw@cosy.sbg.ac.at>
date Tue, 14 Aug 2007 21:11:21 +0200
parents be303a3f5ea8
children cbecc570129d
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"
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
23
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
24 //--------------------------------------------------------
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
25 void add_hor_add_ver(double **in, int N, double **out);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
26 void add_hor_sub_ver(double **in, int N, double **out);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
27 void sub_hor_add_ver(double **in, int N, double **out);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
28 void sub_hor_sub_ver(double **in, int N, double **out);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
29 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
30
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
31 //--------------------------------------------------------
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
32 double cu[1024];
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
33 double cv[1024];
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
34 int height, width;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
35 //--------------------------------------------------------
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
36 void add_hor_add_ver(double **in, int N, double **out)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
37 {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
38 double **temp;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
39 int r, c;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
40 temp = dmatrix(N, N);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
41 for (r = 0; r < N; r++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
42 for (c = 0; c < N / 2; c++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
43 temp[r][c] = (in[r][2 * c] + in[r][2 * c + 1]) / 2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
44 for (c = 0; c < N / 2; c++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
45 for (r = 0; r < N / 2; r++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
46 out[r][c] = (temp[2 * r][c] + temp[2 * r + 1][c]) / 2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
47 freematrix_d(temp, N);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
48 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
49 //--------------------------------------------------------
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
50 void add_hor_sub_ver(double **in, int N, double **out)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
51 {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
52 double **temp;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
53 int r, c;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
54 temp = dmatrix(N, N);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
55 for (r = 0; r < N; r++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
56 for (c = 0; c < N / 2; c++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
57 temp[r][c] = (in[r][2 * c] + in[r][2 * c + 1]) / 2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
58 for (c = 0; c < N / 2; c++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
59 for (r = 0; r < N / 2; r++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
60 out[r][c] = (temp[2 * r][c] - temp[2 * r + 1][c]) / 2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
61 freematrix_d(temp, N);
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 void sub_hor_add_ver(double **in, int N, double **out)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
65 {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
66 double **temp;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
67 int r, c;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
68 temp = dmatrix(N, N);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
69 for (r = 0; r < N; r++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
70 for (c = 0; c < N / 2; c++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
71 temp[r][c] = (in[r][2 * c] - in[r][2 * c + 1]) / 2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
72 for (c = 0; c < N / 2; c++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
73 for (r = 0; r < N / 2; r++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
74 out[r][c] = (temp[2 * r][c] + temp[2 * r + 1][c]) / 2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
75 freematrix_d(temp, N);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
76 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
77 //--------------------------------------------------------
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
78 void sub_hor_sub_ver(double **in, int N, double **out)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
79 {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
80 double **temp;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
81 int r, c;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
82 temp = dmatrix(N, N);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
83 for (r = 0; r < N; r++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
84 for (c = 0; c < N / 2; c++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
85 temp[r][c] = (in[r][2 * c] - in[r][2 * c + 1]) / 2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
86 for (c = 0; c < N / 2; c++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
87 for (r = 0; r < N / 2; r++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
88 out[r][c] = (temp[2 * r][c] - temp[2 * r + 1][c]) / 2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
89 freematrix_d(temp, N);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
90 }
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 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
94 {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
95 int row, col, count;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
96 long int elem, temp, seed;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
97 double z;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
98
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
99
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
100 seed = key;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
101 z = 0.0;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
102 count = 0;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
103 elem = 0;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
104 row = 2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
105 col = -1;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
106 do {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
107 do {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
108 row--;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
109 col++;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
110 elem++;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
111 if (col < N) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
112 if (elem > M) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
113 temp = row * N + col;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
114 z += i[temp] * gasdev(&seed);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
115 count++;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
116 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
117 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
118 } while (row > 0);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
119 row = 2 + col;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
120 col = -1;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
121 } while (count < L);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
122
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
123 return (z / L);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
124 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
125
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
126 int main(int argc, char* argv[])
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
127 {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
128 double **i;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
129 FILE *in;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
130 int N;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
131 long int key, M1, L1, M2, L2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
132 double **ll, **lh, **hl, **hh;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
133 double *v1, *v2, *v3, *v99;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
134 double m1, m2, m3, detect_value, m99;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
135 int ** image_i;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
136 int c;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
137 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
138 double a_ll = 0.1, a_other = 0.2;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
139
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
140 pgm_init(&argc, argv); wm_init2();
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
141
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
142 while ((c = getopt(argc, argv, "a:b:t:m:s:l:")) != EOF) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
143 switch (c) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
144 case 'a':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
145 a_ll = atof(optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
146 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
147 case 'b':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
148 a_other = atof(optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
149 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
150 case 't':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
151 coeff_start_1 = atoi(optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
152 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
153 case 'm':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
154 wm_length_1 = atoi(optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
155 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
156 case 's':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
157 coeff_start_ll = atoi(optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
158 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
159 case 'l':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
160 wm_length_ll = atoi(optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
161 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
162 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
163 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
164 argc -= optind;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
165 argv += optind;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
166
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
167 in = stdin;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
168 open_image(in, &width, &height);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
169 image_i = imatrix(height, width);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
170 load_image(image_i, in, width, height);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
171
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
172 if (height == width)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
173 N = height;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
174 else {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
175 fprintf(stderr, "Cannot Proccess non-square images!\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
176 exit( -11);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
177 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
178 // starting coeff. for 1st level decomp.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
179 M1 = coeff_start_1;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
180 // number of coeffs to alter
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
181 L1 = wm_length_1;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
182 // alpha parameter
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
183
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
184 // now the LL band
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
185 M2 = coeff_start_ll;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
186 L2 = wm_length_ll;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
187
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
188
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
189 i = dmatrix(N, N);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
190 ll = dmatrix(N / 2, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
191 lh = dmatrix(N / 2, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
192 hl = dmatrix(N / 2, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
193 hh = dmatrix(N / 2, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
194 v1 = dvector(N * N / 4);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
195 v2 = dvector(N * N / 4);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
196 v3 = dvector(N * N / 4);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
197 v99 = dvector(N * N / 4);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
198
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
199 matrix_i2d(image_i, i, N);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
200
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
201 //---------------------1o decomposition-------------------
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
202 add_hor_add_ver(i, N, ll);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
203 add_hor_sub_ver(i, N, lh);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
204 sub_hor_add_ver(i, N, hl);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
205 sub_hor_sub_ver(i, N, hh);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
206 //---------------------Detect Watermark from all bands----
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
207 put_matrix_2_vector(lh, v1, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
208 put_matrix_2_vector(hl, v2, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
209 put_matrix_2_vector(hh, v3, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
210 put_matrix_2_vector(ll, v99, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
211 fct2d(v1, N / 2, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
212 fct2d(v2, N / 2, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
213 fct2d(v3, N / 2, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
214 fct2d(v99, N / 2, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
215 for (key = 1; key <= 1000; key++) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
216 m1 = detect_mark(v1, N / 2, key, L1, M1, a_other);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
217 m2 = detect_mark(v2, N / 2, key, L1, M1, a_other);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
218 m3 = detect_mark(v3, N / 2, key, L1, M1, a_other);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
219 m99 = detect_mark(v99, N / 2, key, L2, M2, a_ll);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
220 detect_value = (m1 + m2 + m3 + m99) / 4;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
221 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
222 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
223 //--------------------------------------------------------
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
224 free(v1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
225 free(v2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
226 free(v3);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
227 free(v99);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
228 freematrix_d(ll, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
229 freematrix_d(hl, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
230 freematrix_d(lh, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
231 freematrix_d(hh, N / 2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
232 fclose(in);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
233 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
234
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
235
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
236
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
237

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