int main(int argc, char* argv[]) { FILE *in; int **image; double **image_i; double **image_d; int c; int N; int coeff_start = 5000, wm_length = 10000; double wm_alpha = 0.2; int width, height; pgm_init(&argc, argv); wm_init2(); while ((c = getopt(argc, argv, "a:s:l:")) != EOF) { switch (c) { case 'a': wm_alpha = atof(optarg); break; case 's': coeff_start = atoi(optarg); break; case 'l': wm_length = atoi(optarg); break; } } argc -= optind; argv += optind; in = stdin; open_image(in, &width, &height); image = imatrix(height, width); load_image(image, in, width, height); if (height == width) N = height; else { fprintf(stderr, "Cannot Proccess non-square images!\n"); exit( -11); } image_i = dmatrix(height, width); image_d = dmatrix(height, width); if (image_d == NULL) { fprintf(stderr, "Unable to allocate the double array\n"); exit(1); } matrix_i2d(image, image_i, N); hartley(image_i, image_d, N); read_watermark(image_d, N, coeff_start, wm_length, wm_alpha); freematrix_d(image_i, height); freematrix_d(image_d, height); fclose(in); exit(EXIT_SUCCESS); }
void idct(FLOAT *x,FLOAT *y,int m,FLOAT *tab) { int n, n2, i; FLOAT *cp1, *cp2, *xp1, *xp2, *yp1, *yp2; double arg, delta_w; /* Compute: n = length of transform n2 = n/2 */ n = 1 << m; n2 = n >> 1; /* Update table of sines & cosines if n has changed */ if( (int) (*tab) != n) { delta_w = PI / (2*n); cp1 = tab + n2; cp2 = cp1 + n2; arg = 0; for( i = 0; i < n2; i++ ) { *(cp1++) = (FLOAT) (cos(arg) - sin(arg)) * SQH; *(cp2++) = (FLOAT) (cos(arg) + sin(arg)) * SQH; arg += delta_w; } } /* Rotation from x to y */ *y = *x; *(y+n2) = *(x+n2); cp1 = tab + n2 + 1; cp2 = cp1 + n2; xp1 = x + 1; xp2 = x + (n - 1); yp1 = y + 1; yp2 = y + (n - 1); for ( i = 1; i < n2; i++ ) { *(yp1++) = (*cp1) * (*xp1) + (*cp2) * (*xp2); *(yp2--) = (*cp2++) * (*xp1++) - (*cp1++) * (*xp2--); } hartley(y, m, tab); /* Bck to x sequence */ xp1 = x; xp2 = x + (n-1); yp1 = y; yp2 = y + n2; for ( i = 0; i < n2; i++) { *xp1 = *(yp1++); *xp2 = *(yp2++); xp1 += 2; xp2 -= 2; } }
static void apply(const plan *ego_, R *ri, R *ii, R *ro, R *io) { const P *ego = (const P *) ego_; INT i; INT n = ego->n, is = ego->is, os = ego->os; const TWR *W = ego->td->W; E *buf; size_t bufsz = n * 2 * sizeof(E); BUF_ALLOC(E *, buf, bufsz); hartley(n, ri, ii, is, buf, ro, io); for (i = 1; i + i < n; ++i) { cdot(n, buf, W, ro + i * os, io + i * os, ro + (n - i) * os, io + (n - i) * os); W += n - 1; } BUF_FREE(buf, bufsz); }