Ignore:
Timestamp:
08/08/08 20:11:24 (5 years ago)
Author:
sam
Message:
  • blur.c: implement box blur; currently runs in O(n) but we could make it O(1) trivially.
File:
1 edited

Legend:

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

    r2661 r2681  
    8686} 
    8787 
     88/* FIXME: box blur would be incredibly faster using an accumulator instead 
     89 * of a convolution filter... */ 
     90pipi_image_t *pipi_box_blur(pipi_image_t *src, int size) 
     91{ 
     92    return pipi_box_blur_ext(src, size, size); 
     93} 
     94 
     95pipi_image_t *pipi_box_blur_ext(pipi_image_t *src, int m, int n) 
     96{ 
     97    pipi_image_t *ret; 
     98    double *kernel; 
     99    int i; 
     100 
     101    kernel = malloc(m * n * sizeof(double)); 
     102    for(i = 0; i < m * n; i++) 
     103        kernel[i] = 1. / (m * n); 
     104 
     105    ret = pipi_convolution(src, m, n, kernel); 
     106 
     107    free(kernel); 
     108 
     109    return ret; 
     110} 
     111 
Note: See TracChangeset for help on using the changeset viewer.