Large-breadth PCB multilayer board edge detection method and system
By optimizing the filter coefficients of the filter using a genetic algorithm, the problems of noise sensitivity and image details loss in the prior art are solved, and the accuracy of multi-layer board edge detection of large-format PCB is improved.
Patent Information
- Application Number
- CN202411561165.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-02-14
AI Technical Summary
The existing large-format PCB multi-layer board edge detection technology is sensitive to noise, easily lose image details, and the limitations of using fixed thresholds during image binarization.
Genetic algorithms are used to optimize the filter coefficients of the filters in the edge detector, obtain the maximum fitness value through image training, update the evaluation function in the genetic algorithm, iteratively optimize the better filter coefficients, and reduce the impact of noise on image details.
The accuracy of multi-layer board edge detection is improved, the impact of noise on image details is reduced, and the difficulty of manually selecting the optimal filter coefficient is overcome.
Smart Images

Figure CN119444784A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of machine vision technology, and in particular to a large-format PCB multilayer board edge detection method and system. Background Art
[0002] Image edge detection is one of the most challenging problems in image processing and one of the most important technologies in computer vision. Its main purpose is to detect and identify a set of pixels with drastic changes in brightness in an image. These pixels usually correspond to the contours or structural changes of an object. In image processing, correct edge detection plays a vital role in analyzing image content, segmenting and locating objects in an image, and other tasks.
[0003] In the detection and identification application of large-format PCB multilayer boards, edge detection is very important. Accurately detect edge information to obtain corresponding contour information. Therefore, edge detection technology is a key core technology in the automatic slitting of large-format PCB multilayer boards, and it is also a pain point that the industry urgently needs to solve. Due to technical reasons, most research and technical personnel currently implement large-format PCB multilayer board edge detection mainly based on Prewitt operator, Canny operator, Laplace operator, etc., and these edge detection methods have the following problems: (1) Sensitive to noise and easy to lose image details. (2) The limitation of using a fixed threshold in the process of image binarization. Summary of the invention
[0004] In view of the above-mentioned defects, the purpose of the present invention is to propose a large-format PCB multilayer board edge detection method and system to solve the problem that it is difficult to eliminate the influence of noise in the existing PCB multilayer board edge detection, resulting in loss of image details.
[0005] To achieve this purpose, the present invention adopts the following technical solution: a large-format PCB multilayer board edge detection method, comprising the following steps:
[0006] Step S1: using a genetic algorithm to optimize the filter coefficients of the filter in the edge detector;
[0007] Step S2: transforming the optimized filter coefficients, using the transformed filter coefficients for image training, and obtaining the maximum fitness value in the image training;
[0008] Step S3: Use the maximum fitness value to update the evaluation function in the genetic algorithm;
[0009] Step S4: Use a set of training images with different textures and different brightness distributions to train the edge detector. Through continuous iteration, select the edge detector with the best performance, output the filter coefficients of the edge detector with the best performance, and then use the filter coefficients for new image detection.
[0010] Preferably, in step S1, only the filter coefficients of the filter in one direction are optimized.
[0011] Preferably, the steps for obtaining the maximum fitness value in step S2 are as follows:
[0012] Step S21: Obtaining the correlation coefficient between the output edge image and its corresponding optimal edge image;
[0013] Step S22: obtaining a similarity coefficient between the output edge image and its corresponding optimal edge image;
[0014] Step S23: Add the correlation coefficient and the similarity coefficient by weighted combination to obtain the maximum fitness value.
[0015] Preferably, the steps of training the edge detector in step S4 are as follows:
[0016] Fully automatic clustering of images using K-means method to extract the required number of thresholds;
[0017] A genetic algorithm is used to select the optimal threshold level for each training image;
[0018] The optimal edge image is compared with the output edge image of the edge detector to determine the performance of the edge detector.
[0019] A large-format PCB multilayer board edge detection system, using the large-format PCB multilayer board edge detection method, including an optimization module, a training module, an update module and an output module;
[0020] The optimization module is used to optimize the filter coefficients of the filter in the edge detector using a genetic algorithm;
[0021] The training module is used to transform the optimized filter coefficients, use the transformed filter coefficients for image training, and obtain the maximum fitness value in the image training;
[0022] The updating module is used to update the evaluation function in the genetic algorithm using the maximum fitness value;
[0023] The output module is used to train an edge detector using a set of training images with different textures and different brightness distributions, select the edge detector with the best performance through continuous iteration, output the filter coefficients of the edge detector with the best performance, and then use the filter coefficients for new image detection.
[0024] Preferably, the optimization module further includes a selection unit;
[0025] The selecting unit is used for selecting the filter coefficients of the filter in only one direction for optimization.
[0026] Preferably, the training module includes a fitness value acquisition unit;
[0027] The fitness value acquisition unit is used to acquire the correlation coefficient between the output edge image and the optimal edge image corresponding to it;
[0028] Obtaining a similarity coefficient between the output edge image and its corresponding optimal edge image;
[0029] The correlation coefficient and the similarity coefficient are added by weighted combination to obtain the maximum fitness value.
[0030] Preferably, the output module includes a binarization unit, a threshold selection unit and a detection unit;
[0031] The binarization unit is used to perform fully automatic clustering of the image using a K-means method to extract a required number of thresholds;
[0032] The threshold selection unit is used to select an optimal threshold level for each training image using a genetic algorithm;
[0033] The detection unit is used to compare the optimal edge image with the output edge image of the edge detector to determine the performance of the edge detector.
[0034] One of the above technical solutions has the following advantages or beneficial effects: In the present invention, a genetic algorithm is used to optimize the filter coefficient of the filter, and then the optimized filter coefficient is trained on an image, and the maximum fitness value is obtained, wherein the maximum fitness value is used to update the evaluation function in the genetic algorithm, and in subsequent continuous updates and iterations, a better filter coefficient can be optimized, thereby overcoming the problem of manually selecting the optimal filter coefficient. Finally, the influence of noise on image details is reduced, thereby improving the detection accuracy of the edge of the multilayer board. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 is a flow chart of an embodiment of the method of the present invention.
[0036] Figure 2 It is a schematic diagram of the structure of an embodiment of the system of the present invention. DETAILED DESCRIPTION
[0037] The embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals represent the same or similar elements or elements having the same or similar functions from beginning to end. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.
[0038] In the description of the embodiments of the present invention, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0039] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, unless otherwise specified, the meaning of "plurality" is two or more. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0040] like Figures 1-2 As shown, a large-format PCB multilayer board edge detection method includes the following steps:
[0041] Step S1: using a genetic algorithm to optimize the filter coefficients of the filter in the edge detector;
[0042] The genetic algorithm starts with k randomly generated individuals, called a "population". Each individual is represented by a one-dimensional string. This string is called a "chromosome" and each symbol is called a "gene". Genetic algorithm steps:
[0043] The population is randomly generated. The fitness of the individual is judged according to the strategy to see if it meets the optimization criteria. If it does, the best individual and its optimal solution are output and the process ends. Otherwise, the process proceeds to the next step. Parents are selected based on fitness. Individuals with high fitness have a high probability of being selected, and individuals with low fitness are eliminated.
[0044] The chromosomes of the parents are crossed in a certain way to produce offspring.
[0045] Mutate the chromosomes of the offspring.
[0046] Generate a new generation of population by crossover and mutation, and return to step 2 until the optimal solution is generated.
[0047] So the filter coefficients are converted into the representation of the genetic algorithm.
[0048] Specific example: 1. Initialization, first, you need to define the initial parameters of the genetic algorithm, such as population size, chromosome length (that is, the number of filter coefficients, here is 9), genetic generation, crossover rate, mutation rate, etc. Chromosome representation: Each chromosome represents a possible combination of filter coefficients. For the Sobel operator x-direction filter, the chromosome can be represented as: [-1,-2,-1,0,0,0,1,2,1]. But when optimizing, we will allow these values to vary within a certain range, for example, each coefficient can be an integer between -3 and 3.
[0049] 2. Encoding and decoding. Encoding: During initialization, a population is randomly generated, and each individual (chromosome) in the population contains 9 random integers between -3 and 3. Decoding: The decoding process is simple, that is, the integers in the chromosome are directly used as the coefficients of the filter.
[0050] 3. Fitness function, calculate the fitness value. 4. Selection: According to the result of the fitness function, select individuals with high fitness as parents of the next generation. The selection strategy is roulette selection. 5. Crossover: Crossover operation is performed between the selected parents to produce new offspring. The crossover operation can be to exchange some genes of two chromosomes at randomly selected points. 6. Mutation: There is a certain probability to mutate certain genes in the chromosome to increase the diversity of the population. The mutation operation can be a simple change in the value of a gene. 7. Iteration: Repeat the selection, crossover and mutation process until the predetermined genetic generation number is reached.
[0051] Example: Suppose after several iterations, a filter coefficient combination with good performance is obtained: [-1,-3,-2,0,0,1,2,3,1].
[0052] Step S2: transforming the optimized filter coefficients, using the transformed filter coefficients for image training, and obtaining the maximum fitness value in the image training;
[0053] When performing genetic algorithms, the coefficients in the filter need to be converted from coded form to digital form before they can be optimized. However, in image training, the opposite is true. They need to be converted into their original form before they can be used in image training. Therefore, the optimized filter coefficients need to be converted in format.
[0054] Step S3: Use the maximum fitness value to update the evaluation function in the genetic algorithm;
[0055] In the edge detection of PCB multi-layer, the selection of filter coefficient is the most important parameter in edge extraction. In traditional detection, the filter coefficient is selected manually, which leads to high noise sensitivity and easy loss of image. In order to reduce the influence of sound sensitivity on the image. In the present invention, the filter coefficient of the filter is optimized by using a genetic algorithm, and then the optimized filter coefficient is trained on the image, and the maximum fitness is obtained, wherein the maximum fitness is used to update the evaluation function in the genetic algorithm. In the subsequent continuous update iteration, a better filter coefficient can be optimized, thereby overcoming the problem of manually selecting the optimal filter coefficient. Finally, the influence of noise on the image details is reduced, thereby improving the detection accuracy of the edge of the multilayer board.
[0056] Step S4: Use a set of training images with different textures and different brightness distributions to train the edge detector. Through continuous iteration, select the edge detector with the best performance, output the filter coefficients of the edge detector with the best performance, and then use the filter coefficients for new image detection.
[0057] Preferably, in step S1, only the filter coefficients of the filter in one direction are optimized.
[0058] When using genetic algorithm for optimization, since the algorithm itself needs to be updated and iterated many times, the optimization takes a certain amount of time. There are filters in the X direction and filters in the Y direction in the filter. Therefore, under normal circumstances, the filter coefficients of the filters in the two directions need to be optimized. Since one filter can be expressed as a transformation of another filter. In the present invention, only the filter coefficients of the filter in one direction are optimized, and the filter coefficients of the filter in the other direction are transformed by the optimized filter coefficients. The optimization time is greatly reduced. The speed of training is accelerated.
[0059] Preferably, the steps for obtaining the maximum fitness value in step S2 are as follows:
[0060] Step S21: Obtaining the correlation coefficient between the output edge image and its corresponding optimal edge image;
[0061] For large-format PCB multilayer board images, edge images will be output during the training process. The correlation coefficient (Corr) between the output edge image and its corresponding optimal edge image can be obtained by the following formula:
[0062]
[0063] Where x and y are image sliding windows of size N×N; μ x , μ y are the average pixel grayscale values of the optimal edge image and the output edge image within their respective window sizes; x ij ,y ijThey represent the pixel grayscale values of the optimal edge image and the output edge image respectively.
[0064] Step S22: obtaining a similarity coefficient between the output edge image and its corresponding optimal edge image;
[0065] The formula for obtaining similarity is as follows:
[0066]
[0067] where σ x and σ y are the variances of the pixel grayscale values of the optimal edge image and the output edge image within the window size, σ xy is the covariance of the pixel grayscale values of the optimal edge image and the output edge image, c1 and c2 are constant coefficients to prevent the denominator from being zero.
[0068] Step S23: Add the correlation coefficient and the similarity coefficient by weighted combination to obtain the maximum fitness value.
[0069] The formula for obtaining the maximum fitness is as follows:
[0070] F = λ1*Corr(x,y)+λ2*SSIM(x,y); where λ1 and λ2 are weight coefficients respectively.
[0071] In the present invention, both the correlation coefficient and the structural similarity index are calculation methods based on sliding windows, which can better handle local changes in the image and improve the robustness of the evaluation. After combining the two indicators of the correlation coefficient and the structural similarity index, the similarity between the output edge image and the optimal edge image can be more comprehensively evaluated. Thus, training can be better performed from the optimal edge image.
[0072] It is worth mentioning that the optimal edge image is an image with the best edge identified by vision (human eyes).
[0073] Preferably, the steps of training the edge detector in step S4 are as follows:
[0074] Fully automatic clustering of images using K-means method to extract the required number of thresholds;
[0075] A genetic algorithm is used to select the optimal threshold level for each training image;
[0076] The execution example of K-means algorithm is as follows:
[0077] 1. Select 5 initial cluster centers (image thresholds, for example, 123, 132, 136, 112, 126).
[0078] 2. For each pixel's grayscale value in an image, calculate its distance from each cluster center and assign it to the cluster center closest to it. Use Euclidean distance as the distance metric.
[0079] 3. For each cluster, recalculate its cluster center. The new cluster center is the mean of all data points (grayscale values) in the cluster.
[0080] 4. Iteration: Repeat the allocation and update steps until the termination condition is met. The termination condition is that the cluster center no longer changes significantly: that is, the distance between the new cluster center and the old cluster center is less than a preset threshold (for example, 5).
[0081] 6. Get 5 initial cluster center values.
[0082] 7. Use genetic algorithm to obtain the optimal threshold.
[0083] The optimal edge image is compared with the output edge image of the edge detector to determine the performance of the edge detector.
[0084] When determining the edge detector, various data can be compared between the optimal edge image and the edge image detected by the edge detector. For example, the edge accuracy, completeness, noise level and other data are compared. For example, in the accuracy comparison, the overlap between the edge output by the detector and the optimal edge image is calculated, that is, the ratio of the number of correctly detected edges to the total number of edges. When the ratio is greater than the ratio threshold, it can be considered that the accuracy is passed. Other data detections have different detection surfaces. For example, the completeness can be judged by the number of identified edges, and the noise level can be judged by the output false edges or unnecessary details. I will not explain it in detail here.
[0085] The present invention uses the K-means algorithm to automatically obtain the image threshold of each image, and can automatically determine the threshold according to the pixel value distribution of the image, so as to better achieve the effect of binarization. At the same time, when binarization is performed, the genetic algorithm is used to select the optimal threshold, so as to avoid falling into the local optimal solution.
[0086] A large-format PCB multilayer board edge detection system, using the large-format PCB multilayer board edge detection method, including an optimization module, a training module, an update module and an output module;
[0087] The optimization module is used to optimize the filter coefficients of the filter in the edge detector using a genetic algorithm;
[0088] The training module is used to transform the optimized filter coefficients, use the transformed filter coefficients for image training, and obtain the maximum fitness value in the image training;
[0089] The updating module is used to update the evaluation function in the genetic algorithm using the maximum fitness value;
[0090] The output module is used to train an edge detector using a set of training images with different textures and different brightness distributions, select the edge detector with the best performance through continuous iteration, output the filter coefficients of the edge detector with the best performance, and then use the filter coefficients for new image detection.
[0091] Preferably, the optimization module further includes a selection unit;
[0092] The selecting unit is used for selecting the filter coefficients of the filter in only one direction for optimization.
[0093] Preferably, the training module includes a fitness value acquisition unit;
[0094] The fitness value acquisition unit is used to acquire the correlation coefficient between the output edge image and the optimal edge image corresponding to it;
[0095] Obtaining a similarity coefficient between the output edge image and its corresponding optimal edge image;
[0096] The correlation coefficient and the similarity coefficient are added by weighted combination to obtain the maximum fitness value.
[0097] Preferably, the output module includes a binarization unit, a threshold selection unit and a detection unit;
[0098] The binarization unit is used to perform fully automatic clustering of the image using a K-means method to extract a required number of thresholds;
[0099] The threshold selection unit is used to select an optimal threshold level for each training image using a genetic algorithm;
[0100] The detection unit is used to compare the optimal edge image with the output edge image of the edge detector to determine the performance of the edge detector.
[0101] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0102] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A large-format PCB multilayer board edge detection method, characterized in that: The steps include: Step S1: using a genetic algorithm to optimize the filter coefficients of the filter in the edge detector; Step S2: transforming the optimized filter coefficients, using the transformed filter coefficients for image training, and obtaining the maximum fitness value in the image training; Step S3: Use the maximum fitness value to update the evaluation function in the genetic algorithm; Step S4: Use a set of training images with different textures and different brightness distributions to train the edge detector. Through continuous iteration, select the edge detector with the best performance, output the filter coefficient of the edge detector with the best performance, and then use the filter coefficient for new image detection.
2. A large-format PCB multilayer board edge detection method according to claim 1, characterized in that: In the step S1, only the filter coefficients of the filter in one direction are optimized.
3. A large-format PCB multilayer board edge detection method according to claim 1, characterized in that: The steps for obtaining the maximum fitness value in step S2 are as follows: Step S21: Obtaining the correlation coefficient between the output edge image and its corresponding optimal edge image; Step S22: obtaining a similarity coefficient between the output edge image and its corresponding optimal edge image; Step S23: Add the correlation coefficient and the similarity coefficient by weighted combination to obtain the maximum fitness value.
4. A large-format PCB multilayer board edge detection method according to claim 1, characterized in that: The steps for training the edge detector in step S4 are as follows: Fully automatic clustering of images using K-means method to extract the required number of thresholds; A genetic algorithm is used to select the optimal threshold level for each training image; The optimal edge image is compared with the output edge image of the edge detector to determine the performance of the edge detector.
5. A large-format PCB multilayer board edge detection system, using a large-format PCB multilayer board edge detection method according to any one of claims 1 to 4, characterized in that: Includes optimization module, training module, update module and output module; The optimization module is used to optimize the filter coefficients of the filter in the edge detector using a genetic algorithm; The training module is used to transform the optimized filter coefficients, use the transformed filter coefficients for image training, and obtain the maximum fitness value in the image training; The updating module is used to update the evaluation function in the genetic algorithm using the maximum fitness value; The output module is used to train an edge detector using a set of training images with different textures and different brightness distributions, select the edge detector with the best performance through continuous iteration, output the filter coefficients of the edge detector with the best performance, and then use the filter coefficients for new image detection.
6. A large-format PCB multilayer board edge detection system according to claim 5, characterized in that: The optimization module also includes a selection unit; The selecting unit is used for selecting the filter coefficients of the filter in only one direction for optimization.
7. A large-format PCB multilayer board edge detection system according to claim 5, characterized in that: The training module includes a fitness value acquisition unit; The fitness value acquisition unit is used to acquire the correlation coefficient between the output edge image and the optimal edge image corresponding to it; Obtaining a similarity coefficient between the output edge image and its corresponding optimal edge image; The correlation coefficient and the similarity coefficient are added by weighted combination to obtain the maximum fitness value.
8. A large-format PCB multilayer board edge detection system according to claim 5, characterized in that: The output module includes a binarization unit, a threshold selection unit and a detection unit; The binarization unit is used to perform fully automatic clustering of the image using a K-means method to extract a required number of thresholds; The threshold selection unit is used to select an optimal threshold level for each training image using a genetic algorithm; The detection unit is used to compare the optimal edge image with the output edge image of the edge detector to determine the performance of the edge detector.