Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
One row of a scanned page is 13 pixels: 6 white, then 3 black, then 4 white. Without compression each pixel takes 1 byte. With run-length encoding each run is a count byte and a colour byte.
Compression reduces file size: less storage, less bandwidth and a shorter transmission time. Lossy compression removes data for good (lower resolution or colour depth, lower sample rate or resolution). Lossless compression loses nothing; run-length encoding stores each run of repeated values as a count and a value.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Step 1. The pairs. (6, white), (3, black), (4, white).
Step 2. Size after. 3 pairs of 2 bytes: bytes.
Step 3. Saving. bytes.
Check. Decoding gives pixels in the same order, so nothing is lost.
Answer: (a) (6, white), (3, black), (4, white). (b) 6 bytes, a saving of 7 bytes.
Log in to join the discussion.
Loading…