It is described a gain calibration for a two-dimensional X-ray detector (315), in which the gain coefficients for scattered radiation (307b) and direct radiation (307a) are measured or estimated separately. A weighed average may be applied on the appropriate scatter fraction. The scatter fraction depending gain calibration method produces less ring artifacts in X-ray images as compared to known gain calibration methods, which do not take into account the fraction of scattered radiation reaching the X-ray detector (315).