An apparatus for correcting an X-ray detector signal d, comprising: - an input interface; - a signal processing unit; and - a signal correction unit; wherein the input interface is configured to receive a detector signal d representing X-ray radiation detected by an X-ray detector, wherein the detector is configured such that the detector signal comprises one or more pulses that relate to detected X-ray quanta and/or X-ray photons; wherein the apparatus is configured to determine a basis signal b on the basis of a difference between the detector signal and a correction signal c and to periodically or randomly provide a sampling pulse P s, wherein the basis signal can be regarded as a corrected detector signal and is calculated as the correction signal subtracted from the detector signal or is calculated as the correction signal added to the detector signal; wherein the signal processing unit is configured to process the basis signal to provide a process signal p, the signal correction unit iteratively determining a new or updated correction signal or determining that the correction signal is to remain the same with every sampling pulse; wherein the signal correction unit is configured iteratively to (i) sample a first process value V 1 of the process signal at a first sampling period T s1 subsequent to the sampling pulse, (ii) observe the process signal during the first sampling period and a first validation period T v1 subsequent to the first sampling period, and detect a first process signal pulse U 1 at the process signal in the first sampling period and/or the first validation period, wherein the signal correction unit is configured to compare the value of the process signal with an upper threshold value p th,max and/or a lower threshold value p th,min, wherein the upper threshold value is larger than a baseline value p base of the basis signal and the lower threshold value is smaller than the baseline value to determine if the first process signal pulse has occurred if the value of the process signal exceeds the upper threshold value or the lower threshold value, wherein the baseline value relates to a value of the process signal in absence of X-ray impinging at the X-ray detector and/or any leakage from the X-ray detector; and (iii) provide the correction signal on the basis of the first process value V 1 subsequent to the first validation period, if the first process signal pulse has not been detected and not provide the correction signal or keep the correction signal at the same value if the first process signal pulse has been detected. - an input interface; - a signal processing unit; and - a signal correction unit; (i) sample a first process value V 1 of the process signal at a first sampling period T s1 subsequent to the sampling pulse, (ii) observe the process signal during the first sampling period and a first validation period T v1 subsequent to the first sampling period, and detect a first process signal pulse U 1 at the process signal in the first sampling period and/or the first validation period, wherein the signal correction unit is configured to compare the value of the process signal with an upper threshold value p th,max and/or a lower threshold value p th,min, wherein the upper threshold value is larger than a baseline value p base of the basis signal and the lower threshold value is smaller than the baseline value to determine if the first process signal pulse has occurred if the value of the process signal exceeds the upper threshold value or the lower threshold value, wherein the baseline value relates to a value of the process signal in absence of X-ray impinging at the X-ray detector and/or any leakage from the X-ray detector; and (iii) provide the correction signal on the basis of the first process value V 1 subsequent to the first validation period, if the first process signal pulse has not been detected and not provide the correction signal or keep the correction signal at the same value if the first process signal pulse has been detected.