What's the Secret?
The answer is a technique called blue-screening. Using this technique, actors enact their scenes against a solid background of bright blue or green (in that case, termed green-screening) rather than on a regular movie set, usually with the aid of visual cues to help them keep their location and actions straight.
How Does Blue-Screening Work?
What the bright, blank background does is create a clear field around the actor, allowing for clean outlines of his or her body and motions. When the film of the actor against the blue screen is taken into a digital editing medium, the blue or green background can be edited out using a transparency filter that causes all things in each frame in that particular shade of blue or green to appear invisible. (For this reason, actors cant wear any clothing in that shade, or even wear much white that might reflect the background shade, because the filter will catch it and create a hole in the actors clothing or body.)
But How Does That Create the Finished Scene?
With the blue screen edited out, nothing is left but the actor(s) seemingly floating in empty space; using layered compositing, they can then be laid over the background intended for the scene. Lighting effects to match the scene can even be added, so that they seem to blend in better rather than being wholly displaced because they were filmed in a different lighting environment.
How Else is Blue-Screening Used?
This technique also works when creating the illusions of rotating heads, severed body parts moving about, and similar effects. This time, its the actor wearing a blue suit, save for on the body parts to be filmed. For instance, in the film The Addams Family, the animated hand would have been attached to an actor covered entirely in a blue suit, save for the hand itself.
For a head rotating while still attached to a body, the blue screening would probably be done in two parts; first, the actor would be shot against the backdrop with his or her head covered in a blue mask; then, another shoot would take place with the actor reproducing his or her motions against a blue screen, with their body obscured by a blue suit while they performed the appropriate motions to make it seem as though their head was spinning during the scene shot previously. The two would be layered together, with the position of the head adjusted to match the motions of the body in the main scene, and a convincing illusion would be born.
And there you have it: blue-screening.

