Welcome to Data Representation: Representing Images!

Hello future Computer Scientists! This chapter is all about how your computer manages to display beautiful, complex images when all it truly understands are 0s and 1s (binary).

Don't worry if maths or physics aren't your favourite subjects—we will break down image representation into simple building blocks. By the end of this section, you will understand the three key ingredients needed to store any picture digitally: pixels, resolution, and colour depth.

Key Takeaway: Why is this important?

Understanding image representation is crucial because it directly impacts file size and image quality. This knowledge helps us calculate storage requirements, which is a core skill in Computer Science.

1. Bitmaps and Pixels: The Foundation of Digital Images

When a computer stores a photo, it doesn't store the scene itself. Instead, it stores a massive map, describing every tiny dot that makes up the picture. This type of image is called a Bitmap (a map of bits).

Analogy: The Graph Paper Picture

Imagine trying to recreate a famous painting using only graph paper. You colour in each small square with a single colour until the picture appears. A digital bitmap image works exactly like this graph paper.

What is a Pixel?

The smallest element in a digital image is called a Pixel (short for Picture Element).

  • A pixel is a single, tiny, uniform square (or dot) of colour.
  • Every pixel is assigned a binary code (a sequence of 0s and 1s) that tells the computer exactly what colour it should be.
  • The computer looks at the "map" (the bitmap) and sets the screen display for each pixel based on the stored binary code.

Quick Check: If you zoom in extremely close on a photo on your phone or computer screen, you will eventually see the individual squares—those are the pixels!

Quick Review: Bitmap vs. Pixel

Bitmap: The overall grid or map of all the pixels.
Pixel: A single coloured dot within the grid.

2. Resolution: The Size of the Grid

The first factor that determines the quality and file size of an image is Resolution.

Resolution refers to the total number of pixels used to create the image. It is usually given as the width multiplied by the height.

Calculating Resolution

If an image has 1200 pixels across (width) and 800 pixels down (height), its resolution is 1200 x 800.

To find the total number of pixels in the image, you simply multiply the width by the height:
Total Pixels = Width x Height
Example: \(1200 \times 800 = 960,000\) pixels.

Impact of Resolution

  • Higher Resolution: Means the image has more pixels. This results in greater detail and clarity (a sharper image).
  • Lower Resolution: Means fewer pixels. If you try to display a low-resolution image on a large screen, the pixels will become noticeable (making the image look "blocky" or pixelated).
  • File Size: Higher resolution requires storing more pixel data, leading to a larger file size.

Don't worry! When people talk about a screen being "Full HD 1080p," they are referring to a resolution of 1920 pixels (width) by 1080 pixels (height). That's over 2 million pixels!

3. Colour Depth: Defining the Colour of Each Dot

We know a pixel is a single coloured dot. But how does the computer know which colour it is? This is determined by the Colour Depth.

What is Colour Depth (Bits Per Pixel - BPP)?

Colour Depth is the number of bits used to store the colour information for a single pixel. It is sometimes called Bits Per Pixel (BPP).

Since a bit can only be 0 or 1, using more bits allows us to create many more combinations, and therefore, many more colours.

Calculating the Number of Available Colours

The number of colours that can be represented is calculated using the formula:
Number of Colours = \(2^{\text{Colour Depth (in bits)}}\)

Step-by-Step Examples of Colour Depth

Let's look at how increasing the BPP drastically increases the colour options:

Example 1: 1-bit Colour Depth
  • BPP: 1 bit
  • Calculation: \(2^1 = 2\) colours
  • Result: This image can only display 2 colours (usually black and white).
Example 2: 8-bit Colour Depth
  • BPP: 8 bits
  • Calculation: \(2^8 = 256\) colours
  • Result: This was common for older computer games. It allows for a limited range of colours, but not enough for photo-realistic quality.
Example 3: 24-bit Colour Depth (True Colour)
  • BPP: 24 bits
  • Calculation: \(2^{24} = 16,777,216\) colours (approx. 16.7 million)
  • Result: This is known as True Colour. Since the human eye can only distinguish around 10 million colours, 24-bit depth is considered photo-realistic and is the standard for modern digital photography and displays.

Memory Aid: More Bits Per Pixel (BPP) = Deeper Colour = Better Quality = Larger File Size.

Did you know? 24-bit colour depth is achieved by dedicating 8 bits each to the three primary colours of light: Red, Green, and Blue (RGB). \(8 \text{ bits } + 8 \text{ bits } + 8 \text{ bits } = 24 \text{ bits}\).

4. Calculating Image File Size

Now we put resolution and colour depth together to calculate the uncompressed file size (measured in bits, bytes, KB, or MB).

The Core Formula

File Size (in bits) = Total Number of Pixels \(\times\) Colour Depth (BPP)

Step-by-Step Calculation Process

Follow these four crucial steps to calculate the file size accurately:

Step 1: Calculate Total Pixels (Resolution)

Multiply the image width by the image height.
Example: An image is 400 pixels wide and 300 pixels high.
\(400 \times 300 = 120,000\) pixels

Step 2: Calculate Total Bits (File Size in Bits)

Multiply the total number of pixels by the Colour Depth (BPP).
Example: The image above has a Colour Depth of 8 bits (8 BPP).
\(120,000 \times 8 = 960,000\) bits

Step 3: Convert Bits to Bytes

Since there are 8 bits in 1 byte, divide the total number of bits by 8.
\(960,000 \div 8 = 120,000\) bytes

Step 4: Convert to Kilobytes (KB) or Megabytes (MB)

For large files, we convert to larger units. Remember that for storage calculations:
\(1 \text{ Kilobyte (KB)} = 1024 \text{ Bytes}\)
\(1 \text{ Megabyte (MB)} = 1024 \text{ KB}\)

To convert the result from Step 3 (120,000 bytes) into Kilobytes (KB):
\(120,000 \div 1024 \approx 117.19\) KB

🚨 Common Mistake Alert 🚨

Always remember to divide by 1024 (not 1000) when converting bytes to KB, KB to MB, etc., in Computer Science, as these are binary unit conversions!

Summary of Calculations

Calculating file size shows the trade-off between quality and storage:

  • If you double the resolution (e.g., from 400x300 to 800x600), the number of pixels quadruples, and the file size quadruples.
  • If you double the colour depth (e.g., from 8 BPP to 16 BPP), the file size doubles.

This explains why high-resolution, high-colour images take up so much space on your phone!

Chapter Key Takeaways Summary
  • Digital images are stored as Bitmaps, grids made of individual Pixels.
  • Resolution (Width x Height) determines the total number of pixels.
  • Colour Depth (BPP) determines the number of bits used per pixel, influencing colour fidelity (\(2^{\text{BPP}}\) colours).
  • File Size (in bits) = Resolution \(\times\) Colour Depth.
  • Conversion Units: 8 bits = 1 Byte; 1024 Bytes = 1 KB.

You've mastered how computers see and store pictures! Great job! Now you are ready to tackle practice questions on data calculation.