The invention relates to the technical field of
machine vision and
image processing, and discloses a plastic tray appearance defect automatic detection method based on
machine vision. In the plastic tray conveying process, tray surface images are collected in real time, a
gray level image matrix is constructed, smooth images are obtained through filtering under different smooth scales, local binary codes are generated through a fixed direction neighborhood comparison center and a neighborhood
gray level, a
square window is established at the position away from the boundary, and a local texture
energy diagram is obtained through summation of codes squares. The method comprises the following steps: calculating a difference value among energy diagrams of different scales according to pixels, counting an average value and a standard deviation to construct a global threshold value, carrying out
binary segmentation on a difference chart, screening defect regions according to eight neighborhoods and areas, marking pixels of the defect regions, and outputting geometric positions and statistical information, thereby weakening the influence of tray movement and illumination change, and improving the accuracy of the detection result.
Noise suppression and texture reservation are considered, the sensitivity of a traditional edge and fixed threshold method is reduced, and automatic defect detection and quantification are achieved.