Browse Source

* filter/blur.c: minor optimisation in the kernel generation.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2618 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam 16 years ago
parent
commit
ea38654c88
1 changed files with 5 additions and 7 deletions
  1. +5
    -7
      pipi/filter/blur.c

+ 5
- 7
pipi/filter/blur.c View File

@@ -39,7 +39,7 @@ pipi_image_t *pipi_gaussian_blur_ext(pipi_image_t *src, float rx, float ry,
pipi_pixels_t *srcp, *dstp;
float *srcdata, *dstdata;
double *kernel, *buffer;
double K, L;
double K;
int x, y, i, w, h, kr, kw;

w = src->w;
@@ -56,12 +56,11 @@ pipi_image_t *pipi_gaussian_blur_ext(pipi_image_t *src, float rx, float ry,

kr = (int)(3. * rx + 0.99999);
kw = 2 * kr + 1;
K = 1. / (sqrt(2. * M_PI) * rx);
L = -1. / (2. * rx * rx);
K = -1. / (2. * rx * rx);

kernel = malloc(kw * sizeof(double));
for(i = -kr; i <= kr; i++)
kernel[i + kr] = exp(L * ((double)i - dx) * ((double)i - dx)) * K;
kernel[i + kr] = exp(K * ((double)i - dx) * ((double)i - dx));

for(y = 0; y < h; y++)
{
@@ -94,12 +93,11 @@ pipi_image_t *pipi_gaussian_blur_ext(pipi_image_t *src, float rx, float ry,

kr = (int)(3. * ry + 0.99999);
kw = 2 * kr + 1;
K = 1. / (sqrt(2. * M_PI) * ry);
L = -1. / (2. * ry * ry);
K = -1. / (2. * ry * ry);

kernel = malloc(kw * sizeof(double));
for(i = -kr; i <= kr; i++)
kernel[i + kr] = exp(L * ((double)i - dy) * ((double)i - dy)) * K;
kernel[i + kr] = exp(K * ((double)i - dy) * ((double)i - dy));

for(y = 0; y < h; y++)
{


Loading…
Cancel
Save