AI Glossary / MLOps and deployment / Advanced
Lossy compression
Definition
Lossy compression reduces the representation of data by allowing some information to be discarded or approximated. Decoding produces a reconstruction that need not equal the original input exactly. The design aims to balance storage or transmission cost against an appropriate measure of error or quality. It is common in media processing, but the acceptable tradeoff depends on the application rather than on the word lossy alone.
What it means
A smaller representation can be obtained by deciding which distinctions need not be preserved for a particular use. An image intended for quick viewing may tolerate changes that would be unacceptable in an exact archival record or a numerical analysis. “Looks the same” and “contains the same values” are different requirements. Lossy compression does not necessarily mean obviously poor quality, but a visually pleasing reconstruction cannot prove that every original detail is still available or that every downstream task will behave identically.
How it works
Many systems predict or transform the data, quantize selected values into a smaller set of possibilities, and then encode the resulting symbols efficiently. Quantization merges distinct inputs into the same representation, making exact inversion impossible in general. Other systems use different models, including learned ones, but must still define reconstruction and rate-quality behavior. A transform is not automatically the lossy step; it can be reversible before subsequent approximation. The complete pipeline, including color conversion, resizing and preprocessing, determines what information is actually preserved.
Three practical examples
- A website team reduces image sizes and checks visual quality at the displayed dimensions before selecting encoding settings.
- A video-service experiment compares delivered bitrate with motion artifacts and playback requirements on representative scenes.
- A scientific-data team evaluates a compression method against an explicit numerical-error requirement and tests whether important derived results remain acceptable.
Think of it this way
Imagine recording a journey by rounding each position to a nearby grid point. The resulting route can be easier to describe, but several original positions may now share the same recorded location. A reader can recover the grid route, not determine exactly which original position was chosen. A fine grid preserves more detail and may require more information; a coarse grid loses more. This analogy captures approximation without implying that every compression system uses a literal spatial grid or the same error measure.
Worked example
In an original scalar-quantization illustration, round [12, 18, 23, 27] to the nearest multiple of ten. The reconstructed values are [10, 20, 20, 30]. Reconstruction minus input gives errors [−2, 2, −3, 3]. The squared errors are [4, 4, 9, 9], whose mean is 26/4 = 6.5 in squared input units. Values such as 18 and 23 both reconstruct as 20, so the decoded value alone cannot identify which was the original. This demonstrates information loss and one distortion measure. It does not calculate a compressed file size: that requires a defined representation for the quantized indices, their permitted range and any headers or other overhead.
Illustrative case study
A fictional online-learning team compresses diagrams for faster page loading. Photographs remain acceptable at its first chosen setting, but small labels in the diagrams become harder to read. The team evaluates content types separately and adjusts the workflow to preserve legibility where it matters. It also keeps suitable source assets so future exports do not repeatedly start from already degraded copies. The scenario shows why a single aggregate quality score or one attractive sample is insufficient for selecting settings across an entire website. Success depends on the actual content and the learner's task.
Common misconceptions and mistakes
Lossy does not mean unusable, and lossless does not mean uncompressed. Another mistake is assuming that raising quality during a later export restores information discarded earlier. It may reduce additional loss, but it does not recover the original by itself. Repeated decoding and re-encoding can introduce further changes, although the amount depends on the pipeline. Numerical error, perceived quality and task accuracy are also different measures. A low average error can hide a locally important defect, while an attractive reconstruction can include details that are not faithful to the source.
Business use
Lossy compression can reduce delivery costs and improve responsiveness when the resulting changes are acceptable. Define the intended use and quality requirement before choosing settings. Evaluate complete assets, representative difficult examples and the actual viewing or analysis conditions. Keep source material when future reuse requires greater fidelity. For an AI pipeline, compare downstream performance using compressed and reference inputs rather than assuming that human visual judgments transfer directly to model behavior. Track storage, processing and delivery costs alongside quality so the decision reflects the complete workflow.
People also ask
Can a lossy result look indistinguishable from its source?
It can under particular viewing conditions, but that does not establish exact equality.
Is quantization the same as entropy coding?
No. Quantization can discard distinctions, while entropy coding can represent its input symbols losslessly.
Does the toy example prove a particular compression ratio?
No. It specifies approximation but not the complete stored format.
Check your understanding
What did both 18 and 23 reconstruct as?
Answer: Twenty.
What was the mean squared error?
Answer: 6.5 in squared input units.
Why can the decoder not recover the original from the value 20 alone?
Answer: Multiple original values were mapped to the same reconstruction, so the distinguishing information was discarded.
Related terms
- Entropy coding
- Lossless compression
- Quantization
- rate-distortion tradeoff
- perceptual coding
- reconstruction error
Learn next
Quantize a small set of values at several step sizes and calculate reconstruction errors. Then specify an actual index representation and count its storage cost. For media, compare both numerical metrics and task-relevant inspection so the selected quality measure matches the intended use.
More in MLOps and deployment
- Linear predictive coding - Linear predictive coding, or LPC, is a method used in speech analysis and coding that models a sample as a weighted combination of preceding samples.
- Log area ratio - A log area ratio, or LAR, is a transformed parameter used in speech-signal modeling and coding, commonly derived from a reflection coefficient.
- Lossless predictive audio compression - Lossless predictive audio compression refers here to LPAC, a historical audio-coding system associated with Tilman Liebchen and research at the Technical...
- Lossy data conversion - Lossy data conversion changes data from one representation to another in a way that prevents complete recovery of the original information from the...
- LZ4 (compression algorithm) - LZ4 is a lossless compression algorithm designed with an emphasis on fast compression and decompression.
- LZFSE - LZFSE is a lossless data-compression algorithm that combines Lempel - Ziv-style matching with Finite State Entropy coding.
Sources
Timothy B. Terriberry, introductory video-coding material, including quantization: https://people.xiph.org/~tterribe/pubs/lca2012/auckland/intro_to_video1.pdf The four-value calculation, route analogy and learning-website case are original educational illustrations. The source provides technical context for quantization in video coding; the entry does not generalize one codec's exact processing steps to every lossy format.
Previous: Lossless predictive audio compression Next: Lossy data conversion