The brain (and technically, even before that, the nervous system on the way to the brain) does a huge amount of preprocessing and heuristics in order to turn the vast amount of raw data you get from your eyes into actually useful information.
*Most* of what you think you see is not literally what you see. It is a post-processed representation.
In this context, one of the big things that the brain relies on is contrast and extrapolation. It doesn’t tell you “this is color code A and that is color code B”. It sees a region that’s roughly kind of one color, sees another with a high contrast, and uses that to infer the color of the other region. (ETA: specifically, in this case, we see “red” because that is an inferred contrast color to “cyan”.)
The immediate reason it does this is that this is how brains evolved.
The detailed reason of why we might have evolved this way is what is beneficial in a natural environment. In particular, as relevant to this, a lot of the “optical illusions” that we experience are useful heuristics when dealing with natural colors in *changing light conditions* – particularly daylight vs. shadows vs. night-time. Often, shadows create areas where you can’t see all the relevant colors, but you can see contrast; and it is beneficial to be able to make good “guesses” based on that contrast.
Latest Answers