Changeset 2643


Ignore:
Timestamp:
Aug 2, 2008, 2:12:58 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • blur.c: adapt the kernel size to large values of dx and/or dy.
  • blur.c: fix the dx/dy sign meaning.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/pipi/filter/blur.c

    r2634 r2643  
    6767    buffer = malloc(w * h * (gray ? 1 : 4) * sizeof(double));
    6868
    69     kr = (int)(3. * rx + 1.99999);
     69    /* FIXME: the kernel becomes far too big with large values of dx, because
     70     * we grow both left and right. Fix the growing direction. */
     71    kr = (int)(3. * rx + .99999 + ceil(abs(dx)));
    7072    kw = 2 * kr + 1;
    7173    K = -1. / (2. * rx * rx);
     
    7375    kernel = malloc(kw * sizeof(double));
    7476    for(i = -kr; i <= kr; i++)
    75         kernel[i + kr] = exp(K * ((double)i - dx) * ((double)i - dx));
     77        kernel[i + kr] = exp(K * ((double)i + dx) * ((double)i + dx));
    7678
    7779    for(y = 0; y < h; y++)
     
    126128    free(kernel);
    127129
    128     kr = (int)(3. * ry + 1.99999);
     130    kr = (int)(3. * ry + .99999 + ceil(abs(dy)));
    129131    kw = 2 * kr + 1;
    130132    K = -1. / (2. * ry * ry);
     
    132134    kernel = malloc(kw * sizeof(double));
    133135    for(i = -kr; i <= kr; i++)
    134         kernel[i + kr] = exp(K * ((double)i - dy) * ((double)i - dy));
     136        kernel[i + kr] = exp(K * ((double)i + dy) * ((double)i + dy));
    135137
    136138    for(y = 0; y < h; y++)
Note: See TracChangeset for help on using the changeset viewer.