Browse Source

* blur.c: adapt the kernel size to large values of dx and/or dy.

* blur.c: fix the dx/dy sign meaning.

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

+ 6
- 4
pipi/filter/blur.c View File

@@ -66,13 +66,15 @@ pipi_image_t *pipi_gaussian_blur_ext(pipi_image_t *src, float rx, float ry,

buffer = malloc(w * h * (gray ? 1 : 4) * sizeof(double));

kr = (int)(3. * rx + 1.99999);
/* FIXME: the kernel becomes far too big with large values of dx, because
* we grow both left and right. Fix the growing direction. */
kr = (int)(3. * rx + .99999 + ceil(abs(dx)));
kw = 2 * kr + 1;
K = -1. / (2. * rx * rx);

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

for(y = 0; y < h; y++)
{
@@ -125,13 +127,13 @@ pipi_image_t *pipi_gaussian_blur_ext(pipi_image_t *src, float rx, float ry,

free(kernel);

kr = (int)(3. * ry + 1.99999);
kr = (int)(3. * ry + .99999 + ceil(abs(dy)));
kw = 2 * kr + 1;
K = -1. / (2. * ry * ry);

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

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


Loading…
Cancel
Save