An x-ray imaging system includes an x-ray source and detector. The detector is a photon counting x-ray detector, enabling detection of photon-counting events. The system acquires at least one phase contrast image based on photon-counting events. The detector includes x-ray detector sub-modules, also referred to as wafers, each including detector elements. The sub-modules are oriented in edge-on geometry with their edge directed towards the x-ray source, assuming the x-rays enter through the edge. Each sub-module or wafer has a thickness with two opposite sides of different potentials to enable charge drift towards the side, where the detector elements/pixels, are arranged. The system estimates charge diffusion from a Compton interaction or an interaction through photoeffect related to an incident x-ray photon in a sub-module or wafer of the x-ray detector, and estimates a point of interaction of the x-ray photon sub-module based on the determined estimate of charge diffusion.