Suppose you have some 3-bit data, say, grayscale values for which 000 = black and 111 = white. You have a display device that takes 8-bit data, and you want to extend the bit width of your data to match.
If you just pad the data with zeros, you get the value 11100000 for white, which is not full white for the 8-bit display—that would be 11111111. What can you do?
One clever trick is to repeat the bits you have as many times as necessary to fill the output field width. For example, if the 3-bit input value is ABC, the output value would be ABCABCAB. This produces the following mapping, which interpolates nicely between full black and full white (see Table 1). Note that this mapping preserves the original bits; if you want to go back to the 3-bit representation, just take the MSBs and you have the original data.
Input | Output |
---|---|
0 | 0 |
1 | 100100 |
10 | 1001001 |
11 | 1101101 |
100 | 10010010 |
101 | 10110110 |
110 | 11011011 |
111 | 11111111 |
— ADVERTISMENT—
—Advertise Here—