Inspecting a pixel's RGB numbers

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

Inspecting a pixel's RGB numbers

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. A pixel viewer shows rgb(255, 0, 0) for the pixel you clicked. What colour is that pixel?
A Pure red
B Pure green
2. What does an eyedropper tool do when you click on an image?
A Shows the red, green and blue numbers stored for that one pixel
B Shows the average colour of the whole image
3. Which range of numbers can each of the red, green and blue values be in an 8-bit-per-channel pixel?
A 0 to 100
B 0 to 255
4. You use an eyedropper on a pixel and see rgb(0, 0, 255). Which statement is correct?
A The red number is 255 and green and blue are 0
B The blue number is 255 and red and green are 0
5. You compare two neighbouring pixels in a smooth blue sky: rgb(30, 144, 255) and rgb(31, 145, 255). What do you expect?
A The numbers are very similar
B The numbers are completely different

Match the Pairs

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

Left columnRight column
1rgb(255, 0, 0) Argb(255, 255, 255)
2rgb(0, 0, 255) Brgb(200, 30, 30) and rgb(198, 32, 31)
3An eyedropper picked a pixel and showed that red, green and blue are all 255, so the pixel is white COnly two numbers are given. An eyedropper always shows three numbers for a pixel: red, green and blue.
4Comparing two neighbouring pixels: the first reads rgb(200, 30, 30) and the next reads rgb(198, 32, 31), so they are almost the same colour DThe numbers a pixel viewer shows for a pure blue pixel: no red, no green, full blue
5rgb(300, 20, 40) EThe red number is 300, but each RGB number stored for a pixel must be between 0 and 255. An eyedropper would never show 300.
6rgb(255, 0) FThe numbers an eyedropper shows for a pure red pixel: full red, no green, no blue

Definitions

eyedropper

Fill in the Blanks

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

1.
colour = __________(photo, 40, 25)
2.
rgb(___, 0, 0)
3.
rgb(255, 255, _)
4.
left = eyedropper(photo, 5, 5) right = eyedropper(photo, _, 5)
5.
middle = colour._____

Spot the Error

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

Question 1
A pixel = eyedropper(img, 10, 5)
B print(pixel.red)
C print(pixel.yellow)
D print(pixel.blue)
Question 2
A # Eyedropper found pure red
B rgb = (256, 0, 0)
C print(rgb)
Question 3
A a = eyedropper(img, 5, 5)
B b = eyedropper(img, 6, 5)
C if a = b:
D print("Same colour")
Question 4
A pixel = eyedropper(img, 8, 8)
B black = (255, 255, 255)
C if pixel == black:
D print("Black pixel")
Question 5
A pixel = eyedropper(img, 1, 1)
B red = pixel.red
C green = pixel.green
D blue = pixel.red
E print(red, green, blue)

Answer Key

Inspecting a pixel's RGB numbers
Section A: Quick Questions
Q1
A — Pure red
Q2
A — Shows the red, green and blue numbers stored for that one pixel
Q3
B — 0 to 255
Q4
B — The blue number is 255 and red and green are 0
Q5
A — The numbers are very similar
Section B: Match the Pairs
Q1
rgb(255, 0, 0) → The numbers an eyedropper shows for a pure red pixel: full red, no green, no blue
Q2
rgb(0, 0, 255) → The numbers a pixel viewer shows for a pure blue pixel: no red, no green, full blue
Q3
An eyedropper picked a pixel and showed that red, green and blue are all 255, so the pixel is white → rgb(255, 255, 255)
Q4
Comparing two neighbouring pixels: the first reads rgb(200, 30, 30) and the next reads rgb(198, 32, 31), so they are almost the same colour → rgb(200, 30, 30) and rgb(198, 32, 31)
Q5
rgb(300, 20, 40) → The red number is 300, but each RGB number stored for a pixel must be between 0 and 255. An eyedropper would never show 300.
Q6
rgb(255, 0) → Only two numbers are given. An eyedropper always shows three numbers for a pixel: red, green and blue.
Section C: Definitions
Q1
eyedropper — A tool that picks one pixel in an image and shows the red, green and blue numbers (0 to 255) stored for it, such as rgb(255, 0, 0) for pure red.
Section D: Fill in the Blanks
Q1
colour = eyedropper(photo, 40, 25)
Q2
rgb(255, 0, 0)
Q3
rgb(255, 255, 0)
Q4
left = eyedropper(photo, 5, 5) right = eyedropper(photo, 6, 5)
Q5
middle = colour.green
Section E: Spot the Error
Q1
C — Line 3 should read the green number. An eyedropper only stores red, green and blue numbers for a pixel, so there is no yellow value. It should be print(pixel.green).
Q2
B — Each RGB number must be from 0 to 255. Pure red is (255, 0, 0), so 256 is out of range. It should be rgb = (255, 0, 0).
Q3
C — A single = assigns a value. To compare two neighbouring pixels you need the comparison operator ==. It should be if a == b:.
Q4
B — Black has the red, green and blue numbers all at 0. (255, 255, 255) is white. It should be black = (0, 0, 0).
Q5
D — The variable blue is being given the pixel's red number. The blue number is stored in pixel.blue, so the line should be blue = pixel.blue.