A method performed by a processor for enabling estimation of an initial point of interaction of an x-ray photon in a photon-counting x-ray detector , which is based on a number of x-ray detector sub-modules or wafers, each of which comprises detector elements distributed over the detector sub-module or wafer in two directions including the direction of the incoming x-rays, wherein the x-ray detector sub-modules are oriented in edge-on geometry with the edge directed towards an x-ray source, assuming the x-rays enter through the edge, wherein each detector 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, also referred to as pixels, are arranged, and wherein the method comprises: - determining (S1) an estimate of charge diffusion originating from a Compton interaction or an interaction through photoeffect related to the x-ray photon in a detector sub-module or wafer of the x-ray detector, wherein the estimate of charge diffusion is determined by measuring or estimating the shape and/or width of the charge diffusion based on induced current caused by moving electron-hole pairs originating from the Compton interaction or interaction through photoeffect, as detected by detector elements distributed over the x-ray detector sub-module or wafer in the two directions including the direction of the incoming x-rays, and - estimating (S2) the initial point of interaction along the thickness of the detector sub-module based on the determined estimate of the shape and/or width of charge diffusion. wherein each detector 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, also referred to as pixels, are arranged, and wherein the method comprises: - determining (S1) an estimate of charge diffusion originating from a Compton interaction or an interaction through photoeffect related to the x-ray photon in a detector sub-module or wafer of the x-ray detector, wherein the estimate of charge diffusion is determined by measuring or estimating the shape and/or width of the charge diffusion based on induced current caused by moving electron-hole pairs originating from the Compton interaction or interaction through photoeffect, as detected by detector elements distributed over the x-ray detector sub-module or wafer in the two directions including the direction of the incoming x-rays, and - estimating (S2) the initial point of interaction along the thickness of the detector sub-module based on the determined estimate of the shape and/or width of charge diffusion. - determining (S1) an estimate of charge diffusion originating from a Compton interaction or an interaction through photoeffect related to the x-ray photon in a detector sub-module or wafer of the x-ray detector, wherein the estimate of charge diffusion is determined by measuring or estimating the shape and/or width of the charge diffusion based on induced current caused by moving electron-hole pairs originating from the Compton interaction or interaction through photoeffect, as detected by detector elements distributed over the x-ray detector sub-module or wafer in the two directions including the direction of the incoming x-rays, and - estimating (S2) the initial point of interaction along the thickness of the detector sub-module based on the determined estimate of the shape and/or width of charge diffusion. <EOS>