1. An X-ray inspection apparatus that irradiates X-rays onto an object in a container to be conveyed, detects the amount of X-rays transmitted therethrough, and determines whether or not there is a contaminant in the container, the X-ray inspection apparatus comprising: an irradiation unit configured to irradiate X-rays onto the object in the container; an X-ray detection unit configured to detect the amount of X-rays that are irradiated onto the object in the container by the irradiation unit; an image formation unit configured to create an X-ray image based on the amount of X-rays detected by the X-ray detection unit; an inside area defining unit configured to define an area inside the rim of the container within an area corresponding to the object in the container in the X-ray image created by the image formation unit; an extension area defining unit configured to rotate a circle having a predetermined radius such that the circle externally touches the inside area defined by the inside area defining unit in order to define an extension area that uses the locus of the center of the circle as a boundary of the extension area; a reduction area defining unit configured to rotate a circle having a predetermined radius such that the circle internally touches the extension area defined by the extension area defining unit in order to define a reduction area that uses the locus of the center of this circle as a boundary of the reduction area; a mask area defining unit configured to define an area outside the boundary of the reduction area defined by the reduction area defining unit as a mask area; an inspection area defining unit configured to define an area inside the mask area defined by the mask area defining unit as an inspection area; and a first contaminant detection unit configured to detect a contaminant in the inspection area defined by the inspection area defining unit.