Kaynağa Gözat

* 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 yıl önce
ebeveyn
işleme
ea38654c88
1 değiştirilmiş dosya ile 5 ekleme ve 7 silme
  1. +5
    -7
      pipi/filter/blur.c

+ 5
- 7
pipi/filter/blur.c Dosyayı Görüntüle

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


w = src->w; 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); kr = (int)(3. * rx + 0.99999);
kw = 2 * kr + 1; 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)); kernel = malloc(kw * sizeof(double));
for(i = -kr; i <= kr; i++) 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++) 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); kr = (int)(3. * ry + 0.99999);
kw = 2 * kr + 1; 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)); kernel = malloc(kw * sizeof(double));
for(i = -kr; i <= kr; i++) 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++) for(y = 0; y < h; y++)
{ {


Yükleniyor…
İptal
Kaydet