PROBLEM TO BE SOLVED: To provide an X-ray imaging apparatus capable of automatically selecting one X-ray image with the best focus in a prescribed region.SOLUTION: The X-ray imaging apparatus includes: an X-ray irradiation part which irradiates a subject with an X-ray an X-ray detection part which detects the X-ray having passed through the subject (test subject) and an image processing part which generates the X-ray image (panoramic image) on the basis of the detection result of the X-ray detection part. The image processing part generates plural X-ray images including a tooth row of the subject in an imaging region, calculates a first-order differential image by differentiating only in the horizontal direction of the panoramic image a prescribed region including at least a part of the region where the tooth row is imaged with respect to each of the X-ray images including the tooth row of the subject in the imaging region, calculates a second-order differential image by differentiating the first-order differential image only in the horizontal direction of the panoramic image, and selects one X-ray image with the maximum average of the pixel values of the second-order differential image among all the X-ray images including the tooth row in the imaging region.SELECTED DRAWING: Figure 6