Modeling secondary electron images for linewidth measurement by critical dimension scanning electron microscopy