A1.1.8

Describe the concept of compression

Compression decreases disk space needed for files and bandwidth for transfer → more efficient use of resources.

2 min read340 words

Lossless vs Lossy Compression

Lossless Compression

  • Identifies redundant patterns and eliminates them without losing essential information.
  • Decompressed (解压缩, 从压缩状态恢复到原文件状态) file is an exact replica of the original — preserves integrity and quality.
  • Process is reversible.
  • Compression ratio generally smaller than lossy.

Lossy Compression

  • More aggressive strategy for higher compression ratios.
  • Deliberately discards data — typically minor details less noticeable to human eye/ear (perceptual redundancy).
  • Significantly smaller file sizes → suitable for audio, video, images.
  • Discarded info can compromise (危及, 损害) quality of reconstructed file → process is irreversible.

Differences

FeatureLosslessLossy
Data IntegrityPreserves all original data; decompressed = originalIntroduces variations; some data deliberately discarded
Compression RatioLower (no data removed)Higher (less important data removed)
ApplicationsWhere integrity is critical: backups, archives, document editingAudio/video/images where slight quality loss is acceptable
Perceptual RedundancyNot exploitedExploited — discards what humans won’t notice
Reversible?Reversible — perfectly reconstructedIrreversible — discarded data cannot be restored

Run-length encoding, Transform coding

  • Run-length encoding (RLE) — simple, efficient lossless technique for data with repetitive patterns. Replaces consecutive occurrences of the same value with a single code representing the run length. E.g., AAAAA5A.
  • Transform coding — advanced lossy technique. Uses mathematical transformations (like DCT, Discrete Cosine Transform) to convert data into a form where structure/redundancy are easier to identify → much higher compression ratios.
    • Lossy: compressed file cannot be perfectly reconstructed; irreversible — data deliberately discarded permanently.

Widely used in:

  • JPEG: transforms images into frequency domain before quantizing (量化).
  • MP3: transforms audio into frequency domain before encoding (编码).
Compression TypeExamplesTypical Applications
LosslessGIF, TIFF, PNG, PDF, ZIPBackups, archives, text files, simple graphics
LossyJPEG, MP3, MP4Images, audio, video where small quality loss is OK
Technique (Lossless)Run-Length Encoding (RLE)Fax images (传真), simple graphics, text
Technique (Lossy)Transform Coding (JPEG, MP3, MP4)Image, audio, video compression

Start typing to search all published objectives.