1. A method for determining the position of a first structure relative to a second structure or a part thereof, 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, c) producing a masked measurement image with a masked region which corresponds to the second structure or part thereof and from which the section of the measurement image corresponding to the at least one faulty pixel is excluded, wherein in the determination of the relative position only the masked region makes a contribution, and forming an optimization function of the shift of the masked measurement image and the reference image relative to each other, d) determining the extreme value of the optimization function and determining the 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 thereof based on the optimum shift value determined in step d).