Method and device for detecting coating quality of printed circuit board and storage medium
By performing differential image processing on the grayscale images of the printed circuit board coating image and the standard template, including threshold extraction, morphological processing and connectivity analysis, the problem of numerous noise points is solved, and high precision and efficiency of coating quality inspection are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- DONGGUAN ANDA AUTOMATIC EQUIP
- Filing Date
- 2026-01-20
- Publication Date
- 2026-04-28
AI Technical Summary
In existing technologies, the difference images for printed circuit board coating quality inspection have many noise points, which cannot truly reflect the differences between the coated image and the standard coated image, and the accuracy of the difference display is poor.
By acquiring the coating image of the printed circuit board and the grayscale image of the standard template, difference image processing is performed, including threshold extraction, morphological processing and connectivity analysis, noise points are filtered out to ensure the integrity of the contours of the difference regions, and dispersed defect regions are merged through connectivity analysis to obtain the standard difference image.
It improves the accuracy of coating quality inspection difference display, ensures the integrity of defect areas, and reduces the amount of data calculation in the inspection process.
Smart Images

Figure CN121937435A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electronic manufacturing and testing technology, and in particular to a method, apparatus and storage medium for testing the coating quality of printed circuit boards. Background Technology
[0002] With the continuous improvement of the three-proof process (moisture-proof, corrosion-proof, and anti-static) of printed circuit board assemblies (PCBAs), applying conformal coating or adhesive to key components and parts of the PCBA has become a common process in the industry.
[0003] To ensure the coating quality of the coating process, before performing quality inspection on the PCBA coating image, it is necessary to perform a subtraction operation between the PCBA coating image and the standard coating image. The standard coating image is subtracted from the PCBA coating image, and the difference image is obtained based on this subtraction operation. The difference image reflects the difference between the PCBA coating image and the standard coating image. Finally, the coating quality inspection is performed based on the difference image.
[0004] However, this method of obtaining difference images results in a large number of noise points in the obtained difference images, making it impossible for the difference images to truly reflect the differences between the PCBA coating image and the standard coating image. At the same time, the difference images obtained by the above method cannot directly characterize the physical properties of defects, and the difference display accuracy of the difference images is poor. Summary of the Invention
[0005] This invention provides a method, apparatus, electronic device, storage medium, and computer program product for inspecting the coating quality of printed circuit boards, in order to solve the problem that difference images cannot accurately reflect the actual differences between the PCBA coating image and the standard template.
[0006] According to another aspect of the present invention, a method for inspecting the coating quality of a printed circuit board is provided, comprising: A first grayscale image corresponding to the coating image of the printed circuit board and a second grayscale image corresponding to the standard template are obtained; wherein, the standard template includes a coating area template, an uncoated area template and an unrelated area template. Obtain the difference image between the first grayscale image and the second grayscale image, and perform threshold extraction and morphological processing on the difference image; Based on the connectivity analysis results of the difference image, the standard difference image between the first grayscale image and the second grayscale image is obtained, so as to obtain the coating quality detection result of the printed circuit board based on the standard difference image.
[0007] The step of obtaining the difference image between the first grayscale image and the second grayscale image includes: obtaining a first grayscale histogram corresponding to the first grayscale image and a second grayscale histogram corresponding to the second grayscale image; normalizing the first grayscale histogram and the second grayscale histogram, and obtaining the correlation coefficient between the first grayscale histogram and the second grayscale histogram based on the normalization result; if the correlation coefficient is determined to be greater than or equal to a preset similarity threshold, obtaining the difference image between the first grayscale image and the second grayscale image.
[0008] The threshold extraction and morphological processing of the difference image includes: performing morphological opening and morphological closing operations sequentially on the difference image after threshold extraction.
[0009] The step of obtaining the standard difference image between the first grayscale image and the second grayscale image based on the connectivity analysis result of the difference image further includes: copying the difference image into a comparison difference image and performing an erosion operation on the comparison difference image; performing a difference operation on the difference image and the comparison difference image to obtain the contour of the difference region based on the difference operation result; and obtaining the connectivity analysis result of the difference image based on the contour of the difference region.
[0010] The step of obtaining the standard difference image between the first grayscale image and the second grayscale image based on the connectivity analysis results of the difference image includes: obtaining the geometric features of each connected region in the difference image, and deleting noise interference regions in each connected region based on the geometric features of each connected region; wherein, the geometric features include at least one of area, perimeter, and minimum bounding rectangle.
[0011] The step of obtaining the coating quality inspection result of the printed circuit board based on the standard deviation image further includes: mapping each connected region to a corresponding region type based on the contour point set of each connected region; wherein the region type includes coated regions, uncoated regions, and non-associated regions; and obtaining the defect type of each connected region based on the feature parameters and region type of each connected region; wherein the feature parameters include shape features and geometric features.
[0012] According to another aspect of the present invention, a coating quality inspection device for printed circuit boards is provided, comprising: A grayscale image acquisition module is used to acquire a first grayscale image corresponding to the coating image of the printed circuit board, and a second grayscale image corresponding to a standard template; wherein, the standard template includes a coating area template, an uncoated area template, and an unrelated area template. The difference image acquisition module is used to acquire the difference image between the first grayscale image and the second grayscale image, and to perform threshold extraction and morphological processing on the difference image; The standard deviation acquisition module is used to acquire the standard deviation image between the first grayscale image and the second grayscale image based on the connectivity analysis results of the difference image, so as to acquire the coating quality inspection result of the printed circuit board based on the standard deviation image.
[0013] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the coating quality inspection method for printed circuit boards according to any embodiment of the present invention.
[0014] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the coating quality inspection method for printed circuit boards according to any embodiment of the present invention.
[0015] According to another aspect of the present invention, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the coating quality inspection method for printed circuit boards according to any embodiment of the present invention.
[0016] The technical solution of this invention first acquires a first grayscale image corresponding to the coating image of the printed circuit board and a second grayscale image corresponding to the standard template; then, it acquires the difference image between the first and second grayscale images, and performs threshold extraction and morphological processing on the difference image; finally, based on the connectivity analysis results of the difference image, it acquires the standard difference image between the first and second grayscale images, and obtains the coating quality inspection result of the printed circuit board based on the standard difference image. This not only filters out minute noise difference regions through threshold extraction and morphological processing, ensuring the integrity of the difference region's outline and improving the positioning accuracy of the difference region, but also achieves the connection and merging of scattered defect regions through connectivity analysis, ensuring the integrity of the defect region while reducing the data computation volume of the quality inspection process, greatly improving the difference display accuracy of the difference image.
[0017] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a flowchart of a method for detecting the coating quality of a printed circuit board according to Embodiment 1 of the present invention; Figure 2 This is a flowchart of another method for detecting the coating quality of a printed circuit board according to Embodiment 2 of the present invention; Figure 3 This is a flowchart of another method for detecting the coating quality of a printed circuit board according to Embodiment 3 of the present invention; Figure 4 This is a schematic diagram of the structure of a coating quality inspection device for printed circuit boards according to Embodiment 4 of the present invention; Figure 5 This is a schematic diagram of the structure of an electronic device that implements the coating quality inspection method for printed circuit boards according to embodiments of the present invention. Detailed Implementation
[0020] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0021] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0022] Example 1 Figure 1This is a flowchart of a method for detecting the coating quality of a printed circuit board according to Embodiment 1 of the present invention. This embodiment is applicable to situations where matching results between a coating image and a standard template are obtained based on threshold extraction processing, morphological processing, and connectivity analysis. This method can be executed by a printed circuit board coating quality detection device, which can be implemented in hardware and / or software. This device can be configured in an electronic device, which can exist as a standalone device or be configured within a coating device. Figure 1 As shown, the method includes: S101. Obtain a first grayscale image corresponding to the coating image of the printed circuit board, and a second grayscale image corresponding to the standard template; wherein, the standard template includes a coating area template, an uncoated area template, and an unrelated area template.
[0023] A printed circuit board (PCB) is a PCB to be inspected after coating. A coating image is an image of the coated surface of the PCB captured by the vision component of the coating equipment, used to reflect the coating status of the PCB. The coating image can be a complete coating image captured in a single shot by the vision component, or a complete coating image composed of multiple partial images captured using a high-resolution imaging technique. This image represents the overall coating status of the PCB. The corresponding standard template is also a complete coating image, representing the overall coating status of a defect-free PCBA sample. Alternatively, a coating image can be a single high-resolution imaging image, representing the coating status of a specific area of the PCB. The corresponding standard template is also a single high-resolution imaging image, representing the coating status of a specific area of a defect-free PCBA sample.
[0024] Flying images are localized images dynamically captured in motion by the vision components of coating equipment (e.g., industrial cameras) during the inspection of printed circuit board assemblies (PCBAs). The purpose is to achieve rapid visual inspection of the PCBA without stopping the conveyor, thereby improving inspection efficiency. Since each flying image only reflects a localized portion of the PCBA, multiple flying images need to be stitched together to form a complete coating image. These stitched images are primarily used for detecting random defects in global functions (e.g., bubbles, foam; wrinkles, orange peel effect; cracks and foreign objects); component inspection (IC pins, capacitors, resistors, inductors, solder joints, spring contacts, and exposed copper, etc.); and measurement of coating width and thickness.
[0025] Coated areas refer to areas requiring a protective coating; non-coated areas refer to areas where coating coverage is strictly prohibited, such as areas requiring protection through masking or isolation processes; excluded areas refer to areas unrelated to the coating process or requiring no treatment, i.e., areas not considered, such as areas excluded due to redundancy or functional irrelevance. On a defect-free PCBA prototype, images of coated areas, non-coated areas, and excluded areas are acquired respectively, serving as templates for coated areas, non-coated areas, and excluded areas.
[0026] The coating image of the printed circuit board and the standard template are processed into grayscale to obtain a first grayscale image corresponding to the coating image and a second grayscale image corresponding to the standard template. Grayscale processing not only simplifies the processing complexity of the coating image and the standard template and reduces the amount of computation, but also the grayscale image only contains brightness information, avoiding visual interference caused by color channel differences, so that the coating equipment can focus more on the shape and brightness distribution of the object.
[0027] Specifically, in the process of converting the original color image to a grayscale image, in order to reduce data dimensionality and remove color interference, the three-dimensional RGB image can be converted to a one-dimensional grayscale space using a weighted average method, as follows: ; Where Gray represents the calculated grayscale value; R, G, and B represent the pixel values of the red, green, and blue channels, respectively; and K1, K2, and k3 represent the weights of the red, green, and blue channels, respectively.
[0028] S102. Obtain the difference image between the first grayscale image and the second grayscale image, and perform threshold extraction and morphological processing on the difference image.
[0029] The gray values of corresponding pixels in the first grayscale image and the second grayscale image are compared one by one, the absolute difference between the two is calculated, and these differences are combined into a new image (i.e., the difference image). The value of each pixel in the difference image represents the degree of difference between corresponding points in the two original images (i.e., the first grayscale image and the second grayscale image). The larger the difference, the more obvious the pixel difference at that position.
[0030] Thresholding extraction involves using a pre-configured pixel threshold to identify regions in the difference image with pixel values greater than the threshold as significantly different regions. These regions are then assigned a color label, for example, white for a pixel value of 255. Conversely, regions with pixel values less than or equal to the threshold are considered insignificantly different regions and are assigned a different color label, for example, black for a pixel value of 0. This process transforms the continuously changing difference image into a binary image with only black and white pixels, highlighting regions with significant differences and filtering out minor differences that may be caused by noise or normal fluctuations. The difference image after thresholding extraction is essentially a binary difference image.
[0031] Mathematical morphology is an image processing technique based on image shape and structure. It changes the morphological features of an image by moving small, predefined shaped structuring elements (SEs) on the image and performing specific set operations with image pixels. In this embodiment of the invention, difference images can be processed by morphological closing operations.
[0032] Morphological closing is a process that involves first dilating and then eroding. Dilating expands the foreground region (the area of interest) to fill small holes and connect adjacent regions. Erosion shrinks the foreground region to remove small noise points and break fine connections. Morphological closing can eliminate small holes in binarized difference images and connect adjacent difference regions that are broken by tiny gaps, making the contours of the difference regions more continuous and complete.
[0033] Optionally, in this embodiment of the invention, the threshold extraction and morphological processing of the difference image includes: performing morphological opening and morphological closing operations sequentially on the difference image after threshold extraction.
[0034] Specifically, morphological opening operations can remove small noise points (i.e., isolated white points) and broken fine connections outside the foreground. In the difference image after binarization, there are often a large number of isolated noise points. Therefore, we can first use morphological opening operations to denoise the binarized difference image, and then use morphological closing operations to fill holes to obtain a complete and smooth target area. Thus, by using cascaded morphological opening and morphological closing operations, noise points in the binarized difference image are eliminated, while ensuring the structural integrity of the image.
[0035] S103. Based on the connectivity analysis results of the difference image, obtain the standard difference image between the first grayscale image and the second grayscale image, so as to obtain the coating quality detection result of the printed circuit board based on the standard difference image.
[0036] Connected Component Analysis (CCA) is the process of extracting pixel regions (called connected regions) that have the same pixel value (e.g., foreground images with the same pixel value) and are adjacent in position (e.g., 4-neighborhood or 8-neighborhood) from a binarized image, and assigning a unique identifier to each region. Its purpose is to connect multiple small blocks that are scattered but actually belong to the same defect to form a complete defect region.
[0037] The connected regions obtained through connectivity analysis in the difference image are actually the difference regions between the coated image and the standard template. Based on this, the difference image (i.e., the standard difference image) obtained from the connectivity analysis results can clearly show the significant differences between the coated image and the standard template, thus completing the matching between the coated image and the standard template. Based on the position, size, shape and other parameter characteristics of the difference regions in the standard difference image, it is possible to determine whether there are defects in the printed circuit board corresponding to the coated image and the specific type of defect.
[0038] Optionally, in this embodiment of the invention, obtaining the standard difference image between the first grayscale image and the second grayscale image based on the connectivity analysis result of the difference image further includes: copying the difference image into a comparison difference image and performing an erosion operation on the comparison difference image; performing a difference operation on the difference image and the comparison difference image to obtain the difference region contour based on the difference operation result; and obtaining the connectivity analysis result of the difference image based on the difference region contour.
[0039] Specifically, the difference image after morphological operations is copied as a contrast difference image, and an erosion operation is performed on the contrast difference image. The contrast difference image after erosion shrinks the difference region. Then, the difference image before erosion is subtracted from the contrast difference image after erosion, and the result of the subtraction is the contour of the difference region. The structural elements required for the erosion operation can be cross kernels, rectangular kernels, or circular kernels, etc. Based on this, the contour information of the difference region is extracted by the difference image before erosion and the contrast difference image after erosion, realizing the accurate positioning of the difference region and further improving the matching accuracy between the coated image and the standard template.
[0040] Optionally, in this embodiment of the invention, obtaining the standard difference image between the first grayscale image and the second grayscale image based on the connectivity analysis results of the difference image includes: obtaining the connectivity analysis results of the difference image using a queue-based region growing method.
[0041] Specifically, region growing is an expansion-based segmentation method based on seed points. Starting from an initial seed point (e.g., a single pixel or a small region), it merges pixels in the neighboring pixels of the seed point into the current region according to similarity criteria (e.g., pixel value less than a preset threshold, or color and texture consistency). These new pixels are then used as new seed points. This process is repeated until no new pixels can be added, ultimately forming a complete connected region.
[0042] In region growing, the queue is a key data structure for managing the order of seed points. The first-in, first-out (FIFO) nature of the queue determines the breadth-first search order of region growing (i.e., processing all neighborhoods of the initial seed point first, then processing the neighborhoods of those neighborhoods, and so on outwards). Therefore, by using queue-based region growing for connectivity analysis, breadth-first search is achieved, ensuring that all connected regions are extracted starting from the initial seed point and expanding outwards from the neighborhood, significantly improving the efficiency of foreground image extraction from the difference image.
[0043] Optionally, in this embodiment of the invention, obtaining the standard difference image between the first grayscale image and the second grayscale image based on the connectivity analysis results of the difference image includes: obtaining the geometric features of each connected region in the difference image, and deleting noise interference regions in each connected region based on the geometric features of each connected region; wherein, the geometric features include at least one of area, perimeter, and minimum bounding rectangle.
[0044] Specifically, small regions in the connected region whose geometric features are much smaller than the normal defect size are usually residual noise from the image processing. After deleting these small regions with geometric features smaller than the preset geometric threshold, noise and minor differences unrelated to coating can be further filtered to obtain a clearer and more realistic difference region. Finally, a standard deviation image containing the main difference regions between the coated image and the standard template is obtained, which further improves the matching accuracy between the coated image and the standard template.
[0045] Optionally, in this embodiment of the invention, obtaining the coating quality inspection result of the printed circuit board based on the standard deviation image further includes: mapping each connected region to a corresponding region type based on the contour point set of each connected region; wherein the region type includes coated regions, uncoated regions, and non-associated regions; obtaining the defect type of each connected region based on the feature parameters and region type of each connected region; wherein the feature parameters include shape features and geometric features.
[0046] Specifically, the points on the contour of a connected region form the contour point set of that connected region. This contour point set actually reflects the position coordinates of the connected region. Based on the location of the contour click, each connected region can be mapped to the corresponding region type, that is, it can be determined whether each connected region belongs to a coated region, an uncoated region, or an unrelated region. In addition to the geometric features that reflect the size of the connected region, the feature parameters also include shape features that describe its shape. Based on the feature parameters and region type of the current connected region, the defect type of each connected region can be obtained.
[0047] If the difference area is located in the coated area and has small geometric features and a regular shape (e.g., a circular or rectangular notch), it indicates that there is insufficient coating in that area, meaning the defect type of the difference area is undercoating. If the difference area is located in the uncoated area and has large geometric features (e.g., greater than a preset geometric threshold), it indicates that the defect type of the difference area is overcoating. If the difference area is located in the uncoated area and has small geometric features (e.g., less than or equal to a preset geometric threshold) and an irregular shape (e.g., star-shaped or scattered), resulting in isolated dot-like or sputtering anomalies in the uncoated area, it indicates that the defect type of the difference area is splattering.
[0048] If the difference area is located within the coated area and distributed along the boundary of the coated area, the defect type of the difference area is uneven boundary; if the difference area is located within the coated area and is a circular or elliptical cavity, the defect type of the difference area is air bubble, which may be caused by air bubbles mixed in during the coating process; if the difference area is located within the coated area and is wavy or cracked, the defect type of the difference area is wrinkle, which may be caused by uneven shrinkage due to excessive coating thickness or improper curing conditions.
[0049] If the discrepancy region is located in a non-associated region, further detection of that region can be omitted, reducing computational resource consumption. Thus, based on the feature parameters and region type of each connected region, the detection of various defect types such as under-coating, over-coating, splattering, uneven boundaries, bubbles, and wrinkles is realized, expanding the defect detection range of printed circuit board coating images and further improving the defect detection accuracy of printed circuit board coating images.
[0050] The technical solution of this invention first acquires a first grayscale image corresponding to the coating image of the printed circuit board and a second grayscale image corresponding to the standard template; then, it acquires the difference image between the first and second grayscale images, and performs threshold extraction and morphological processing on the difference image; finally, based on the connectivity analysis results of the difference image, it acquires the standard difference image between the first and second grayscale images. This not only filters out minute noise difference regions through threshold extraction and morphological processing, ensuring the integrity of the difference regions' outlines and improving the positioning accuracy of the difference regions, but also achieves the connection and merging of scattered defect regions through connectivity analysis, ensuring the integrity of the defect regions while reducing the data computation volume of the quality inspection process, greatly improving the difference display accuracy of the difference image.
[0051] Example 2 Figure 2 This is a flowchart of a method for detecting the coating quality of a printed circuit board according to Embodiment 2 of the present invention. The relationship between this embodiment and the above embodiments is that, before obtaining the difference image between the first grayscale image and the second grayscale image, a pre-detection is performed based on the grayscale histogram, such as... Figure 2 As shown, the method specifically includes: S201. Obtain a first grayscale image corresponding to the coating image of the printed circuit board, and a second grayscale image corresponding to the standard template; wherein, the standard template includes a coating area template, an uncoated area template, and an unrelated area template.
[0052] S202. Obtain the first grayscale histogram corresponding to the first grayscale image and the second grayscale histogram corresponding to the second grayscale image.
[0053] After obtaining the first grayscale image and the second grayscale image, their corresponding histograms are obtained, namely the first grayscale histogram and the second grayscale histogram. The grayscale histogram clearly shows the distribution of the number of pixels at different grayscale levels in the image, reflecting the overall brightness and contrast of the image. By examining the grayscale histograms of the two images, it can be preliminarily determined whether the two images are similar in overall grayscale distribution.
[0054] S203. Normalize the first gray-level histogram and the second gray-level histogram, and obtain the correlation coefficient between the first gray-level histogram and the second gray-level histogram based on the normalization result.
[0055] Normalization can eliminate the problem that the absolute values of the histograms of the first and second gray-level histograms cannot be directly compared due to differences in size (i.e., different total number of pixels) or differences in the size of local regions. After normalization, the histogram represents the probability (or frequency) of each gray-level pixel, so that the histograms of different images have a unified comparison benchmark, ensuring the comparability of subsequent correlation analysis results.
[0056] By calculating the similarity between the normalized first gray-level histogram and the second gray-level histogram, the correlation coefficient between the two gray-level histograms is obtained, thereby quantitatively evaluating the similarity between the two images in the overall gray-level distribution trend. The larger the correlation coefficient, the closer the overall brightness distribution of the two images is; the smaller the correlation coefficient, the greater the difference between the two images. The degree of difference between the two images can be determined by using the correlation coefficient and a preset similarity threshold.
[0057] Specifically, the normalized first gray-level histogram can be represented as: The normalized second gray-level histogram can be represented as: ;in, It is grayscale. Probability estimate of occurrence (i.e. probability density); The image has a gray level of 1. The number of pixels; and These are the total number of pixels in the first grayscale histogram and the total number of pixels in the second grayscale histogram, respectively.
[0058] Furthermore, assessing the similarity between the first and second gray-level histograms can be achieved by calculating the correlation between the two histograms, specifically using the following equation: ; in, It is the correlation coefficient, with a value range of [-1, 1]. The closer the correlation coefficient is to 1, the more similar the distribution shapes of the two gray-level histograms are. , They are and The mean; They are and The standard deviation.
[0059] S204. If it is determined that the correlation coefficient is greater than or equal to a preset similarity threshold, obtain the difference image between the first grayscale image and the second grayscale image, and perform threshold extraction processing and morphological processing on the difference image.
[0060] If the correlation coefficient is less than the preset similarity threshold, it indicates that the difference between the first gray-level histogram and the second gray-level histogram is large, and the two do not have a basis for matching. At this time, a prompt message can be issued to guide the inspection personnel to complete the defect detection of the coated image through manual inspection, so as to avoid missed detection and false detection. If the correlation coefficient is greater than or equal to the preset similarity threshold, it indicates that the difference between the first gray-level histogram and the second gray-level histogram is small, and the two have a basis for subsequent pixel-by-pixel comparison. Thus, by calculating the correlation coefficient between the first gray-level histogram and the second gray-level histogram, a rapid judgment of global similarity is achieved, avoiding redundant pixel-by-pixel comparisons of coated images with excessive differences and standard templates, which greatly saves computational resources.
[0061] S205. Based on the connected region processing result of the difference image, obtain the standard difference image between the first grayscale image and the second grayscale image, so as to obtain the coating quality detection result of the printed circuit board based on the standard difference image.
[0062] The technical solution of this invention first obtains a first grayscale histogram corresponding to a first grayscale image and a second grayscale histogram corresponding to a second grayscale image; then, it normalizes the first and second grayscale histograms and obtains the correlation coefficient between them based on the normalization result; finally, if the correlation coefficient is determined to be greater than or equal to a preset similarity threshold, it obtains the difference image between the first and second grayscale images. Thus, by calculating the correlation coefficient between the first and second grayscale histograms, rapid global similarity judgment is achieved, avoiding redundant pixel-by-pixel comparisons of coated images with excessively large differences and standard templates, greatly saving computational resources.
[0063] Example 3 Figure 3 This is a flowchart of a method for detecting the coating quality of a printed circuit board according to Embodiment 3 of the present invention. The relationship between this embodiment and the above embodiments is that, through processing methods such as grayscale histogram, threshold extraction, morphological processing, difference region contouring, connectivity analysis, and noise interference region deletion, a standard difference image between the coated image and the standard template is obtained. Figure 3 As shown, the method specifically includes: S301, Start; Execute S302.
[0064] S302. Obtain the first grayscale image corresponding to the coating image of the printed circuit board and the second grayscale image corresponding to the standard template; execute S303.
[0065] S303. Obtain the first grayscale histogram corresponding to the first grayscale image and the second grayscale histogram corresponding to the second grayscale image; execute S304.
[0066] S304. Normalize the first grayscale histogram and the second grayscale histogram; execute S305.
[0067] S305. Based on the normalization result, obtain the correlation coefficient between the first gray-level histogram and the second gray-level histogram; execute S306.
[0068] S306. Determine whether the correlation coefficient is greater than or equal to a preset similarity threshold; if yes, proceed to S307; if no, proceed to S313.
[0069] S307. Obtain the difference image between the first grayscale image and the second grayscale image; execute S308.
[0070] S308. Perform threshold extraction processing on the difference image; execute S309.
[0071] S309. Perform morphological processing on the difference image; execute S310.
[0072] S310, Perform connectivity analysis on the difference image; execute S311.
[0073] S311. Obtain the geometric features of each connected region in the difference image, and delete the noise interference region in each connected region according to the geometric features of each connected region; execute S312.
[0074] S312. Obtain the standard difference image between the first grayscale image and the second grayscale image, so as to obtain the coating quality inspection result of the printed circuit board based on the standard difference image; execute S313.
[0075] S313, End.
[0076] The technical solution of this invention firstly achieves rapid global similarity judgment by calculating the correlation coefficient between the first gray-level histogram and the second gray-level histogram. Then, through threshold extraction and morphological processing, minute noise difference regions are filtered out, ensuring the integrity of the outline of the difference regions and improving the positioning accuracy of the difference regions. Finally, connectivity analysis is used to connect and merge scattered defect regions, which not only ensures the integrity of the defect regions but also reduces the amount of data calculation in the quality inspection process, greatly improving the difference display accuracy of the difference image.
[0077] Example 4 Figure 4This is a structural block diagram of a printed circuit board coating quality inspection device provided in Embodiment 4 of the present invention. The device specifically includes: The grayscale image acquisition module 401 is used to acquire a first grayscale image corresponding to the coating image of the printed circuit board, and a second grayscale image corresponding to a standard template; wherein, the standard template includes a coating area template, an uncoated area template, and an unrelated area template. The difference image acquisition module 402 is used to acquire the difference image between the first grayscale image and the second grayscale image, and to perform threshold extraction and morphological processing on the difference image; The standard deviation acquisition module 403 is used to acquire the standard deviation image between the first grayscale image and the second grayscale image based on the connectivity analysis results of the difference image.
[0078] The technical solution of this invention first acquires a first grayscale image corresponding to the coating image of the printed circuit board and a second grayscale image corresponding to the standard template; then, it acquires the difference image between the first and second grayscale images, and performs threshold extraction and morphological processing on the difference image; finally, based on the connectivity analysis results of the difference image, it acquires the standard difference image between the first and second grayscale images. This not only filters out minute noise difference regions through threshold extraction and morphological processing, ensuring the integrity of the difference regions' outlines and improving the positioning accuracy of the difference regions, but also achieves the connection and merging of scattered defect regions through connectivity analysis, ensuring the integrity of the defect regions while reducing the data computation volume of the quality inspection process, greatly improving the difference display accuracy of the difference image.
[0079] Optionally, the difference image acquisition module 402 is specifically used to acquire a first gray-level histogram corresponding to the first gray-level image and a second gray-level histogram corresponding to the second gray-level image; normalize the first gray-level histogram and the second gray-level histogram, and obtain the correlation coefficient between the first gray-level histogram and the second gray-level histogram based on the normalization result; if it is determined that the correlation coefficient is greater than or equal to a preset similarity threshold, acquire the difference image between the first gray-level image and the second gray-level image.
[0080] Optionally, the difference image acquisition module 402 is further used to perform morphological opening and morphological closing operations on the difference image after threshold extraction.
[0081] Optionally, the standard difference acquisition module 403 is specifically used to copy the difference image into a comparison difference image and perform an erosion operation on the comparison difference image; perform a difference operation on the difference image and the comparison difference image to obtain the difference region contour based on the difference operation result; and obtain the connectivity analysis result of the difference image based on the difference region contour.
[0082] Optionally, the standard deviation acquisition module 403 is further configured to acquire the geometric features of each connected region in the difference image, and delete the noise interference region in each connected region according to the geometric features of each connected region; wherein, the geometric features include at least one of area, perimeter and minimum bounding rectangle.
[0083] Optionally, the printed circuit board coating quality inspection device is further configured to map each connected region to a corresponding region type based on the contour point set of each connected region; wherein the region type includes coated regions, uncoated regions, and non-associated regions; and to obtain the defect type of each connected region based on the feature parameters and region type of each connected region; wherein the feature parameters include shape features and geometric features.
[0084] The above-described apparatus can execute the coating quality inspection method for printed circuit boards provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects for executing the method. Technical details not described in detail in this embodiment can be found in the coating quality inspection method for printed circuit boards provided in any embodiment of the present invention.
[0085] Example 5 Figure 5 A schematic diagram of an electronic device 10 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, electronic devices, blade electronic devices, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0086] like Figure 5As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0087] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0088] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as the coating quality inspection method for printed circuit boards.
[0089] In some embodiments, the printed circuit board coating quality inspection method can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as a storage unit. In some embodiments, part or all of the computer program can be loaded and / or installed on a heterogeneous hardware accelerator via ROM and / or a communication unit. When the computer program is loaded into RAM and executed by a processor, one or more steps of the printed circuit board coating quality inspection method described above can be performed. Alternatively, in other embodiments, the processor can be configured to perform the printed circuit board coating quality inspection method by any other suitable means (e.g., by means of firmware).
[0090] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0091] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0092] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0093] To provide interaction with a user terminal, the systems and techniques described herein can be implemented on a heterogeneous hardware accelerator, which includes: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user terminal; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user terminal provides input to the heterogeneous hardware accelerator. Other types of devices can also be used to provide interaction with the user terminal; for example, the feedback provided to the user terminal can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or haptic feedback); and input from the user terminal can be received in any form (including sound input, voice input, or haptic input).
[0094] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., client computers with graphical user interfaces or web browsers through which client computers can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0095] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0096] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0097] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for inspecting the coating quality of a printed circuit board, characterized in that, include: A first grayscale image corresponding to the coating image of the printed circuit board and a second grayscale image corresponding to the standard template are obtained; wherein, the standard template includes a coating area template, an uncoated area template and an unrelated area template. Obtain the difference image between the first grayscale image and the second grayscale image, and perform threshold extraction and morphological processing on the difference image; Based on the connectivity analysis results of the difference image, the standard difference image between the first grayscale image and the second grayscale image is obtained, so as to obtain the coating quality detection result of the printed circuit board based on the standard difference image.
2. The method for detecting the coating quality of printed circuit boards according to claim 1, characterized in that, The step of obtaining the difference image between the first grayscale image and the second grayscale image includes: Obtain the first grayscale histogram corresponding to the first grayscale image and the second grayscale histogram corresponding to the second grayscale image; The first gray-level histogram and the second gray-level histogram are normalized, and the correlation coefficient between the first gray-level histogram and the second gray-level histogram is obtained based on the normalization result. If the correlation coefficient is determined to be greater than or equal to a preset similarity threshold, the difference image between the first grayscale image and the second grayscale image is obtained.
3. The method for detecting the coating quality of printed circuit boards according to claim 1, characterized in that, The threshold extraction and morphological processing of the difference image includes: For the difference image after threshold extraction, morphological opening and morphological closing operations are performed sequentially.
4. The method for detecting the coating quality of printed circuit boards according to claim 1, characterized in that, The step of obtaining the standard difference image between the first grayscale image and the second grayscale image based on the connectivity analysis results of the difference image further includes: The difference image is copied as a contrast difference image, and the contrast difference image is subjected to an erosion operation. Perform a difference operation between the difference image and the comparison difference image to obtain the contour of the difference region based on the difference operation result; Based on the contour of the difference region, the connectivity analysis results of the difference image are obtained.
5. The method for detecting the coating quality of printed circuit boards according to claim 1, characterized in that, The step of obtaining the standard difference image between the first grayscale image and the second grayscale image based on the connectivity analysis results of the difference image includes: Obtain the geometric features of each connected region in the difference image, and delete the noise interference region in each connected region according to the geometric features of each connected region; wherein, the geometric features include at least one of area, perimeter and minimum bounding rectangle.
6. The method for detecting the coating quality of printed circuit boards according to claim 1, characterized in that, The step of obtaining the coating quality inspection result of the printed circuit board based on the standard difference image further includes: Based on the contour point set of each connected region, each connected region is mapped to a corresponding region type; wherein, the region type includes coated regions, uncoated regions, and non-associated regions; Based on the feature parameters and region type of each connected region, the defect type of each connected region is obtained; wherein, the feature parameters include shape features and geometric features.
7. A device for inspecting the coating quality of printed circuit boards, characterized in that, include: A grayscale image acquisition module is used to acquire a first grayscale image corresponding to the coating image of the printed circuit board, and a second grayscale image corresponding to a standard template; wherein, the standard template includes a coating area template, an uncoated area template, and an unrelated area template. The difference image acquisition module is used to acquire the difference image between the first grayscale image and the second grayscale image, and to perform threshold extraction and morphological processing on the difference image; The standard deviation acquisition module is used to acquire the standard deviation image between the first grayscale image and the second grayscale image based on the connectivity analysis results of the difference image, so as to acquire the coating quality inspection result of the printed circuit board based on the standard deviation image.
8. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the coating quality inspection method for the printed circuit board according to any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed by a processor, implement the coating quality inspection method for the printed circuit board according to any one of claims 1-6.
10. A computer program product comprising a computer program that, when executed by a processor, implements the coating quality inspection method for a printed circuit board according to any one of claims 1-6.