☰ Year plan · Communication Technology

Numbers behind sound, pictures and video

Week 5 · Chapter 6 Information Design (2): numerical calculations and complements, digitalization of sound, images, video and compression, information design (touched lightly) · 3 lessons
2

Sound, pictures and video as numbers

ICT Secondary 1 Term 1, Chapter 6, Lessons 6-5 to 6-10: pp. 65–84
GoalExplain how sound, pictures and video become numbers, and calculate file sizes with the unit stated.
New words
sampling · measuring a wave at regular timespixel · one dot of a picture, with one colourcompression · making a file smallercompression ratio · original size ÷ compressed size
Explanation

Sound is a wave. To store it, a computer samples the wave: it measures the height at regular times. Each measure is rounded to a whole number (quantization) and written as bits (encoding). More samples per second and more bits per sample copy the sound more closely, but the file is bigger. The size is: samples per second × bits per sample × seconds × channels, in bits; divide by 8 for bytes. In this lesson 1 KB = 1,000 bytes and 1 MB = 1,000,000 bytes. For 8,000 samples per second, 8 bits, 10 seconds, one channel: 8,000 × 8 × 10 = 640,000 bits = 80,000 bytes = 80 KB. A picture is a grid of pixels. The resolution is the number of pixels wide × the number high. The colour depth is the number of bits per pixel: 1 bit gives 2 colours, 8 bits give 256, and 24 bits give 16,777,216 (about 16.7 million). On a screen, red, green and blue light add up to white; in printing, cyan, magenta and yellow inks subtract light. Size in bytes = pixels × bits per pixel ÷ 8. A 100 × 50 picture with 8 bits is 5,000 × 8 ÷ 8 = 5,000 bytes = 5 KB. Raster pictures are pixels and blur when enlarged; vector pictures are shapes described by formulas and stay sharp. A video is many pictures, called frames, shown quickly: its size is one image × frames per second × seconds, which is huge, so we compress. Lossless compression can restore the file exactly; lossy compression drops details people hardly notice, and cannot be undone.

Worked examples
0001100000011000000110001111111111111111000110000001100000011000
Here is an 8 × 8 picture with 1 bit per pixel (1 = black). It has 8 × 8 = 64 pixels, so it needs 64 bits = 8 bytes. Each row is one byte.
0501001501509015rawlosslesslossysize in KB
Video size and compression. A short clip: 10 frames per second for 3 seconds is 30 frames. Each frame is a 100 × 50 picture of 5,000 bytes, like the one in the explanation, so the raw clip is 30 × 5,000 = 150,000 bytes = 150 KB (1 KB = 1,000 bytes). After compression it is 15 KB, so the compression ratio is 150 ÷ 15 = 10 (10 to 1). The picture shows invented sizes for the same clip.
Class activity

Work out on paper, stating the unit rule (1 KB = 1,000 bytes): the size of a 5-second recording with 4,000 samples per second, 8 bits and one channel. Then the size of a 40 × 25 picture with 8 bits per pixel.

Practice
1
A picture uses 2 bits per pixel. How many colours can it show?
2
Why does a vector picture stay sharp when enlarged?
3
Size of a 16 × 16 picture with 1 bit per pixel, in bytes?
4
A 200 KB file is compressed to 50 KB. What is the compression ratio?