To solve the location matching problem and angle matching problem in the optical detection system of printed circuit board defect,a method of sub-regional image matching is put forward.The method segments the tested PCB and the standard PCB image into M×N sub-images and uses improved normalized cross correlation algorithm to match the location shift separately.The combined effects of all sub-images' matching offer results with both location matching and angle matching ones for the entire image,thus one algorithm can be used to achieve two matching purposes.Experiments shows that the method reduces the number of matching calculations,improves the image matching speed and the efficiency of defect detecting system.