Lesson 10: Lossy Compression


Students are introduced to lossy compression via the Lossy Text Compression widget. They apply this concept and their prior knowledge of sampling to create their own lossy compressions of image files using the Lossy Image Widget. Students then discuss several practical scenarios where they need to decide whether to use a lossy or lossless compression algorithm. The lesson ends with a discussion of the situations where lossless compression is important and the situations where lossy compression is important.


After exploring lossless compression in yesterday’s lesson, students are introduced to lossy compression. A theme throughout the lesson is that lossy compression can greatly reduce the file size, but it can also greatly reduce the quality and it’s important to find that balance between quality and file size. The real challenge here is finding where that line is - how much can we compress but still keep it recognizable? In the final discussion, students compare lossy compression with lossless compression to see that each has value depending on the situation - lossy is useful when file size needs to be minimized, but lossless is important when its vital to be able to reconstruct the original image.


Lesson Modifications

Warm Up (5 mins)

Activity (30 mins)

Wrap Up (10 mins)

View on Code Studio


Students will be able to:

  • Examine the effects of lossy compression on text & images
  • Given a piece of media, decide whether to use lossy or lossless compression based on the needs of a situation


  • Explore each of the widgets for this lesson
  • Decide how you will let students share their lossy compressions with each other or the whole class
  • Have CSP Unit 1 - Digital Information - Presentation ready for the discussion towards the end of the lesson


Heads Up! Please make a copy of any documents you plan to share with students.

For the Teachers

Teaching Guide

Lesson Modifications

Attention, teachers! If you are teaching virtually or in a socially-distanced classroom, please read the full lesson plan below, then click here to access the modifications.

Warm Up (5 mins)

Discussion Goal

Goal: Students should identify that this widget is similar to yesterday’s text compression widget because it also shortens text, but it is different in that some of the information is permanently lost when it is shortened. You can emphasize this point by supplying some carefully-chosen sample text and seeing that the results can be ambiguous:

  • “there are three tiers of tires at the shop”

Students may debate whether or not this really fits the definition of compression we saw yesterday, which is a great bridge to the next part of the lesson.


This widget claims you can keep the first letter of a word then remove all of the vowels and the result will still be readable. Let’s test this out - what are some other sentences we should try with this widget?

Do This: Navigate to the widget using the link in the slide and try out a few phrases before returning to the slide.

Prompt: How is this widget similar to the widget we used yesterday? How is it different?

Activity (30 mins)

Teaching Tip

Video: Students should have seen these definitions in the video at the end of yesterday’s class. However, it could be worthwhile to replay part of the video here as well to reinforce that vocabulary - specifically, just the section where Aloe Bloc discusses lossy & lossless compression.


Yesterday’s widget was an example of lossless compression because we could always reverse the process to recreate the original. This widget is an example of lossy compression because some information gets lost, making this process not reversible. In today’s lesson, we will investigate how lossy compression works with images.

Do This: Have students open Code Studio - they will use several widgets throughout today's lesson.

Lossy Image v1 (5 minutes)

Teaching Tip

For the app to work, students need to click the "Run" button on the app before they can play with it. They may need to be reminded of this when starting.

Level 2: Have students adjust the slider to see different lossy compressions.

Discussion Goal

Goal: Guide the conversation towards these two observations:

  • The larger the sample size, the smaller the file size but the image looks worse
  • The smaller the sample size, the better the image looks but the file size is larger

Ultimately, students should be aware that there are tradeoffs with compression - highly compressed images may not look as good as lower compressed images, but will have a smaller file size.

Prompt: What do you notice about the quality of the image when you compress it? What do you notice about the compressed file size?

Lossy Image v2 (15 minutes)

Level 3: Have students pick a new image. Encourage students to settle on a compression that they think still represents the original image while maintaining a high compression rate (low number of bytes).

Teaching Tip

This activity emphasizes that there is a balancing act between compressing an image while making sure it is still recognizable, and students are trying to find where this balance is for their particular image. Sharing results with the class is a way for students to see a wide variety of images and compressions before the next class discussion. There are many ways to structure this share-out, but here are a few options:

