TIFF 6.0 Specification
Final—June 3, 1992
use 12-bit-maximum codes and the resulting LZW table is unacceptably large.
Fortunately, due to the adaptive nature of LZW, we do not pay a significant com-
pression ratio penalty for combining several pixels into one byte before compress-
ing. For example, our 4-bit sample images compressed about 3 percent worse, and
our 1-bit images compressed about 5 percent better. And it is easier to write an
LZW compressor that always uses the same character depth than it is to write one
that handles varying depths.
We can now describe some of the routine and variable references in our
pseudocode:
InitializeStringTable() initializes the string table to contain all possible single-
character strings. There are 256 of them, numbered 0 through 255, since our char-
acters are bytes.
WriteCode() writes a code to the output stream. The first code written is a
ClearCode, which is defined to be code #256.
is our “prefix string.”
GetNextCharacter() retrieves the next character value from the input stream. This
will be a number between 0 and 255 because our characters are bytes.
The “+” signs indicate string concatenation.
AddTableEntry() adds a table entry. (InitializeStringTable() has already put 256
entries in our table. Each entry consists of a single-character string, and its associ-
ated code value, which, in our application, is identical to the character itself. That
is, the 0th entry in our table consists of the string <0>, with a corresponding code
value of <0>, the 1st entry in the table consists of the string <1>, with a corre-
sponding code value of <1> and the 255th entry in our table consists of the string
<255>, with a corresponding code value of <255>.) So, the first entry that added
to our string table will be at position 256, right? Well, not quite, because we re-
serve code #256 for a special “Clear” code. We also reserve code #257 for a spe-
cial “EndOfInformation” code that we write out at the end of the strip. So the first
multiple-character entry added to the string table will be at position 258.
For example, suppose we have input data that looks like this:
Pixel 0:<7>
Pixel 1:<7>
Pixel 2:<7>
Pixel 3:<8>
Pixel 4:<8>
Pixel 5:<7>
Pixel 6:<7>
Pixel 7:<6>
Pixel 8:<6>
First, we read Pixel 0 into K.
ΩK
is then simply <7>, because
is an empty string
at this point. Is the string <7> already in the string table? Of course, because all
single character strings were put in the table by InitializeStringTable(). So set
equal to <7>, and then go to the top of the loop.
59
Index Bookmark Pages Text
Previous Next
Pages: Index All Pages
This HTML file was created by VeryPDF PDF to HTML Converter product.