Introduction to Representing Images

Welcome! Have you ever wondered how your computer or phone displays a beautiful photo when, deep down, the computer only understands 0s and 1s? In this chapter, we are going to pull back the curtain and see how computers turn simple numbers into the colorful images we see on our screens every day. Don't worry if this seems a bit strange at first—once you see the pattern, it’s as simple as building with LEGO!

What is a Pixel?

The word pixel is actually short for "picture element". Think of a pixel as a single tiny dot of color. If you zoom in really close to your TV or computer screen, you’ll see that every image is actually made up of thousands (or millions) of these tiny dots arranged in a grid.

Analogy: Imagine a giant mosaic made of small square tiles. From far away, it looks like a person or a landscape. But if you walk right up to it, you see it’s just thousands of individual colored squares. Each square is a pixel.

Quick Review: The Basics

• A pixel is the smallest identifiable area of an image.
• Images are displayed as a grid of pixels.
• Each pixel is represented by a binary pattern.

Bitmap Images

In this syllabus, we focus on bitmaps. A bitmap image is simply a map of where each "bit" of data goes to create the picture. There are two main things that decide what a bitmap looks like: Image Size and Colour Depth.

1. Image Size (Resolution)

The size of an image is expressed as width x height in pixels.
Example: An image that is 10 pixels wide and 10 pixels high has a total of 100 pixels.

2. Colour Depth

Colour depth is the number of bits used to represent each pixel. The more bits you use per pixel, the more colors you can show!

• If we use 1 bit per pixel, we can only have 2 colors (usually Black and White). This is because a bit can only be a 0 or a 1.
• If we use 2 bits per pixel, we can have 4 colors (\( 2^2 = 4 \)).
• Modern photos often use 24-bit depth, which allows for over 16 million colors!

Did you know? Increasing the number of pixels (resolution) or the colour depth makes the image look much better and more realistic, but it also makes the file size much larger!

Key Takeaway

Higher Resolution + Higher Colour Depth = Better Quality + Larger File Size.

Calculating Image File Size

One of the most important skills in this chapter is calculating how much space an image takes up. Don't worry if math isn't your favorite subject—we use the same simple formula every time!

The Formula

To find the size in bits:
\( Size = Width \times Height \times Colour\ Depth \)

To find the size in bytes:
\( Size = (Width \times Height \times Colour\ Depth) / 8 \)

Step-by-Step Example

Problem: An image is 10 pixels wide, 20 pixels high, and has a colour depth of 8 bits. What is the file size in bytes?

1. Multiply the width by the height: \( 10 \times 20 = 200 \) pixels.
2. Multiply by the colour depth: \( 200 \times 8 = 1,600 \) bits.
3. Divide by 8 to get bytes: \( 1,600 / 8 = 200 \) bytes.

Common Mistake to Avoid: Always check if the question asks for the answer in bits or bytes. If it asks for bytes, remember to divide your final answer by 8!

Converting Between Binary and Images

In your exam, you might be asked to turn a grid of pixels into binary code, or vice versa. This is like a "color by numbers" game.

Binary to Image

Imagine a \( 3 \times 3 \) grid and the binary code: 101 010 101.
If 1 = Black and 0 = White, the image would look like a checkerboard:
• Row 1: Black, White, Black
• Row 2: White, Black, White
• Row 3: Black, White, Black

Image to Binary

To convert an image to binary, just read the grid like a book (left to right, top to bottom) and write down the number for each color.
Example: If you see a row of three pixels that are White, Black, White, and the key says Black is 1 and White is 0, you would write: 010.

Memory Aid: "P.D.S."

To remember how images work, think of P.D.S.:
P - Pixels (The dots)
D - Depth (The colors)
S - Size (The width x height)

Summary and Quick Review

Pixel: A single point in an image (Picture Element).
Image Size: Measured in pixels (Width x Height).
Colour Depth: The number of bits per pixel. More bits = more colors.
File Size Calculation: \( Width \times Height \times Depth \).
Binary Representation: Each pixel's color is stored as a binary number. A simple 1-bit image uses 0 for one color and 1 for another.

You've got this! Just remember that images are just grids of dots, and each dot is just a number. Practice the file size formula a few times, and you'll be an expert in no time!