Data Conversion by Multi-Bit Neighborhood Mask Dithered Interpolation
(input)-o----->[quantizer]------>[adder]-->[table]
| ^
|--->[neighborhood sample]--|
Fig.1 Neighborhood Mask Dither
Single-bit mask dither requires 2**k samples
to converge for k truncated bits. For example, consider the case of a 17x17x17
table
...then 5 table entries and their weights would be:( T[R + (r & 0x08)>>3][G + (g & 0x08)>>3][B + (b & 0x08)>>3]<<3 + T[R + (r & 0x04)>>2][G + (g & 0x04)>>2][B + (b & 0x04)>>2]<<2 + T[R + (r & 0x02)>>1][G + (g & 0x02)>>1][B + (b & 0x02)>>1]<<1 + T[R + (r & 0x01)][G + (g & 0x01)][B + (b & 0x01)] + T[R][G][B] ) >> 4This implementation generates a weighted average for each sample. Alternatively, here is code for a 2-bit mask dither of 4 truncated bits shift[] = {3,2,3,1,3,2,3,0};
for(i=0; i < end; i++) { /* for all samples */
r = RGB[0][i]; g = RGB[1][i]; b = RGB[2][i]; /* sample data */
R = r >> 4; G = g >> 4; B == B >> 4; /* truncate to index sparse table T[][][] */
m = shift[i & 0x07]; /* select the shift for this sample */
if( 0 == m ) { /* special case lsb */
/* 4 bits have 16 possible values;
/* for convergence with 8 samples, the lsb and 0 each have weight 0.5 */
weighted_average[i] = (T[R+(r & 1)][G+(g & 1)][B+(b & 1)] + T[R][G][B])>>1;
}
else {
#define mask(c) ((c>>m) & 1); /* test a bit */
/* increment indices with masked bits */
weighted_average[i] = T[R+mask(r)][G+mask(g)][B+mask(b)]<<(m-1);
}
}
For n-dimensional interpolation, up to 2**n table entries are accessed. |
|
maintained by blekenbleu |