The control of line-edge or line-width roughness (LER/LWR) is a challenge, especially for future devices that are fabricated using extreme-ultraviolet (EUV) lithography. Accurate analysis of the LER/LWR plays an essential role in this challenge and requires the noise involved in scanning-electron-microscope (SEM) images to be reduced by appropriate noise filtering prior to analysis. To achieve this, we simulated the SEM images using a Monte Carlo method, and detected line edges in both experimental and theoretical images after noise filtering using new image-analysis software. The validity of this software and these simulations was confirmed by a good agreement between the experimental and theoretical results. In the case when the image pixels aligned perpendicular (crosswise) to line edges were averaged, the variance var(φ) that was additionally induced by the image noise decreased with a number N PIX,X of averaged pixels, with exceptions when N PIX,X was relatively large, whereupon the variance increased. The optimal N PIX,X to minimize var(φ ) was formulated based on a statistical mechanism of this change. LER/LWR statistics estimated using the crosswise filtering remained unaffected when N PIX,X was smaller than the aforementioned optimal value, but monotonically changed when N PIX,X was larger contrary to expectations. This change was possibly caused by an asymmetric scan-signal profile at edges. On the other hand, averaging image pixels aligned parallel (longitudinal) to line edges not only reduced var(φ ) but smoothed real LER/LWR. As a result, the nominal variance of real LWR, obtained using simple arithmetic, monotonically decreased with a number N PIX,L of averaged pixels. Artifactual oscillations were additionally observed in power spectral densities. Var(φ ) in this case decreased in inverse proportion to the square root of N PIX,L according to the statistical mechanism clarified here.