From 37ab68e449756ba0917fdfb777a98b1d312089df Mon Sep 17 00:00:00 2001 From: sam Date: Thu, 14 Aug 2008 18:35:07 +0000 Subject: [PATCH] * blur.c: improve the Gaussian kernel generation by interpolating its values in a quincunx pattern. git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2719 92316355-f0b4-4df1-b90c-862c8a59935f --- pipi/filter/blur.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/pipi/filter/blur.c b/pipi/filter/blur.c index 1533cdc..9b54225 100644 --- a/pipi/filter/blur.c +++ b/pipi/filter/blur.c @@ -71,11 +71,27 @@ pipi_image_t *pipi_gaussian_blur_ext(pipi_image_t *src, float rx, float ry, { for(i = -krx; i <= krx; i++) { - double u = (double)i * cost - (double)j * sint + dx; - double v = (double)j * cost + (double)i * sint + dy; - double ex = Kx * u * u; - double ey = Ky * v * v; - double d = exp(ex + ey); + static double const samples[] = + { + -.50, -.50, 0.5, + .50, -.50, 0.5, + .0, .0, 1, + -.50, .50, 0.5, + .50, .50, 0.5 + }; + double u, v, ex, ey, d = 0.; + int k; + + for(k = 0; k < 5; k++) + { + u = ((double)i + samples[k * 3]) * cost + - ((double)j + samples[k * 3 + 1]) * sint + dx; + v = ((double)i + samples[k * 3]) * sint + + ((double)j + samples[k * 3 + 1]) * cost + dy; + ex = Kx * u * u; + ey = Ky * v * v; + d += samples[k * 3 + 2] * exp(ex + ey); + } kernel[(j + kry) * m + i + krx] = d; t += d;