Lossless compression gives back exactly the original data. Lossy compression throws away detail people are unlikely to notice, such as tiny differences in shade, so files get much smaller, but that detail is gone for good. Music and photos online are usually lossy; text, medical scans and evidence must be lossless.
A song streamed on your phone is about a tenth of the size of the same song on a CD. What did they throw away, and why can't you hear it?
Run-length encoding gives back exactly what went in: it is lossless. But a photo has few long runs, because neighbouring pixels are almost never exactly the same shade. Lossy compression makes runs longer on purpose: shades that are close enough (within a tolerance) are stored as the same. The file shrinks a lot, but the small differences are thrown away.
This board stores a grey picture as runs of count × shade, two numbers a run. Pixel by pixel it would be 48 numbers.
Predict: Read the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.
Try: Try it on the board and compare the result with your prediction.
Investigate: Work out why it happens, one step at a time.
Modify: Change the problem on purpose and see what happens.
Practise: A few on your own, to check you have it.
Make: Make your own problem using what you have learned. Expect a few tries; that is normal.
Make your prediction first. Help opens once you've locked it in.
PredictRead the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.
Does it come back?
TryTry it on the board and compare the result with your prediction.
Try: raise the tolerance
Was your prediction right? Slide the tolerance back to 0: the picture is perfect again, because the board always starts from the original. A saved lossy file doesn't have one.
Try it yourselfYour edits are saved in this browser.
Raise the tolerance to 40 or more. How many numbers are stored now, and how many pixels came back different?
Use the board. This ticks when you get there.
InvestigateWork out why it happens, one step at a time.
Worked example: lossless versus lossy
Worked exampleBefore each step, say what you think comes next.
t=0:28 numbers,0 changedLossless: only exact runs. Already smaller than 48.
t=28:18 numbers,13 changedShades next to each other (28 apart) now count as the same.
t=40:16 numbers,16 changedSmaller again, and a third of the pixels are a different shade.
lossyThe changed pixels were never stored, so they can't be recovered.
choose by purposeLossy where small changes don't matter; lossless where every value counts.
Now define lossless.
Sam explains what happens to a lossy photo. Click the line where it first goes wrong.
ModifyChange the problem on purpose and see what happens.
Vary: one setting at a time
Try it yourselfYour edits are saved in this browser.
Set the tolerance to 0. How many pixels come back different?
Use the board. This ticks when you get there.
Push the tolerance to 128, the most. How many numbers now? Does it still look like the picture?
Use the board. This ticks when you get there.
PractiseA few on your own, to check you have it.
Choose a format
MakeMake your own problem using what you have learned. Expect a few tries; that is normal.
The edge of lossless
Then: would that tolerance work for a different picture? Why not?
Try it yourselfYour edits are saved in this browser.
Need a hint?
Raise the tolerance one at a time and watch the pixels that came back different.
Another hint
The first change happens when two neighbouring shades are within the tolerance.
Another hint
Go back one from the first tolerance that changes a pixel.
Find the largest tolerance that still gives back every pixel exactly.
Use the board. This ticks when you get there.
For teachers
Students raise the tolerance of a lossy run-length compressor on a grey picture to see that lossy compression stores far fewer numbers but permanently changes data, and decide where lossy and lossless each belong (AC9TDI10K03 node 3). About 45 minutes.
I can explain the difference between lossy and lossless compression.
I can choose lossy or lossless for a purpose and justify it.
I can name a consequence of using lossy compression in the wrong place.
Before class
Try the Try and Make boards yourself.
The one idea: lossless gives back exactly the original; lossy discards information permanently to save more space; choose by purpose. Kit contexts for width: medical images and legal evidence (lossless), music streaming and photos online (lossy).
Simplification: real lossy formats (JPEG, MP3) don't merge nearby shades in runs; they use smarter maths to throw away what people perceive least. The board shows the same trade-off in a form students can see.
Running the lesson
Predict: students who chose "yes" hold Sam's misconception; return to them after the Try.
Try: ask which parts of the picture changed first, and why.
Worked example: ask what a doctor or a court would say about the 16 changed pixels.
Vary: debate the "worth it" question in pairs before checking.
Make: compare: why is 27 the edge for this picture?
The hard part (on purpose)
Students believe lost detail can be recovered because the board can slide back to 0. Point out that the board keeps the original; a saved lossy file does not.
When students get stuck
A student says the detail comes back when you open the file (Sam's mistake). Ask: Where would the original shades be stored? Fix: Nowhere: they were thrown away.
A student thinks lossy is always bad. Ask: How long would a song take to stream at ten times the size? Fix: Lossy is a trade-off that suits many purposes.
Stretch and support
Stretch: Save a photo as JPEG at quality 100 and quality 10 and compare the sizes and what changed. Which details went first?
Support: Give the two definitions on a card: lossless = exact recovery; lossy = permanent loss for a smaller file.
Where it leads
Builds on: Run-length encoding. Where it leads: file formats and codecs (MP3 vs WAV, JPEG vs PNG), and the ethics of altered images and evidence.
What each step is for
does it come back?: Committing to whether the picture comes back exactly tests the new move: lossy compression permanently discards information.
Try: raise the tolerance: Raising the tolerance settles the prediction: fewer numbers are stored, and some pixels come back a different shade.
Worked example: lossless versus lossy: Comparing tolerance 0 with 28 and 40 models the trade-off: fewer numbers, more pixels changed, for good. Sam thinks lost detail is restored, the misconception planted after the method; the context question asks where lossy must not be used.
Vary: one setting at a time: Each task changes the tolerance: back to lossless, all the way up, then reading the trade-off, then choosing for a context.
choose a format: Naming lossy and lossless formats, consequences of lossy in the wrong context, saving a lossy file again, and a review of run-length codes.
the edge of lossless: Finding the largest tolerance that still gives back every pixel reverses the process: students find exactly where lossless ends for this picture.
Now you can
Explain the difference between lossy and lossless compression.
Choose lossy or lossless for a purpose and justify it.
Name a consequence of using lossy compression in the wrong place.