{
  "id": "lossy-data-compression",
  "title": "Lossy data compression",
  "lang": "en",
  "source_lang": "en",
  "summary": "Lossy data compression reduces the size of digital data by discarding information, trading exact reconstruction for lower storage requirements or transmission rates.",
  "category": "computer-science",
  "subcategory": "algorithms-theory",
  "type": "concept",
  "aliases": [
    "Lossy compression",
    "irreversible compression"
  ],
  "generated_at": "2026-11-03",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/lossy-data-compression/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/lossy-data-compression/",
      "json": "https://aiwiki.page/zh/lossy-data-compression.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "Lossy data compression is a form of data compression in which an encoder produces a compact representation of data and a decoder reconstructs an approximation of the original. Unlike lossless compression, it does not guarantee exact recovery of the input. It is widely used for images, audio, and video, where substantial reductions in storage and transmission requirements can be achieved while preserving acceptable perceptual quality. It is also used for numerical and scientific data when reconstruction errors can be controlled.\n\nThe defining trade-off is between the size of the compressed representation and the distortion introduced by reconstruction. What counts as acceptable distortion depends on the application: a change that is inaudible in recorded music, invisible in a photograph, or negligible in a simulation may nevertheless matter for another use of the same data."
    },
    {
      "heading": "Basic principles",
      "text": "Lossless compression exploits redundancy while retaining enough information to recover every original symbol. Lossy compression additionally exploits tolerance for approximation. Multiple possible inputs can produce the same compressed representation, so the decoder generally cannot determine which input was originally encoded.\n\nThis process is not equivalent to accidental corruption. A lossy encoder deliberately selects a representation according to a coding method and a quality objective. Transmission errors, by contrast, are unintended changes that may occur after encoding.\n\nLoss can arise through several mechanisms:\n\n- Quantization: replacing values with representatives from a smaller set.\n- Resolution reduction: retaining fewer spatial or temporal samples.\n- Component removal: discarding information judged less important to perception or a specified task.\n- Approximate modeling: representing a signal using a limited set of parameters and reconstructing it from that model.\n\nFor example, rounding a measured value from 12.347 to 12.35 discards information about its finer precision. A media codec performs more elaborate operations, but the underlying principle is similar.\n\nLossiness is a property of the complete encoding and decoding process, not necessarily every stage within it. A lossy codec commonly includes a final lossless coding stage. Conversely, a file saved in a lossless format can contain data that were already degraded by earlier lossy processing."
    },
    {
      "heading": "Rate–distortion theory",
      "text": "The theoretical foundation of lossy compression is rate–distortion theory, developed within information theory, notably through the work of Claude Shannon. It studies the minimum information rate needed to represent a source subject to an allowed level of reconstruction error.\n\nLet \\(X\\) represent an original source value and \\(\\hat{X}\\) its reconstruction. A distortion measure \\(d(X,\\hat{X})\\) assigns a cost to their difference. For a discrete memoryless source, the rate–distortion function can be expressed as\n\n\\[R(D)= \\min_{p(\\hat{x}\\mid x):\\,\\mathbb{E}[d(X,\\hat{X})]\\leq D} I(X;\\hat{X}),\\]\n\nwhere \\(D\\) is the allowed average distortion and \\(I(X;\\hat{X})\\) is the mutual information between the source and reconstruction. The expectation is taken over their joint distribution.\n\nUnder the relevant asymptotic assumptions, \\(R(D)\\) describes the lowest achievable average rate for the specified distortion limit. Practical codecs also face restrictions on block length, processing time, memory, delay, and compatibility, so they do not generally attain this theoretical bound.\n\nA common practical formulation minimizes\n\n\\[J=D+\\lambda R,\\]\n\nwhere \\(R\\) is the coded length or rate and \\(\\lambda\\) controls the relative cost of using more bits. An encoder can use this objective to select prediction modes, quantization strengths, or other coding decisions.\n\nThe theory depends critically on the chosen distortion measure. Low numerical error does not automatically imply high perceptual quality or preservation of all information relevant to a later task."
    },
    {
      "heading": "Main coding techniques",
      "text": "Quantization\n\nQuantization maps a larger set of possible values to a smaller set of reconstruction values. In a uniform scalar quantizer, adjacent reconstruction levels are equally spaced. A simplified rounding quantizer is\n\n\\[Q(x)=\\Delta\\,\\operatorname{round}\\left(\\frac{x}{\\Delta}\\right),\\]\n\nwhere \\(\\Delta\\) is the step size. For this idealized quantizer, without clipping or overload, the absolute error is at most \\(\\Delta/2\\).\n\nLarger steps generally make the output easier to compress but increase error. Nonuniform quantizers allocate precision unevenly, according to source statistics or perceptual sensitivity. Vector quantization represents groups of values jointly using entries in a codebook.\n\nQuantization in media compression is related to, but distinct in application from, neural network quantization, which reduces the precision of model parameters or intermediate computations.\n\nTransform coding\n\nTransform coding converts a block or sequence of samples into coefficients that describe different patterns or frequency components. For suitable signals, much of the significant variation is concentrated in relatively few coefficients.\n\nThe discrete cosine transform is widely used in image and video coding. Wavelet transforms provide another approach, representing information at multiple scales. An encoder quantizes the transformed coefficients, often preserving some more accurately than others.\n\nA transform is not inherently lossy: an exactly reversible transform can preserve all information. The principal loss usually arises from coefficient quantization or removal, although implementation precision may introduce additional error.\n\nPredictive coding\n\nPredictive coding estimates a value from information already available to the decoder. Rather than storing the original value directly, the encoder represents the difference between it and its prediction, called the residual.\n\nPredictions may use neighboring image samples, earlier audio samples, or previously reconstructed video frames. Video encoders often use motion-compensated prediction to account for apparent movement between frames.\n\nPrediction alone need not introduce loss. Loss typically enters when the residual or prediction parameters are quantized. Encoders generally use reconstructed reference data when forming predictions so that their internal state matches the decoder’s and avoids unintended prediction drift.\n\nPerceptual coding and subsampling\n\nPerceptual coding allocates information according to characteristics of human hearing or vision. Audio coding can exploit masking, in which one sound makes another harder to hear. Image and video coding often preserve brightness detail more accurately than color detail.\n\nChroma subsampling reduces the spatial resolution of color-difference components in a suitable color space. It can save substantial data but may visibly affect fine colored text, graphics, or sharp color boundaries. This makes it less suitable for some screen content than for natural imagery.\n\nPerceptual models are approximations. Their success depends on the signal, viewing or listening conditions, and the observer.\n\nEntropy coding\n\nAfter prediction, transformation, and quantization, an encoder typically compresses the remaining symbols losslessly using entropy coding. Methods include Huffman coding and arithmetic coding.\n\nThis stage reduces statistical redundancy in the quantized representation. It does not restore information discarded earlier."
    },
    {
      "heading": "Applications and formats",
      "text": "Images\n\nJPEG commonly uses block-based transform coding and quantization for photographs. Strong compression may produce visible block boundaries, ringing near edges, and loss of fine texture. JPEG also includes coding modes beyond its familiar lossy form.\n\nOther image coding systems use different transforms, prediction methods, or combinations of techniques. Some formats support both lossy and lossless modes, so a format name alone does not always establish whether a particular image was encoded lossily.\n\nPNG, by contrast, uses lossless compression. Converting a degraded JPEG image to PNG preserves the decoded pixels but does not recover the original image detail.\n\nAudio\n\nLossy audio formats such as MP3, AAC, and Opus reduce data rates through combinations of spectral analysis, quantization, prediction, and perceptual modeling. Speech-oriented methods may also represent aspects of speech production using compact parameters.\n\nTheir purpose differs from that of FLAC, which reconstructs the original encoded audio samples exactly. Whether listeners can distinguish a lossy reconstruction from its source depends on the codec, settings, material, playback conditions, and listener.\n\nVideo\n\nVideo codecs exploit both spatial structure within frames and temporal relationships between frames. H.264/AVC and other widely deployed video standards combine prediction, transform coding, quantization, and entropy coding.\n\nVideo compression enables streaming, video conferencing, broadcasting, and practical storage of large video collections. Its design involves trade-offs beyond visual quality: interactive communication requires low delay, while offline encoding can spend more computation searching for efficient representations.\n\nScientific and numerical data\n\nLossy compression can reduce the storage and communication costs of large simulations, sensor measurements, and multidimensional datasets. Some methods enforce absolute or relative error bounds instead of optimizing perceptual appearance.\n\nFor example, an absolute-error requirement may specify\n\n\\[|x_i-\\hat{x}_i|\\leq \\varepsilon\\]\n\nfor every reconstructed value covered by the guarantee. Such a bound does not automatically guarantee preservation of derived quantities, threshold events, correlations, or conclusions. Suitability depends on how the reconstructed data will be analyzed."
    },
    {
      "heading": "Measuring compression and quality",
      "text": "Compression efficiency is often expressed as a compression ratio,\n\n\\[C=\\frac{S_{\\text{original}}}{S_{\\text{compressed}}},\\]\n\nwhere both sizes use the same units and include clearly specified components. For media, rate may instead be reported as bits per second or bits per pixel. Ratios are meaningful only when the uncompressed representation and included overhead are identified.\n\nA common distortion measure is mean squared error:\n\n\\[\\operatorname{MSE} =\\frac{1}{N}\\sum_{i=1}^{N}(x_i-\\hat{x}_i)^2.\\]\n\nFor images and video, peak signal-to-noise ratio is often derived from MSE:\n\n\\[\\operatorname{PSNR} =10\\log_{10} \\left(\\frac{L^2}{\\operatorname{MSE}}\\right),\\]\n\nwhere \\(L\\) is the maximum reference sample value under the stated convention.\n\nThese measures are reproducible but do not fully capture perception. Two reconstructions with similar numerical error can differ substantially in visible or audible quality. Perceptual metrics and controlled subjective tests therefore complement sample-based error measures.\n\nA complete comparison considers a rate–distortion curve rather than a single quality score. Encoding speed, decoding cost, memory use, energy consumption, and delay can also determine whether a codec is practical."
    },
    {
      "heading": "Development and learned compression",
      "text": "Lossy compression developed from several related traditions, including quantization, predictive communication systems, transform coding, and statistical source coding. The spread of digital media made standardized decoders and interoperable bitstreams especially important. JPEG became a major image standard in the early 1990s, while successive audio and video standards enabled increasingly efficient distribution of multimedia.\n\nMore recent research uses machine learning to learn transforms, probability models, or reconstruction procedures. A learned image codec may use an autoencoder to map an input into a compact latent representation, quantize that representation, and reconstruct the image with a learned decoder.\n\nLearned methods can optimize combinations of coded rate, numerical distortion, and perceptual objectives. Systems incorporating generative artificial intelligence may reconstruct plausible textures that do not correspond exactly to the source. This can improve perceived realism at very low rates, but visual plausibility and source fidelity are different objectives."
    },
    {
      "heading": "Limitations and operational concerns",
      "text": "Irreversibility. Once information has been discarded, decoding cannot uniquely recover it from the compressed representation alone. Enhancement methods can estimate missing details but cannot generally establish the original values.\n\nGeneration loss. Repeated decoding, editing, and lossy re-encoding can accumulate degradation. Copying an existing compressed file without re-encoding does not itself introduce additional compression loss. Some changes can also be performed directly on compressed data without a full lossy recompression cycle.\n\nContent-dependent artifacts. Block-based coding can expose block boundaries; coarse quantization can cause banding or ringing; audio coding can introduce tonal artifacts or pre-echo. A setting that performs well for one signal may perform poorly for another.\n\nTask mismatch. Compression optimized for human perception may remove details needed by computer vision, measurement, or other automated analysis. Changes can also affect data quality in ways not captured by an average error score.\n\nInterpretation of “transparent.” A perceptually transparent encoding is one that cannot be reliably distinguished from its reference under specified test conditions. Transparency does not mean mathematical identity, universal indistinguishability, or suitability for every future use.\n\nPreservation of source information. A lossy derivative cannot provide the same exact-reconstruction guarantee as an independently retained original or losslessly encoded source. This distinction matters when later editing, verification, or reanalysis depends on information that the lossy encoding may have removed."
    }
  ],
  "links": [
    "data-compression",
    "lossless-data-compression",
    "information-theory",
    "expected-value",
    "quantization-signal-processing",
    "neural-network-quantization",
    "discrete-cosine-transform",
    "color-space",
    "huffman-coding",
    "arithmetic-coding",
    "jpeg",
    "png",
    "flac",
    "h264-avc",
    "pixel",
    "machine-learning",
    "autoencoder",
    "latent-space",
    "generative-artificial-intelligence",
    "computer-vision",
    "data-quality"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}