2.2 Data compression: lossySmaller still, if you can live with "almost"

Lossy compression algorithms can significantly reduce the number of bits stored or transmitted, but they only allow the reconstruction of an approximation of the original data. Some information is thrown away permanently. The trick is choosing what to throw away: details people barely notice, like tiny color differences in a photo or sounds too quiet to hear under louder ones.
Here's a simple picture of the idea. Round each pixel's brightness to the nearest 10. Eight pixels that had seven different values now use only three: 50, 60 and 70. Fewer distinct values means more repetition, which compresses much better. But you can never get the original values back. Was that first pixel 52 or 49? The rounded file can't say.
?Wait, what's the difference between lossless and lossy again?
So which do you choose? The course gives a clean rule. In situations where quality, or the ability to reconstruct the original exactly, is maximally important, use lossless compression. In situations where minimizing size or transmission time is maximally important, use lossy compression. Video streaming, music apps and photo sharing usually use lossy. Documents, spreadsheets, program code and medical records use lossless.
| Situation | Choose | Why |
|---|---|---|
| A spreadsheet of bank balances | Lossless | Every digit must come back exactly |
| Source code of a program | Lossless | One changed character can break it |
| A video stream on a slow connection | Lossy | Small size matters most; slight blur is fine |
| Photos for a social media post | Lossy | Faster upload, the eye barely notices |
| A medical scan a doctor will study | Lossless | Lost detail could hide something important |
?Wait, does lossy compression make a file "worse"?
I thought about it. Show me
- (a) Lossless: every grade must come back exactly, and a changed digit would be a real error.
Why?
Exactness is maximally important. - (b) Lossy: keeping the call smooth on little bandwidth matters more than perfect detail in each frame.
Why?
Minimizing transmission time is maximally important. - (c) Lossless: edits and large prints need all the original detail, and lossy loss can't be undone later.
- (d) Lossy: speech still sounds clear after lossy compression, and fitting more episodes matters most.
Answer: (a) Lossless. (b) Lossy. (c) Lossless. (d) Lossy. In each case, decide whether exactness or size matters most.
Stuck? Get a hint
- For each one, ask: would losing a little detail cause a real problem?
- If yes, lossless. If small size or speed matters most, lossy.
- Remember lossy loss can never be undone.
- ALossy, because medical files are large
- BLossless, because the images must be reconstructed exactly
- CLossy, because doctors can request a new X-ray if needed
- DNo compression can be used on images
Show the answer
B. When the ability to reconstruct the original is maximally important, lossless is the right choice. Large size is a real concern, but lossy compression could remove exactly the tiny detail a doctor needs.
- ALossy compression usually produces a smaller file, but the original cannot be reconstructed exactly.
- BLossless compression always produces a smaller file than lossy compression of the same data.
- CLossy compression can be undone exactly if the file is decompressed twice.
- DLossless compression removes details people cannot notice.
Show the answer
A. Lossy trades exactness for size: much smaller files, approximate reconstruction. Lossless files are usually bigger than lossy ones, and lossy loss can never be undone.

Compression questions almost always hinge on one phrase in the stem. "Must be restored exactly", "every digit", "text", "code": lossless. "As small as possible", "fast streaming", "slight loss is acceptable": lossy.
- Lossy: can greatly reduce bits, but only an approximation of the original can be reconstructed.
- Use lossless when quality or exact reconstruction is maximally important.
- Use lossy when minimizing size or transmission time is maximally important.
- Information removed by lossy compression is gone permanently.