The roughness and uncertainty are important parameters of surface morphology. The least square middle line method is often used to estimate the roughness and its uncertainty. However, the roughness and its uncertainty obtained by the least square middle line method are inaccurate. This paper proposes a method to calculate exactly the roughness and its uncertainty by piecewise fitting the smooth B-spline filter assessment middle lines. A B-spline smoothing filter is selected to determine the assessment middle line of roughness. The B-spline filter can not only give the accurate roughness, but also obtain the smooth assessment middle line. The model of roughness uncertainty is proposed by piecewise fitting B-spline filter middle lines as the quadratic curves. The S-shaped test part is used to verify the model of roughness uncertainty.