Browse Source

* filter/blur.c: avoid annoying side effects with very small or negative

blur radii.

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

+ 10
- 2
pipi/filter/blur.c View File

@@ -27,6 +27,11 @@
#include "pipi.h"
#include "pipi_internals.h"

/* Any standard deviation below this value will be rounded up, in order
* to avoid ridiculously low values. exp(-1/(2*0.2*0.2)) is < 10^-5 so
* there is little chance that any value below 0.2 will be useful. */
#define BLUR_EPSILON 0.2

pipi_image_t *pipi_gaussian_blur(pipi_image_t *src, float radius)
{
return pipi_gaussian_blur_ext(src, radius, radius, 0.0, 0.0);
@@ -42,6 +47,9 @@ pipi_image_t *pipi_gaussian_blur_ext(pipi_image_t *src, float rx, float ry,
double K;
int x, y, i, w, h, kr, kw;

if(rx < BLUR_EPSILON) rx = BLUR_EPSILON;
if(ry < BLUR_EPSILON) ry = BLUR_EPSILON;

w = src->w;
h = src->h;

@@ -54,7 +62,7 @@ pipi_image_t *pipi_gaussian_blur_ext(pipi_image_t *src, float rx, float ry,

buffer = malloc(w * h * 4 * sizeof(double));

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

@@ -91,7 +99,7 @@ pipi_image_t *pipi_gaussian_blur_ext(pipi_image_t *src, float rx, float ry,

free(kernel);

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



Loading…
Cancel
Save