- [Craig] In this video, we explore how images are represented in a computer system.
(uplifting piano jingle)
As we know, everything in a computer system must be stored in binary, and this includes images.
There are two ways of storing images in binary.
One is called a bitmap and the other is called a vector.
With bitmaps, an image is made from lots of different coloured squares,
each square having a binary value.
With vectors, the mathematics to draw the image is stored instead.
For example, a circle can be drawn if you know
the X and Y coordinates from the middle, the radius, the width and the colour.
Therefore, technical drawings and clip art are best stored as a vector
and photographs that are not made out of shapes as a bitmap.
In this video, we're only considering bitmap images in more detail,
as those are the only images you need to be aware of for your exams.
Here is a typical bitmap image of a butterfly.
If we zoom in, you can see the image is made of lots of different coloured pixels.
This is a bitmap.
Here's another bitmap.
This is a simple image so we can investigate how the computer actually stores bitmap images.
You can see the image is made up of just black and white pixels.
There are just two colours.
Well, in binary we have just two states as well.
So we can give each colour a binary value.
Zero for black and one for white.
We can now store this image in binary, in memory and on secondary storage.
Let's have a look at this raw binary.
You will notice that it no longer looks like a butterfly at all.
And to reconstruct the image,
we would need to know how many pixels wide the image was and how many pixels high it was.
This data needs to be stored along with the image, and this is known as metadata.
It allows the computer to take the raw binary data and make the correct resolution image.
In addition to the width and height, we also need to store how many bits each pixel is.
In this case, just one bit is being used for the two colours.
Here we have an image in two-bit colour.
Two bits gives us four possible binary combinations;
zero zero, zero one, one zero, and one one.
So now we can have four colours.
The amount of binary data we need to store for this image
has doubled compared to the previous black and white image.
However, the quality has improved, as we now have more colours.
Here is the image again, this time in three-bit colour.
It's worth noting that as the colour, depth and resolution,
that's the width and height of the image,
increases, so too does the size of the file.
Today, we're using 24-bit colour for images.
This means that each pixel is stored in 24 bits.
That gives us 2 to the power of 24 colours, which is over 16 million,
as many as the human eye can see.
Each of the binary combinations is now standardised into an agreed colour palette.
However, representing these 24-bit colours is cumbersome for humans.
So we use a six-digit hexadecimal representation instead, as shown here.
So let's just recap.
Images can be stored in binary as bitmaps or vectors.
Bitmap pictures are constructed from coloured squares called pixels.
Vector pictures store the mathematics to draw colour shapes.
Each pixel of a bitmap is stored in binary.
The number of bits required for each pixel depends on the number of colours required.
One bit has two possible values, zero and one.
Therefore, one bit can store just two colours; e.g., black or white.
Two bits have four possible values;
zero zero, zero one, one zero, and one one.
Therefore, two bits can store four colours.
The number of colours can be calculated as two to the n,
where n is the number of bits for each pixel.
The number of bits for each pixel is known as the colour depth.
Metadata is additional data stored alongside the image
to define the width, height, colour depth and colour palette.
The greater the colour depth and resolution, the larger the file size of the image.
Photographs these days are stored in 24-bit colour depth.
Each pixel is 24 bits.
This is 2 to the power of 24 or over 16 million colours,
the number of different colours the human eye can see.
(uplifting piano jingle)