Changeset 2759
- Timestamp:
- Aug 23, 2008, 3:07:42 PM (14 years ago)
- Location:
- libpipi/trunk
- Files:
-
- 3 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
libpipi/trunk/examples/edd.c
r2715 r2759 39 39 double best = 1., fx = -1., fy = -1., bfx = 0., bfy = 0.; 40 40 double e, e0, e1; 41 pipi_image_t *img, * gauss, *dither, *tmp;41 pipi_image_t *img, *kernel, *gauss, *dither, *tmp; 42 42 int dx, dy; 43 43 … … 53 53 pipi_getpixels(img, PIPI_PIXELS_Y_F); 54 54 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); 56 58 pipi_free(img); 57 59 -
libpipi/trunk/pipi/Makefile.am
r2758 r2759 66 66 dither_sources = \ 67 67 dither/ediff.c \ 68 dither/floydsteinberg.c \69 dither/jajuni.c \70 dither/atkinson.c \71 68 dither/ordered.c \ 72 69 dither/ostromoukhov.c \ -
libpipi/trunk/pipi/codec.c
r2757 r2759 30 30 { 31 31 if(!strncmp(name, "random:", 7) || 32 !strncmp(name, "ediff:", 6) || 32 33 !strncmp(name, "bayer:", 6)) 33 34 return pipi_load_stock(name); -
libpipi/trunk/pipi/context.c
r2758 r2759 85 85 src = ctx->images[ctx->nimages - 1]; 86 86 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")) 100 88 dst = pipi_dither_ostromoukhov(src, 0); 101 89 else if(!strcmp(method, "sost")) … … 106 94 return -1; 107 95 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); 108 104 pipi_free(ctx->images[ctx->nimages - 2]); 109 105 ctx->nimages--; -
libpipi/trunk/pipi/dither/ediff.c
r2758 r2759 25 25 /* Perform a generic error diffusion dithering. The first non-zero 26 26 * 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. */ 28 31 pipi_image_t *pipi_dither_ediff(pipi_image_t *img, pipi_image_t *ker, 29 32 pipi_scan_t scan) -
libpipi/trunk/pipi/pipi.h
r2758 r2759 150 150 extern pipi_image_t *pipi_dither_ediff(pipi_image_t *, pipi_image_t *, 151 151 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);155 152 extern pipi_image_t *pipi_dither_ordered(pipi_image_t *, pipi_image_t *); 156 153 extern pipi_image_t *pipi_dither_random(pipi_image_t *); -
libpipi/trunk/pipi/stock.c
r2757 r2759 74 74 } 75 75 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 76 121 /* Generate a completely random image. */ 77 122 if(!strncmp(name, "random:", 7))
Note: See TracChangeset
for help on using the changeset viewer.