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.

Goals

Students will be able to:

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.

Resources

Getting Started

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.

Discussion 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.

Remarks

Activity

The Pixelation Widget

For today's activity, each student will use the Pixelation Widget, which can be found in the CSP-Widgets repository. Each widget is a Quorum project which you can run inside of Quorum Studio.

Here are a few resources you can use to guide you through using Quorum Studio and downloading the repository:

Using the Pixelation Widget

Display (Optional): Watch the Code.org pixelation widget video. The widget shown is different than the one we will use, but the primary concept (using 1's and 0's to set pixel colors) is the same.


How to use the Widget

Students type in the textbox on the right to sequentially set pixel values. Typing a 1 will make the next pixel white, and typing a 0 will make the next pixel black.

Students can set the width and height of the image using the text fields at the top of the widget. You can ignore the settings for colored pixels or bits per pixel for now -- these will be used in a future lesson.

The widget is accessible with screen readers. While using a screen reader, students can focus on the pixel region, then use the arrow keys to inspect how bright each pixel on the grid is. The first grid coordinate, (0, 0), is in the top left corner.

You can also increase or decrease the size of all text in the widget using the CONTROL + PLUS or CONTROL + MINUS keyboard shortcuts, respectively.

Do This: Students will recreate the letter A as shown in the image below using the black and white Pixelation Widget. They must first use the fields at the top of the widget to adjust 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).

A 3 by 5 image in the Pixelation Widget depicting a simple A. Every pixel in the left and right columns black, except for the top row, which is white. The middle column is all white, except for a pixel in the top row and another in the middle row, which are both black.

Teaching Tip

The point of this activity is to get students familiar with the tool and practice entering the bits. Once most of the class has finished, you can move on, or optionally give students another challenge of your choosing to practice with. Encourage students who are finished to help those who haven't.

Sampling an Analog Image

Remarks

Distribute: U1L7 Black and White Images - Activity Guide


Teaching Tip

Questions to Ask as You 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?

Alternative Strategies: While working with students with visual impairments, rather than using the images on the worksheet, you might consider asking your students to use geometric shapes as an analog source. Here are a couple of examples:

  • Triangles - While one or two sides of a triangle might align with the pixel grid, at least one side will be angled. At larger sample sizes, the angled edge may feel more jagged, rather than a smooth line.
  • Circles - Curved edges are particularly difficult to represent with large samples. If the dimensions of the grid are extremely small, such as 2x2, a circle can be indistinguishable from a square.

Challenges A & B

Do This:

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:

Wrap Up

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.

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

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

Assessment: Check for Understanding

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?

Standards Alignment