1. A method for determining a position of a first structure relative to a second structure or a part of the second structure, the method comprising: a) providing a reference image containing the first structure with a plurality of image pixels, b) providing a measurement image containing the second structure with a plurality of image pixels, wherein the measurement image is recorded with an image sensor with a plurality of sensor pixels and the image sensor has at least one known faulty sensor pixel, and the position of the at least one faulty sensor pixel is known, c) producing a modified measurement image based on the measurement image of step b), the modified measurement image comprises a masked region which corresponds to the second structure or a part of the second structure and from which a section of the measurement image corresponding to the at least one faulty pixel is excluded, the modified measurement image having a size that is different from the measurement image, wherein in the determination of the position of the first structure relative to the second structure or a part of the second structure, only the masked region makes a contribution, and forming an optimization function of a shift of the modified measurement image and the reference image relative to each other, d) determining an extreme value of the optimization function and determining an optimum value of the shift based on the extreme value of the optimization function, and e) determining the position of the first structure relative to the second structure or a part of the second structure based on the optimum shift value determined in step d).