Accurate measurement of linewidth is a critical problem in sub-100 nm semiconductor manufacturing, where required accuracy is below 1 nm. Critical dimension scanning electron microscopes (CD-SEMs) are usually used for such measurements. A cross correlation of CD-SEMs, while demonstrating a good relative trend, is often subjected to a significant absolute linewidth error. There is no proven algorithm for absolute edge detection in CD-SEMs. In this article, the authors demonstrate that edge detection depends greatly on parameters of SEM settings, such as beam diameter, and pattern properties, such as the wall angle of a pattern. When both the signal and pattern are known, an offset for a specific SEM algorithm can be found. An algorithm for automatic edge detection in CD-SEMs can be tuned for beam parameters and the type of pattern. A SEM signal was simulated using the advanced Monte Carlo software CHARIOT. Input data for the modeling were three dimensional microstructures and e-beam parameters. A known pattern was then compared to a simulated signal. Such a comparison allowed to define the edge position and calibrate a SEM so that any system- and pattern-dependent errors could be removed.