This paper deals with an application to automatic compensation of grinding wheel wear by an image processing based real-time measurement method in dry curve grinding. An online image measurement system was schemed out and its principle was introduced in detail. Real time image of workpiece and grinding wheel is grabbed by CCD camera during grinding process. For the purpose of increasing the measurement precision, a new sub-pixel level accuracy edge detection approach combining Zernike moments operator with Sobel operator is proposed for locating the edge of the machined workpiece, which has advantages of fast processing speed and high edge locating accuracy. The wear amount of the grinding wheel is calculated by the image processing software, and is compensated automatically by NC controller. Finally, this method is applied to a new type CNC curve grinding machine MD9040. The experimental results show that the measurement and compensation method proposed in this paper is effective, and the contour error of the workpiece with real-time compensation is less than the feeding resolution for a compensation of 2μm.