Mobile app version of vmapp.org
Login or Join
Karen819

: Reverse-engineer alpha channel This is something that I stumble over occasionally. I have an image that was clearly created using some form of blending / alpha channel magic, usually for things

@Karen819

Posted in: #AdobePhotoshop #Gimp

This is something that I stumble over occasionally. I have an image that was clearly created using some form of blending / alpha channel magic, usually for things like smooth edges.

For example:



There is a blend between the white arrow and the orange background, but alpha information is not included in the PNG for this. Now say I would like to transplant the arrow on top of a gradient.

It would seem that it should be possible to reverse-engineer the alpha values, given that I know both colors that presumably were the basis for the blend operation.

I think what I want to do is this: stackoverflow.com/questions/746899/how-to-calculate-an-rgb-colour-by-specifying-an-alpha-blending-amount - but in Photoshop (or maybe Gimp).

Is it possible, or am I one the wrong track entirely?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Karen819

2 Comments

Sorted by latest first Latest Oldest Best

 

@Looi7658678

For this particular image, there are (at least) two easy ways to obtain a reasonable approximation of the original alpha channel in GIMP:


Use the Color to Alpha tool to make the white parts transparent. You can then turn the alpha channel into a mask and invert (and normalize) it.
Alternatively, just extract the blue color channel and normalize it: the orange contains almost no blue, so only the white parts show up in that channel.


In both cases, you first need to convert the image from indexed color to RGB.

In principle, you could also just use Color to Alpha directly to turn the orange areas transparent, but trying to do that with your example image may give some rather surprising results. (I know it surprised me when I tried it.) The problem is that the orange and white colors in the image are not actually solid: there's a funny "plaid" texture underlying both colors, and it also looks like someone applied a sharpening filter to the image, resulting in a darkened outline around the white areas. Both of these are very subtle effects in the original image, but picking the wrong color to make transparent can hugely amplify them.

10% popularity Vote Up Vote Down


 

@Murphy569

This can be done manually by simply creating an orange layer on top of a white layer and reducing the opacity of the orange layer until it produces the same RGB value as the PNG image, but this is a pretty tedious process, and I'd only recommend that if you only have a handful of pixels you need to calculate the alpha channel for.

A better way of doing it is to open the image in Photoshop, then go to Image->Adjustments->Channel Mixer... and select the "Black & White Infrared (RGB)" preset. This will turn the image into B&W, with the orange parts black. Now copy the new B&W image and paste it into a new channel.

At this point, you would normally just load the selection from the channel to create the "V" layer. However, your image has been lossily compressed using indexed colors. So if you look closely, you'll notice that the previously orange area is actually a very dark gray with a grid pattern from the dithering, and the outer edges of the V actually look darker than the rest of the BG area.

To fix this, with the new channel active, go to Image->Adjustments->Replace Color..., click on the damaged background region, and put in the following settings:


[x] Localized Color Clusters
Fuzziness 10
Lightness -100


Now the new channel should look nice and clean, with the background area completely black and the "V" region completely white, with nice clean antialiasing. Now you can load selection from the channel and create a new fill layer with it. Then you can apply a gradient fill to the original PNG layer or create it in a new layer.

Alternatively, with really simple geometric shapes like this, you could just recreate it in Illustrator using vector shapes. This is usually my preferred method, since it makes the image more flexible.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme