1. An X-ray imaging apparatus comprising: an X-ray source configured to irradiate X-rays to a subject; an X-ray detector configured to detect X-rays penetrating the subject, and generate a frame image comprising pieces of X-ray data for energy bands; an image divider configured to divide the frame image into images of substances, using the pieces of the X-ray data; and an image generator configured to restore the frame image by performing motion compensation on an image of a first substance of the frame image, among the images of the substances of the frame image, and an image of the first substance of a previous frame image.