The invention relates to an x-ray device (1) for imaging an object (41). A radiation detector (3) of the x-ray device includes detector elements (21) for detecting radiation, each detector element (21) comprising an adjustable sensitive volume, where an x-ray photon entering the sensitive volume produces an electric signal used for generating the image data. Further, the device comprises a control unit (9) configured to control the sensitive volume of at least one of the detector elements (21) in accordance with a geometric structure of the object (41) to be imaged in order to reduce a pile-up effect in the detector element. Moreover, the invention relates to a method for operating the device (1) and to a computer program for carrying out the method.