Metal electroplating surface defect detection method and system
By using a Naive Bayes classifier to classify the image features of electroplated metal parts, the problems of inefficient current detection methods and high computing resource consumption are solved, and automated detection and efficient calculation of metal plating surface defects are realized.
Patent Information
- Application Number
- CN202411875194.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-03-28
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing metal electroplating surface defect detection methods mostly rely on manual detection, are inefficient, and the model structure based on deep learning is complex, and the computing resources are consumed, so it is not suitable for industrial scenarios.
A metal electroplating surface defect detection method is provided, and the image features of the electroplating metal parts are classified using a naive Bayes classifier. The detection methods include obtaining images, cropping, grayscale, compression and expansion processing, and generating image features and inputting them to the naive Bayes classifier for classification.
It realizes automated detection of surface defects of electroplating of metal products, reduces the consumption of computing resources, is suitable for industrial scenarios, and the training data set does not require too many samples to achieve high accuracy.
Smart Images

Figure CN119722642A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of metal detection, and in particular to a metal electroplating surface defect detection method and system. Background Art
[0002] With the development of society, electroplating the surface of metal products is the main method to improve the aesthetics of metal products. It can also improve the corrosion resistance and wear resistance of metal products. After electroplating, the surface of metal products should be bright and uniform. However, some electroplated metal products may have some defects due to some force majeure. Therefore, it is necessary to test the electroplated metal products and select the metal products with defects on the electroplated surface.
[0003] However, most of the existing related detection methods rely on manual inspection and are inefficient. In addition, although the related classification detection model based on deep learning has high accuracy and mobility, the model structure is usually more complex and consumes a lot of computing resources, which is not suitable for the industrial scenario of metal electroplating surface defect detection. Summary of the invention
[0004] In view of the above-mentioned technical deficiencies, the purpose of the present invention is to provide a metal electroplating surface defect detection method and system, aiming to solve the problem that most of the existing related detection methods rely on manual detection and are inefficient, and although the related image classification detection model based on deep learning has high accuracy and mobility, the model structure is usually more complex and consumes a lot of computing resources, which is not suitable for the industrial scenario of metal electroplating surface defect detection.
[0005] In view of the above problems, the present application provides a metal electroplating surface defect detection method and system.
[0006] The first aspect disclosed in the present application provides a method for detecting defects on a metal electroplating surface, the method comprising the following steps: Step 1: Obtain an image of the electroplated metal part to be inspected against a solid color background, crop, grayscale and compress the image to generate an image to be inspected with a resolution of n×n, where n is the height and width of the image to be inspected; Step 2: Perform an expansion operation on the image to be detected with a resolution of n×n to generate a 2 An image feature composed of independent pixel data, wherein each independent pixel data is the value of the pixel gray value; Step 3: 2 The image features composed of independent pixel data are input into the trained naive Bayes classifier to perform classification calculations to determine the category to which the electroplated metal part to be inspected belongs, wherein the category includes the presence of surface defects and the absence of surface defects.
[0007] Preferably, the step 1 specifically includes the following steps: Step 1.1: Obtain an image of the electroplated metal part to be inspected against a solid color background, increase the brightness and contrast of the image by 25% respectively, and generate an enhanced image; Step 1.2: Crop the enhanced image to generate a cropped image with equal height and width, and grayscale the cropped image to generate a grayscale image; Step 1.3: Establish a sliding window with a height and width of w to compress the grayscale image and generate a detection image with a resolution of n×n, where the value of w is the height of the grayscale image divided by n and rounded up. The sliding window starts from the upper left corner of the grayscale image and moves from left to right and from top to bottom. The offset of each movement is w. Each time the sliding window moves to a new position, the average grayscale value of the pixel in the sliding window is calculated, and the average grayscale value of the pixel in the sliding window is replaced by the average.
[0008] Preferably, the step 2 specifically includes the following steps: Arrange all pixel data of the image to be detected with a resolution of n×n in sequence from left to right and from top to bottom to generate n sequentially arranged 2 Independent pixel data, as n 2 The image feature is composed of independent pixel data, where each independent pixel data is composed of grayscale values, and the grayscale value range is greater than or equal to 0 and less than or equal to 255.
[0009] Preferably, the training step of the naive Bayes classifier in step 3 includes: Acquire images of 1000 electroplated metal parts against a solid color background to generate a first data set, wherein the 1000 electroplated metal parts include electroplated metal parts with surface defects and electroplated metal parts without surface defects; The images of 1000 electroplated metal parts on a solid color background included in the first data set are respectively subjected to the same cropping, graying and compression processing as in step 1 to generate a second data set; The same expansion operation as step 2 is performed on the 1000 images of electroplated metal parts on a solid color background that have been cropped, grayed, and compressed in the second data set to generate 1000 sets of image features. Each set of image features consists of n 2 The 1000 sets of image features are composed of independent pixel data, and the 1000 sets of image features are used as the electroplated metal parts data set; For the image features of all electroplated metal parts with surface defects in the electroplated metal parts data set, the average value of each independent pixel data of the image features of the electroplated metal parts with surface defects is calculated. and variance , where t is used to indicate the presence of surface defects, i=1,2,...,n 2 , used to represent the i-th independent pixel data; For all the image features of electroplated metal parts without surface defects in the electroplated metal parts data set, the average value of each independent pixel data of the image features of the electroplated metal parts without surface defects is calculated. and variance , as the parameters of the naive Bayes classifier for the absence of surface defects, where f is used to indicate the absence of surface defects.
[0010] Preferably, the step 3 specifically includes the following steps: Step 3.1: Calculate and generate the prior probability of the presence of surface defects and the prior probability of the absence of surface defects, where the prior probability of the presence of surface defects is the proportion of electroplated metal parts with surface defects in the electroplated metal parts data set, and the prior probability of the absence of surface defects is the proportion of electroplated metal parts without surface defects in the electroplated metal parts data set; Step 3.2: Set n 2 The image feature composed of independent pixel data is used as input to complete the training of the naive Bayes classifier, and the probability of the existence of surface defects is calculated using formula (1), where: Used to indicate the probability of the presence of surface defects, Used to express the prior probability of the presence of surface defects, Used to represent the i-th independent pixel data, is used to express the conditional probability given the presence of surface defects, and : Formula (1); Step 3.3: Set n 2 The image feature composed of independent pixel data is used as input to complete the training of the naive Bayes classifier, and the probability of no surface defects is calculated using formula (2), where: Used to express the probability of no surface defects, Used to express the prior probability of the absence of surface defects, Used to represent the i-th independent pixel data, is used to represent the conditional probability that there are no surface defects, and : Formula (2); Step 3.4: When Greater than or equal to When the electroplated metal parts to be inspected belong to the category of surface defects, Less than When the electroplated metal part to be inspected belongs to the category of no surface defects.
[0011] The second aspect disclosed in the present application provides a metal electroplating surface defect detection system, the system is used for the above-mentioned metal electroplating surface defect detection method, the system comprises: A preprocessing module, the preprocessing module is used to obtain an image of the electroplated metal part to be detected under a solid color background, crop, grayscale and compress the image to generate an image to be detected with a resolution of n×n, where n is the height and width of the image to be detected; A processing module is used to perform an expansion operation on the image to be detected with a resolution of n×n to generate a 2 An image feature composed of independent pixel data, where each independent pixel data consists of a grayscale value; A detection module is used to detect 2 The image features composed of independent pixel data are input into the trained naive Bayes classifier to perform classification calculations to determine the category to which the electroplated metal part to be inspected belongs, wherein the category includes the presence of surface defects and the absence of surface defects.
[0012] The third aspect disclosed in the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned metal electroplating surface defect detection method when executing the computer program.
[0013] The fourth aspect disclosed in the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the above-mentioned method for detecting surface defects of metal electroplating are implemented.
[0014] The fifth aspect disclosed in the present application provides a computer program product, including a computer program or instructions, which, when executed by a processor, implement the steps of the above-mentioned metal electroplating surface defect detection method.
[0015] The beneficial effects of the present invention are: (1) A metal electroplating surface defect detection method and system are provided to realize automatic detection of the electroplated surface of metal products, solving the problem that most existing related detection methods rely on manual detection and are inefficient.
[0016] (2) The naive Bayes classifier in traditional machine learning is used to detect defects on the surface of electroplated metal products without consuming too much computing resources, which is suitable for industrial scenarios.
[0017] (3) The data set used in training the naive Bayes classifier does not need to include too many training samples to achieve a relatively high accuracy and is easy to construct. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 The present invention is an overall flow chart of a metal electroplating surface defect detection method.
[0020] Figure 2 This is an overall structural diagram of a metal electroplating surface defect detection system. DETAILED DESCRIPTION
[0021] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0022] like Figure 1 As shown, the embodiment of the present application provides a method for detecting metal electroplating surface defects, the method comprising the following steps: Step 1: Obtain an image of the electroplated metal part to be inspected against a solid color background, crop, grayscale and compress the image to generate an image to be inspected with a resolution of n×n, where n is the height and width of the image to be inspected; Step 2: Perform an expansion operation on the image to be detected with a resolution of n×n to generate a 2 An image feature composed of independent pixel data, wherein each independent pixel data is the value of the pixel gray value; Step 3: 2 The image features composed of independent pixel data are input into the trained naive Bayes classifier to perform classification calculations to determine the category to which the electroplated metal part to be inspected belongs, wherein the category includes the presence of surface defects and the absence of surface defects.
[0023] Furthermore, the step 1 specifically includes the following steps: Step 1.1: Obtain an image of the electroplated metal part to be inspected against a solid color background, increase the brightness and contrast of the image by 25% respectively, and generate an enhanced image; Step 1.2: Crop the enhanced image to generate a cropped image with equal height and width, and grayscale the cropped image to generate a grayscale image; Step 1.3: Establish a sliding window with a height and width of w to compress the grayscale image and generate a detection image with a resolution of n×n, where the value of w is the height of the grayscale image divided by n and rounded up. The sliding window starts from the upper left corner of the grayscale image and moves from left to right and from top to bottom. The offset of each movement is w. Each time the sliding window moves to a new position, the average grayscale value of the pixel in the sliding window is calculated, and the average grayscale value of the pixel in the sliding window is replaced by the average.
[0024] Furthermore, the step 2 specifically includes the following steps: Arrange all pixel data of the image to be detected with a resolution of n×n in sequence from left to right and from top to bottom to generate n sequentially arranged 2 Independent pixel data, as n 2 The image feature is composed of independent pixel data, where each independent pixel data is composed of grayscale values, and the grayscale value range is greater than or equal to 0 and less than or equal to 255.
[0025] Furthermore, the training steps of the naive Bayes classifier in step 3 include: Acquire images of 1000 electroplated metal parts against a solid color background to generate a first data set, wherein the 1000 electroplated metal parts include electroplated metal parts with surface defects and electroplated metal parts without surface defects; The images of 1000 electroplated metal parts on a solid color background included in the first data set are respectively subjected to the same cropping, graying and compression processing as in step 1 to generate a second data set; The same expansion operation as step 2 is performed on the 1000 images of electroplated metal parts on a solid color background that have been cropped, grayed, and compressed in the second data set to generate 1000 sets of image features. Each set of image features consists of n 2 The 1000 sets of image features are composed of independent pixel data, and the 1000 sets of image features are used as the electroplated metal parts data set; For all the image features of electroplated metal parts with surface defects in the electroplated metal parts data set, the average value of each independent pixel data of the image features of the electroplated metal parts with surface defects is calculated. and variance , where t is used to indicate the presence of surface defects, i=1,2,...,n 2 , used to represent the i-th independent pixel data; For all the image features of electroplated metal parts without surface defects in the electroplated metal parts data set, the average value of each independent pixel data of the image features of the electroplated metal parts without surface defects is calculated. and variance , as the parameters of the naive Bayes classifier for the absence of surface defects, where f is used to indicate the absence of surface defects.
[0026] Furthermore, the step 3 specifically includes the following steps: Step 3.1: Calculate and generate the prior probability of the presence of surface defects and the prior probability of the absence of surface defects, where the prior probability of the presence of surface defects is the proportion of electroplated metal parts with surface defects in the electroplated metal parts data set, and the prior probability of the absence of surface defects is the proportion of electroplated metal parts without surface defects in the electroplated metal parts data set; Step 3.2: Set n 2 The image feature composed of independent pixel data is used as input to complete the training of the naive Bayes classifier, and the probability of the existence of surface defects is calculated using formula (1), where: Used to indicate the probability of the presence of surface defects, Used to express the prior probability of the presence of surface defects, Used to represent the i-th independent pixel data, is used to express the conditional probability given the presence of surface defects, and : Formula (1); Step 3.3: Set n 2 The image feature composed of independent pixel data is used as input to complete the training of the naive Bayes classifier, and the probability of no surface defects is calculated using formula (2), where: Used to express the probability of no surface defects, Used to express the prior probability of the absence of surface defects, Used to represent the i-th independent pixel data, is used to represent the conditional probability that there are no surface defects, and : Formula (2); Step 3.4: When Greater than or equal to When the electroplated metal parts to be inspected belong to the category of surface defects, Less than When the electroplated metal part to be inspected belongs to the category of no surface defects.
[0027] In summary, the metal electroplating surface defect detection method provided by the embodiment of the present application has the following technical effects: (1) A metal electroplating surface defect detection method and system are provided to realize automatic detection of the electroplated surface of metal products, solving the problem that most existing related detection methods rely on manual detection and are inefficient.
[0028] (2) The naive Bayes classifier in traditional machine learning is used to detect defects on the surface of electroplated metal products without consuming too much computing resources, which is suitable for industrial scenarios.
[0029] (3) The data set used in training the naive Bayes classifier does not need to include too many training samples to achieve a relatively high accuracy and is easy to construct.
[0030] Based on the same inventive concept as the metal electroplating surface defect detection method in the above-mentioned embodiment, Figure 2 As shown, the present application provides a metal electroplating surface defect detection system, the system comprising: A preprocessing module, the preprocessing module is used to obtain an image of the electroplated metal part to be detected under a solid color background, crop, grayscale and compress the image to generate an image to be detected with a resolution of n×n, where n is the height and width of the image to be detected; A processing module is used to perform an expansion operation on the image to be detected with a resolution of n×n to generate a 2 An image feature composed of independent pixel data, where each independent pixel data consists of a grayscale value; A detection module is used to detect 2 The image features composed of independent pixel data are input into the trained naive Bayes classifier to perform classification calculations to determine the category to which the electroplated metal part to be inspected belongs, wherein the category includes the presence of surface defects and the absence of surface defects.
[0031] Through the above-mentioned detailed description of a metal electroplating surface defect detection method in this specification, those skilled in the art can clearly understand a metal electroplating surface defect detection system in this embodiment. Since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0032] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned metal electroplating surface defect detection method when executing the computer program.
[0033] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned metal electroplating surface defect detection method are implemented.
[0034] In one embodiment, a computer program product is provided, including a computer program or instructions, which implement the steps of the above-mentioned metal electroplating surface defect detection method when executed by a processor.
[0035] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0036] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for detecting defects on a metal electroplating surface, characterized in that: The method comprises the following steps: Step 1: Obtain an image of the electroplated metal part to be inspected against a solid color background, crop, grayscale and compress the image to generate an image to be inspected with a resolution of n×n, where n is the height and width of the image to be inspected; Step 2: Perform an expansion operation on the image to be detected with a resolution of n×n to generate a 2 An image feature composed of independent pixel data, wherein each independent pixel data is the value of the pixel gray value; Step 3: 2 The image features composed of independent pixel data are input into the trained naive Bayes classifier to perform classification calculations to determine the category to which the electroplated metal part to be inspected belongs, wherein the category includes the presence of surface defects and the absence of surface defects.
2. A method for detecting metal electroplating surface defects as claimed in claim 1, characterized in that: The step 1 specifically comprises the following steps: Step 1.1: Obtain an image of the electroplated metal part to be inspected against a solid color background, increase the brightness and contrast of the image by 25% respectively, and generate an enhanced image; Step 1.2: Crop the enhanced image to generate a cropped image with equal height and width, and grayscale the cropped image to generate a grayscale image; Step 1.3: Establish a sliding window with a height and width of w to compress the grayscale image and generate a detection image with a resolution of n×n, where the value of w is the height of the grayscale image divided by n and rounded up. The sliding window starts from the upper left corner of the grayscale image and moves from left to right and from top to bottom. The offset of each movement is w. Each time the sliding window moves to a new position, the average grayscale value of the pixel in the sliding window is calculated, and the average grayscale value of the pixel in the sliding window is replaced by the average.
3. A method for detecting metal electroplating surface defects as claimed in claim 1, characterized in that: The step 2 specifically includes the following steps: Arrange all pixel data of the image to be detected with a resolution of n×n in sequence from left to right and from top to bottom to generate n sequentially arranged 2 Independent pixel data, as n 2 The image feature is composed of independent pixel data, where each independent pixel data is composed of grayscale values, and the range of grayscale values is greater than or equal to 0 and less than or equal to 255.
4. A method for detecting metal electroplating surface defects as claimed in claim 1, characterized in that: The training steps of the naive Bayes classifier in step 3 include: Acquire images of 1000 electroplated metal parts against a solid color background to generate a first data set, wherein the 1000 electroplated metal parts include electroplated metal parts with surface defects and electroplated metal parts without surface defects; The images of 1000 electroplated metal parts on a solid color background included in the first data set are respectively subjected to the same cropping, graying and compression processing as in step 1 to generate a second data set; The same expansion operation as step 2 is performed on the 1000 images of electroplated metal parts on a solid color background that have been cropped, grayed, and compressed in the second data set to generate 1000 sets of image features. Each set of image features consists of n 2 The 1000 sets of image features are composed of independent pixel data, and the 1000 sets of image features are used as the electroplated metal parts data set; For the image features of all electroplated metal parts with surface defects in the electroplated metal parts data set, the average value of each independent pixel data of the image features of the electroplated metal parts with surface defects is calculated. and variance , where t is used to indicate the presence of surface defects, i=1,2,...,n 2 , used to represent the i-th independent pixel data; For all the image features of electroplated metal parts without surface defects in the electroplated metal parts data set, the average value of each independent pixel data of the image features of the electroplated metal parts without surface defects is calculated. and variance , as the parameters of the naive Bayes classifier for the absence of surface defects, where f is used to indicate the absence of surface defects.
5. A method for detecting metal electroplating surface defects as claimed in claim 4, characterized in that: The step 3 specifically comprises the following steps: Step 3.1: Calculate and generate the prior probability of the presence of surface defects and the prior probability of the absence of surface defects, where the prior probability of the presence of surface defects is the proportion of electroplated metal parts with surface defects in the electroplated metal parts data set, and the prior probability of the absence of surface defects is the proportion of electroplated metal parts without surface defects in the electroplated metal parts data set; Step 3.2: Set n 2 The image feature composed of independent pixel data is used as input to complete the training of the naive Bayes classifier, and the probability of the existence of surface defects is calculated using formula (1), where: Used to indicate the probability of the presence of surface defects, Used to express the prior probability of the presence of surface defects, Used to represent the i-th independent pixel data, is used to express the conditional probability given the presence of surface defects, and : Formula (1); Step 3.3: Set n 2 The image feature composed of independent pixel data is used as input to complete the training of the naive Bayes classifier, and the probability of no surface defects is calculated using formula (2), where: Used to express the probability of no surface defects, Used to express the prior probability of the absence of surface defects, Used to represent the i-th independent pixel data, is used to represent the conditional probability that there are no surface defects, and : Formula (2); Step 3.4: When Greater than or equal to When the electroplated metal parts to be inspected belong to the category of surface defects, Less than When the electroplated metal part to be inspected belongs to the category of no surface defects.
6. A metal electroplating surface defect detection system, the system comprising: A preprocessing module, the preprocessing module is used to obtain an image of the electroplated metal part to be detected under a solid color background, crop, grayscale and compress the image to generate an image to be detected with a resolution of n×n, where n is the height and width of the image to be detected; A processing module is used to perform an expansion operation on the image to be detected with a resolution of n×n to generate a 2 An image feature composed of independent pixel data, where each independent pixel data consists of a grayscale value; A detection module is used to detect 2 The image features composed of independent pixel data are input into the trained naive Bayes classifier to perform classification calculations to determine the category to which the electroplated metal part to be inspected belongs, wherein the category includes the presence of surface defects and the absence of surface defects.
7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of a metal electroplating surface defect detection method described in any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of a metal electroplating surface defect detection method described in any one of claims 1 to 5 are implemented.
9. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps of a metal electroplating surface defect detection method described in any one of claims 1 to 5 are implemented.
Citation Information
Cited By
Injection-molded electroplated part surface defect detection method based on machine vision
CN122290098A