Computers interpret electrical signals as bits, and bits can be used to represent numbers, and numbers can be used to represent colours, which suggests that we can represent virtually anything!
Representation
Today we’re exploring a fundamental question: How do we represent the world as data?
We’ll look at “representation” in two important senses:
Technical: How computers encode rich concepts (like colour) as numbers
Social: Who is represented in this discipline, and why it matters
Let’s start with something personal and familiar: colour.
Colour interpretation
What’s your favorite colour? Do you have a sense for why it’s your favorite? Does that colour influence your dress/decor/purchases?
Activity—In pairs, choose a colour (primary or secondary) and find something in its cultural symbolism that surprises you. Contradictions are especially interesting. Report your findings to the class (briefly).
05:00
Colour—representation
First, some general questions…
What does data look like to a computer?
Is that enough?
Colour—representation
Can we use bits to represent integers?
3
1
5
7
103
102
101
100
103
102
101
100
23
22
21
20
Your turn: Binary to decimal
Convert these binary numbers to decimal:
Binary
Decimal
1010
_______
1101
_______
0111
_______
03:00
Your turn: Thinking about bits
What’s the largest number you can represent with 4 bits? _______
How many bits do you need to represent 120? _______
If I give you one more bit, what happens to how many numbers you can represent?
How high can you count on your fingers? and toes?
03:00
From bits to… everything?
We’ve seen that bits can represent integers.
But integers are just the beginning!
If we can assign numbers to things, we can represent anything:
Text (A=65, B=66, …)
Sound (amplitude samples)
Images (pixel colours)
Video (sequences of images)
Your favorite song, your family photos, this lecture…
Let’s see how this works with colour.
Colour—representation
Can we use integers to represent colours?
One way: RGB (red, green, blue), where each “component” is in range 0 through 255.
Examine each pixel. If its red colour channel is high (over 200, say), then leave it as is. Otherwise, change the pixel to grey by setting all 3 colour channels to the average of their original values.
Colour and Code
Your turn: Change image or boost
Experiment with the code! Try one or more of these:
Find a different image URL and boost a different colour (green? blue?)
Change the threshold value (try 150 instead of 200)
Instead of greying, try inverting: red = 255 - red
What happens if you boost pixels that are LOW in red instead of high?
12:00
What you learned today
You’ve discovered something profound:
Computers store everything as bits (0s and 1s)
Bits can represent integers (using binary, base 2)
Integers can represent colours (RGB: three numbers 0-255)
Which means bits can represent images (grids of pixels)