Reverse Alpha Blending Explained

👨‍💻
Abhin Krishna
2 min read

If you have ever layered a semi-transparent image over another in Photoshop, you have already used Alpha Blending. This is exactly the technique Google Gemini uses to stamp its visible sparkle logo onto AI generated images. But here is the cool part: because this blending is just a fixed mathematical equation, we can run the math backwards to perfectly restore the original pixels hidden underneath.

The Compositing Equation

When Gemini applies the watermark, it calculates the final color of every single pixel in that bottom right corner using a standard formula:

watermarked_pixel = (alpha * logo_color) + (1 - alpha) * original_pixel

In this equation, alpha represents the transparency of the watermark mask (ranging from 0 to 1), and logo_color is pure white, which has a pixel value of 255.

The Reversal

Since we know the logo color is always pure white, and we can map out the exact alpha transparency levels from a reference watermark, we essentially have two out of the three variables needed. A quick bit of algebra allows us to rearrange the formula and solve directly for the original_pixel:

original_pixel = (watermarked_pixel - alpha * 255) / (1 - alpha)

By applying this reversed formula to every pixel inside the watermark bounding box, the logo mathematically dissolves. It leaves behind the exact, original generated pixel colors. There is no AI guessing, no messy blurring, and no generative inpainting. It is just pure, unadulterated mathematics doing the heavy lifting.

Related Articles