All posts
Technical··7 min read

Reverse Alpha Blending: The Math Behind Removing AI Watermarks

How a single equation reverses exactly what Google did to stamp the Gemini sparkle, and why the result is mathematically lossless — unlike AI inpainting, which guesses.

If you have ever wondered why some watermark removers produce smeared, blurry results and others look like the original image had no watermark at all, the answer is one equation: the alpha blend. Both Google (when it stamps the sparkle) and the remover (when it lifts it) are using the same math. The difference is that the remover is solving the equation in reverse.

Forward: how Google applies the watermark

After the generative model produces the final pixels, Google composites the four-point sparkle on top using the standard alpha-compositing formula. For every pixel inside the watermark box:

watermarked = α × logo + (1 − α) × original

α is the alpha (transparency) of the logo at that pixel, ranging from 0 (fully transparent, original shines through) to 1 (fully opaque, original is hidden). logo is the RGB value of the sparkle sprite at that pixel. original is the RGB value the model produced. watermarked is what ends up in the file.

Reverse: how a remover recovers the original

Both watermarked and α are observable. logo is also known — it is a fixed sprite Google has been using unchanged across Gemini 1.5, 2.0 Flash, Imagen 3, Imagen 4, and Nano Banana. So the original pixel is uniquely determined by:

original = (watermarked − α × logo) / (1 − α)

That is it. There is no AI. There is no inpainting model. There is no generative guess. It is the algebraic inverse of the operation Google performed. The original pixel value is recovered exactly — not approximately, not "close enough", exactly.

Why this is lossless

In a lossless operation, the output differs from the source only inside the watermark zone, and the difference inside that zone is by definition the watermark itself. Outside the watermark zone, every byte of the file is identical. Inside the watermark zone, the reverse equation recovers the original bytes with full 8-bit precision.

The only catch is the math fails when α = 1, because you would divide by zero. That happens in a tiny region — the very brightest center pixel of the sparkle, where the logo is fully opaque. In practice this affects one or two pixels. An edge-diffusion step fills them in by sampling nearby recovered pixels, which is invisible on smooth backgrounds and barely noticeable on highly textured ones.

Where the alpha map comes from

The sparkle is composited at one of two fixed sizes: 48×48 (older Gemini exports) or 96×96 (Gemini 2.0 Flash and later). The alpha map — the per-pixel transparency value at every position in the logo — is the same for every Gemini export worldwide. Google does not randomize or rotate the watermark.

To detect which size is on a given image, the tool runs normalized cross-correlation (NCC) between the bundled 48×48 alpha map and the bottom-right quadrant of the image, then again with the 96×96 map. NCC is the standard template-matching metric from signal processing — it peaks at 1.0 when the watermark is exactly aligned. Whichever map scores higher is the one stamped on the image, and the peak position gives the exact corner offset.

Why AI inpainting produces smears

General-purpose watermark removers wrap a generative inpainting model around the watermark area. The model looks at the surrounding pixels and generates plausible content to fill in the gap. That works well on uniform backgrounds (sky, blank wall, single-color gradients) and produces smears on textured ones (buildings, faces, fabric).

The reason is fundamental: inpainting guesses. It uses a learned prior about what natural images look like, then samples from that prior conditioned on the surrounding pixels. The guess is statistically reasonable but rarely matches the exact original. Reverse alpha blending, by contrast, computes. The original pixels are mathematically determined by the equation; there is no degree of freedom left for the algorithm to choose.

When the equation fails

Three scenarios break the approach. First, if the file has been re-compressed (heavy JPEG re-encoding, screenshot, social media re-upload), the watermarked pixel values are no longer the values Google wrote. The recovery becomes approximate. Second, if Google ever changes the sparkle (new logo design, new position, new size), the bundled alpha maps are out of date and the detector fails — a problem we mitigate by re-running detection whenever Google updates. Third, if the image contains a fully transparent region in the watermark zone (rare in practice), the math still works but the edge-diffusion step has nothing to sample from.

Implementation in the browser

The whole pipeline runs in JavaScript in your browser. NCC is computed against the RGBA pixel buffer pulled from a Canvas. The reverse blend is a single for loop over the watermark box. Edge diffusion is a small Gaussian kernel applied to the recovered pixels. Total time per image: well under a second for a 4K export.

For video, the pipeline runs the same way on every frame, demuxed and decoded with the WebCodecs API, re-encoded, and muxed back into an MP4 with the original audio track preserved bit-for-bit. Frame rate, resolution, and bitrate are unchanged.

What about SynthID?

SynthID is a different beast — an invisible signal embedded into every pixel of the image, not a corner logo. There is no alpha map to reverse; the operation is fundamentally irreversible without lossy regeneration. This tool removes only the visible sparkle. Read our SynthID explainer for the full picture.

See it in action

The reverse alpha-blend pipeline is what powers the tool. Upload a Gemini image and watch the math run.

Open the tool