CSE 4227 · Deck 13 · slides 75–106

LZW Paper Trainer

Press Next and watch the answer-script table fill in one row at a time, exactly as you write it in the exam. Then try Yes / No quiz, and finally Fill the table: you type every cell yourself and the page marks it like an examiner.

The whole method is one question, asked again and again

Before you start (write this line in the paper): the image is 8-bit, so dictionary locations 0–255 already hold every gray level 0–255. New entries start at 256. A 9-bit code gives 512 locations. Read the pixels left to right, top to bottom. The Currently Recognized Sequence (CRS) starts empty.

Take the CRS, stick the next pixel P on the end. Is “CRS-P” already in the dictionary?

YES
  1. Write nothing in Encoded Output.
  2. CRS grows: CRS = CRS-P.
NO
  1. Output the code of CRS (a single pixel's code is the pixel itself).
  2. Add “CRS-P” at the next free location (256, 257, …).
  3. CRS restarts as just P.

When the pixels run out: output the code of the last CRS. Done.

Trainer

Mode

Image

CRS (what you are holding)P (pixel being processed)

Same pixels in reading order

New dictionary entries

Answer script
Currently recognized sequencePixel being processedEncoded outputDictionary location (code word)Dictionary entry

Things that cost marks