Optical encoders and laser interferometers are two primary solutions in nanometer metrology. As the precision of encoders depends on the uniformity of grating pitches, it is essential to evaluate pitches accurately. We use a CCD image sensor to acquire grating image for evaluating the pitches with high precision. Digital image correlation technique is applied to filter out the noises. We propose three methods for determining the pitches of grating with peak positions of correlation coefficients. Numerical simulation indicated the average of pitch deviations from the true pitch and the pitch variations are less than 0.02 pixel and 0.1 pixel for these three methods when the ideal grating image is added with salt and pepper noise, speckle noise, and Gaussian noise. Experimental results demonstrated that our method can measure the pitch of the grating accurately, for example, our home-made grating with 20μm period has 475nm peak-to-valley uniformity with 40nm standard deviation during 35mm range. Another measurement illustrated that our home-made grating has 40nm peak-to-valley uniformity with 10nm standard deviation. This work verified that our lab can fabricate high-accuracy gratings which should be interesting for practical application in optical encoders.