Ever notice that when you try to blur a really colorful image in Photoshop or Instagram, you end up with a dark, ugly line between colors? We wouldn’t see that line in real life, so why does it appear on the computer? MinutePhysics tells us why this dark boundary shows up and explains the mathematics behind color blending on computers:
If we were to look at out of focus scenes and images in real life, the colors would blend smoothly into each other. But, for some reason, when a computer tries to use transparent edges or blur an image, this really obvious dark boundary creeps in between the colors.
This is because of how we perceive brightness.
“Our eyes and brains are simply better at detecting small differences in the absolute brightness of dark scenes, and bad at detecting the same differences in bright scenes.”
Computers, however, don’t detect brightness the same way we do. They only count the number of photons hitting a photodetector, so additional photons register the same increase in brightness no matter what the surrounding scene looks like.
Basically, when a digital image is stored on a computer, the brightness value of each color at each point of the image is recorded. Zero represents zero brightness and one represents 100% brightness. With this logic, you would think that 0.5 brightness would be half as bright, right in the middle of the two colors, the perfect blend. Well, not so.
Take a look at this example. Because of our logarithmic vision, half brightness might look right, but in terms of absolute physical brightness, it has only 1/5 as many photons as white.
Back in the early days of digital imaging, in an effort to save disk space, software engineers took advantage of the fact that we are better at detecting small differences in the brightness of dark scenes. Instead of storing the brightness values in an image, a digital camera stores the square roots. Then, those numbers are squared back when the image is displayed on a computer screen.
That shortcut works fine until the image is modified.
Since blurring works by replacing each pixel with an average of the colors of nearby pixels, when you take that average can really alter the results. Most computers average the brightness values of the image file. That’s the wrong way to do it.
They’ve forgotten that the actual brightness values were square-rooted by the camera. The result is an image that is too dark.
A Simple Fix to Correct Computer Colors
In order to correctly blend the colors, computers should first square each of the brightnesses to cancel out the square-rooting done in camera, then average them, then square root it back.
The default setting in Photoshop is set to the incorrect method, but there are advanced options to change that.
So, if you find yourself grimacing at your recently edited image because the beautiful, bright colors that first appeared now have this weird brownish line running between them, you don’t have to do the math yourself to fix it. Just go into Photoshop’s advanced settings (Edit > Color Settings), and change the color blending by checking Blend RGB Colors Using Gamma.