Mobile app version of vmapp.org
Login or Join
Karen819

: How can I de-mix/de-blend two colors? I'm "reverse engineering" a graphics package based on rasterized images to recreate the graphics package as layered components. I have a situation whereby

@Karen819

Posted in: #AdobePhotoshop #BlendModes #ColorConversion #ColorReproduction

I'm "reverse engineering" a graphics package based on rasterized images to recreate the graphics package as layered components.

I have a situation whereby I have two elements, each with some level of alpha transparency, that were layered on top of each other. I know the color of the background element as well as the resultant color. How can I find the original color and transparency of the foreground element?

Better yet, how can I separate these two elements such that when I rebuild them on top of each other, they look like the original?

Is there a way to do this within Adobe Photoshop or perhaps an online utility?

Background Purple: rgba(81,16,110,.88)
Resultant Purple: rgba(48,15,65,.95)
Foreground Purple: ????

Here is a sample image for reference:


UPDATE
I understand the basic math behind calculating this manually, as detailed here, but this doesn't really work well for more complex alpha de-compositing. Like in this example:


Is there a way to subtract an rgba value from all pixels in an image?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Karen819

1 Comments

Sorted by latest first Latest Oldest Best

 

@Cugini998

One can easily reverse engineer this image. the transparency grid of a screen capture makes it slightly harder for me to verify but still not a big problem you'll just have to calculate yourself. Alpha blending is:

total_Alpha = top_alpha + bottom_alpha(1-top_alpha)


so in this case we get:

0.95 = x + .88 (1-x) =>
0.95 = x + .88 - .88x =>
0.95-0.88 = 0.12x =>
x = 0.07/0.12 ≈ .58


Now this is correct if you measured correctly but i have some doubts about that but since you show it on a transparency grid i wont bother to verify my calculation.

total_RGB = (top_rgb*top_alpha + bottom_rgb*bottom_alpha(1-top_alpha))/total_alpha


Where its convenient to calculate with float colors so colorshannel/255 in your case. I will leave this calculation for you to do.

Calculations

Photoshop can do calculations on individual channels. Its just a bit messy for several reasons. First, Photoshop can not handle negative values. So you would need to offset the values appropriately, this work fine if you turn floating point precision on. Without floating points otherwise values above max in addition to values under zero will clip, take care. Second the GUI is messy and you can not just type in your operations.

Basic channel calculations are available in Image → Calculations, this allows you to do calculations on one channel at a time. Calculations allows you to do all the basic mathematical operations, add, subtract, multiply and divide for all pixels in one go for one channel. With the limitation in mind this should be doable.



Image 1: Calcualtions.

Tip: Record your calculations into an action. If you screw up then it's easy to backtrack where you left off.

Second layer modes Multiply, Add, subtract and Divide do exist. They work pretty well on color channels if you do not have an alpha in the images. Again no negative values available so be sure to calculate so your values do not clip.

examples of me doing almost what you ask can be found in following post:


Can image transparency be calculated automatically from multiple non-transparent samples?


Note: All this said, I would still suggest you use something like numpy, matlab, Mathematica even imageMagik for the job it is MUCH faster to develop and use. Due to this I'm not going to do the calculations for you.

Note 2: Some cases can not be solved as theres no way to separate alpha contribution and color. Most notably when the sum of the layers alpha is 100% than you will not be bale to deduce the alpha value. And thus you can not know what the color is without guessing.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme