Bladeren bron

* blur.c: implement box blur; currently runs in O(n) but we could make it

O(1) trivially.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2681 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam 16 jaren geleden
bovenliggende
commit
77ec441434
2 gewijzigde bestanden met toevoegingen van 26 en 0 verwijderingen
  1. +24
    -0
      pipi/filter/blur.c
  2. +2
    -0
      pipi/pipi.h

+ 24
- 0
pipi/filter/blur.c Bestand weergeven

@@ -85,3 +85,27 @@ pipi_image_t *pipi_gaussian_blur_ext(pipi_image_t *src, float rx, float ry,
return ret;
}

/* FIXME: box blur would be incredibly faster using an accumulator instead
* of a convolution filter... */
pipi_image_t *pipi_box_blur(pipi_image_t *src, int size)
{
return pipi_box_blur_ext(src, size, size);
}

pipi_image_t *pipi_box_blur_ext(pipi_image_t *src, int m, int n)
{
pipi_image_t *ret;
double *kernel;
int i;

kernel = malloc(m * n * sizeof(double));
for(i = 0; i < m * n; i++)
kernel[i] = 1. / (m * n);

ret = pipi_convolution(src, m, n, kernel);

free(kernel);

return ret;
}


+ 2
- 0
pipi/pipi.h Bestand weergeven

@@ -81,6 +81,8 @@ extern pipi_image_t *pipi_convolution(pipi_image_t *, int, int, double[]);
extern pipi_image_t *pipi_gaussian_blur(pipi_image_t *, float);
extern pipi_image_t *pipi_gaussian_blur_ext(pipi_image_t *,
float, float, float, float);
extern pipi_image_t *pipi_box_blur(pipi_image_t *, int);
extern pipi_image_t *pipi_box_blur_ext(pipi_image_t *, int, int);
extern pipi_image_t *pipi_autocontrast(pipi_image_t *);

extern int pipi_flood_fill(pipi_image_t *,


Laden…
Annuleren
Opslaan