This optical illusion relies on a principle called "Chromatic Adaptation".
An object may be viewed under various conditions. For example, it may be illuminated by the sunlight, the light of a fire, or a harsh electric light. In all of these situations, the visual system indicates that the object has the same color: an apple always appears red, whether viewed at night or during the day. This feature of the visual system is called chromatic adaptation.
Have you ever entered a movie theater on a sunny afternoon? The room probably appeared completely dark but as your visual system adjusted to the reduced level of light you were able to see better after a few moments.
This "adaptation mechanism" allows our eyes to recover from an oversensitivity to a particular stimuli. "Chromatic adaptation" occurs when our eyes adjust to certain color stimuli. Chromatic adaptation is one of the more easily fooled aspects of vision, and is prone to some of the most spectacular optical illusions.
Original Rainbow and Waterfall Picture