JPEG Mosquito Noise in High-Contrast Text

This article examines how mosquito noise manifests when high-contrast text is compressed using the JPEG format. It breaks down the visual characteristics of this common compression artifact, explores the mathematical and technical mechanics behind the Discrete Cosine Transform (DCT) that cause it, and outlines why sharp text boundaries are uniquely susceptible to visual degradation.

What Mosquito Noise Looks Like

Mosquito noise is a high-frequency ringing artifact that appears as a hazy, buzzing cluster of stray pixels or faint dots surrounding sharp edges. In high-contrast text—such as black typography set against a pure white background—it manifests as a dirty, smudged halo tracing the contours of the letterforms.

Rather than appearing as solid blocks, the distortion looks like a swarm of minute, translucent specks hovering around the strokes, counters, and serifs of the characters. At smaller font sizes, this noise blends into the negative space, degrading edge definition, blurring character terminals, and making the text look out of focus or poorly rendered.

The Mechanism Behind the Artifact

The root cause of mosquito noise lies in the lossy compression pipeline used by JPEG, specifically the Discrete Cosine Transform (DCT) and subsequent quantization:

  1. 8x8 Block Division: JPEG partitions an image into 8x8 pixel blocks and converts spatial pixel data into frequency domain data via DCT.
  2. High-Frequency Representation: Sharp transitions—such as the sudden shift from a dark pixel inside a letter to a bright background pixel—are represented by very high spatial frequencies. In mathematical terms, representing an abrupt step function requires a broad sum of high-frequency cosine waves.
  3. Aggressive Quantization: Because the human visual system is less sensitive to fine spatial details in natural images, JPEG compression algorithms discard or heavily round down (quantize) high-frequency coefficients to save file space.
  4. The Gibbs Phenomenon: When the image is decompressed using the Inverse Discrete Cosine Transform (IDCT), the missing high-frequency data prevents the algorithm from reconstructing the sharp edge cleanly. The truncated frequencies produce mathematical ripples—an effect known as the Gibbs phenomenon.

In the spatial domain, these ripples manifest across the 8x8 block as oscillating color or luminance errors, appearing visually as the speckled "mosquito" noise hugging the text boundary.

Why High-Contrast Text Suffers Most

Natural photographs contain gradual gradients, textures, and continuous tones that easily mask minor reconstruction oscillations. High-contrast text, by contrast, contains extreme luminance deltas within single-pixel spans and large areas of flat color.

Without complex natural textures to hide the reconstructed ripples, the oscillations sit starkly exposed on the uniform background. Furthermore, because letter boundaries rarely align perfectly with JPEG's rigid 8x8 block grid, the ringing artifacts frequently spill across adjacent blocks, amplifying the perceived messiness.

Preventing Mosquito Noise in Text

Because JPEG was engineered specifically for continuous-tone photographic imagery, it is inherently ill-suited for text and line art. To prevent mosquito noise: