A method for generating an energy resolved X ray image is proposed usable e.g. for mammography or CT applications. First a preferably low dose X ray beam (5) is directed through a region of interest of an object (15) such as a female breast and initial X ray intensity values are acquired. Based on these initial X ray intensity values energy threshold values of for example a photon counting energy resolving X ray detector (9) are specifically adapted to local properties and features of the object (15). With such adapted energy threshold values energy resolved main X ray intensity values are acquired for finally generating the energy resolved X ray image. The principle of such specific adapting of energy threshold values in energy resolved X ray image acquisition may be advantageously implemented in scanning X ray systems wherein first detector elements (17) of a scanned X ray detector (9) are used to acquire the initial X ray intensity values in order to then set the energy threshold values for subsequent detector elements (17) with which main X ray intensity values are acquired.