Surface roughness is an important quality characteristic in grinding. Measurement of surface roughness by means of mechanical stylus is widely done in metrology. In this paper, a new machine vision system has been utilized to quantify the surface roughness of machined surfaces (ground and milled). Compared with other measurement methods, it is accurate, quick and credible. This system is mounted on the grinding machine and automates the measurement process by using computer control to automatically position the CCD and capture digital images of machined surfaces between grinding cycles. It was proposed that the proportional formula was used in calibrating this system, and calibration precision meets application requirement. Not only the statistic character of gray image but also which of edge image were calculated out. These characters include the mean value of pixels (Mean), standard deviation (σ), maximal value (Max) and minimal value (Min), the number of pixels on the examine line(Count), etc. It was found out that the standard deviation value σ of the gray image could express the surface roughness most. The correlation between σ and Ra is established by interpolating σ value used Lagrange interpolation law, and the σ value is converted into Ra value through the calculation procedure finally.