Aiming at the shortcomings of manual detection methods for surface defects of bearing outer rings, a surface defect detection method based on machine vision is proposed. The common defects on the bearing surface are scratches, cracks, and peeling. The defect images are analyzed by the LabVIEW image processing module. Make fast and accurate inspections. In this paper, a CMOS industrial camera is used to obtain the bearing image, and the gray histogram of the image is analyzed to determine whether it is a defective bearing. In order to solve the problem of uneven illumination in image segmentation, it is proposed to first use morphological processing for background. Then, the difference map containing defect information is obtained, and then the Otsu method is used for image segmentation; an edge detection method is designed based on morphology, which can achieve complete edge extraction and good denoising effect. Experiments show that the method has strong practicability and self-adaptability, and can accurately detect bearing surface defects.