Taken from a website
The ghostly birds you see here are called afterimages. An
afterimage is an image that stays with you even after you have
stopped looking at an object. The back of your eye is lined with
light sensitive cells, called cones, which are sensitive to certain
colors of light. When you stare at the red bird, your red-sensitive
cones adapt to the light and lose their sensitivity. When you shift
your gaze to the white background of the bird cage, you see white
(minus red) where the red-sensitive cells have become adapted.
White light minus red light is blue-green light. That's why the
afterimage you see is blue-green and in the shape of a parrot. The
same thing happens when you stare at the green bird, but this time
it's the green-sensitive cones that adapt. White minus green light
is magenta light, so you see the afterimage as a magenta
cardinal.
My understanding from physics: All the colours when moving fast
enough will produce a white colour. So, when white minus red, you
are left with blue and green (primary colours). When you add green
and blue, you get cyan (secondary colour). The same for the green
bird. When white minus green, left with red and blue. When red
light is mixed with blue light, you get mangeta.