The apple蘋果
The apple from Lesson 2. Which rows shrink the most, and which hardly shrink at all?
第二課的那顆蘋果。哪幾列縮得最多?哪幾列幾乎沒縮?
How Computers Work · Unit 3 · Lesson 12 · 電腦概論 單元三 第十二課
A wall of 256 colored squares is packed row by row in 3D: squares of the same color in a row join into one bar with a number on it. Watch one picture shrink to a fraction of its size and another grow to twice its size. Then draw your own picture to pack, throw detail away and try to get it back, and decide what must never be lost.
在 3D 裡把一面 256 格的彩色方塊牆一列一列壓起來:同一列裡相鄰的同色方塊合成一長條,上面寫著格數。看一張圖縮到原來的幾分之一,另一張卻變成兩倍大。接著自己畫一張圖來壓、把細節丟掉再試著還原,並分辨哪些東西一點都不能少。
A file gets smaller when its repetition is written in a shorter way: not “red, red, red, red, red,” but “5 red.” That kind of compression loses nothing, and the file can be unpacked exactly as it was. Another kind goes further and throws away detail that people hardly notice. It makes files much smaller, but what is thrown away cannot come back.
把檔案裡重複的地方用比較短的方式寫下來,檔案就變小了:不寫「紅、紅、紅、紅、紅」,而寫「5 個紅」。這種壓縮什麼都不會丟,解開來和原來一模一樣。另一種壓縮更進一步,把人不太注意得到的細節丟掉。檔案會小得多,可是丟掉的拿不回來。
3D Model · 3D 模型
The wall is a picture of 16 by 16 squares, like the pixel wall in Lesson 2. To store it as it is, the computer keeps one number for every square: 256 numbers. Press Pack it. Row by row, squares of the same color that sit side by side join into one bar, and the bar is stored as just two numbers: how many, and which color. Watch the counter on the right. Then try the other pictures, and press Unpack to get every square back.
這面牆是一張 16 × 16 格的圖,就像第二課的像素牆。照原樣存,電腦要替每一格記一個數,一共 256 個數。按「壓縮」。一列接一列,並排的同色方塊合成一長條,而一長條只要記兩個數:幾格、什麼顏色。注意看右邊的計數。接著試試其他幾張圖,再按「解開」,讓每一格都回來。
Drag to turn · 拖曳旋轉
This 3D model needs WebGL, which this browser does not support. The buttons and the two counters below still work, and so do the reading and the games.
這個瀏覽器不支援 WebGL,無法顯示 3D 模型;下面的按鈕和兩個計數照樣能用,課文和小遊戲也都能用。
A teaching model. The method here is the simplest one there is, called run-length encoding, and it looks only along each row. The compression inside real formats such as ZIP is far more clever: it can also spot patterns that repeat further apart. Counting each color as one number is a simplification too. What carries over to the real thing is the idea: repetition can be written in a shorter way, and where there is no repetition, there is nothing to save.
這是教學用的示意模型。這裡用的是最簡單的一種方法,叫運行長度編碼(run-length encoding),而且只沿著每一列看。ZIP 這類真的格式裡的壓縮聰明得多,隔得比較遠的重複也找得出來。把每個顏色算成一個數,也是簡化過的。真正相通的是這個道理:重複的地方可以寫短;沒有重複,就沒有東西可以省。
Model and code are drawn and programmed by My Culture Connect. Every picture is tested to unpack exactly, and every number on this page is checked, in tools/computers/test/rle.test.mjs.
模型與程式由人師教育協會自行繪製、撰寫;每一張圖都測過「解開後一格不差」,頁面上每一個數字也都有自動測試(tools/computers/test/rle.test.mjs)。
Reading · 英文閱讀
In Lesson 2 you saw that a picture is a long list of numbers, and that a photo from a phone holds millions of them. Yet the photo files on a phone are often far smaller than that. Songs and videos are smaller than you would expect too. Something is making them shrink. It is called data compression: reducing the amount of data needed to store a piece of information or to send it.
The first idea is repetition. Suppose a row of a picture has sixteen squares, all of them red. You could write “red” sixteen times. Or you could write “16 red.” That is two numbers instead of sixteen, and nothing has been lost. A picture with large areas of one color, such as a blue sky above green grass, shrinks a great deal this way.
But it does not always work. Take a picture where no two squares next to each other are the same color. Now every square has to be written as “1 of this color,” which is two numbers instead of one. The file gets bigger, not smaller. Compression is not magic. It finds patterns, and where there is no pattern, there is nothing to save.
Compression of this kind is called lossless. When the file is unpacked, every number comes back exactly as it was. That matters for text, where every character is important, and for programs. ZIP files work this way, with cleverer methods than counting. English text can generally be compressed to one-half or one-third of its original size.
For photos and music there is a second kind, called lossy compression. It throws away detail that people hardly notice. The JPEG format for photos discards what the human eye cannot see. The MP3 format for music discards sounds that the ear is least likely to miss. The files become very much smaller. But the detail that was thrown away is gone, and no program can bring it back.
So there is a choice to make. An essay must come back letter for letter, so it needs lossless compression. A photo to share with friends can lose a little. Either way, a smaller file takes up less storage and travels more quickly to another computer. And a file that has already been compressed, such as a JPEG photo, will hardly shrink at all if you compress it again.
Questions · 閱讀理解
How can “16 red” replace sixteen squares without losing anything?
Why does a picture with no repetition get bigger when it is packed this way?
What is the difference between lossless and lossy compression? Give one thing that needs each.
Words & Phrases · 生字及片語
Quick Check · 小測驗
1. What does data compression do?
2. Which picture shrinks the most when same-colored squares in a row are counted?
3. What is true of lossless compression?
4. What does lossy compression do?
5. According to the reading, what happens if you compress a JPEG photo again?
Try It in the Model · 在模型裡試試
Then pack “Sky and grass,” and after each picture press Unpack to check that nothing was lost.
接著壓壓看「天空與草地」;每張圖壓完都按一次「解開」,確認什麼都沒有少。
The apple from Lesson 2. Which rows shrink the most, and which hardly shrink at all?
第二課的那顆蘋果。哪幾列縮得最多?哪幾列幾乎沒縮?
Every row is a single color. How many numbers does each row need now?
每一列都只有一種顏色。現在每一列要記幾個數?
It is the same picture turned on its side, yet it doubles in size. What changed?
這是同一張圖轉了九十度,壓完卻變成兩倍大。是什麼不一樣了?
No two neighbors are the same. Is there anything here for the method to shorten?
沒有任何相鄰的兩格同色。這張圖有什麼地方可以讓這個方法寫短嗎?
Try It · 自己試試
Choose a color and paint on the grid of 8 by 8 squares. On the right, each row is written as counts and colors, and the bar shows how many numbers your picture needs when packed. As it is, it always needs 64. Can you draw a picture that packs into 16 numbers? One that needs 128?
選一個顏色,在 8 × 8 的格子上畫。右邊會把每一列寫成「幾個+顏色」,長條顯示你的圖壓縮後要記幾個數。照原樣存一定是 64 個。你畫得出只要 16 個數的圖嗎?要 128 個數的呢?
Your picture · 你的圖
Packed, row by row · 壓縮後,一列一列
As it is: 64 numbers. Packed · 原來 64 個數,壓縮後0
The black line on the bar marks 64, the size of the picture as it is. A green bar to the left of the line means the packed picture is smaller. A red bar to the right means it is bigger.長條上的黑線標的是 64,也就是原圖的大小。綠色長條在黑線左邊,表示壓縮後變小;紅色長條超過黑線,表示壓縮後反而變大。
See Why · 看看為什麼
This is the other kind of compression. Choose a block size, and every block of squares becomes a single color: the one that most of its squares had. Fewer numbers need to be kept. Compare the two pictures, and then press the button to try to get the original back.
這是另一種壓縮。選一個方塊大小,每一塊裡的格子就都變成同一個顏色——原來那一塊裡最多的那個顏色。要記的數變少了。比一比兩張圖,再按按鈕,試著把原圖要回來。
Make every block one color · 把每一塊變成同一個顏色
This is only a picture of the idea. Real lossy formats such as JPEG are far more careful about which details they throw away, so that the eye hardly notices. The rule is the same, though: what was not kept cannot be brought back.這只是用來說明道理的示意。JPEG 這類真的失真格式,在「丟掉哪些細節」上講究得多,所以眼睛幾乎看不出來。但規則是一樣的:沒有留下來的,就拿不回來。
Game · 小遊戲
Eight things to compress. For each one, decide: must it come back exactly as it was, or is it all right to lose a little detail?
一共八樣要壓縮的東西。每一樣都想一想:它一定要原封不動地回來,還是少一點細節沒關係?
Right on the first try · 第一次就答對 0 / 0
These answers follow Britannica’s article on data compression, except the program and the exam scores, which are our own examples of things where every character matters.這些答案依照大英百科「資料壓縮」條目;只有「電腦程式」和「成績表」是我們自己舉的例子,用來說明「每個字元都重要」的東西。
Stories Behind Compression · 壓縮的故事
Four short stories about writing things in less space.
關於「用比較少的空間寫東西」的四個小故事。
Morse Code · 摩斯電碼
Britannica points out that compression is older than digital technology. Morse Code assigned the shortest codes to the most common characters, so that a message took less time to send. And telephones cut off the high frequencies of the voice, which is an early example of lossy compression: some of the sound is thrown away, and the words are still understood.
大英百科指出,壓縮比數位科技還早。摩斯電碼把最短的碼分給最常用的字元,這樣發一則訊息花的時間就比較少。電話則把人聲裡的高頻切掉,這是很早的失真壓縮:聲音的一部分被丟掉了,話還是聽得懂。
36 → 32
Britannica gives an example with only four letters: a, e, r, and t. With four letters, each one needs two bits, so the eighteen letters of “A rat ate a tart at a tea” take 36 bits. But a is the most common letter here and t the next. Give a the code 0, t the code 10, r the code 110, and e the code 111, and the same sentence takes only 32 bits. Short codes for common things: the Morse idea again, in bits.
大英百科舉了一個只有四個字母的例子:a、e、r、t。四個字母,每個要用兩個位元,所以「A rat ate a tart at a tea」這十八個字母要 36 個位元。可是這裡 a 最常出現,t 第二。讓 a 的碼是 0、t 是 10、r 是 110、e 是 111,同一句話就只要 32 個位元。常用的給短碼——又是摩斯電碼的想法,只是換成位元。
JPEG, MP3
According to Britannica, the Joint Photographic Experts Group was formed in 1986 to create a standard that used data compression to keep picture files small. The JPEG standard works by averaging color variation and discarding what the human eye cannot see. The MP3 format, part of a standard released in 1993, did the same for music: it reduced the size of a CD audio file by discarding certain sounds, based on what the ear is least likely to miss. Britannica adds that the data lost in an MP3 is not reversible.
根據大英百科,聯合圖像專家小組(Joint Photographic Experts Group)在 1986 年成立,目的是訂出一套用資料壓縮讓圖檔變小的標準。JPEG 標準的做法是把顏色的變化平均掉,丟掉人眼看不出來的部分。MP3 格式屬於 1993 年發布的一套標準,它對音樂做了同樣的事:根據耳朵最不容易察覺少了什麼,丟掉某些聲音,把 CD 音訊檔變小。大英百科還說,MP3 壓縮時丟掉的資料是無法復原的。
Lempel, Ziv
The model on this page can only count squares that sit side by side. Real compression programs do better. Britannica describes the Lempel-Ziv algorithm, invented by the Israeli computer scientists Abraham Lempel and Jacob Ziv. It uses the text itself as a dictionary: when a string of characters appears again, it is replaced by numbers that say where it appeared before and how long it was. Britannica notes that Zip uses variations of this algorithm.
這一頁的模型只會數並排的格子。真的壓縮程式厲害得多。大英百科介紹了 Lempel-Ziv 演算法,由以色列電腦科學家倫佩爾(Abraham Lempel)和立夫(Jacob Ziv)發明。它把文章自己當成字典:一串字元再次出現時,就換成幾個數,說明它之前出現在哪裡、有多長。大英百科提到,Zip 用的就是這個演算法的變化版本。
Myth vs. Fact · 常見迷思
✗ Myth · 迷思Compression always makes a file smaller.壓縮一定會讓檔案變小。
✓ Fact · 事實Not when there is nothing to shorten. In the model, the scrambled picture grows from 256 numbers to 512.沒有東西可以寫短的時候就不會。在模型裡,那張雜亂的圖從 256 個數變成 512 個。
✗ Myth · 迷思Compressing a file always loses some quality.壓縮一定會損失一點品質。
✓ Fact · 事實Lossless compression can be reversed to give back the original data exactly. ZIP is lossless.無失真壓縮可以完全還原成原來的資料。ZIP 就是無失真的。
✗ Myth · 迷思If a photo was saved with too much compression, you can get the detail back later.照片壓得太過頭,之後還能把細節救回來。
✓ Fact · 事實Lossy compression throws detail away, and what was not kept cannot be brought back.失真壓縮是把細節丟掉;沒有留下來的,就拿不回來。
✗ Myth · 迷思Putting photos in a ZIP file makes them much smaller.把照片放進 ZIP 檔,就會小很多。
✓ Fact · 事實Microsoft notes that JPEG images are already highly compressed, so a zipped folder of them is about the same size as the pictures were.Microsoft 的說明提到,JPEG 圖片本來就已經高度壓縮,所以把它們壓成一個資料夾,大小和原來那些照片差不多。
Remember It · 記憶口訣
Not “red, red, red.” Just “3 red.”
不說「紅、紅、紅」,說「3 個紅」。
Compression needs repetition.
壓縮要靠重複。
Every number, exactly.
每一個數,分毫不差。
Smaller, but the detail is gone for good.
比較小,可是細節永遠沒了。
Before You Start · 動手之前
Classroom Activity 1 · 課堂活動一
You need · 準備材料
Steps · 步驟
Reading with counts is lossless compression: B’s copy should match square for square. Ask which pictures took fewer words and which took more. In Taiwan’s junior high Information Technology curriculum, this lesson builds on “Data representation, processing, and analysis”: 資 D-IV-1 and 資 D-IV-2, on how pictures and sound are turned into digital data. Compression itself is not named in the junior high content.
用「幾個」來唸,就是無失真壓縮:B 的那一張應該一格不差。問問大家,哪些圖說的字比較少,哪些反而比較多。對照十二年國教國中「資訊科技」的學習內容,這一課延伸自「資料表示、處理及分析」主題的資 D-IV-1 資料數位化之原理與方法、資 D-IV-2 數位資料的表示方法;國中的學習內容並沒有直接列出「壓縮」。
Classroom Activity 2 · 課堂活動二
You need · 準備材料
Steps · 步驟
The text file should shrink a good deal. The photo should stay about the same size, because a JPEG has already been compressed. Menu names differ a little between versions of Windows and macOS. Measure for yourself: the exact numbers depend on your files.
文字檔應該會縮小不少。照片的大小應該差不多,因為 JPEG 本來就已經壓縮過了。不同版本的 Windows 和 macOS,選單的名稱會略有不同。請自己量量看:實際的數字要看你的檔案。
Go Further · 延伸閱讀
Sources · 資料出處
Facts on this page were checked against these sources (October 2026); the picture wall is our own illustration, and every number is tested · 本頁的事實依下列資料查證(2026 年 10 月);像素牆是我們自己的示意,每一個數字都有測試