1. A device for generating an energy-resolved X-ray image comprising a multiplicity of pixels, wherein the device comprises: an X-ray source; an X-ray detector; an adapting means; and a control and evaluation unit; wherein the X-ray source is configured to direct an X-ray beam through a region of interest of an object; wherein the X-ray detector is configured to acquire initial X-ray intensity values of X-rays transmitted through the region of interest for each of the pixels; wherein the adapting means are configured to adapt an energy threshold value for each pixel in dependence of the acquired X-ray intensity values for each of the pixels; and wherein the X-ray source is further configured to direct an X-ray beam having an X-ray spectrum through the region of interest of the object; wherein the X-ray detector is further configured to acquire first main X-ray intensity values of X-rays transmitted through the region of interest within a first partial X-ray spectrum range at enemies below the adapted energy threshold value and to acquire second main X-ray intensity values of X-rays transmitted through the region of interest within a second partial X-ray spectrum range at energies above the adapted energy threshold value for each of the pixels, respectively; and wherein the control and evaluation unit is configured to generate the energy-resolved X-ray image based on the first and second main x-ray intensity values for each of the pixels.