How to use pre-multiplied during image convolution to solve alpha bleed problem?

后端 未结 3 709
南方客
南方客 2021-02-02 17:40

i\'m trying to apply a box blur to an transparent image, and i\'m getting a \"dark halo\" around the edges.

Jerry Huxtable has a short mention of the problem, and a very

3条回答
  •  情书的邮戳
    2021-02-02 18:22

    Following the advice in your link, you pre-multiply before blurring and un-pre-multiply after blurring. In your example, pre-multiplying actually does nothing, since there are no semi-transparent pixels. You did the blur, then you need you un-pre-multiply by doing (assuming normalized color values from 0 to 1):

    RGB' = RGB/A  (if A is > 0)
    A' = A
    

    This will get you a non-pre-multiplied blurred final image.

提交回复
热议问题