📘 CodingMarble Learn

Image Communication

A picture is a grid of pixels, and each pixel is a number. To send a picture we send the numbers. Compression makes the list shorter, encryption hides it with a key, and a TV draws the picture again line by line.

🎬 Step-by-step story

  1. This picture is made of tiny squares called pixels. Each square has one colour.
  2. Each colour gets a number. The whole picture is now a list of 64 numbers.
  3. The numbers go down the wire one by one. The receiver draws the picture row by row, like a TV.
  4. A line of the same colour is squashed into "colour, how many". Now we send fewer numbers.
  5. A secret key changes the numbers. Anyone who peeks sees only noise.
  6. Your turn. Move the two keys. When both are equal, the picture is clear again.

Tip: drag the 3D scene to turn it. Use two fingers to zoom.

🤔 Common doubts, cleared

How can a colour be a number?

We agree on a table: 0 is white, 1 is blue, and so on. Real photos use three numbers (red, green, blue) for every pixel.

Why is the picture on the right blank at first?

The numbers have not arrived yet. The receiver fills in the squares as the numbers come, row by row.

Why do we need compression?

Big pictures have millions of numbers. Fewer numbers means faster sending and less space on your phone.

Can a stranger see my picture if they catch the numbers?

Not if it is encrypted. Without the right key they only see coloured noise.

What happens if the two keys are different?

The receiver undoes the wrong amount, so the colours come out wrong. Try it with the sliders.

A picture is numbers

A pixel is one tiny square of a picture. Many pixels side by side make the whole picture. A computer cannot send a colour, so it gives each colour a number. A black and white pixel needs 1 bit. A colour pixel on a phone usually needs 24 bits (3 bytes): one byte each for red, green and blue.

A still image is one picture that does not move. Photos, scanned pages and fax pages are still images. To send one, we send its numbers along a wire or by radio, and the receiver draws the squares again.

Size of a picture = width × height × bits per pixel. A 1920 × 1080 photo with 24 bits per pixel has 2,073,600 pixels, so 6,220,800 bytes, about 6.2 MB.

How a television shows a moving picture

A moving picture is many still pictures shown quickly. Each still picture is a frame. If 25 to 30 frames are shown in one second, your eyes see smooth motion.

The TV does not send a whole frame at once. It sends the picture one line at a time, from the top to the bottom. This is called scanning. A camera scans the scene into lines, the signal travels, and the screen draws the lines again in the same order. Colour TV does this for three colours: red, green and blue, and mixes them on the screen.

Older TVs sent a signal made of waves (analogue). Today most TV is digital: the lines are numbers, and the numbers are compressed to save space.

Compression: make the list shorter

Compression means storing the same picture in fewer numbers, so it is quick to send and uses less space.

Lossless compression loses nothing. After you open it, you get exactly the same picture. Example, run-length coding: 20 white pixels in a row become "white, 20". ZIP and PNG are lossless.

Lossy compression throws away small details your eyes hardly notice. The file is much smaller, but you cannot get the lost detail back. JPEG is lossy. Too much lossy compression makes the picture blocky.

Encryption: lock it with a key

A wire or radio wave can be listened to by anyone. Encryption changes the numbers using a secret key, so a stranger sees only noise. Decryption changes them back with the key.

In the 3D, the key adds a number to every pixel value. With the wrong key, the colours come out wrong. Real systems use much harder maths, but the idea is the same: same key opens the lock (this is called a symmetric key), a wrong key gives rubbish.

Order matters: compress first, then encrypt. Encrypted data looks random, and random data cannot be squashed.

Try it

In the 3D, jump to the last step. Set the sender key to 2 and the receiver key to 3 and press "Send again". Is the picture clear? Now make both keys equal and send again. Predict first, then check. At home, draw a 6 × 6 grid on paper, colour a smiley, and write the numbers row by row. Give the list to a friend and see if they can draw your picture.

Key formulas and definitions

Worked examples

1. How many pixels are in a picture 8 pixels wide and 8 tall?

8 × 8 = 64 pixels.

2. A black and white picture is 100 × 50 pixels, 1 bit per pixel. How many bytes?

Bits = 100 × 50 × 1 = 5000. Bytes = 5000 ÷ 8 = 625 bytes.

3. A photo is 1000 × 800 pixels with 24 bits per pixel. Find its size in MB (1 MB = 1,000,000 bytes).

Pixels = 800,000. Bytes = 800,000 × 3 = 2,400,000. Size = 2.4 MB.

4. Write the run-length code for WWWWBBWWW.

Four W, two B, three W: (W,4)(B,2)(W,3).

5. A 2.4 MB photo is compressed to 0.3 MB. Find the compression ratio.

Ratio = 2.4 ÷ 0.3 = 8. The file is 8 times smaller.

6. A TV shows 25 frames per second. How many frames in 2 minutes?

2 minutes = 120 s. Frames = 25 × 120 = 3000.

Common mistakes

Practice quiz

1. The smallest dot of a picture is called:
2. Which compression gives back the exact same picture?
3. A TV builds a frame by drawing:
4. Encryption is used to:
5. 1 byte equals:

Practice: answer these yourself

Type or choose your answer, then press Check. Use a hint if you are stuck; the full solution appears after you answer.

Frequently asked questions

How is an image sent over the internet?

The picture is turned into numbers (pixels), usually compressed (like JPEG), often encrypted, and cut into small packets. The receiver joins the packets, decrypts, decompresses and draws it.

What is the difference between lossy and lossless compression?

Lossless keeps every bit, so you get the exact picture back (PNG, ZIP). Lossy drops small details to make the file much smaller (JPEG) and they cannot be recovered.

Why does a TV send the picture line by line?

One wire or radio channel can carry one signal at a time. Sending the picture as a sequence of lines lets the screen redraw it in the same order.

Where this is taught

Japan高校(専門学科)1〜3年Telecommunication Technology

Learn first

Learn next

Related lessons

All Physics lessons