Encoding a black-and-white image as 0s and 1s

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Encoding a black-and-white image as 0s and 1s

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Our key says 1 = black and 0 = white. How do we write a black pixel?
A 1
B 0
2. A row has 5 pixels: black, white, white, white, black. Which code is right?
A 10001
B 01110
3. A row of 5 white pixels is encoded as...
A 00000
B 11111
4. How many bits does each pixel need in a black-and-white picture?
A Five bits per pixel
B One bit per pixel
5. A 5 by 5 black-and-white picture has 5 rows of 5 pixels. How many bits are needed in total?
A 5 bits
B 25 bits

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
101110 A1 = black, 0 = white
211111 BOne row of a 5 pixel wide picture: white, black, black, black, white
3A key for a black-and-white picture says black is 1 and white is 0 CWhite pixels should be 0, not 1. In the key, 1 means black, so 11111 is a row of black pixels.
4A 5 by 5 picture is written one row at a time, so it takes 5 rows of 5 digits DThere are only 4 digits but the row has 5 pixels. One digit is missing, so the row should be 10001.
5A row of 5 white pixels is written 11111 E00100 01100 00100 00100 01110
6A row with black, white, white, white, black is written 1001 FA row where all 5 pixels are black

Definitions

1 = black, 0 = white

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
Key: 1 = black, 0 = white Row 1 pixels: B W W W B Row 1 code: _____
2.
Key: 1 = black, 0 = white Row 2 pixels: B W B W B Row 2 code: 1 0 _ 0 1
3.
Key: 1 = black, 0 = white Letter T, row 1 is all black: 5 pixels Row 1 code: _____
4.
Grid: 5 by 5, one bit per pixel Bits in the whole grid: __
5.
Key: 1 = black, 0 = white Letter O, row 1 pixels: W B B B W Row 1 code: _____

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A Key: 1 = white, 0 = black
B Row 1: 1 1 1 1 1
C Row 2: 0 0 1 0 0
D Row 3: 0 0 1 0 0
Question 2
A Picture: letter L, 5 by 5
B Row 1: 1 0 0 0 0
C Row 2: 1 0 0 0 0
D Row 3: 1 0 0 0
E Row 4: 1 0 0 0 0
F Row 5: 1 1 1 1 1
Question 3
A Key: 1 = black, 0 = white
B Row 1: 0 1 0 1 2
C Row 2: 0 0 0 0 0
D Row 3: 1 0 0 0 1
E Row 4: 0 1 1 1 0
Question 4
A Black = 1, White = 0
B B W W W B -> 1 0 0 0 1
C W B B B W -> 1 0 0 0 1
D B W W W B -> 1 0 0 0 1
Question 5
A Key: 1 = black, 0 = white
B Row 1: 0 0 1 0 0
C Row 2: 0 1 1 0 0
D Row 3: 0 0 1 0 0 0
E Row 4: 0 0 1 0 0
F Row 5: 0 1 1 1 0

Answer Key

Encoding a black-and-white image as 0s and 1s
Section A: Quick Questions
Q1
A — 1
Q2
A — 10001
Q3
A — 00000
Q4
B — One bit per pixel
Q5
B — 25 bits
Section B: Match the Pairs
Q1
01110 → One row of a 5 pixel wide picture: white, black, black, black, white
Q2
11111 → A row where all 5 pixels are black
Q3
A key for a black-and-white picture says black is 1 and white is 0 → 1 = black, 0 = white
Q4
A 5 by 5 picture is written one row at a time, so it takes 5 rows of 5 digits → 00100 01100 00100 00100 01110
Q5
A row of 5 white pixels is written 11111 → White pixels should be 0, not 1. In the key, 1 means black, so 11111 is a row of black pixels.
Q6
A row with black, white, white, white, black is written 1001 → There are only 4 digits but the row has 5 pixels. One digit is missing, so the row should be 10001.
Section C: Definitions
Q1
1 = black, 0 = white — To encode a black-and-white picture, write 1 for each black pixel and 0 for each white pixel. Work row by row, one bit per pixel.
Section D: Fill in the Blanks
Q1
Key: 1 = black, 0 = white Row 1 pixels: B W W W B Row 1 code: 10001
Q2
Key: 1 = black, 0 = white Row 2 pixels: B W B W B Row 2 code: 1 0 1 0 1
Q3
Key: 1 = black, 0 = white Letter T, row 1 is all black: 5 pixels Row 1 code: 11111
Q4
Grid: 5 by 5, one bit per pixel Bits in the whole grid: 25
Q5
Key: 1 = black, 0 = white Letter O, row 1 pixels: W B B B W Row 1 code: 01110
Section E: Spot the Error
Q1
A — The key is back to front. In this code 1 stands for a black pixel and 0 stands for a white pixel, so it should say: Key: 1 = black, 0 = white.
Q2
D — Each row of a 5 by 5 picture needs 5 bits, one for each pixel. This row has only 4 bits. It should be: Row 3: 1 0 0 0 0.
Q3
B — A black-and-white picture only uses the bits 0 and 1. The digit 2 is not allowed. The row should be: Row 1: 0 1 0 1 0.
Q4
C — The 0s and 1s are swapped. White pixels are 0 and black pixels are 1, so W B B B W must be written 0 1 1 1 0.
Q5
D — This row has 6 bits, but the grid is only 5 pixels wide. There must be one bit per pixel, so it should be: Row 3: 0 0 1 0 0.