Watch bottom cover defect inspection method and system based on machine vision
Through the machine vision-based defect inspection method of watch bottom cover, the problems of noise interference and defect information loss of traditional detection methods are solved, and more accurate and complete defect detection is achieved, improving the reliability of defect inspection.
Patent Information
- Application Number
- CN202510194572.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-21
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2045-02-21
AI Technical Summary
When traditional edge detection algorithms detect defects in the watch bottom cover, the threshold setting is too low, resulting in serious noise interference, and denoising will lose defect information, resulting in poor detection effect.
Using the machine vision-based defect inspection method for watch bottom cover, we obtain grayscale images, and obtain multiple edge images based on the iteration order of threshold drop, calculate the noise factor and defect factor of each edge pixel point, identify suspected defect lines and transition lines, evaluate the degree of connection and the possibility of the same defect, give each edge pixel point defect weight, and finally perform defect detection.
By extracting edge information at different levels, evaluating the noise and defect degree of edge pixel points, identifying potential defect areas, improving the accuracy and completeness of defect detection, reducing noise interference, and enhancing the reliability of defect inspection.
Smart Images

Figure CN119672026B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of defect inspection, and in particular to a method and system for inspecting defect of a watch bottom cover based on machine vision. Background Art
[0002] With the development of the watch manufacturing industry, consumers have an increasing demand for the appearance quality of watch bottom covers. Among them, the watch bottom cover is a key component of the watch. Whether there are defects on its surface will have a great impact on the product's appearance quality and market competitiveness.
[0003] In the prior art, the traditional method of detecting defects in the bottom cover of a watch is to use an edge detection algorithm. However, since the defects in the bottom cover of the watch are extremely inconspicuous, the threshold of the edge detection algorithm is set extremely low, resulting in the detection result being seriously interfered by noise. Similarly, since the defects are extremely inconspicuous, a large amount of defect information will be lost if denoising is performed. Therefore, the traditional detection method cannot accurately obtain the defects in the bottom cover of the watch, and the defect inspection effect is poor. Summary of the invention
[0004] In order to solve the technical problem that the traditional detection means cannot accurately obtain the defects in the bottom cover of the watch, and the defect detection effect is poor, the purpose of the present invention is to provide a method and system for defect detection of the bottom cover of the watch based on machine vision, and the technical scheme adopted is as follows:
[0005] The present invention proposes a method for inspecting defects on a watch bottom cover based on machine vision, the method comprising:
[0006] Get the grayscale image of the watch bottom cover;
[0007] Based on the threshold descent iteration sequence, multiple edge images corresponding to the grayscale image are obtained; for any edge image, the noise factor of each edge pixel is obtained according to the relative distance distribution between different edge pixels in the neighborhood of each edge pixel; the defect factor of each edge pixel on each edge image is obtained according to the gradient change characteristics of the edge pixel in the local range of the same position between different edge images and the noise factor;
[0008] According to the position distribution of edge pixels on the first edge image, multiple suspected defect lines are obtained, and transition lines between the suspected defect lines are obtained; according to the gradient direction of the pixels between the two suspected defect lines and the relative distribution characteristics of the transition lines, the degree of connection between the two suspected defect lines is obtained; according to the position distribution, corresponding defect factors and degree of connection of the difference edge pixels between different edge images and the transition lines between the two suspected defect lines, the possibility of the same defect between the two suspected defect lines is obtained; according to the relative distance between each edge pixel and different transition lines on each edge image, and the possibility of the same defect between the two suspected defect lines, the defect weight of each edge pixel on each edge image is obtained;
[0009] According to the defect weights of different edge pixels in the local range of each edge pixel on the last edge image and the grayscale distribution, the defect possibility of each edge pixel on the last edge image is obtained;
[0010] Defect detection is performed based on the defect probability.
[0011] Furthermore, the method for obtaining the edge image includes:
[0012] Based on the threshold descent iterative sequence, the sobel operator is used to detect the grayscale image and obtain the corresponding multiple edge images.
[0013] Furthermore, the method for obtaining the noise factor includes:
[0014] The noise factor is obtained according to the noise factor acquisition formula. For each edge image, the noise factor acquisition formula is expressed as:
[0015] ;in, Indicates Noise factor of edge pixels; Indicates The variance of the relative distance between an edge pixel and other edge pixels in the neighborhood; Indicates The edge pixel and the The relative distance between other edge pixels; Indicates the number of other edge pixels in the neighborhood; Indicates The edge pixel in the neighborhood of other edge pixels and the The relative distance between other edge pixels; represents the logistic function; Indicates taking the absolute value.
[0016] Furthermore, the method for obtaining the defect factor includes:
[0017] Obtain the cosine value of the angle between each edge pixel point on each edge image and each edge pixel point in the local range as the gradient direction similarity;
[0018] Obtaining the ratio between the gradient direction similarity and the noise factor corresponding to different edge pixel points in the local range and accumulating them as the first accumulated value;
[0019] Obtain the difference between the first accumulated value in the local range corresponding to the same position between each subsequent edge image and each edge image as the first difference; accumulate the first difference values of all subsequent edge images as the defect factor of each edge pixel on each edge image.
[0020] Further, the step of obtaining a plurality of suspected defect lines and obtaining transition lines between the suspected defect lines includes:
[0021] For the first edge image, other edge pixels within the 8-neighborhood range of each edge pixel are obtained as similar pixels; all similar pixels of each edge pixel are obtained to form a suspected defect line;
[0022] The relative distance between the corresponding edge pixel points of the two suspected defect lines is obtained, the one with the smallest relative distance is selected, and the corresponding edge pixel points are connected to form a transition line between the two suspected defect lines.
[0023] Furthermore, the method for obtaining the degree of connection includes:
[0024] Obtain the mean value of the gradient direction of all pixels on each suspected defect line as the overall gradient direction on each suspected defect line;
[0025] Obtain the cosine value of the angle between the overall direction of the gradient of the two suspected defect lines as the first connection coefficient; obtain the average value of the angle between the gradient direction of the two suspected defect lines and the transition line, and calculate the cosine value of the average angle as the second connection coefficient;
[0026] The product of the first connection coefficient and the second connection coefficient is obtained, and the product result is compared with the relative distance corresponding to the transition line to obtain the connection degree between the two suspected defect lines.
[0027] Furthermore, the method for obtaining the probability of the same defect includes:
[0028] Compare the difference of edge pixel points between each other edge image and the first edge image to obtain the difference edge pixel points on each other edge image;
[0029] According to the relative distance between different difference edge pixels and transition lines on all other edge images, the defect factor and the degree of connection between the two corresponding suspected defect lines, the possibility of the same defect between the two suspected defect lines is obtained. The relative distance between the difference edge pixels and the transition line is negatively correlated with the possibility of the same defect, and the defect factor and the degree of connection between the two corresponding suspected defect lines are positively correlated with the possibility of the same defect.
[0030] Furthermore, the method for obtaining the defect weight includes:
[0031] For any edge image, the defect weight of each edge pixel is obtained according to the relative distance between each edge pixel and each transition line, and the possibility of the same defect between the two suspected defect lines where each transition line is located. The relative distance between each edge pixel and each transition line is negatively correlated with the defect weight, and the possibility of the same defect between the two suspected defect lines where each transition line is located is positively correlated with the defect weight.
[0032] Furthermore, the method for obtaining the defect possibility of each edge pixel point includes:
[0033] For the last edge image, the difference accumulated value of the grayscale value between each other edge pixel and different other edge pixels in the local range of each edge pixel is obtained as the grayscale difference level;
[0034] According to the defect weights and grayscale difference levels of different edge pixels in the local range of each edge pixel, the defect possibility of each edge pixel is obtained. The defect weight is positively correlated with the defect possibility, and the grayscale difference level is negatively correlated with the defect possibility.
[0035] The present invention also proposes a watch bottom cover defect inspection system based on machine vision, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements any one of the steps of the watch bottom cover defect inspection method based on machine vision.
[0036] The present invention has the following beneficial effects:
[0037] The present invention obtains multiple edge images corresponding to the grayscale image in sequence based on the threshold descent iteration, which is helpful to extract edge information at different levels and capture subtle edge features in the image; for any edge image, the noise factor of each edge pixel is obtained according to the relative distance distribution between different edge pixels in the neighborhood of each edge pixel, which is helpful to evaluate the noise level of the edge pixel; according to the gradient change characteristics of the edge pixel in the local range of the same position between different edge images, and the noise factor, the defect factor of each edge pixel on each edge image is obtained, and the defect degree of the edge pixel is more accurately evaluated; according to the position distribution of the edge pixel on the first edge image, multiple suspected defect lines are obtained, and the transition lines between the suspected defect lines are obtained, so as to have a deeper understanding of the morphology and characteristics of the defect area and identify the potential defect area; according to the gradient direction of the pixels between two suspected defect lines and the relative distribution characteristics of the transition lines, two suspected defect lines are obtained. The degree of connection between suspected defect lines helps to evaluate the tightness of connection between suspected defect lines; according to the position distribution of the difference edge pixels between different edge images and the transition line between two suspected defect lines, the corresponding defect factor and the degree of connection, the possibility of the same defect between the two suspected defect lines is obtained, which improves the integrity of defect identification and can more comprehensively identify the defect area; according to the relative distance between each edge pixel and different transition lines on each edge image, and the possibility of the same defect between the two suspected defect lines, the defect weight of each edge pixel on each edge image is obtained, which helps to highlight the defect area and reduce the influence of the non-defect area; according to the defect weights of different edge pixels in the local range of each edge pixel on the last edge image, and the grayscale distribution, the defect possibility of each edge pixel on the last edge image is obtained, which improves the reliability and accuracy of defect detection and can more accurately identify the defect area; defect detection is performed. The present invention improves the accuracy of defect inspection by obtaining the accurate defect possibility of each edge pixel. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are 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.
[0039] Figure 1 A flowchart of a method for inspecting watch bottom cover defects based on machine vision provided by one embodiment of the present invention;
[0040] Figure 2A flow chart of a method for obtaining a defect factor provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0041] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of a watch bottom cover defect inspection method and system based on machine vision proposed by the present invention, its specific implementation, structure, features and effects, in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.
[0042] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0043] The following is a detailed description of a watch bottom cover defect inspection method and system based on machine vision provided by the present invention in conjunction with the accompanying drawings.
[0044] See also Figure 1 , which shows a method flow chart of a method for inspecting watch bottom cover defects based on machine vision provided by an embodiment of the present invention, specifically comprising:
[0045] Step S1: Acquire a grayscale image of the bottom cover of the watch.
[0046] In the embodiment of the present invention, in order to ensure the quality of the watch appearance, the watch bottom cover needs to be inspected for defects; first, the surface image of the watch bottom cover is obtained by an industrial camera. It should be noted that the processing method for each watch bottom cover is the same, which will not be described in detail here. Only the surface image of a watch cover is used as an example in the following.
[0047] In one embodiment of the present invention, in order to facilitate the subsequent image processing process, the surface image of the captured watch bottom cover is preprocessed to enhance the image quality, and then the processed image is analyzed. It should be noted that the image preprocessing operation is a technical means well known to those skilled in the art, and can be specifically set according to the specific implementation scenario. In one embodiment of the present invention, a grayscale algorithm is used to obtain a grayscale image of the watch bottom cover, highlighting the local brightness and changes caused by defects in the watch bottom cover, as well as the contours and details of the image, so that the image is clearer and easier to perform operations such as feature extraction and image recognition; the specific grayscale algorithms are all technical means well known to those skilled in the art, and will not be described in detail here.
[0048] Step S2: obtaining multiple edge images corresponding to the grayscale image in sequence based on the threshold descent iteration; for any edge image, obtaining the noise factor of each edge pixel according to the relative distance distribution between different edge pixels in the neighborhood of each edge pixel; obtaining the defect factor of each edge pixel on each edge image according to the gradient change characteristics of the edge pixel in the local range of the same position between different edge images and the noise factor.
[0049] Since the defects in the bottom cover of a watch are usually very shallow, when detecting the defects in the bottom cover, the threshold is set very low to identify the defects, but if it is too low, the noise of the bottom cover of the watch will be identified; by continuously adjusting the threshold, the edge information in the image can be gradually refined, edge images of different fineness can be obtained, and the information in the image can be understood more comprehensively; based on the threshold descent iterative sequence, multiple edge images corresponding to the grayscale image are obtained.
[0050] Preferably, in one embodiment of the present invention, the method for acquiring the edge image includes:
[0051] Based on the threshold descent iterative sequence, the sobel operator is used to detect the grayscale image and obtain the corresponding multiple edge images.
[0052] It should be noted that, in one embodiment of the present invention, the threshold descent iteration sequence starts with a preset starting threshold, and each descent iteration obtains the next threshold until the termination threshold is reached, thereby obtaining multiple edge images; wherein, the preset starting threshold is 20, the termination threshold is 5, and the step length of each descent iteration is 1; in other embodiments of the present invention, the preset starting threshold, termination threshold and iteration step length may be set according to specific circumstances, and are not limited or elaborated herein.
[0053] It should be noted that the specific Sobel operator is a technical means well known to those skilled in the art and will not be described in detail here.
[0054] Since the defect in the watch bottom cover is caused by an accidental collision during the production of the watch bottom cover, the pixel points corresponding to the defect are presented in a continuous form in the image, while the noise is randomly distributed in various positions in the image with relatively discrete distances. By analyzing the relative distance distribution between different edge pixels, the distribution characteristics between pixels can be reflected, which is helpful to evaluate the noise performance of pixels. For any edge image, the noise factor of each edge pixel is obtained according to the relative distance distribution between different edge pixels in the neighborhood of each edge pixel.
[0055] Preferably, in one embodiment of the present invention, the method for obtaining the noise factor includes:
[0056] The noise factor is obtained according to the noise factor acquisition formula. For each edge image, the noise factor acquisition formula is expressed as:
[0057] ;
[0058] in, Indicates Noise factor of edge pixels; Indicates The variance of the relative distance between an edge pixel and other edge pixels in the neighborhood; Indicates The edge pixel and the The relative distance between other edge pixels; Indicates the number of other edge pixels in the neighborhood; Indicates The edge pixel in the neighborhood of other edge pixels and the The relative distance between other edge pixels; represents the logistic function; Indicates taking the absolute value.
[0059] In the formulation of noise factor acquisition, Indicates The average relative distance between the edge pixel and different edge pixels in the neighborhood reflects the The average distance between an edge pixel and other pixels in the neighborhood. The larger the relative distance mean, the greater the average distance, and the less close the pixels are. Indicates The mean of the relative distances between different edge pixels in the neighborhood of an edge pixel reflects the general distance between other pixels in the domain. The larger the mean, the greater the general distance between other pixels, and the less close the pixels are. Reflect the The average distance between an edge pixel and other pixels in the neighborhood range deviates from the general distance between other pixels in the domain range. The less close the distance is, the more discrete the distribution is, and the more likely it is a noise pixel. Indicates The variance of the relative distance between an edge pixel and other edge pixels in the neighborhood. The larger the variance, the more discrete the relative distance distribution, the more likely it is a noise pixel, and the larger the noise factor.
[0060] It should be noted that, in one embodiment of the present invention, the relative distance is obtained by calculating the Euclidean distance between pixel points; in other embodiments of the present invention, it can also be obtained by calculating the Manhattan distance; the specific Euclidean distance and Manhattan distance are technical means well known to those skilled in the art and will not be elaborated here.
[0061] It should be noted that, in one embodiment of the present invention, the neighborhood range is based on each edge pixel point and is composed of the 10 edge pixel points with the closest relative distance to other edge pixel points; in other embodiments of the present invention, the size of the neighborhood range can be set according to the specific circumstances, and is not limited or elaborated here.
[0062] As the edge detection threshold continues to decrease, subsequent edge images will relatively identify more and more edge pixels, and edge pixels corresponding to the same defect are more likely to be identified. By analyzing the gradient change characteristics of edge pixels in the local range of edge pixels at the same position, the direction and trend of edge pixels are reflected, which helps to evaluate the degree of defect of edge pixels. The larger the noise factor, the more likely the edge pixel is a noise point and the smaller the defect factor. According to the gradient change characteristics of edge pixels in the local range of the same position between different edge images and the noise factor, the defect factor of each edge pixel on each edge image is obtained.
[0063] Preferably, in one embodiment of the present invention, the method for obtaining the defect factor is as follows: Figure 2 , which shows a flow chart of a method for obtaining a defect factor, including:
[0064] Step S201: obtaining the cosine value of the angle in the gradient direction between each edge pixel point on each edge image and each edge pixel point in the local range as the gradient direction similarity.
[0065] Since the defect on the bottom cover of the watch is caused by an accidental collision, the defect may appear in a relatively uniform or regular manner. The pixels of the same defect in the local range of the defect have similar gradient directions. The similarity between the gradient directions of the pixel points is reflected by calculating the cosine value of the angle between the gradient directions of the pixel points. The larger the cosine value of the angle, the more similar the gradient directions are, and the more likely they are to belong to the same edge.
[0066] It should be noted that, in one embodiment of the present invention, the size of the local range is centered on each edge pixel point and constructs a 10×10 range with other edge pixels; in other embodiments of the present invention, the size of the local range can be set according to specific circumstances, and is not limited or elaborated here.
[0067] Step S202: Obtain the ratio between the gradient direction similarity and the noise factor corresponding to different edge pixels in the local range and add them up as a first accumulated value.
[0068] The ratio reflects the relative strength of the directional consistency of edge pixels under the influence of noise; the greater the similarity of the gradient direction, the greater the possibility that the pixels belong to the same edge; the larger the noise factor, the greater the possibility that the pixels appear as noise; the smaller the first accumulated value, the more likely it is noise.
[0069] Step S203: Obtain the difference between the first accumulated value in the local range corresponding to the same position between each subsequent edge image and each edge image as the first difference; accumulate the first difference values of all subsequent edge images as the defect factor of each edge pixel on each edge image.
[0070] As the threshold continues to decrease, more pixels exist in each subsequent edge image. By calculating the difference in the first accumulated values between different edge images, the difference in the direction consistency of edge pixels in different edge images is reflected. The larger the difference, the less likely the pixels in the subsequent edge images belong to the same defect, and the smaller the possibility that the edge pixels are defects.
[0071] In one embodiment of the present invention, for each edge image, the defect factor is expressed as:
[0072] ;
[0073] in, Indicates The defect factor of edge pixels; Indicates The edge pixels are behind the other The local range of the corresponding position on the edge image The first The cosine value of the angle between edge pixels in the gradient direction; Indicates The edge pixels are behind the other The local range of the corresponding position on the edge image Noise factor of edge pixels; Indicates the first edge image on each edge image The local range of the edge pixel The first The cosine value of the angle between edge pixels in the gradient direction; Indicates the first edge image on each edge image The local range of the edge pixel Noise factor of edge pixels; Indicates the following other The edge image The number of edge pixels in the local range corresponding to the edge pixel; Indicates the first edge image on each edge image The number of edge pixels within the local range of edge pixels; Indicates the number of other edge images behind each edge image.
[0074] In the formula for the defect factor, Indicates The edge pixels are behind the other The local range of the corresponding position on the edge image The first The cosine value of the angle in the gradient direction between the edge pixels and the The ratio of the noise factors of edge pixels, It represents the first accumulated value of each edge image. The larger the first accumulated value, the larger the cosine value of the angle, the larger the gradient direction angle between pixels, the less close the gradient directions are, and the smaller the possibility of defects.
[0075] Step S3: According to the position distribution of edge pixels on the first edge image, multiple suspected defect lines are obtained, and transition lines between the suspected defect lines are obtained; according to the gradient direction of the pixels between the two suspected defect lines and the relative distribution characteristics of the transition lines, the degree of connection between the two suspected defect lines is obtained; according to the position distribution of the difference edge pixels between different edge images and the transition lines between the two suspected defect lines, the corresponding defect factors and the degree of connection, the possibility of the same defect between the two suspected defect lines is obtained; according to the relative distance between each edge pixel and different transition lines on each edge image, and the corresponding possibility of the same defect between the two suspected defect lines, the defect weight of each edge pixel on each edge image is obtained.
[0076] Since the defect on the bottom cover of the watch is very shallow, the defect may be intermittent in the edge image, which is more likely to be judged as noise in the future. By analyzing the position distribution of edge pixels, adjacent intermittent defect edges can be more effectively identified and constructed into complete suspected defect lines, which helps to reduce noise interference and improve recognition accuracy. According to the position distribution of edge pixels on the first edge image, multiple suspected defect lines are obtained, and transition lines between suspected defect lines are obtained.
[0077] Preferably, in one embodiment of the present invention, obtaining a plurality of suspected defect lines and obtaining transition lines between the suspected defect lines comprises:
[0078] For the first edge image, other edge pixels within the 8-neighborhood range of each edge pixel are obtained as similar pixels; all similar pixels of each edge pixel are obtained to form a suspected defect line;
[0079] The relative distance between the corresponding edge pixel points of the two suspected defect lines is obtained, the one with the smallest relative distance is selected, and the corresponding edge pixel points are connected to form a transition line between the two suspected defect lines.
[0080] Since the gradient directions of each pixel in the same defect line are similar, and the area between the two defect lines is perpendicular to the gradient direction, analyzing the gradient direction of the pixel points and the relative distribution characteristics of the transition lines is more helpful to evaluate the connectivity between the defect lines; according to the gradient direction of the pixel points and the relative distribution characteristics of the transition lines between the two suspected defect lines, the degree of connectivity between the two suspected defect lines is obtained.
[0081] Preferably, in one embodiment of the present invention, the method for obtaining the degree of connection includes:
[0082] Obtain the mean value of the gradient direction of all pixels on each suspected defect line as the overall gradient direction on each suspected defect line;
[0083] Obtain the cosine value of the angle between the overall direction of the gradient of the two suspected defect lines as the first connection coefficient; obtain the average value of the angle between the gradient direction of the two suspected defect lines and the transition line, and calculate the cosine value of the average angle as the second connection coefficient;
[0084] The product of the first connection coefficient and the second connection coefficient is obtained, and the product result is compared with the relative distance corresponding to the transition line to obtain the connection degree between the two suspected defect lines.
[0085] As the threshold of the edge detection operator is continuously reduced, new pixels will gradually appear near the transition line between two suspected defect lines in the same defect. By analyzing the position distribution of the difference edge pixels and the transition line, the spatial relationship between the suspected defect lines can be reflected; the defect factor reflects the abnormality of the edge pixel relative to the surrounding pixels and evaluates the degree of defect; the degree of connection reflects the similarity and continuity between the two suspected defect lines in terms of gradient direction, etc. The higher the degree of continuity, the greater the possibility that they are caused by the same defect; according to the position distribution of the difference edge pixels and the transition line between the two suspected defect lines between different edge images, the corresponding defect factor and the degree of connection, the possibility of the same defect between the two suspected defect lines is obtained.
[0086] Preferably, in one embodiment of the present invention, the method for obtaining the probability of the same defect includes:
[0087] Compare the difference of edge pixel points between each other edge image and the first edge image to obtain the difference edge pixel points on each other edge image;
[0088] According to the relative distance between different difference edge pixels and transition lines on all other edge images, the defect factor and the degree of connection between the two corresponding suspected defect lines, the possibility of the same defect between the two suspected defect lines is obtained. The relative distance between the difference edge pixels and the transition line is negatively correlated with the possibility of the same defect, and the defect factor and the degree of connection between the two corresponding suspected defect lines are positively correlated with the possibility of the same defect.
[0089] Among them, the greater the relative distance between the difference edge pixel and the transition line, the farther the newly added pixel is from the transition line, the larger the gap between the two suspected defect lines, and the smaller the possibility that the two suspected defect lines are the same defect line; the larger the defect factor, the greater the possibility that the pixel is a defect pixel, the greater the degree of connection between the two suspected defect lines, and the greater the possibility that they are the same defect line.
[0090] In one embodiment of the present invention, the formula for the probability of the same defect is expressed as:
[0091] ;
[0092] in, Indicates the possibility of the same defect for two suspected defect lines; Indicates the degree of connection between two suspected defect lines; Indicates Other edge images The defect factor of the difference edge pixels; Indicates Other edge images The relative distance between the difference edge pixel and the transition line; Indicates the number of difference edge pixels; Indicates the number of edge images other than the first edge image.
[0093] In the same defect probability formula, Indicates Other edge images The defect factor of the difference edge pixel and the The ratio of the relative distance between the difference edge pixel and the transition line. The larger the ratio, the larger the defect factor. The smaller the relative distance, the more likely it is that the defect pixel is located between the suspected defect lines. The greater the degree of connection between the two suspected defect lines, the greater the possibility of the same defect.
[0094] By calculating the relative distance between each edge pixel and different transition lines, the relative position relationship between the pixel and the defect area can be understood. Edge pixels with closer distances are more likely to belong to the defect area. The possibility of the same defect reflects the degree of association and consistency between the two suspected defect lines, so a higher defect weight should be assigned. The defect weight of each edge pixel on each edge image is obtained according to the relative distance between each edge pixel and different transition lines on each edge image, as well as the possibility of the same defect between the two suspected defect lines.
[0095] Preferably, in one embodiment of the present invention, the method for obtaining defect weights includes:
[0096] For any edge image, the defect weight of each edge pixel is obtained according to the relative distance between each edge pixel and each transition line, and the possibility of the same defect between the two suspected defect lines where each transition line is located. The relative distance between each edge pixel and each transition line is negatively correlated with the defect weight, and the possibility of the same defect between the two suspected defect lines where each transition line is located is positively correlated with the defect weight.
[0097] The larger the relative distance between each edge pixel and each transition line, the farther away it is from the gap between two suspected defect lines, the less likely it is to show the same defect line, and the smaller the defect weight. The greater the possibility that the transition line is the same defect between two suspected defect lines, the greater the credibility of the defect and the greater the defect weight.
[0098] In one embodiment of the present invention, for any edge image, the defect weight formula is expressed as:
[0099] ;
[0100] in, Represents the defect weight of each edge pixel; Indicates that each edge pixel corresponds to the The possibility of a transition line being the same defect between two suspected defect lines; Represents the relationship between each edge pixel and the The relative distance between the transition lines; Indicates the number of transition lines in the edge image; Represents the normalization function.
[0101] In the defect weight formula, Indicates that each edge pixel corresponds to the The probability of the same defect between the two suspected defect lines where the transition line is located and the probability of each edge pixel being The ratio of the relative distances between the transition lines, that is, the larger the ratio, the greater the possibility of the same defect, the smaller the relative distance, the greater the defect weight.
[0102] Step S4: Obtain the defect possibility of each edge pixel on the last edge image according to the defect weights of different edge pixels in the local range of each edge pixel on the last edge image and the grayscale distribution.
[0103] In the defects generated by the same collision, the forces in each position of the defect are similar, so the grayscale values of the pixels on the same defect are similar; while the grayscale value of noise is random. By analyzing the defect weight and grayscale distribution, the defect possibility is evaluated more comprehensively. According to the defect weights and grayscale distribution of different edge pixels in the local range of each edge pixel on the last edge image, the defect possibility of each edge pixel on the last edge image is obtained.
[0104] Preferably, in one embodiment of the present invention, the method for obtaining the defect possibility includes:
[0105] For the last edge image, the difference accumulated value of the grayscale value between each other edge pixel and different other edge pixels in the local range of each edge pixel is obtained as the grayscale difference level;
[0106] According to the defect weights and grayscale difference levels of different edge pixels in the local range of each edge pixel, the defect possibility of each edge pixel is obtained. The defect weight is positively correlated with the defect possibility, and the grayscale difference level is negatively correlated with the defect possibility.
[0107] Among them, the larger the defect weight, the greater the possibility of a defect, the greater the grayscale difference level, the more likely it is the distribution of noise pixels, and the smaller the possibility of a defect.
[0108] In one embodiment of the present invention, the formula for defect probability is expressed as:
[0109] ;
[0110] in, Indicates The probability of defects at edge pixels; Indicates The local range of the edge pixel The defect weights of other edge pixels; Indicates The local range of the edge pixel Gray values of other edge pixels; Indicates The local range of the edge pixel Gray values of other edge pixels; Indicates The number of other edge pixels within the local range of an edge pixel; Represents the normalization function.
[0111] In the formula for defect probability, Indicates The local range of the edge pixel The grayscale values of the other edge pixels and the The difference between the gray values of other edge pixels, Indicates The local range of the edge pixel The accumulated value of the difference in grayscale values between other edge pixels and different other edge pixels. That is, the grayscale difference level, Indicates The local range of the edge pixel The ratio of the defect weight of other edge pixels to the corresponding grayscale difference level, It represents the cumulative value of the corresponding ratios of all other edge pixels in the local range. The larger the cumulative value, the larger the ratio, the greater the defect weight corresponding to other edge pixels, and the smaller the grayscale difference level, the more likely it is a defective pixel.
[0112] Step S5: Perform defect detection based on defect possibility.
[0113] Obtaining the defect possibility of each edge pixel can more accurately identify defects on the product surface and improve the accuracy and reliability of detection.
[0114] It should be noted that, in another embodiment of the present invention, after obtaining the defect possibility of each edge pixel point on the last edge image, the defects are detected, including: by comparing the defect possibility of each edge pixel point with a preset possibility threshold, if the defect possibility of each edge pixel point is greater than the preset possibility threshold, the edge pixel point is judged to be a defective pixel point, all defective pixels on the last edge image are obtained, and the area formed by all defective pixels is used as a defective edge; all defective edges are connected using an edge connection algorithm to obtain the defective area in the watch bottom cover; the specific edge connection algorithm is a technical means well known to those skilled in the art and will not be elaborated here.
[0115] It should be noted that, in one embodiment of the present invention, the preset possibility threshold is 0.8; in other embodiments of the present invention, the preset possibility threshold may be specifically set according to specific circumstances, which is not limited or elaborated herein.
[0116] In summary, for any edge image, the present invention obtains the noise factor and defect factor of each edge pixel; obtains multiple suspected defect lines according to the position distribution of edge pixels on the first edge image, and obtains transition lines between the suspected defect lines; obtains the degree of connection between the two suspected defect lines according to the gradient direction of the pixels between the two suspected defect lines and the relative distribution characteristics of the transition lines; obtains the defect weight of each edge pixel on each edge image according to the relative distance between each edge pixel and different transition lines on each edge image, and the possibility of the same defect between the two suspected defect lines; obtains the defect possibility of each edge pixel on the last edge image in combination with the grayscale distribution of the pixels; and performs defect detection. The present invention improves the accuracy of defect inspection by obtaining the accurate defect possibility of each edge pixel.
[0117] The present invention also proposes a watch bottom cover defect inspection system based on machine vision, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements any step of a watch bottom cover defect inspection method based on machine vision.
[0118] It should be noted that the sequence of the above embodiments of the present invention is only for description and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0119] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
Claims
1. A method for inspecting defects on a watch bottom cover based on machine vision, characterized in that: The method comprises: Get the grayscale image of the watch bottom cover; Based on the threshold descent iteration sequence, multiple edge images corresponding to the grayscale image are obtained; for any edge image, the noise factor of each edge pixel is obtained according to the relative distance distribution between different edge pixels in the neighborhood of each edge pixel; the defect factor of each edge pixel on each edge image is obtained according to the gradient change characteristics of the edge pixel in the local range of the same position between different edge images and the noise factor; According to the position distribution of edge pixels on the first edge image, multiple suspected defect lines are obtained, and transition lines between the suspected defect lines are obtained; according to the gradient direction of the pixels between the two suspected defect lines and the relative distribution characteristics of the transition lines, the degree of connection between the two suspected defect lines is obtained; according to the position distribution, corresponding defect factors and degree of connection of the difference edge pixels between different edge images and the transition lines between the two suspected defect lines, the possibility of the same defect between the two suspected defect lines is obtained; according to the relative distance between each edge pixel and different transition lines on each edge image, and the possibility of the same defect between the two suspected defect lines, the defect weight of each edge pixel on each edge image is obtained; According to the defect weights of different edge pixels in the local range of each edge pixel on the last edge image and the grayscale distribution, the defect possibility of each edge pixel on the last edge image is obtained; Defect detection is performed based on the defect probability.
2. A machine vision-based watch bottom cover defect inspection method according to claim 1, characterized in that: The method for obtaining the edge image comprises: Based on the threshold descent iterative sequence, the sobel operator is used to detect the grayscale image and obtain the corresponding multiple edge images.
3. The method for inspecting watch bottom cover defects based on machine vision according to claim 1, characterized in that: The method for obtaining the noise factor includes: The noise factor is obtained according to the noise factor acquisition formula. For each edge image, the noise factor acquisition formula is expressed as: ;in, Indicates Noise factor of edge pixels; Indicates The variance of the relative distance between an edge pixel and other edge pixels in the neighborhood; Indicates The edge pixel and the The relative distance between other edge pixels; Indicates the number of other edge pixels in the neighborhood; Indicates The edge pixel in the neighborhood of other edge pixels and the The relative distance between other edge pixels; represents the logistic function; Indicates taking the absolute value.
4. The method for inspecting watch bottom cover defects based on machine vision according to claim 1, characterized in that: The method for obtaining the defect factor includes: Obtain the cosine value of the angle between each edge pixel point on each edge image and each edge pixel point in the local range as the gradient direction similarity; Obtaining the ratio between the gradient direction similarity and the noise factor corresponding to different edge pixel points in the local range and accumulating them as the first accumulated value; Obtain the difference between the first accumulated value in the local range corresponding to the same position between each subsequent edge image and each edge image as the first difference; accumulate the first difference values of all subsequent edge images as the defect factor of each edge pixel on each edge image.
5. The method for inspecting watch bottom cover defects based on machine vision according to claim 1, characterized in that: The step of obtaining a plurality of suspected defect lines and obtaining transition lines between the suspected defect lines includes: For the first edge image, other edge pixels within the 8-neighborhood range of each edge pixel are obtained as similar pixels; all similar pixels of each edge pixel are obtained to form a suspected defect line; The relative distance between the corresponding edge pixel points of the two suspected defect lines is obtained, the one with the smallest relative distance is selected, and the corresponding edge pixel points are connected to form a transition line between the two suspected defect lines.
6. The method for inspecting watch bottom cover defects based on machine vision according to claim 1, characterized in that: The method for obtaining the connection degree includes: Obtain the mean value of the gradient direction of all pixels on each suspected defect line as the overall gradient direction on each suspected defect line; Obtain the cosine value of the angle between the overall direction of the gradient of the two suspected defect lines as the first connection coefficient; obtain the average value of the angle between the gradient direction of the two suspected defect lines and the transition line, and calculate the cosine value of the average angle as the second connection coefficient; The product of the first connection coefficient and the second connection coefficient is obtained, and the product result is compared with the relative distance corresponding to the transition line to obtain the connection degree between the two suspected defect lines.
7. The method for inspecting watch bottom cover defects based on machine vision according to claim 1, characterized in that: The method for obtaining the probability of the same defect includes: Compare the difference of edge pixel points between each other edge image and the first edge image to obtain the difference edge pixel points on each other edge image; According to the relative distance between different difference edge pixels and transition lines on all other edge images, the defect factor and the degree of connection between the two corresponding suspected defect lines, the possibility of the same defect between the two suspected defect lines is obtained. The relative distance between the difference edge pixels and the transition line is negatively correlated with the possibility of the same defect, and the defect factor and the degree of connection between the two corresponding suspected defect lines are positively correlated with the possibility of the same defect.
8. The method for inspecting watch bottom cover defects based on machine vision according to claim 1, characterized in that: The method for obtaining the defect weight includes: For any edge image, the defect weight of each edge pixel is obtained according to the relative distance between each edge pixel and each transition line, and the possibility of the same defect between the two suspected defect lines where each transition line is located. The relative distance between each edge pixel and each transition line is negatively correlated with the defect weight, and the possibility of the same defect between the two suspected defect lines where each transition line is located is positively correlated with the defect weight.
9. The method for inspecting watch bottom cover defects based on machine vision according to claim 1, characterized in that: The method for obtaining the defect possibility of each edge pixel point includes: For the last edge image, the difference accumulated value of the grayscale value between each other edge pixel and different other edge pixels in the local range of each edge pixel is obtained as the grayscale difference level; According to the defect weights and grayscale difference levels of different edge pixels in the local range of each edge pixel, the defect possibility of each edge pixel is obtained. The defect weight is positively correlated with the defect possibility, and the grayscale difference level is negatively correlated with the defect possibility.
10. A machine vision-based watch bottom cover defect inspection system, the system comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of a watch bottom cover defect inspection method based on machine vision as described in any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
Image detection method and device, electronic equipment and readable storage medium
CN110796115A
Cloth broken weft defect detection method
CN116630309A