Page 1 of 1

[SOLVED] Custom logic for alpha blending

Posted: 2013-01-23T09:43:42-07:00
by comper
Hi! I'm working with a number of PNG images which have a 0% alpha background. However, some parts of the image have other alpha levels. I want to create a new image which ignores the 0% alpha, but combines the other alpha levels with an RGB value of my choosing. The idea is that I can remove any colour with alpha that "touches" the background of the image so that it's a pure colour of one form or another. Is there any tool within IM that allow this or would this require some custom coding ?

Thanks!

Re: Custom logic for alpha blending

Posted: 2013-01-23T10:50:13-07:00
by fmw42
Not sure what you really want, but just copy the alpha channel and composite onto another image of the background you want.

Please clarify what you want under the 0% alpha and what you want under the other alpha values.

Re: Custom logic for alpha blending

Posted: 2013-01-23T16:25:02-07:00
by snibgo

[SOLVED] Re: Custom logic for alpha blending

Posted: 2013-01-24T03:24:59-07:00
by comper
Thanks, snibgo! That's precisely the sort of thing I was looking at!

Thanks again :)

c

Re: [SOLVED] Custom logic for alpha blending

Posted: 2013-01-28T17:24:19-07:00
by anthony
Ignoring the alpha (fully transparent) areas of an image is typically done by multiplying all colors by the alpha channel, before blending. Afterwards the colors are divided by not only the blend amounts (typically number of pixels involved) but also the alpha values (number of partial pixels blended together).

The result is that semi-transparent colors are handled properly, but all resulting fully transparent pixels will become full-transparent black.

Almost all IM operators do this. This includes... Resize, Distorts, Scales, Compositions, Convolution, Morphology, Blur, and operations involving 'fuzz' factors, (color replacement, animation frame optimization)

Operations which do not handle transparency include: auto-level, normalize, FX (you have to DIY it), and if the channel 'Sync' flag is disabled: mathematical compositions, and convolution.

NOTE Comparison (except for a 'fuzz metric') does not do anything special with regards to alpha channel.
And even with 'fuzz' metric, it only equates transparency as equivalent, It does not ignore comparisons on color to transparent, which would be useful for 'overly match' or 'masked sub-image search'.