Better^2 Raytrace output for Imagen printers
Geoffrey Cooper
geof at imagen.UUCP
Fri Aug 15 06:18:47 AEST 1986
As always, I came up with "just the right thing" just after posting.
The following is a better dither function. The difference between it and
the one posted is [1] the grid function is now exp(x*.66) instead of exp(x),
and [2] one line of code is added to skew the grid in a bricklayer's pattern
rather than straight up and down. [1] makes the greatest difference -- it
has the effect of darkening the picture and bringing out more grey levels.
[2] is most noticeable when you are looking at the picture from close up.
- Geof Cooper
IMAGEN
-----------CUT HERE---------------
dither(x, y, level)
int x, y, level;
{
int dlev; /* dither level */
static unsigned char expgrid[64] = {
9, 10, 11, 11, 12, 12, 13, 14,
40, 42, 44, 46, 49, 51, 54, 15,
37, 112, 118, 124, 130, 137, 57, 15,
36, 106, 208, 219, 230, 145, 60, 16,
34, 101, 197, 254, 243, 152, 63, 17,
32, 96, 187, 178, 169, 160, 66, 18,
30, 91, 86, 82, 78, 74, 70, 19,
29, 27, 26, 25, 23, 22, 21, 20
};
/*
* skew every second line over by half a grid to get a brick-layer's
* pattern, rather than a straight grid. The human eye is too good
* at seeing straight lines when the points in the grid line up.
*/
x += (y & 8) >> 1;
/* apply an 8x8 grid: */
dlev = ((y & 7) << 3) + (x & 7);
/* apply dithering function and compare */
return ( level < expgrid[dlev] );
}
More information about the Comp.sources.unix
mailing list