A grainy image, or a faint shadow of something that is not in the beam, is usually not a problem with the source, the sample, or the settings. It is a calibration problem, and it comes from a property every X-ray detector has.
Every pixel responds differently
Detector pixels are not identical. Given exactly the same radiation, each one produces a slightly different output.
Take a simplified detector with four pixels, and measure each at two energies while holding current constant. Output is reported in ADU, analog-to-digital units, the raw numbers coming out of the converter.
At 40 kV, the first pixel might read 90 while its immediate neighbor reads 100, a third reads 410, and a fourth reads 130. Push to 90 kV and those become roughly 980, 1000, 1200, and 800.
Two things stand out. The pixels disagree at any given energy, and they do not disagree by a consistent amount. The fourth pixel starts higher than the first at 40 kV and ends lower at 90 kV, so their responses are not simply offset from each other. They have different slopes.
Why that ruins the image
In an X-ray image, the pixel value is the measurement. Zero ADU means no radiation reached that pixel and reads black. The maximum means full saturation and reads white, and on a 16-bit detector that maximum is around 65,500.
Everything between those extremes is supposed to represent density variation inside the sample. That is the entire information content of the image.
If neighboring pixels report different values for identical radiation, that variation gets added on top of the real signal. The result looks grainy, or shows structured shadowing, and the actual density differences being inspected are buried underneath detector behavior. This is usually called fixed pattern noise, because unlike random noise it does not average away across exposures. It is the same pattern every time.
The linear model
Over a working range, each pixel behaves approximately linearly. Its output for a given input follows the form of a straight line:
y = ax + b
where b is the pixel’s offset and a is its gain.
If a and b are known for every pixel, the deviation can be corrected. Calibration is the process of measuring them.
Offset calibration
The first reference image is taken with the X-ray source off. In principle every pixel should read zero.
In practice, they do not. Detectors produce output with no radiation present at all, and the amount varies pixel to pixel. This image, sometimes called a dark field, measures b for every pixel, and the correction subtracts it so that no radiation reliably produces zero.
Gain calibration
The second reference image is taken with the source on at a chosen energy, and nothing in the beam. Every pixel is receiving identical radiation, so every pixel should report the same value.
They do not, and the differences measure a. Correcting for them makes the image uniformly flat, which is why this is generally called flat field correction.
The output is a matrix with an a and b value for every pixel on the detector. It looks like an image because it is one, mapping the detector’s own behavior rather than any sample.
Applied together, the two corrections take a raw, uneven, grainy frame and produce something flat, where variation in the image corresponds to variation in the sample.
Why linear is an approximation
Real pixel response is not perfectly straight. It tapers at both the low and high ends of the range, and the linear model only holds well through the middle.
That has a practical consequence. A calibration performed at one power level is valid across a range around it, but not indefinitely. Work at significantly lower or higher power than the calibration conditions, and the approximation degrades. If an inspection moves well outside the range where the machine was calibrated, calibrate again at those conditions. On a modern system that is a couple of clicks rather than a procedure.
The mistake to avoid
Both reference images must be collected with nothing on the stage. No sample, no fixture, nothing in the beam path.
If a sample is present during calibration, its attenuation gets measured as pixel behavior and folded into the a and b values. The correction then treats that sample’s shadow as the detector’s baseline, and subtracts it from every image afterward.
The result is exactly what it sounds like. A ghost of the calibration sample appears faintly in every subsequent image, in the same place, on every part inspected from then on. It is a common enough mistake to be worth stating plainly: an empty beam path is not a suggestion, it is what makes the reference images references.