To easily detect the position the edge of a pattern coated with a thin film.
At the time of detecting the position of the edge of a pattern 1 having a rectangular cross section and formed on a sample which is entirely coated with a thin film F, the height variation of the surface of the thin film F from a reference plane on the surface of the film F in the direction crossing the pattern P is detected in a non-contacting state and the edge position of the pattern P1 is detected based on the inclined parts of the waveform (c) of the detected height signal. Since the edge position of the pattern P1 is detected based on the inclined parts of the waveform of the detected height signal by detecting the height variation (ruggedness) of the surface of the thin film F from the reference plane, the midpoint positions of the inclined parts of the waveform of the height signal, for example, can be detected as the edge positions of the pattern P1 even when the pattern is formed on a sample which is entirely coated with the thin film F.