← Teacher guide

Colour and images

Students mix red, green and blue light on a pixel grid to see that a bitmap is a grid of pixels, each stored as three numbers from 0 to 255, and compare bitmaps with vector pictures stored as shapes (AC9TDI8K03 node 3).

Data representation · Data as numbers · about 40 minutes · Open the student lesson

Classroom resources

Load these into Waypoints Prepare: choose Load URL and paste the copied address, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.

Students will be able to

Timing

Predict and Try 6 min · Worked example 12 min · Vary 10 min · Practise and Make 12 min

Before class

Try the Try and Make boards yourself first.

The one idea: a bitmap is a grid of pixels and each pixel is three numbers (red, green, blue), each from 0 to 255. Vector pictures store shapes instead, which is why they stay sharp when scaled.

Simplifications: real images are much bigger and usually compressed (Years 9–10); some formats also store transparency (a fourth number). "0 to 255 fits in one byte" is stated here and explained in the binary lessons.

Hands-on: CS Unplugged's Image representation activity (colour by numbers on grid paper) works well before the board.

Running the lesson

  1. Predict: students who chose brown are thinking of paint. Ask them to hold the thought until the Try.
  2. Try: have students find the colour of 255, 128, 0 (orange) before checking.
  3. Worked example: ask how many numbers a phone photo might need (millions of pixels × 3).
  4. Vary: ask why grey has equal numbers.
  5. Make: ask how many different numbers they actually used.

The hard part (on purpose)

Students mix light like paint (red and green make brown). Let them predict, then see yellow on the board; a magnifier on a white part of a real screen shows the three coloured dots.

When students get stuck

What you will seeA question to askThe fix
A student says 255, 255, 0 is brown (Sam's mistake).Does a screen mix paint, or add light?Light adds up: red and green light look yellow.
A student thinks black pixels store nothing.Press Show numbers. What does a black pixel hold?0, 0, 0: still three numbers.

Answers to the checks

  1. 255, 255, 0: A pixel is stored as red **255**, green **255**, blue **0**. What colour is it?
    Yellow. Full red light and full green light together look yellow. Light adds up, so it mixes differently from paint, where red and green make a muddy brown.
  2. Try: mix a colour: Set Red to 255, Green to 255 and Blue to 0, then click a pixel to paint it. What colour is it?

    255, 255, 0 is yellow: full red and full green light.
  3. Colours from light: An image is 10 pixels wide and 10 pixels high, with three numbers for each pixel. How many numbers is that?
    300
    10 × 10 = 100 pixels, × 3 numbers = 300 numbers.
  4. Find the mistake: Sam works out the colour of 255, 255, 0. Click the line where the working first goes wrong.
    line 4
    Line 4: that is how paint mixes. A screen adds light, and full red plus full green light looks yellow.
  5. Shapes, not pixels: A logo is stored as **circle: centre 50, 50, radius 40, colour 255, 0, 0** instead of as pixels. What happens when you zoom in a long way?
    It stays sharp: the computer draws the circle again at the new size
    This is a vector picture: numbers describe shapes, and the computer draws them at whatever size you need, so edges stay sharp. A bitmap stores every pixel, so zooming makes the pixels bigger.
  6. White: Paint a pixel white.

    White is all three lights full: 255, 255, 255.
  7. Two lights: Now turn red off and paint a pixel. What colour is 0, 255, 255?

    Green and blue light make cyan, a light blue.
  8. Less light: Paint a dark red: red at about half (128), green and blue off.

    Less red light makes a darker red. The number is the amount of light.
  9. Grey: Paint a grey: all three the same, at 128.

    Equal amounts of all three lights are a grey. 0 is black and 255 is white, so 128 is mid grey.
  10. Black still counts: The board starts with every pixel black (0, 0, 0). How many numbers does that 4 × 4 picture store?
    48
    Every pixel is three numbers, even black ones: 16 × 3 = 48. (Show numbers on the board to see them.)
  11. Blue: What colour is **0, 0, 255**?
    Blue
    Only the blue light is on, at full.
  12. Magenta: What colour is **255, 0, 255**?
    Magenta (pink-purple)
    Red and blue light together make magenta.
  13. Count the numbers: A small photo is 100 pixels wide and 50 high, with three numbers a pixel. How many numbers?
    15000
    100 × 50 = 5000 pixels, × 3 = 15 000 numbers.
  14. Bitmap or vector?: Which picture is best stored as a vector (shapes to draw)?
    A school logo that must print sharp on a poster and a pen
    Logos are made of simple shapes and need to be sharp at any size, so they suit vector.
  15. Review: text codes: Review: as text, what character has the code 65?
    A
    A is 65. The same 65 in an image would be a dark amount of one colour.
  16. copy a picture: Copy the picture: set each colour with the sliders, then click the pixels to paint them.

    12 pixels of 255, 255, 0 and 4 of 0, 0, 255: 48 numbers in all.

Solutions

One possible solution for each task. Other correct programs are fine.

Vary: one light at a time › White

Open task: any program that does what the step asks.

Vary: one light at a time › Two lights

Open task: any program that does what the step asks.

Vary: one light at a time › Less light

Open task: any program that does what the step asks.

Vary: one light at a time › Grey

Open task: any program that does what the step asks.

Vary: one light at a time › Black still counts

Open task: any program that does what the step asks.

copy a picture

Open task: any program that does what the step asks.

Stretch and support

Stretch: Find the RGB numbers for your favourite colour with the sliders. Then look at the colour picker in a drawing app: it shows the same three numbers.

Support: Give the six main colours: red 255,0,0; green 0,255,0; blue 0,0,255; yellow 255,255,0; cyan 0,255,255; magenta 255,0,255.

Exit ticket

What colour is 0, 255, 0? How many numbers store a 3 × 2 image?

Green. 3 × 2 = 6 pixels × 3 = 18 numbers.

What each step is for

Where it leads

Next: Shapes as numbers (vector pictures and 3D models).

Code links: turtle's color() takes RGB amounts; the Teachable Machine lessons train on images, which the model sees as these numbers. Later: why each amount stops at 255 (How many patterns?), and compressing images (Years 9–10).

Sources