The present invention allows for calibration of a scanning probe microscope under computer control. The present invention comprehends either the removal of nonlinear artifacts in the microscope output data after measurement has been taken (a off-line process), or the correction of nonlinear movements in the microscope scanner such that the scanner moves in a linear fashion during measurement (a realtime process). The realtime process may be operated in both an open-loop and a closed-loop process. The processes of the present invention uses an average cross-section of the scan in order to simplify the calculation and to improve the signal-to-noise ratio. Interpolation methods and centroid calculations are used to locate features on the scanned sample to subpixel precision. Comparison of the measured scan feature positions with the known topography of the scanned calibration specimen enable the present invention to assemble a calibrated length scale which may be used to correct individual feature positions in a full two-dimensional scan, each scan line in a two-dimensional image, or an average cross-section of the two-dimensional scan.