Lesson 7: Black and White Images

Concept Invention | Widget

Overview

Students explore how black and white images are represented. Students use the black and white pixelation widget to represent each pixel of an image with black or white light. They learn how to sample an analog image using small squares of uniform size (each represented with a black or white value) and reflect on the pros and cons of choosing a smaller or larger square size when sampling.

Purpose

Throughout this unit, students gradually discover how to use bits to represent more complex data types. In this case, students work on representing images using sampling. Students quickly realize that very tiny sample squares are needed to approximate an image’s curves and small details. The smaller we make each sample, the more bits are needed. Students must also wrestle with deciding whether each square should be a 0 or 1, as many squares have both white and black in the same square. They will have more control over the representation of each bit in the next lesson.

Agenda

Lesson Modifications

Warm Up (5 mins)

Activity (35 mins)

Wrap Up (5 mins)

View on Code Studio

Objectives

Students will be able to:

  • Explain how bits can be used to represent the individual pixels of a black and white image
  • Explain how sampling is used to create a digital form of an analog image

Preparation

Links

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

For the Teachers

For the Students

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: The goal here is for students to realize that, depending on the situation, we may want to take readings more frequently. Later in the lesson as students interact with the widget, you can help students make connections that the frequency of readings affects the digital representation that we obtain.

Prompt: You recently did some online shopping and are expecting a package to arrive in about a month. The delivery service has a tracking system which reads the location of the package.

  • How often would you want the location read? Every week? Every day? Every hour? Every minute? Be ready to explain your answer.

Discuss: Students should think for a minute, then share with a partner. Once students have shared, call on a few students to explain their answers with the class.

Remarks

Thank you for sharing your insights. It seems to depend on the situation. Sometimes we want to take a reading of the location more frequently. Today, we’re actually learning about how images are represented in computers, but let’s keep in mind these ideas about how often to take a reading or measurement.

Activity (35 mins)

Intro to the Pixelation Widget (10 mins)

Teaching Tip

Note: The video displays an old version of the Pixelation Widget. In the version your students will use, they no longer need to set the width and height using binary numbers - they can use the slider at the top. They may also note that the width and height is not displayed in their work space in binary numbers.

Also, while the video uses the word "metadata" to describe this information, students do not need to leave this lesson understanding metadata. Metadata will be covered in a later lesson.

Display: Watch the pixelation widget video.

Teaching Tip

Getting Familiar with the Pixelation Widget: Once most of the class has finished levels 3 and 4, you can move on. Encourage students who are finished to help those who haven’t. The point of these two levels is to get students familiar with the tool and practice entering the bits.

Level 3: Students will recreate the letter A using the black and white Pixelation Widget. They must first enter the correct binary numbers to represent the width and height of the image. Then, they will type the appropriate bit for each portion of the image (“0” for black, “1” for white).

Level 4: Students must find and delete the extra bit that is causing the image to be distorted.

Sampling an Analog Image (20 mins)

Remarks

Now that you’ve had a chance to see how to set each pixel black or white, we are going to use the widget to represent an analog image using a process called sampling.

What is an analog? It's a term used to mean something with continuous representation - such as a picture you draw on a piece of paper. Each pencil line smoothly connects to the next, no matter how much you zoomed in on the picture with a magnifying glass.

When we represent an analog image digitally, we will have to make some choices on how to sample the image to get the smoothest representation possible while keeping in mind the number of bits it takes to build that image.

What does it mean to sample? We are choosing how small to make section of the picture we look at when deciding whether to make it black or white. The smaller the sample, the more pixels required to represent that image. Larger samples require less pixels, but the image can become blurry.

Try it out yourself!

Teaching Tip

Questions to Ask as Your Circulate: Having students work from paper copies of the Activity Guide will reinforce the concept of taking readings from an analog image and make it easier to transcribe the bits into the widget. As students work, circulate the room and ask pairs of students questions about their process:

  • How are you deciding whether each square should be black or white?
  • Do you think this process will give a good representation of the image? Why or why not?
  • What would you change about the sampling process to produce a better representation of the image?

Distribute: U1L7 Black and White Images - Activity Guide

Challenges A & B

Do This:

  • Read values from Challenge A (black or white for each square) and input the values into the widget.
  • After Challenge A, answer the questions on the activity guide
  • Repeat for Challenge B.
  • Answer the questions in the activity guide after each challenge.

Regroup: After students have finished Challenge A & Challenge B, discuss the challenges they encountered while completing the challenges. Then direct students on to Challenge C.

Challenge C

Do This:

  • Select your favorite company logo
  • Decide how you are going to sample this logo - use one of the grids in your Activity Guide. Draw the logo.
  • Recreate the logo in the Pixelation Widget on Level 7.
  • Show it to a classmate. Do they recognize the logo? Make adjustments if needed. For example: You may need to increase the sampling.

Wrap Up (5 mins)

Discussion Goal

Goal: We want students to start seeing that there are advantages and disadvantages as a result of decisions we make when we represent data digitally. Some key points to draw out from students:

  • Pros: We get a much more smooth/clearer/accurate representation of the analog image. A little easier to decide whether to make a square black or white.
  • Cons: More bits are needed. Took longer to enter in the widget. Still doesn’t look exactly like the analog image. Still had many squares that contained both black and white, so decisions had to be made to choose one over the other.

Prompt: In Challenges A and B, you and your partner practiced sampling the same image twice. The second time, we did a more frequent sampling by using smaller squares.

  • What are the pros and cons of sampling an image more frequently?

Discuss: Allow students time to think, then have them share in pairs or groups of four. Call on a few students to share with the whole class.

Remarks

Thank you for sharing. It looks like there are several advantages and disadvantages when it comes to sampling more frequently by using smaller squares. We get a better approximation of the analog image when we do more frequent sampling and it was a little easier to decide whether each square should be set to black or white. However, it took longer and we needed a lot more bits. We still got an image that didn’t represent the image accurately enough, though.

Fortunately, a computer does this process much more quickly than we can, and it can store thousands or even millions of bits to represent an analog image.

By this point, we've used bits to represent numbers, text, and images. The same sequence of bits can represent different types of data depending on the context. It all comes down to 0s and 1s!

Journal: Have students add definitions to their journals for: analog data, digital data, and sampling.


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: Assume your friend just sent you 32 bits of pixel data (just the 0s and 1s for black and white pixels) that were encoded after sampling an image. Choose the two statements that are true.

Question: Which of the following would result in a better digital approximation of an analog black and white image?

Question: Your computer science teacher asks you to sample a black and white image that is 4"x6". How would you sample the image to provide a good digital approximation using the pixelation widget? What sample size would you use? How would your decision affect the digital representation?

  • 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)

CS - Computing Systems
  • 3A-CS-02 - Compare levels of abstraction and interactions between application software, system software and hardware layers.
DA - Data & Analysis
  • 2-DA-07 - Represent data using multiple encoding schemes.
  • 3A-DA-09 - Translate between different bit representations of real-world phenomena, such as characters, numbers, and images.

CSP2021

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.A - Explain how data can be represented using bits.
  • DAT-1.A.10 - Analog data can be closely approximated digitally using a sampling technique, which means measuring values of the analog signal at regular intervals called samples. The samples are measured to figure out the exact bits required to store each sample.
  • DAT-1.A.7 - The same sequence of bits may represent different types of data in different contexts.
  • DAT-1.A.8 - Analog data have values that change smoothly, rather than in discrete intervals, over time. Some examples of analog data include pitch and volume of music, colors of a painting, or position of a sprinter during a race.