A method generates a 3D image data set of a volume to be examined, in which at least part of a foreign object is positioned. A set of 2D projection images is recorded, the image regions which present the foreign object are detected in at least two 2D projection images of the set. The image regions which present the foreign object are segmented in the at least two 2D projection images. A marking assigned to the segmented image regions is incorporated in the at least two 2D projection images. The 2D projection images, including the at least two 2D projection images having the incorporated markings, are used for the reconstruction of a 3D image data set containing the marking.