Gallery Walk: Have students circulate around the room. On a post-it note, they should write down what they think the original image is and leave the note on each computer they visit

Screen Sharing: If students have a way to share their screen with the rest of the class, students can volunteer to have their screen projected for the rest of the class.

Circulate: Check in with students as they find images to compress. Emphasize that the goal is for us to eventually be able to identify the image while still keeping the image compressed.

Share Out: Have class share out the compressions they have made with students nearby. Encourage students to try and guess the image.


We’ve now seen that lossy compression can greatly reduce the file size of our images, but we lose some information along the way. Let’s explore what this looks like with some common image compressions we use on the internet.

Compression Decisions (10 minutes)

Teaching Tip

Voting can be done by students holding up the number of fingers for the option they would select.

After voting, briefly discuss each scenario and come to a classroom consensus on the best option.

Note that there is not necessarily one "correct answer" to these scenarios the goal here is to weigh the pros and cons and make an informed decision.

Prompt: Let’s imagine we are trying to use this image for a particular purpose, and we need to decide which level of compression we want to use. We will look at a series of scenarios and we will vote on how much compression is appropriate.

  • Scenario 1: You are sending this as a text message to a friend but you’ve almost run out of data on your phone plan
  • Scenario 2: You are a crime-scene photographer and this image is part of a crime-scene photo
  • Scenario 3: This image is part of a satellite imaging assignment for the military, being used for intelligence gathering
  • Scenario 4: You are a Social Media manager posting this to an Instagram story for an event happening right now
  • Scenario 5: This image will be part of a collage where 100 copies will be stitched together to make a larger image
  • Scenario 6: You are a professional photographer submitting to a design competition where your submission will be carefully judged for color & composition

Wrap Up (10 mins)

Discussion Goal

Goal: This discussion should draw out two key points:

  • Lossless compression is useful when the accuracy of the original item is most important
    • Examples: Bank records, text files, some images
  • Lossy compression is useful when file size is a concern or when it needs to be sent in a reasonable amount of time.
    • Examples: Multimedia - especially streaming media (images, video, audio)


  1. When is it a good idea to use lossless compression?
  2. When should you use lossy compression?
  3. What are the important factors in making that decision?


We’ve seen today that lossy compression can greatly reduce file size, but can also reduce the quality of the image. Finding that balance is important, especially when the size of your file is a concern. But, if you need to recreate an exact copy of the original, then lossless compression is a better choice.

Journal: Have students take out their journals and add the definition for lossy compression.

Assessment: Check For Understanding

Check For Understanding Question(s) and solutions can be found in each lesson on Code Studio. These questions can be used for an exit ticket.

Question: Choose all that match this question: Which of the following describe lossy compression?

Question: You’ve been given a new cell phone with a 2 gigabyte data plan. You plan to use your phone for text messages, images, video, and music. Which of these categories are best compressed using lossless compression? Which of these categories are best compressed using lossy compression? Why?

  • Check Your Understanding
  • 2
  • 3
  • (click tabs to see student view)
View on Code Studio

Student Instructions

View on Code Studio

Student Instructions

In 50 words or less, describe the concept of a number system.

Why are rules required for a number system to be useful?

Standards Alignment

View full course alignment

CSTA K-12 Computer Science Standards (2017)

DA - Data & Analysis
  • 3A-DA-10 - Evaluate the tradeoffs in how data elements are organized and where data is stored.


DAT-1 - The way that the computer represents data is different from the way that the data are interpreted and displayed for the user
DAT-1.D - Compare data compression algorithms to determine which is best in a particular context.
  • DAT-1.D.5 - Lossy data compression algorithms can significantly reduce the number of bits stored or transmitted but only allow reconstruction of an approximation of the original data.
  • DAT-1.D.6 - Lossy data compression algorithms can usually reduce the number of bits stored or transmitted more than lossless compression algorithms.
  • DAT-1.D.7 - In situations where quality or ability to reconstruct the original is maximally important, lossless compression algorithms are typically chosen.
  • DAT-1.D.8 - In situations where minimizing data size or transmission time is maximally important, lossy compression algorithms are typically chosen.