Autofocus system for an optical measuring or microscopy device, in which a distance between an optical imaging unit of the optical measuring or microscopy device, in particular a lens, and a specimen slide is adjustable for focus adjustment, wherein the autofocus system has an autofocus light source and an intensity detector that is spatially resolving in at least one direction, in particular a line detector, wherein the autofocus light source generates an autofocus light beam that is coupled into the beam path of the optical measuring or microscopy device in such a way that the autofocus light beam is incident through the optical imaging unit onto the specimen slide and generates a light spot there, and wherein the intensity detector is arranged in such a way that a light portion of the autofocus light beam, which is reflected by the specimen slide and coupled out of the beam path of the optical measuring or microscopy device in the return direction, is incident onto the intensity detector and generates a reflected light pattern there, and wherein the autofocus system has an evaluation unit connected to the intensity detector, which generates from a displacement of the reflected light pattern compared to a reference pattern determined by means of a reference measurement an autofocus value, which serves as a control signal for focus adjustment, characterized in that the evaluation unit is designed to determine as an autofocus value a calculated displacement between an intensity profile detected by the intensity detector based on the reflected light pattern and a reference intensity profile detected as part of the reference measurement, in which a deviation measure of the two intensity profiles from each other summed over at least one area of the intensity detector is minimal. wherein the autofocus system has an autofocus light source and an intensity detector that is spatially resolving in at least one direction, in particular a line detector, wherein the autofocus light source generates an autofocus light beam that is coupled into the beam path of the optical measuring or microscopy device in such a way that the autofocus light beam is incident through the optical imaging unit onto the specimen slide and generates a light spot there, and wherein the intensity detector is arranged in such a way that a light portion of the autofocus light beam, which is reflected by the specimen slide and coupled out of the beam path of the optical measuring or microscopy device in the return direction, is incident onto the intensity detector and generates a reflected light pattern there, and wherein the autofocus system has an evaluation unit connected to the intensity detector, which generates from a displacement of the reflected light pattern compared to a reference pattern determined by means of a reference measurement an autofocus value, which serves as a control signal for focus adjustment, characterized in that the evaluation unit is designed to determine as an autofocus value a calculated displacement between an intensity profile detected by the intensity detector based on the reflected light pattern and a reference intensity profile detected as part of the reference measurement, in which a deviation measure of the two intensity profiles from each other summed over at least one area of the intensity detector is minimal.