A method of performing scatter correction on an X-ray image comprises obtaining 200 an input image based on a source X-ray image of a sample acquired using an X-ray detector, and determining 202 a model of the sample based on the input image. The model is then evaluated 204 by computing 206, based on the model, simulated X-ray image data and evaluating 201 the modeled image data against the input image to determine 212 whether a convergence criterion is fulfilled. An updated model of the sample is generated 214 if the convergence criterion is not fulfilled. The model evaluating step is repeated based on one or more successive improved models until the convergence criterion is fulfilled in a final iteration, and scatter correction is then performed on the source X-ray image using simulated image data computed during the final iteration. Also claimed is a method in which composition information of a sample is determined using a similar iterative model adjustment process. Also claimed is a method of configuring an x-ray image processing system based on comparisons of simulated x-ray images and real x-ray images.