Changeset 2670 for libpipi/trunk/pipi/dither/dbs.c
- Timestamp:
- 08/04/08 19:23:59 (5 years ago)
- File:
-
- 1 edited
-
libpipi/trunk/pipi/dither/dbs.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libpipi/trunk/pipi/dither/dbs.c
r2666 r2670 36 36 * guaranteed stop condition here. */ 37 37 38 pipi_image_t *pipi_dither_dbs(pipi_image_t * src)38 pipi_image_t *pipi_dither_dbs(pipi_image_t *img) 39 39 { 40 40 double kernel[NN * NN]; 41 41 double t = 0.; 42 pipi_image_t * dst, *tmp1, *tmp2;43 pipi_pixels_t * srcp, *dstp, *tmp1p, *tmp2p;42 pipi_image_t *src, *dst, *tmp1, *tmp2; 43 pipi_pixels_t *dstp, *tmp1p, *tmp2p; 44 44 int *changelist; 45 float * srcdata, *dstdata, *tmp1data, *tmp2data;45 float *dstdata, *tmp1data, *tmp2data; 46 46 int i, j, x, y, w, h, cw, ch; 47 47 … … 62 62 kernel[j * NN + i] /= t; 63 63 64 w = src->w;65 h = src->h;64 w = img->w; 65 h = img->h; 66 66 67 67 cw = (w + CELL - 1) / CELL; … … 70 70 memset(changelist, 0, cw * ch * sizeof(int)); 71 71 72 src p = pipi_getpixels(src, PIPI_PIXELS_Y_F);73 srcdata = (float *)srcp->pixels;72 src = pipi_copy(img); 73 pipi_getpixels(src, PIPI_PIXELS_Y_F); 74 74 75 75 tmp1 = pipi_convolution(src, NN, NN, kernel); … … 77 77 tmp1data = (float *)tmp1p->pixels; 78 78 79 /* The initial dither is an empty image. So is its blurred version, 80 * but I leave the pipi_convolution() call here in case we choose 81 * to change the way to create the initial dither. */ 82 dst = pipi_new(w, h); 79 dst = pipi_dither_floydsteinberg(src, PIPI_SCAN_SERPENTINE); 83 80 dstp = pipi_getpixels(dst, PIPI_PIXELS_Y_F); 84 81 dstdata = (float *)dstp->pixels; 85 82 86 for(y = 0; y < h; y++) 87 for(x = 0; x < w; x++) 88 dstdata[y * w + x] = srcdata[y * w + x] > 0.5 ? 1.0 : 0.0; 83 pipi_free(src); 89 84 90 85 tmp2 = pipi_convolution(dst, NN, NN, kernel);
Note: See TracChangeset
for help on using the changeset viewer.
