The present invention relates to an X-
ray detector comprising a directly converting
semiconductor layer (60) having a plurality of pixels for converting incident
radiation into electrical measurement signals with a
band gap energy characteristic of the
semiconductor layer, wherein said incident
radiation is x-
ray radiation emitted by an x-
ray source (2) or light emitted by at least one
light source (30, 33). Further, an evaluation unit (67) is provided for calculating evaluation signals per pixel or group of pixels from first electrical measurement signals generated per pixel or group of pixels when light from said at least one
light source at a first intensity is coupled into the
semiconductor layer and second electrical measurement signals generated per pixel or group of pixels when light from said at least one
light source at a second intensity is coupled into the semiconductor layer, wherein said evaluation unit is configured to detect per pixel or group of pixels a
noise peak in said first and second electrical measurement signals and to determine offset and
gain per pixel or group of pixels from the detected
noise peaks. A detection unit (69) is provided for determining detection signals from electrical measurement signals generated when x-
ray radiation is incident onto the semiconductor layer, and a calibration unit (68) is provided for calibrating the detection unit on the basis of the evaluation signals.