Path: utzoo!utgpu!water!watmath!watcgl!awpaeth From: awpaeth@watcgl.waterloo.edu (Alan W. Paeth) Newsgroups: comp.graphics Subject: Re: convolution kernel program wanted Message-ID: <2758@watcgl.waterloo.edu> Date: 18 Dec 87 03:35:49 GMT Reply-To: awpaeth@watcgl.waterloo.edu (Alan W. Paeth) Organization: U. of Waterloo, Ontario Lines: 47 Subject: Convolution Kernels /* * Kaiser window weights/coefficients for rectangular convolution kernels * Note: this is a 2-D radial distribution, though the reference mentions that * a rectangular window (Cartesian product of two 1-D filters) is not bad * * Kernel coefficients might be negative -- simple-minded filtering software * take note! * * Alan Paeth, University of Waterloo, 1985 * Taken TK5102.5 T93 (book, US Library of Congress) */ #include#include main(argc, argv) char **argv; { int w, h; float a, t, x, y, r, z; if (argc != 5) usage(); w = atoi(argv[1]); h = atoi(argv[2]); a = atof(argv[3]); t = atof(argv[4]); for(x = -((w-1.0)/2.0); x <= ((w-1.0)/2.0); x += 1.0) { for(y = -((h-1.0)/2.0); y <= ((h-1.0)/2.0); y += 1.0) { r = sqrt(x*x + y*y); z = (r>t) ? 0 : j0(a*sqrt(1.0-(r/t)*(r/t)))/j0(a); /* Bessel fn. */ printf("%f ", z); } printf("\n"); } exit(0); } usage() { fprintf(stderr,"usage: kaiser [width] [height] [slope] [radius]\n"); exit(1); }