If you were not premultiplying, compositing color C over B with alpha a would be done with "Ca+B(1-a)".
In premultiplied images, the C pixel is replaced with A = Ca and the math is changed to "A+B(1-a)". Substituting Ca for A will show that this is identical.
So mathematically there is no difference.
Advantages of premultiplied:
1. This is what almost all rendering and painting programs produce. Correctly producing a non-premultiplied image would require tracking a "coverage" for each pixel that is seperate from the "transparency". Premultiplied allows you to combine these values very early.
2. Premultiplied images look correct when the rgb channels are viewed. Non-premultiplied images will have noisy and bright pixels at any antialiased edges.
3. Premultipled images are more convienent for other operations such as adding to simulate a double exposure.
4. Premultiplied images allow "glow" where the color is greater than the alpha.
5. Premultiplied over is available on Windows.
Advantages of non-premultiplied:
1. Supposedly this is what .png files are supposed to be, but everybody appears to be ignoring that.
2. The compositied result is always in the range 0-1, with no clamping needed.
3. An 8-bit image can antialias any 8-bit color accurately. A premultiplied image with 1/4 alpha, if added 4 times to get an opaque image, will only have 64 possible colors in 8 bits. This advantage is negated, however, because most implementations do not preserve intermediate results of more than 8 bits, thus the non-premultiplied version produces the same result.
I believe Cairo can do non-premultiplied, by setting the source pattern and the mask to the same image, then doing a copy operation. So you actually have both anyway.
premultiplied alpha
-
blog moved
As described elsewhere, I've quit LiveJournal. If you're interested in my continuing posts, you should look at one of these (each contains feed…
-
dremel
They published a paper on Dremel, my favorite previously-unpublished tool from the Google toolchest. Greg Linden discusses it: "[...] it is capable…
-
treemaps
I finally wrote up my recent adventures in treemapping, complete with nifty clickable visualizations.
- Post a new comment
- 1 comment
- Post a new comment
- 1 comment