|
@@ -27,6 +27,11 @@ |
|
|
#include "pipi.h" |
|
|
#include "pipi.h" |
|
|
#include "pipi_internals.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) |
|
|
pipi_image_t *pipi_gaussian_blur(pipi_image_t *src, float radius) |
|
|
{ |
|
|
{ |
|
|
return pipi_gaussian_blur_ext(src, radius, radius, 0.0, 0.0); |
|
|
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; |
|
|
double K; |
|
|
int x, y, i, w, h, kr, kw; |
|
|
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; |
|
|
w = src->w; |
|
|
h = src->h; |
|
|
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)); |
|
|
buffer = malloc(w * h * 4 * sizeof(double)); |
|
|
|
|
|
|
|
|
kr = (int)(3. * rx + 0.99999); |
|
|
|
|
|
|
|
|
kr = (int)(3. * rx + 1.99999); |
|
|
kw = 2 * kr + 1; |
|
|
kw = 2 * kr + 1; |
|
|
K = -1. / (2. * rx * rx); |
|
|
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); |
|
|
free(kernel); |
|
|
|
|
|
|
|
|
kr = (int)(3. * ry + 0.99999); |
|
|
|
|
|
|
|
|
kr = (int)(3. * ry + 1.99999); |
|
|
kw = 2 * kr + 1; |
|
|
kw = 2 * kr + 1; |
|
|
K = -1. / (2. * ry * ry); |
|
|
K = -1. / (2. * ry * ry); |
|
|
|
|
|
|
|
|