Weird Photoshop Math
Posted: November 4th, 2005 | Filed under: Tips | 3 Comments »Today I was put into a deep shock with how Photoshop calculates final color of the dot which has several semi-transparent objects on its way. Assume for a second that you have a black background and two 50% white squares on top of each other and the background. What do you think, will the resulting picture show grey square or will it be entirely white?
Yes, I also thought that it should be completely white, but I appeared to be wrong. It looked a bit contrieved to me that instead of white I got some grade of grey. “What a hell!”, I was shouting, staring at the screen. How could it be that 50%+50% gave something, but 100%? Later as my shock had worn off I realized that there’s a kind of logic behind this odd math. And here’s what I ended with…
When you paint 50% white over the 100% black you get grey (something in the middle between black and white). It’s pretty reasonable, I expect. Now that you paint another 50% of white it adds some white to pass only 50% of grey color we got after the first painting. This way, we get only 75% of white as result of the second painting. Well, it makes some sense, but is there any way to get what I was expecting right from the start? This is the question…
By the way, this kind of magic happens not only in Adobe products, but Macromedia got infected as well. I don’t know whether it’s good or not, but simple multi-curtains effects became really complext to make with this. I’ve heard from someone the saying that engineers sometimes are absolutely crazy about math, always trying to mimic the real world in the most precise way, which makes their products completely unusable for ordinary people. Ah, yes, that was about digital cameras.
The Ruby on Rails addict, industrial photographer and amateur electronic music composer. In the mean time I build great web applications, contribute to OSS and help AVAAZ to save Great Barrier Reef.
Hmm, as I was reading this I didn’t know wheather or not you were being sarcastic. The only odd math here, my friend, comes from you. In fact, 50% layered over 50% will be 50% for the same reason 50%, 50%, and 100% will be 66.6%. For a better understanding of why this is you will need to know about how computers handle colors. 100% white is represended as the RGB value (256,256,256), Black is (0,0,0), and 50% white is (128,128,128). In grayscale these values would be 256, 0, and 128 respectivly. If you think about it, would it make more sense to add the value of black (0) and white (256) to get the resulting color of blending them, or average them? Just to clear things up, the blending of layers is not the same as adding light, otherwise, with multiple layers, the result would end up being white. And, for future reference, different settings (transparency, and blending) will affect the simple averaging method.
Thanks for your comment Benjamin!
I understand the math and how computer represents colors fairly well as I have 15 year+ computer background starting with sprite animation on Z80 Spectrum in my youth. But that’s not the point.
The point is that I was trying to create a simple curtains effect with several white curtains (say 10) each passing only 10% of light, so that no curtains passes 100% of image and all 10 curtains shut pass none. My immediate reaction was to paint the white rectangle with 10% of opacity and duplicate it 9 times. As the result, with 10 curtains shut I’ve got not pure white but 35% of original image.
I agree that it’s reasonable and makes sense from the point of view of pure math and optics (and I mentioned it in the text), but actually it’s of very little help in practice as the effect as simple as mine requires calculating coefficients for each layer to produce very simple effect, that’s actually very common nowadays.
I agree with you, it’s odd me. I expected the software to help me, but it started teaching.
(just kidding)
In Grayscale:
255,255,255 @ 50% over 0,0,0 = 128,128,128
255,255,255 @ 50% over 128,128,128 = 192,192,192
50% of 128 = 64 + 128 = 192
Makes sense to me.