The invention belongs to the technical field of
machine vision detection, and particularly relates to a defect classification method based on an improved particle swarm
wavelet neural network. The problems that a traditional BP neural network
algorithm is prone to convergence and prematurity, and cause a local minimum value and the like are solved. The method comprises the following steps: loadingan original image, carrying out graying and median filtering
processing, segmenting the image, calculating a defect
feature vector, initializing a particle swarm, calculating a target fitness value,evaluating each particle, updating the position and speed of each particle, checking whether the requirement is met, outputting an optimal solution, and finally carrying out defect classification on the image. According to the method, a variation factor is added, so that the generalization capability of the
algorithm is ensured. A nonlinear
weight factor is set, and a target of flexible adjustmentof global search and local search is realized. A global extreme value of
Gaussian weighting is introduced, convergence of the global extreme value to the optimal solution direction is facilitated, defects can be classified quickly and accurately, the
classification result is more accurate, and the efficiency is higher.