| English | 意味 |
|---|---|
| compression/kəmˈpreʃn/ | 圧縮 |
| lossless/ˈlɒsləs/ | 無損 |
| lossy/ˈlɒsi/ | 有損 |
| bandwidth/ˈbændwɪdθ/ | 帯域幅 |
| run-length encoding/rʌn leŋθ enˈkəʊdɪŋ/ | ラン長符号化 |
| dictionary coding/ˈdɪkʃənəri ˈkəʊdɪŋ/ | 辞書符号化 |
| Huffman coding/ˈhʌfmən ˈkəʊdɪŋ/ | ホフマン符号化 |
| spatial/ˈspeɪʃl/ | 空間的 |
| temporal/ˈtempərəl/ | 時間的 |
The three letters that made the web possible
- In 1987 a programmer named Phil Katz wrote a compression program and put the file format in the public domain. He called it ZIP. He was 24.
- Nothing about the web works without that idea. A single uncompressed second of HD video is about 187 MB; a two-hour film would be 1.3 terabytes. Streaming it over a home connection is arithmetically impossible.
- The films you watch are perhaps a thousandth of that, and they still look right, because the compression throws away things your eye was never going to notice.
- This lesson is compression 压缩: the two families, the three lossless methods, and how to justify one for a given file.
Lossless and lossy
- Compression reduces a file's size, saving storage space and transmission bandwidth 带宽, and making downloads and streams faster.
- Lossless 无损 compression is compression from which the original data can be recovered exactly. ZIP and PNG are lossless.
- Lossy 有损 compression permanently removes some data, so the original cannot be recovered. JPEG, MP3 and streamed video are lossy.

Recover exactly, or shrink much further
無損圧縮とは:
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
無損圧縮では元のデータを正確に再構築でき、テキスト、プログラム、ZIP/PNGにとって必須です。
それぞれの圧縮概念とその意味を結びつけてください。
難易度 2/5 · 140 コイン + 今日初回完了時に小ボーナス付与
無損圧縮はすべてのビットを保持するため、テキストやコードに必要です。有損圧縮は品質とサイズのトレードオフを行うため、写真や音声に適しています。
無損圧縮は元のデータを正確に再構築するため、テキストやプログラムに必要です。一方、有損圧縮はファイルを小さくするためにデータを永続的に削除するため、写真や音声に使われます。
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
そのため、プログラムやZIPは無損圧縮が必要ですが、写真や曲は有損圧縮可以使用します。
Worked example: justify the choice
- A company archives its accounting spreadsheets. Which kind of compression, and why? Lossless, because the spreadsheet must be restored exactly; a single changed value would make the accounts wrong.
- A photographer uploads holiday photographs to a phone gallery. Lossy, because the photographs are viewed on a small screen where the dropped detail is not visible, and the smaller files upload faster and use less storage.
- Name the kind, then give the reason from the situation. "Lossy is smaller" on its own is not a justification.
どのファイルが無損圧縮対象となるべきか?
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
ソースコードを正確に復元する必要がある。単一文字の変更でも機能しなくなる可能性があるため、無損失圧縮が必須である。
Run-length encoding
- Run-length encoding 行程编码 (RLE) replaces a run of repeated values with one value and a count: instead of eight identical white pixels, store "8, white".
- It is excellent on data with long runs, such as icons, diagrams, black-and-white scans and areas of flat colour.
- It is useless, and can make a file larger, on noisy data such as a photograph, where almost no two neighbouring values are equal.

