Unpremultiplication converts premultiplied alpha colour samples back to straight alpha by dividing out a nonzero alpha channel. If is the stored premultiplied colour triple, thenThe alpha value is retained. PNG's encoder guidance specifies this division when converting associated input samples to its unassociated representation, followed by scaling to the output sample range and rounding.[ref]
For an original exact-arithmetic example in Linear-light RGB, let and . The recovered colour is . Multiplying that triple by the retained alpha restores . Dividing the alpha itself would instead destroy the transparency information.
At , all exact premultiplied colour triples arising from finite equal zero. The original colour cannot be recovered from that result: many inputs mapped to the same stored value. PNG's conversion guidance chooses black for this case; that is a defined output convention, not recovered hidden colour.[ref]
Finite precision adds another limitation. Suppose , , and the premultiplied channels are rounded to eight-bit normalized codes. Their integer codes become , while the alpha code is one. Unpremultiplication then yields normalized straight colour , far from the original triple. For fixed exact alpha, a stored component error becomes after division. Near-zero alpha can therefore magnify rounding error even when the conversion formula is correct.
Articles by others on the same topic
There are currently no matching articles.