In this illusion, created by Edward Adelson at MIT, squares A and B are the same shade of gray.
This illusion occurs because our brain does not directly perceive the true colors and brightness of objects in the world, but instead compares the color and brightness of a given item with others in its vicinity.
For instance, the same gray square will look lighter when surrounded by black than when it is surrounded by white. Another example: when you read printed text on a page under indoor lighting, the amount of light reflected by the white space on the page is lower than the amount of light that would be reflected by the black letters in direct sunlight.
Your brain doesn’t really care about actual light levels, though, and instead interprets the letters as black because they remain darker than the rest of the page, no matter the lighting conditions. In other words, every newspaper is also a visual illusion!