1.2 Memory and Storage

1.2.4 Data storage (Images) - click to expand

This section covers:

Images

  • How an image is represented as a series of pixels, represented in binary

  • Metadata

  • The effect of colour depth and resolution on:

    • The quality of the image

    • The size of an image file

Numbers and Characters are covered on the previous page

Sound is covered on the next page

🏠 Click here to go back to the main page.

Other sections in this topic:

πŸ”—1.2.1 Primary storage (Memory)

πŸ”—1.2.2 Secondary storage

πŸ”—1.2.3 Units

πŸ”—1.2.5 Compression

This page looks at how we represent images on a computer system, and how we can represent many different colours using binary.

How do we represent an image on a computer?

Computer displays use a grid of small dots called pixels which can be individually controlled by the displays electronic systems. At its simplest, each individual dot (called a pixel, which stands for picture element), can be on or off. This makes it easy to use a binary number to represent each pixel, if it is turned on, then we can use a 1, and if it is turned off, we can use a 0.

You can see from diagram 1 that the space invader character has been represented by eight bytes of data, and that the binary numbers can be converted to denary values 66, 60, 126,126, 60,90 129 and 129.

Diagram 1 - using single bits to represent single pixels.

Metadata

In the space invader example shown in diagram 1, the image was exactly eight pixels wide which meant that each row of the image fitted into exactly one eight bit byte.

In reality, images are not easily broken down into a number of pixels that fit neatly into eight bit bytes.

The two images shown in diagram 2 use exactly the same data but can show completely the wrong images if they are not displayed correctly. As well as the data for the content of the images (the 1s and 0s), we must also store the dimensions of the image - which we call its resolution. Two values, one for the width and one for the height, are stored with the image data and this extra information is known as metadata.

Metadata must contain the width, height and colour depth (see below) of an image, but may also include much more information. We can store how the image was created (what kind of camera, and the camera settings), the GPS information (where the image was captured), and much more - literally, you can include anything at all in the metadata of an image.

Diagram 2 - we need to store the dimensions of the image (the width and height)

Colour Depth and Resolution

Computers used to have displays which only used two colours (often black and green), but we now use colour displays which can contain thousands of different colours.

To store more than two colours (a 1 or a 0), we need to use more than one bit to represent each pixel. If we use two bits for each pixel, we can display four different values so we can have four colour images. This is known as the colour depth and this information is stored in the metadata for the file. Diagram 3 uses a two bit colour depth which means that the space invader character can now have four different colours.

Obviously, using more bits to represent each pixel will have an effect on the amount of data that it used.

Diagram 3 - using more bits to store each pixel

Calculation Of Image File Size

If we double the colour depth, we double the file size used to store the image but will be able to store four times more colours in the image. This will make a higher quality image that will be more realistic. Modern computers actually use 24 bits (3 bytes) for every single pixel, which can be any one of 16,777,216 different colours.

We can also divide the image up into smaller pixels which means that the width and height resolution are increased (also called the x and y resolution) Increasing the resolution of an image increases the amount of data that is needed to store the image, but increases the quality of the image and makes it more realistic.

In your exam, you may be asked to calculate the size of an image file. To do this, we can use this formula:

filesize in bytes = (x resolution * y resolution * colour depth) /8

An image that is 320 pixels wide and 240 pixels high and uses 16 bit colour depth will be:

filesize in bytes = (320 x 240 * 16) / 8

= 1228800 / 8

= 153600 bytes

We usually convert the answer into one that is less than a 1000, so we would say that this image is 154 kilobytes.

The exam question may involve you converting between kilobytes, megabytes, terabytes etc, and you may be asked to calculate how many images will fit onto a particular sized storage device. i.e. "How many of these images can a 128 megabyte USB memory pen store?"

Quick Test (Requires login)

Other Resources for this topic

Craig and Dave Videos (Requires login)

This section has four pages (click on links)

πŸ”— Binary representation of Numbers

πŸ”— Binary representation of Characters

Binary representation of Images (this page)

πŸ”— Binary representation of Sound

Next section:

πŸ”—1.2.5 Compression