Storing images using Binary
Computers store every bit of data as binary. To store an image they need to convert it to a series of 1's and 0's. They need to encode the image.
An image is made up of thousands of pixels, think of them as tiny dots of colour. To save a picture the computer gives each of these pixels a number based on its colour.
The video explains how this works in real life, but let's simplify it down a bit.
Look at this simple black and white image
We can use 1 to represent black
and 0 for white
As you can see it is fairly easy to encode the image.
So what if we have more than 2 colours? We use exactly the same approach, just with more numbers
Consider this 4 colour image - we can use 0,1,2, 3 to represent the four colours, but we need to use binary not denary so 00, 01, 10, 11
00 = white (0)
01 = black (1)
10 = blue (2)
11 = green (3)
As you can see, to store more colours we just increased the numbers used to store it, or in slightly more technical terms : increased the number of bits used to store a colour. This is called colour depth.
How many bits do I need to store colours? | |||||||||||||||||
Number of bits | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | |||||||||
Number of colours you can store | 2 | 4 | 8 | 16 | 32 | 64 | 128 | 256 |
You may have spotted that the number of colours are powers of 2, specifically they are 2 to the power of the number of bits, so 3 bits allows 2^3 colours (or 8).
As you saw in the video, computers actually split colours into 3 channels (Red, Green Blue) and store a 8bit binary number for each channel.