Each row becomes counts and colours
ランルースエンコーディングが最も効果的なデータは:
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
RLEは同一値の連なりをカウント+値で置き換えるため、一様な領域では優れていますが、ノイズのあるデータでは機能しません。
Worked example: encode a row with RLE
- A row of an 8-pixel black-and-white image reads: white white white black black white white white. Encode it with RLE.
- Three white, two black, three white, so
3W 2B 3W, or as pairs,(3, 0) (2, 1) (3, 0)if white is 0. - Eight values became three pairs. Now encode
W B W B W B W B. Eight runs of one:1W 1B 1W 1B 1W 1B 1W 1B, which stores more than the original. That is exactly why RLE is not used on photographs.
ランルースエンコーディング(無損圧縮方式)
ランルースエンコーディングは、繰り返される値の連なりを1つの値とカウントで置き換えます。無損であり、元のデータを完全に復元できますが、長い連なりがあるデータのみを圧縮できます。
ピクセル行 W W W B B W W W をランルースエンコーディングで符号化してください。形式は「3W 2B 3W」を使います。
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
白3、黒2、白3です。8個の値が3組のペアになりますが、交互のパターンなら8組のペアになり、むしろ大きくなります。
ランルースエンコーディングは常にファイルを小さくする。
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
連なりがないデータ(写真や交互パターンなど)では、すべての連なりが長さ1となり、エンコーディング結果の方が元のデータより大きくなることがあります。
Dictionary coding and Huffman coding
- Dictionary coding 字典编码, used by ZIP and PNG, builds a dictionary of repeated byte sequences and replaces each occurrence with a short index. It suits text and program code, where words and patterns recur.
- Huffman coding 霍夫曼编码 gives short codes to common symbols and long codes to rare ones, so the average code length falls. In "BANANA" the A is commonest and gets the shortest code.
- Both are lossless: the decoder rebuilds the original byte for byte.
ハフマン符号化は以下の方法でサイズを削減します:
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
ハフマン符号化は最も頻度の高い記号に最短のコードを割り当て、平均コード長を短縮します。
各損失なし圧縮手法とその動作原理を対応させよ。
難易度 2/5 · 140 コイン + 今日初回完了時に小ボーナス付与
これら3つはすべて損失なしであり、デコーダーは元のバイトを正確に再構築する。
Lossy methods
- Images (JPEG): fine detail and colour differences the eye barely notices are dropped.
- Sound (MP3, AAC): pitches we hear poorly are removed, along with quiet sounds masked by louder ones at the same moment.
- Video: spatial 空间 compression works within each frame, like JPEG, and temporal 时间 compression stores most frames as only the differences from the previous frame, since consecutive frames are nearly identical.
動画の時間的圧縮は次のようにして機能する:
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
時間的圧縮では、フレーム間の画像がほぼ同一であるため、各フレームが前のフレームとどのように異なるかを記録する。(空間的圧縮はフレーム内の詳細情報を処理する。)
Worked example: how each kind of file is compressed
- Text file: dictionary and Huffman coding turn repeated words and common characters into short codes. It must stay lossless, because one changed character changes the meaning.
- Bitmap image: RLE for runs of identical pixels in icons and diagrams; lossy JPEG for photographs; or reduce the colour depth or resolution, which is also lossy.
- Vector graphic: the drawing list is already small. Remove drawing objects that are not needed, store coordinates to fewer decimal places, or apply a lossless method such as ZIP to the file.
- Sound file: lossy MP3 or AAC removes what the ear cannot hear; lowering the sampling rate or resolution is also lossy; lossless formats keep every sample and shrink much less.
ベクターグラフィックファイルのサイズを小さくする方法として正しいものをすべて選択せよ。
難易度 2/5 · 140 コイン + 今日初回完了時に小ボーナス付与
ベクターファイルはピクセルではなく描画リストであるため、色深度を持たない。色深度はビットマップ特有のものである。
Why streaming must be lossy
- Raw HD video is gigabytes per minute, and a home connection carries a few megabits per second.
- Lossless compression on video achieves perhaps a factor of two, nowhere near enough, so the picture would keep stopping to buffer.
- Lossy compression achieves a factor of a hundred or more by discarding detail the viewer does not notice at normal speed. The reason names the bandwidth and the data rate, not just "it is smaller".
なぜリアルタイム動画ストリーミングでは損失あり圧縮を使用するのか?
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
生HD動画は分あたりギガバイト単位であり、リアルタイムストリーミング中に停止せず送信するには、損失あり圧縮による大幅な縮小が必要である。
Marks that slip away
- Lossless means the original is recovered exactly; lossy means it cannot be. "Lossy loses quality" misses the point that the data is gone for good.
- RLE can make a noisy file larger. Say where it works and where it does not.
- Video compression is spatial and temporal; temporal stores the differences between frames.
- A "justify" answer ties the method to the file's use: exactness for accounts and medical images, size for streaming and phone galleries.
You've got it
- compression saves storage and bandwidth; lossless recovers the original exactly, lossy removes data permanently
- lossless methods: RLE (a value and a count, good on runs, bad on noise), dictionary coding (repeated sequences to short indices), Huffman coding (short codes for common symbols)
- lossy methods drop what the eye or ear misses; video adds spatial within a frame and temporal between frames
- justify from the use: exact data means lossless, limited bandwidth for streaming means lossy