Changeset 2759 for libpipi


Ignore:
Timestamp:
Aug 23, 2008, 3:07:42 PM (12 years ago)
Author:
Sam Hocevar
Message:
  • Get rid of the specific error diffusion functions, since our stock kernels work perfectly well.
Location:
libpipi/trunk
Files:
3 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/examples/edd.c

    r2715 r2759  
    3939    double best = 1., fx = -1., fy = -1., bfx = 0., bfy = 0.;
    4040    double e, e0, e1;
    41     pipi_image_t *img, *gauss, *dither, *tmp;
     41    pipi_image_t *img, *kernel, *gauss, *dither, *tmp;
    4242    int dx, dy;
    4343
     
    5353    pipi_getpixels(img, PIPI_PIXELS_Y_F);
    5454    gauss = pipi_gaussian_blur(img, sigma);
    55     dither = pipi_dither_floydsteinberg(img, PIPI_SCAN_RASTER);
     55    kernel = pipi_load("ediff:fs");
     56    dither = pipi_dither_ediff(img, kernel, PIPI_SCAN_RASTER);
     57    pipi_free(kernel);
    5658    pipi_free(img);
    5759
  • libpipi/trunk/pipi/Makefile.am

    r2758 r2759  
    6666dither_sources = \
    6767        dither/ediff.c \
    68         dither/floydsteinberg.c \
    69         dither/jajuni.c \
    70         dither/atkinson.c \
    7168        dither/ordered.c \
    7269        dither/ostromoukhov.c \
  • libpipi/trunk/pipi/codec.c

    r2757 r2759  
    3030{
    3131    if(!strncmp(name, "random:", 7) ||
     32       !strncmp(name, "ediff:", 6) ||
    3233       !strncmp(name, "bayer:", 6))
    3334        return pipi_load_stock(name);
  • libpipi/trunk/pipi/context.c

    r2758 r2759  
    8585        src = ctx->images[ctx->nimages - 1];
    8686        dst = NULL;
    87         if(!strcmp(method, "fs"))
    88             dst = pipi_dither_floydsteinberg(src, 0);
    89         else if(!strcmp(method, "sfs"))
    90             dst = pipi_dither_floydsteinberg(src, 1);
    91         else if(!strcmp(method, "jajuni"))
    92             dst = pipi_dither_jajuni(src, 0);
    93         else if(!strcmp(method, "sjajuni"))
    94             dst = pipi_dither_jajuni(src, 1);
    95         else if(!strcmp(method, "atkinson"))
    96             dst = pipi_dither_atkinson(src, 0);
    97         else if(!strcmp(method, "satkinson"))
    98             dst = pipi_dither_atkinson(src, 1);
    99         else if(!strcmp(method, "ost"))
     87        if(!strcmp(method, "ost"))
    10088            dst = pipi_dither_ostromoukhov(src, 0);
    10189        else if(!strcmp(method, "sost"))
     
    10694                return -1;
    10795            dst = pipi_dither_ediff(ctx->images[ctx->nimages - 2], src, 0);
     96            pipi_free(ctx->images[ctx->nimages - 2]);
     97            ctx->nimages--;
     98        }
     99        else if(!strcmp(method, "sediff"))
     100        {
     101            if(ctx->nimages < 2)
     102                return -1;
     103            dst = pipi_dither_ediff(ctx->images[ctx->nimages - 2], src, 1);
    108104            pipi_free(ctx->images[ctx->nimages - 2]);
    109105            ctx->nimages--;
  • libpipi/trunk/pipi/dither/ediff.c

    r2758 r2759  
    2525/* Perform a generic error diffusion dithering. The first non-zero
    2626 * element in ker is treated as the current pixel. All other non-zero
    27  * elements are the error diffusion coefficients. */
     27 * elements are the error diffusion coefficients.
     28 * Making the matrix generic is not terribly slower: the performance
     29 * hit is around 4% for Floyd-Steinberg and 13% for JaJuNi, with the
     30 * benefit of a lot less code. */
    2831pipi_image_t *pipi_dither_ediff(pipi_image_t *img, pipi_image_t *ker,
    2932                                pipi_scan_t scan)
  • libpipi/trunk/pipi/pipi.h

    r2758 r2759  
    150150extern pipi_image_t *pipi_dither_ediff(pipi_image_t *, pipi_image_t *,
    151151                                       pipi_scan_t);
    152 extern pipi_image_t *pipi_dither_floydsteinberg(pipi_image_t *, pipi_scan_t);
    153 extern pipi_image_t *pipi_dither_jajuni(pipi_image_t *, pipi_scan_t);
    154 extern pipi_image_t *pipi_dither_atkinson(pipi_image_t *, pipi_scan_t);
    155152extern pipi_image_t *pipi_dither_ordered(pipi_image_t *, pipi_image_t *);
    156153extern pipi_image_t *pipi_dither_random(pipi_image_t *);
  • libpipi/trunk/pipi/stock.c

    r2757 r2759  
    7474    }
    7575
     76    /* Generate an error diffusion matrix. */
     77    if(!strncmp(name, "ediff:", 6))
     78    {
     79        float const *ker;
     80        int w, h;
     81
     82        if(!strcmp(name + 6, "fs"))
     83        {
     84            static float const myker[] =
     85            {
     86                   0.,     1.,  7./16,
     87                3./16,  5./16,  1./16
     88            };
     89            ker = myker; w = 3; h = 2;
     90        }
     91        else if(!strcmp(name + 6, "jajuni"))
     92        {
     93            static float const myker[] =
     94            {
     95                   0.,     0.,     1.,  7./48,  5./48,
     96                3./48,  5./48,  7./48,  5./48,  3./48,
     97                1./48,  3./48,  5./48,  3./48,  1./48,
     98            };
     99            ker = myker; w = 5; h = 3;
     100        }
     101        else if(!strcmp(name + 6, "atkinson"))
     102        {
     103            static float const myker[] =
     104            {
     105                  0.,    1.,  1./8,  1./8,
     106                1./8,  1./8,  1./8,    0.,
     107                  0.,  1./8,    0.,    0.,
     108            };
     109            ker = myker; w = 4; h = 3;
     110        }
     111        else
     112            return NULL;
     113
     114        ret = pipi_new(w, h);
     115        pix = pipi_getpixels(ret, PIPI_PIXELS_Y_F);
     116        memcpy(pix->pixels, ker, w * h * sizeof(float));
     117
     118        return ret;
     119    }
     120
    76121    /* Generate a completely random image. */
    77122    if(!strncmp(name, "random:", 7))
Note: See TracChangeset for help on using the changeset viewer.