X-ray images are created when X-rays from a source penetrate an object and then expose a film. The difference in how different materials absorb the X-rays in the beam produces the contrast that generates the detail of the image.
For a typical medical diagnostic image, the X-ray interaction with matter is primarily through the Photoelectric effect and Compton scattering. The strength of these two mechanisms depends upon the energy of the X-ray photons, the atomic number of the material as well as the density of the material.
This simulation provides a qualitative exploration of the difference of how X-rays interact with varying material properties and how this difference can produce contrast in the x-ray image.