Wow, I'm astounded by how sloppy that document is. First, that they didn't
just use associated (premultiplied) alpha everywhere, despite knowing about
Porter/Duff. Second, the describe images specifically as having values in
[0,255], which is shortsighted and hopelessly parochial. Third, their notation
is counterintuitive and inconsistent. Ick!
OK, let's try to square our notation with theirs.
They say that the blending operation is:
alphao * Co = alphaa * (1-alphab) * Cs + alphaa * alphab * Blend(Cb,Cs) +
(1-alphaa)*alphab*Cb
where Cx is the un-premultiplied color of x, alphax is its alpha. And just to
be confusing, 'o' is output, and Cs is really the color of a. Awful notation,
why call the background 'b' for both alpha and color, but for the foreground
they call it a for the alpha but s for the color, and use 'B' for the blend
function. Makes me want to strangle someone.
And, if I understand correctly, alpha is as always, so alphao = alphaa +
(1-alphaa)*alphab
Anyway, in our premultiplied world, let's call the images A, B, and R, and note
the relationship that their Cx (unpremultiplied) is our X/alphaX. And note
that we can rearrange and collect terms, so for example notice that their
alphaa*Cs is our A, their alphab*Cb is our B.
So, we have, with some multiplication and change of notation:
alphaR = alphaA + (1-alphaA)*alphaB
R = (1-alphaB)*A + alphaA*alphaB*Blend(B/alphaB,A/alphaA) + (1-alpha)*B
I think you can then express their blend functions in terms of the
premultiplied versions. For example, for 'multiply' blend mode, they say that
B(Cb, Cs) = Cb x Cs. So that would give us
R = (1-alphaB)*A + alphaA*alphaB*(B/alphaB*A/alphaA) + (1-alpha)*B
R = (1-alphaB)*A + (B*A) + (1-alpha)*B
That was easy.
I'm thinking that you could run the rest of their formulas through this
substitution and come to find equivalent formulas that express these operations
in terms of premultiplied colors.
-- lg
On Jul 11, 2012, at 7:25 PM, Stefan Stavrev wrote:
> You can read about this here:
>
> http://dvcs.w3.org/hg/FXTF/rawfile/tip/compositing/index.html#blending
>
> Read part '5. Blending' until '5.1 Separable blend modes'.
> It is not that much.
>
> To summarize what is said in that part:
>
> 1. 'Compositing' is 'blending' followed by some of the
> Porter-Duff operations. By 'blending' they mean mixing colors
> and ignoring alpha values.
>
> 2. There are different functions that can be applied in the
> 'blending' step, listed in part 5.1 Separable blend modes.
> It is those that need non-premultiplied color values.
>
> I made this image for the final formula in part 5, to make
> it easier to see things:
>
> http://postimage.org/image/mknubjpdn/
> _______________________________________________
> Oiio-dev mailing list
> [email protected]
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
--
Larry Gritz
[email protected]
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org