Mobile app version of vmapp.org
Login or Join
Murray976

: How to create an alpha mask from an image? I want to create an image which I can use as a texture in OpenGL. The image is a jpg that comes in red. In my OpenGL I want to be able to

@Murray976

Posted in: #AdobePhotoshop #Mask #Png #Transparency

I want to create an image which I can use as a texture in OpenGL. The image is a jpg that comes in red.

In my OpenGL I want to be able to change the red color to any other color the user selects, for this i thought the best solution was just to discard the rgb channels from the original image and only use the alpha channel of the texture, and the rgb the user selected.

The problem is that even thought I have tried for quite some time, this only seems to work for the edges of the image, not the inner part of the image.

This is the example image:



As it can be seen, there are parts that are in pure red, others that are mixed with white, and complete white parts. I need to have "a png alpha image" in where white represents transparent. This means that complete red will have an alpha of 1.0, complete white an alpha of 0.0 and anything in between an alpha between 0.0-1.0.

In OpenGL I have access to the r,g,b,a channels of the texture. So if anyone has another solution that doesn't use alpha that would help too.

Thanks

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Murray976

1 Comments

Sorted by latest first Latest Oldest Best

 

@Lee3735518

I guess you need something like this:





Where deepest red is 100% black. It is not hard to do. You can experiment a bit more with it by:


Desaturate your image to grayscale
Open Levels and tune it up as you need.


I also have done it as PNG with transparency dl.dropboxusercontent.com/u/1007168/Untitled-1.png Please check if this is what you need.

To do it as PNG with transparency and ready for recolor:


Select your layer with image and copy to clipboard. Then create a new mask:

Paste your image from clipboard to the mask:

Turn off the mask and back to usual RGB channels:

Hold Ctrl (Cmd) key and click over little thumb of your mask at Channels palette:

Now you can delete the white. Press DEL:



To check how it works you can try to recolor it by yourself:


Switch on "Hold transparent pixel":

Fill it up with any color:



Here is the sample how it looks recolored in different colors:

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme