This question already has an answer here:

Many are familiar with this popular illusion where a single shade of color appears to be two different shades, depending on what color surrounds it

enter image description here

The orange dots in the image are actually the same color, even though they appear to be clearly different. A detailed explanation can be found here.

Since the perception of a color is affected by what colors it is next to, I wonder, is there information out there for how to correct for this phenomenon?

What I mean is that, suppose I see a color out "in the wild", such as on a color swatch or on someone's web page. I found out what color it is-- say, Coral Pink, #F88379. Then I decide I want to use it in a color scheme. But, because of color constancy, when I place it next to my other colors, it would appear to be slightly different than it would in other contexts.

Has anyone mathematically determined how to correct for this effect? Is there a program I can use to help me do so?

marked as duplicate by Ovaryraptor, Luciano, Paolo Gibellini, Danielillo, Emilie Jul 23 '18 at 0:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Great question... unfortunately I think the answer is pretty much "No". There are way too many variables involved for there to be a catch all solution and any case-specific solution will be to involved to be worth the effort. – Cai Aug 6 '16 at 7:02

This is a color science question not a graphics design one, I've only had a brief intro for color science (one and a half semester in Uni, but thats not enough) so I am not one to ask I'll try to push you forward.

Something like this is possible to do (but not for that illusion). However, the math behind color is way more complicated than it initially seems. Unfortunately most monitors out there are unmanaged when it comes to color. So simply #F88479 is devoid of any meaning without calibrated and color managed monitors. See RGB is device dependent and that value quite literally is different in every monitor out there.

So for a webpage this is hardly worth putting more effort than visually guesstimating the color. As you are relying on the relative color adaption in human eyes. The way this adaption exactly works is hideously complex. This is why you look at the screen and adjust accordingly but do not obsess about the shades as they will be off on nearly everybody's screen.

How to calculate this is a question for color scientists. In reality you need to use some tables and work in some specialized colorspace. The more pedantic you are the more complex it gets.

Note: that any of this will not work for this particular illusion, because vision is context sensitive, the brain 'knows' (thinks it knows) physics and decides from context that the squares are the same color and does what is called "color constancy". There are some normalisation techniques that can approximate this by color normalisation. Here even pretty wild color variation is possible and your eye still reports the same thing, so it is not just colors.


It's going to be very difficult if not impossible. The first issue is, "I like this Coral Pink I see on whatever"

Well what you're looking at it on is playing a role, the temperature of the room, the surrounding, what you've looked at that day even. So by the time it goes from "I like this color" to "#F88379" its already different because your perception has already changed.

Even if you're using some tool that captures colors the reason you liked that color isn't getting captured. For example you see some graffiti on a wall and you like the Coral Pink color it uses. If you look at that graffiti at 5am vs 2pm vs 7pm it will look different in all 3. So which Coral Pink did you actually like? Okay, yes some color capture tools check ambient light. But will it check how you personally perceived it? No. So here's another example:

Say you just took 3g of hallucinogenics and were wandering around a garden. Those vibrant flowers you see aren't going to get picked up by any sensor.

Then like Joojaa said once on a display you still have the trick of monitor calibration, light in the room of every person looking at your site, even wall color. And we haven't even gotten to the issues of color blindness or poor eyesight.

Could some engineer theoretically solve this? Sure, anything can eventually be solved. But solving it in any sort of practical terms for design is a long way off that's for sure.

  • Some color matching devices have a mode that captures the ambient color, but all this is largely irrelevant for a webpage. How often have you needed to check color repriduction in a standardized colormatching room for a webpage. – joojaa Aug 6 '16 at 13:36
  • @joojaa aye but even the ones that capture ambient light that was just one example. It still won't capture how you perceived it. I agree and upvoted your answer just wanted to add that the before part is equally complicated. I'll change the example to something a color matching device can't do :P – Ryan Aug 6 '16 at 16:41

As others have answered the general answer is no, there is no obvious solution to this problem. There are way too many variables involved for there to be a catch all solution (lighting, device calibration, eyesight, context etc. some of which will be different for different people)... which means the only real solution is to "eyeball" it.

That may not sound like the best solution, but if you think about it, it really is. The whole problem is a problem of perception. If you have a design where an area of color looks wrong because of this effect, you correct it. You don't measure the surrounding areas color values and get out your calculator, you just adjust it until it looks right. If it looks too dark, brighten it up a bit. If it looks too washed out you increase the saturation a bit.

The problem is your how your brain perceives what is coming in through your eyes, so trust your eyes and your perception over any automated fix.


Yeah, the CIE CAM 2002 color model will detect such things. Basically it's a set of math to adjust the local perception of color. Yes this is clearly for color science but color science is nothing if it doesn't give numbers. Basically to "fix" this you'd need to take the amount of relative luminance and adjust it to be effectively zero. This is basically the same thing as figuring out where the shadow is and brightening it up until it's gone. If within a 2° you get the amount of local darkness too low, you increase that, if it's too high you lower it. You should end up with a kind of washed out muted shadow thing. Basically fix the white balance locally. --- But the really interesting thing is, since the original picture is how you perceive colors already the new modified image will be how you don't and it'll look wrong.

Not the answer you're looking for? Browse other questions tagged or ask your own question.