A method and device for intelligent detection of screw surface defects
Through pixel point clustering and grayscale sequence analysis of the RGB image of the ball screw surface, the problem of rust defect detection under the influence of reflective and shadowed areas is solved, and more accurate ball screw surface defect detection is achieved, improving the accuracy of the detection results. Sex and image quality.
Patent Information
- Application Number
- CN202410256614.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-06
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2044-03-06
AI Technical Summary
The existing ball screw surface defect detection method cannot accurately identify rust defects in the image due to the existence of reflective areas and shadow areas, which reduces the accuracy of the detection results.
By obtaining the RGB image and grayscale image of the ball screw surface, pixel points are clustered, divided into reflective, rust and shadow categories, and combining the degree of difference in grayscale sequence and the consistency intensity of the class attribute marker sequence to obtain reliable class attributes based on the degree of difference in grayscale sequences and the consistency intensity of class attribute markers. , reclassify pixel points, obtain rust membership, and correct the image through gain coefficient to improve the accuracy of clustering results.
The impact of reflective areas and shadow areas on rust defect recognition is eliminated, the accuracy of ball screw surface defect detection is improved, the rust characteristics in the image is enhanced, and the quality of the detection results is improved.
Smart Images

Figure CN117952955B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to a method and device for intelligently detecting surface defects of a lead screw. Background Art
[0002] Ball screws are the most commonly used transmission elements in tool machinery and precision machinery. Their main function is to convert rotational motion into linear motion, or torque into axial repetitive force, while having the characteristics of high precision, reversibility and high efficiency. Due to their small friction resistance, ball screws are widely used in various industrial equipment and precision instruments. Ball screws are often used in high-precision and cutting-edge fields. However, rust on the surface of ball screws will reduce the accuracy of the equipment during use, causing serious consequences. Therefore, it is necessary to detect rust defects on the surface of ball screws.
[0003] In the process of detecting surface defects of ball screws, the commonly used method in the prior art is to collect and process the defect data of the ball screw surface to obtain a defect data set, use the defect data set to establish a related convolutional neural network model, and use the neural network model to segment and detect defect areas of the ball screw image. However, due to the influence of lighting conditions and environmental interference, a large number of reflective areas and shadow areas are prone to appear in the surface image of the ball screw. The presence of reflective areas and shadow areas makes it impossible to accurately identify rust defects in the image, thereby reducing the accuracy of the ball screw surface defect detection results. Summary of the invention
[0004] In order to solve the technical problem that in the process of ball screw surface defect detection, the rust defects in the image cannot be accurately identified due to the presence of reflective areas and shadow areas, thereby reducing the accuracy of the ball screw surface defect detection results, the purpose of the present invention is to provide a screw surface defect intelligent detection method and device, the technical solution adopted is as follows:
[0005] The present invention proposes an intelligent detection method for screw surface defects, the method comprising:
[0006] Get the RGB image and grayscale image of the ball screw surface;
[0007] Clustering the pixels according to the channel values of the pixels in the RGB image, and obtaining the class attribution labels of the pixels according to the clusters to which the pixels belong, wherein the clusters include reflection class, rust class and shadow class;
[0008] In the grayscale image, all pixels in a preset neighborhood with a pixel as the center are sorted according to grayscale values to obtain a grayscale ordered sequence; according to the difference between the grayscale values of the pixels in the grayscale ordered sequence, the degree of difference of the grayscale sequence is obtained; the grayscale value in the grayscale ordered sequence is set as the class attribution mark of the corresponding pixel; a class attribution mark sequence is obtained, and according to the distribution of the class attribution marks in the class attribution mark sequence, the consistency strength of the class attribution mark sequence is obtained; according to the degree of difference of the grayscale sequence and the consistency strength, the class attribution reliability of the central pixel is obtained;
[0009] Obtain reclassified pixels from the pixels according to the class attribution reliability, obtain the rust membership of the reclassified pixels according to the distribution of the grayscale values of the pixels within a preset neighborhood of each reclassified pixel; and reclassify the reclassified pixels according to the rust membership and grayscale values of the reclassified pixels;
[0010] Obtain a gain coefficient for each channel of the central pixel according to the category to which the reclassified pixel in the RGB image belongs and the channel value of the pixel within the preset neighborhood, and correct each channel of each pixel according to the gain coefficient to obtain an RGB corrected image;
[0011] The pixels are clustered according to the channel values of the pixels in the RGB corrected image, and the surface defects of the ball screw are detected based on the clustering results.
[0012] Furthermore, the method for obtaining the grayscale sequence difference degree includes:
[0013] Taking the absolute value of the difference between the ratio of the grayscale values of adjacent pixels in the grayscale ordered sequence and the constant 1 as the grayscale difference between the adjacent pixels, and normalizing the grayscale difference to obtain a grayscale difference parameter;
[0014] The average value of all the grayscale difference parameters is used as the grayscale sequence difference degree of the grayscale ordered sequence.
[0015] Furthermore, the method for obtaining the consistency strength of the class attribution mark sequence includes:
[0016] Obtain a class attribution label matrix, wherein the rows of the class attribution label matrix represent the types of the class attribution labels, the columns of the class attribution label matrix represent the consecutive times of the same class attribution label in the class attribution label sequence, and the elements in the class attribution label matrix represent the number of subsequences that meet the row condition and the column condition;
[0017] The difference between the number of columns of the class attribution label matrix and the number of columns where each element is located is used as the column number distance of each element, the square of the sum of the column number distance and a preset first constant is used as the column number difference of each element, and the average value of the ratio of all elements in the class attribution label matrix to the column number difference is used as the first characteristic parameter;
[0018] Sorting the class attribution marks in the class attribution mark sequence according to the sorting method of the grayscale sequence to obtain an ordered sequence of class attribution marks, and taking the number of positions with the same position and the same elements in the class attribution mark sequence and the ordered sequence of class attribution marks as a second characteristic parameter;
[0019] The product of the first feature parameter and the second feature parameter is used as the consistency strength of the class attribution label sequence.
[0020] Furthermore, the method for obtaining the class attribution reliability of the central pixel point includes:
[0021] The consistency strength is positively correlated with the class attribution reliability, the grayscale sequence difference degree is negatively correlated with the class attribution reliability, and the value of the class attribution reliability is a normalized value.
[0022] Furthermore, obtaining the rust membership of the reclassified pixel points according to the distribution of the grayscale values of the pixel points within the preset neighborhood range of each reclassified pixel point includes:
[0023] The pixel points whose class attribution reliability is less than a preset reliability threshold are used as the reclassified pixel points;
[0024] Obtaining the minimum grayscale value and the maximum grayscale value within a preset neighborhood range of the reclassified pixel point; taking the number of pixel points whose grayscale values within the preset neighborhood range are less than or equal to the grayscale value of the central pixel point as the first number, and taking the number of pixel points whose grayscale values within the preset neighborhood range are greater than or equal to the grayscale value of the central pixel point as the second number;
[0025] When the minimum gray value is greater than or equal to the preset first gray threshold, the ratio of the second quantity to the first quantity is taken as the rust characteristic value; when the maximum gray value is less than the preset first gray threshold, the ratio of the first quantity to the second quantity is taken as the rust characteristic value; when the minimum gray value is less than the preset first gray threshold and the maximum gray value is greater than or equal to the preset first gray threshold, the absolute value of the difference between the ratio of the second quantity to the first quantity and the constant 1 is taken as the quantity difference, and the quantity difference is negatively correlated with the sum of the preset second constant to obtain the rust characteristic value;
[0026] The rust characteristic value is normalized to obtain the rust membership of the reclassified pixel point.
[0027] Further, the reclassifying the reclassified pixel points according to the rust membership and grayscale value of the reclassified pixel points includes:
[0028] Classifying the reclassified pixel points whose rust membership is greater than a preset membership threshold as the rust class;
[0029] Classify the reclassified pixel points whose rust membership is not greater than a preset membership threshold and whose grayscale value is not greater than a preset second grayscale threshold as the shadow class;
[0030] The reclassified pixel points whose rust membership is not greater than a preset membership threshold and whose grayscale value is greater than a preset second grayscale threshold are classified as the reflective class.
[0031] Furthermore, the method for obtaining the gain coefficient includes:
[0032] The maximum value of all channels of all pixels within the preset neighborhood is used as a channel reference, the average value of each channel of all pixels within the preset neighborhood is used as a channel mean, and the ratio of the channel reference value to the channel mean is used as an initial gain coefficient of each channel of the central pixel;
[0033] The gain coefficient of each channel of the central pixel is obtained according to the product of the initial gain coefficient and the preset class gain factor.
[0034] Furthermore, the step of correcting each channel of the pixel point according to the gain coefficient to obtain an RGB corrected image includes:
[0035] The product value of the gain coefficient and each original channel value of each pixel is used as the corrected channel value of each channel of the pixel, and the corrected channel value of each channel of the pixel is used as the channel value of the corresponding channel of the pixel in the RGB image to obtain an RGB corrected image.
[0036] Further, the detecting of the surface defects of the ball screw according to the clustering result includes:
[0037] The number of rust pixels in the cluster is counted, and the ratio of the number of rust pixels to the total number of pixels is taken as the rust proportion. If the rust proportion is greater than the preset proportion threshold, there is a rust defect on the surface of the ball screw. If the rust proportion is not greater than the preset proportion threshold, there is no rust defect on the surface of the ball screw.
[0038] The present invention also proposes an intelligent detection device for screw surface defects, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of any one of the methods when executing the computer program.
[0039] The present invention has the following beneficial effects:
[0040] The present invention takes into account that there is a relatively obvious difference in color between the rust part and the non-rust part in the RGB image of the ball screw surface, so the pixels can be clustered according to the channel values of the pixels in the RGB image, and there are mainly rust areas, reflective areas and shadow areas in the RGB image, so the clusters are divided into light class, rust class and dark class, and the class attribution mark of the pixel is obtained according to the cluster where the pixel is located, which is used to distinguish the pixel category and provide data support for the subsequent acquisition of class attribution reliability; the existence of the light and shadow areas will reduce the accuracy of the clustering results, and all rust pixels cannot be identified, and the clustering results of the pixels need to be judged, while the grayscale value of the pixels in the reflective area is larger, the grayscale value of the pixels in the shadow area is smaller, and the grayscale value of the pixels in the rust area is relatively centered, so a preset neighborhood range centered on the pixel can be established, and a grayscale ordered sequence and a class attribution mark sequence are obtained, and the degree of difference in the grayscale values in the grayscale ordered sequence can be determined. The consistency of the distribution of class attribution marks in the class attribution mark sequence can reflect the accuracy of the clustering results of the central pixel point, so the class attribution reliability of the central pixel point can be obtained by combining the grayscale sequence difference degree and consistency strength, and the accuracy of the pixel point in the category to which it belongs can be judged by the class attribution reliability, which is convenient for the subsequent acquisition of reclassified pixels; since the grayscale value of the rust pixel point in the image is relatively centered compared with the reflective area pixel point and the shadow area pixel point, the rust membership of the reclassified pixel point can be obtained according to the distribution of the grayscale value of the pixel point in the preset neighborhood range of each reclassified pixel point, thereby improving the accuracy of the recognition of the rust pixel point in the subsequent reclassification, reclassifying the reclassified pixels, improving the accuracy of the clustering results, providing data support for the subsequent correction of the pixels, correcting the pixels according to the obtained gain coefficient, and obtaining the RGB corrected image, thereby improving the image quality, enhancing the characteristics of the rust in the image, and improving the accuracy of the subsequent defect detection. The present invention clusters pixels in an RGB image, analyzes the clustering results, adjusts the categories to which the pixels belong, thereby improving the accuracy of the clustering results, corrects the pixels based on the categories to which the pixels belong, clusters the pixels in the RGB corrected image again, detects rust defects on the surface of a ball screw according to the clustering results, eliminates the influence of the existence of reflective areas and shadow areas on the identification of rust defects in the image, and improves the accuracy of the detection results of surface defects of the ball screw. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] 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.
[0042] Figure 1 A flow chart of a method for intelligently detecting surface defects of a lead screw provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0043] 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 the method and device for intelligent detection of screw surface defects 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.
[0044] 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.
[0045] Embodiment of the intelligent detection method for screw surface defects:
[0046] The specific scheme of the intelligent detection method and device for screw surface defects provided by the present invention is described in detail below with reference to the accompanying drawings.
[0047] See also Figure 1 , which shows a flow chart of a method for intelligent detection of surface defects of a lead screw provided by an embodiment of the present invention, the method comprising:
[0048] Step S1: Acquire the RGB image and grayscale image of the ball screw surface.
[0049] In an embodiment of the present invention, the surface of the ball screw is photographed by a CCD camera to obtain an original image. Since there may be interference factors such as jitter and noise in the shooting process, the quality of the original image will be reduced, and thus the subsequent detection results will be affected. Therefore, it is necessary to denoise the collected original image. Common denoising methods mainly include bilateral filtering denoising, Gaussian filtering denoising, mean filtering denoising, etc. In order to retain the details in the RGB image to a greater extent, in one embodiment of the present invention, bilateral filtering denoising is used to denoise the collected original image. It should be noted that bilateral filtering denoising is a technical means well known to those skilled in the art and will not be repeated here.
[0050] In the subsequent analysis process of the embodiment of the present invention, it is necessary to cluster the pixels in the RGB image, and determine the cluster type and the accuracy of each pixel in the category to which it belongs based on the grayscale value of the pixel. Therefore, the RGB image needs to be converted into a corresponding grayscale image. It should be noted that converting an RGB image into a grayscale image is a technical means well known to those skilled in the art and will not be repeated here.
[0051] Step S2: clustering the pixels according to the channel values of the pixels in the RGB image, and obtaining the class affiliation label of the pixels according to the clusters to which the pixels belong, wherein the clusters include reflection class, rust class and shadow class.
[0052] Since the color of the rust area on the surface of the ball screw is obviously different from the background color, and the various channel components of the pixel points in the RGB image have a certain correlation, in one embodiment of the present invention, the pixel points are clustered according to the channel values of the pixel points in the RGB image. Since the surface of the ball screw is relatively smooth, in addition to the rust area, there are also obvious reflective areas and shadow areas in the acquired RGB image. In order to improve the clustering effect, in one embodiment of the present invention, the K-Means clustering algorithm is used to cluster the pixels, and the cluster cluster is set to 3. It should be noted that the K-Means clustering algorithm is a technical means well known to those skilled in the art and will not be repeated here.
[0053] After completing the clustering of the pixels in the RGB image, it is necessary to distinguish the type of cluster to which the pixels belong. Since there are mainly reflective areas, rust areas and shadow areas in the RGB image, the clusters can be divided into reflective, rust and shadow types. Since the brightness of the pixels in the reflective area is the highest, the pixels in the rust area are second, and the brightness of the pixels in the shadow area is the lowest, and the grayscale value can reflect the brightness of the pixels. The greater the brightness of the pixel, the greater the grayscale value. Therefore, in one embodiment of the present invention, the type of each cluster is determined according to the grayscale value of the cluster center, and the grayscale value with the largest grayscale value is selected. The cluster corresponding to the cluster center of the grayscale value is taken as the reflective class, the cluster corresponding to the cluster center of the minimum grayscale value is taken as the shadow class, the cluster corresponding to the cluster center with the grayscale value in the middle is taken as the rust class, and the class affiliation mark of the pixel point is obtained according to the cluster cluster where the pixel point is located. In one embodiment of the present invention, if the cluster cluster to which the pixel point belongs is the shadow class, the class affiliation mark of the pixel point is set to 1, if the cluster cluster to which the pixel point belongs is the rust class, the class affiliation mark of the pixel point is set to 2, and if the cluster cluster to which the pixel point belongs is the reflective class, the class affiliation mark of the pixel point is set to 3.
[0054] It should be noted that in some other embodiments of the present invention, the class attribution mark can also be set to other numbers, but it is necessary to ensure that the class attribution mark of the reflective pixel point is the largest, the class attribution mark of the rust pixel point is second, and the class attribution mark of the shadow pixel point is the smallest.
[0055] At this point, the class attribution labels of each pixel point have been obtained, and the accuracy of the pixel point clustering results can be analyzed based on the class attribution labels of the pixel points in the subsequent process.
[0056] Step S3: In the grayscale image, all pixels in a preset neighborhood with the pixel as the center are sorted according to the grayscale values to obtain a grayscale ordered sequence; according to the difference between the grayscale values of the pixels in the grayscale ordered sequence, the degree of difference of the grayscale sequence is obtained; the grayscale values in the grayscale ordered sequence are set as the class attribution marks of the corresponding pixels to obtain a class attribution mark sequence, and according to the distribution of the class attribution marks in the class attribution mark sequence, the consistency strength of the class attribution mark sequence is obtained; according to the degree of difference and consistency strength of the grayscale sequence, the class attribution reliability of the central pixel is obtained.
[0057] Since there are reflective areas and shadow areas in RGB images, the characteristics of rust in the reflective area are not particularly obvious, and it is easy to cluster the rust pixels in the reflective area into the reflective class. However, the colors of rust and shadow areas are relatively close, and it is easy to confuse these two types of pixels during the clustering process, thereby reducing the clustering effect. Therefore, it is necessary to analyze the accuracy of the clustering results of each pixel. Considering that the grayscale value of the reflective pixel is larger, the grayscale value of the rust pixel is second, and the grayscale value of the shadow pixel is the smallest, all pixels in the preset neighborhood range centered on the pixel can be sorted by grayscale value to obtain a grayscale ordered sequence. The difference between the grayscale values in the grayscale ordered sequence can reflect the clustering effect of the central pixel. The smaller the difference between the grayscale values in the grayscale ordered sequence, the better the clustering effect. Therefore, according to the difference between the grayscale values of the pixels in the grayscale ordered sequence, the difference degree of the grayscale sequence is obtained. The smaller the difference degree of the grayscale sequence, the more accurate the clustering result of the central pixel is, providing a data basis for the subsequent acquisition of the reliability of class attribution.
[0058] Preferably, in one embodiment of the present invention, the method for obtaining the grayscale sequence difference degree specifically includes:
[0059] The absolute value of the difference between the ratio of the grayscale values of adjacent pixels in the grayscale ordered sequence and the constant 1 is taken as the grayscale difference of adjacent pixels, and the grayscale difference is normalized to obtain the grayscale difference parameter; the average value of all grayscale difference parameters is taken as the grayscale sequence difference degree of the grayscale ordered sequence. The expression of the grayscale sequence difference degree is:
[0060]
[0061] in, Indicates the degree of grayscale sequence difference of grayscale ordered sequence; Indicates the grayscale ordered sequence The gray value of a pixel point. It should be noted that when When it is equal to 0, let ; Indicates the grayscale ordered sequence The gray value of each pixel; Represents the number of pixels in an ordered sequence of grayscale; is a common S-type function used for normalization processing; in one embodiment of the present invention, the preset neighborhood range is set to .
[0062] In the process of obtaining the difference degree of grayscale sequence, represents the grayscale ratio between adjacent pixels in the grayscale ordered sequence. Since the grayscale ratio cannot reflect the difference between the grayscale values of adjacent pixels, in one embodiment of the present invention, As the grayscale difference between adjacent pixels, the grayscale difference The larger the value is, the greater the difference in grayscale between adjacent pixels is. The grayscale difference is normalized by the sigmoid function to obtain the grayscale difference parameter. , and reflects the grayscale difference of the grayscale ordered sequence as a whole by calculating the average value of the grayscale difference parameters between all adjacent pixels, that is, the average value of all grayscale difference parameters The degree of difference of grayscale sequence as grayscale ordered sequence .
[0063] The obtained grayscale sequence difference degree can reflect the difference degree between the grayscale values of pixels in the grayscale ordered sequence, and provide data support for the subsequent classification reliability of pixels.
[0064] In the embodiment of the present invention, the class attribution mark sequence is obtained based on the grayscale ordered sequence. Since the grayscale values of pixels in different clusters in the image are different, the grayscale value of the reflective pixel is the largest, the grayscale value of the rust pixel is the second, and the grayscale value of the shadow pixel is the smallest. Therefore, when the clustering effect of the pixels is good, the distribution of the class attribution marks in the class attribution mark sequence should be expressed as the same class attribution marks concentrated in a certain part of the class attribution mark sequence, that is, the more consistent the distribution of the class attribution marks, otherwise it means that the clustering effect is relatively poor. Therefore, the consistency strength of the class attribution mark sequence can be obtained according to the distribution of the class attribution marks in the class attribution mark sequence.
[0065] Preferably, in one embodiment of the present invention, the method for obtaining the consistency strength of the class attribution tag sequence specifically includes:
[0066] Obtain a class attribution marker matrix, the rows of which represent the types of class attribution markers, the columns of which represent the consecutive times of the same class attribution marker in the class attribution marker sequence, and the elements in the class attribution marker matrix represent the number of subsequences that meet the row and column conditions; take the difference between the number of columns of the class attribution marker matrix and the number of columns where each element is located as the column distance of each element, take the square of the sum of the column distance and the preset first constant as the column difference of each element, and take the average value of the ratio of all elements in the class attribution marker matrix to the column difference as the first feature parameter; sort the class attribution markers in the class attribution marker sequence according to the sorting method of the grayscale sequence to obtain an ordered sequence of class attribution markers, take the number of positions with the same position and the same elements in the class attribution marker sequence and the ordered sequence of class attribution markers as the second feature parameter; take the product of the first feature parameter and the second feature parameter as the consistency strength of the class attribution marker sequence. The specific expression of consistency strength is:
[0067]
[0068] in, Indicates the consistency strength of the class affiliation tag sequence; Represents the number of rows of the class attribution labeling matrix; Represents the number of columns of the class attribution labeling matrix; represents the first OK; represents the first List; Indicates the first Line Elements of a column; represents the number of positions with the same position and the same elements in the class affiliation mark sequence and the ordered sequence of class affiliation marks, i.e., the second characteristic parameter; To preset the first constant, in one embodiment of the present invention Set to 1.
[0069] In the process of obtaining consistency strength, Indicates the first Line The elements of the column, represents the column distance of each element in the class attribution matrix, represents the difference in the number of columns of each element in the class attribution matrix, where It is set to prevent the difference in the number of columns from being 0. If the distribution of the class attribution labels in the class attribution label sequence is more consistent, the class attribution label matrix will show that the elements are concentrated on the right side of the class attribution label matrix, and the element values are larger, that is, the elements in the class attribution matrix are The larger the number of columns of the element, the greater the difference The smaller the value, the more consistent the distribution of the class attribution marker sequence is, and the greater the consistency strength is. Therefore, in one embodiment of the present invention, the average value of the ratio of all elements in the class attribution marker matrix to the column number difference is used as the first feature parameter ; It indicates the number of positions with the same elements in the class affiliation tag sequence and the ordered class affiliation tag sequence. If the distribution of class affiliation tags in the class affiliation tag sequence is more consistent, it means that the number of positions with the same elements in the class affiliation tag sequence and the ordered class affiliation tag sequence is greater. Therefore, As the second feature parameter, the product of the first feature parameter and the second feature parameter is used as the consistency strength of the class attribution tag sequence .
[0070] After obtaining the grayscale sequence difference degree and consistency strength, the class attribution reliability of the central pixel can be obtained by combining the grayscale sequence difference degree and consistency strength, and the clustering effect of the pixel can be judged by the class attribution reliability.
[0071] Preferably, in an embodiment of the present invention, the method for obtaining the class attribution reliability of the central pixel point specifically includes:
[0072] The consistency strength is positively correlated with the class attribution reliability, the grayscale sequence difference is negatively correlated with the class attribution reliability, and the class attribution reliability is a normalized value. The expression of class attribution reliability is:
[0073]
[0074] in, Indicates the reliability of the class attribution of the central pixel; Indicates the consistency strength of the class affiliation tag sequence; Indicates the grayscale sequence difference degree of the grayscale ordered sequence, is through The function is normalized and is always greater than 0; To normalize the function, a Z-score method is used for normalization in one embodiment of the present invention.
[0075] In the process of obtaining the reliability of class attribution, the consistency strength The difference between the grayscale sequence From the analysis, we can see that the consistency strength The larger the value is, the more consistent the distribution of class attribution markers in the class attribution marker sequence is, the greater the class attribution reliability is, and the degree of grayscale sequence difference is The smaller the value, the smaller the difference in the grayscale values of the pixels in the grayscale ordered sequence, and the greater the reliability of the class attribution. Therefore, in one embodiment of the present invention, the ratio of the consistency strength and the sequence difference degree is normalized and used as the reliability of the class attribution of the central pixel. .
[0076] It should be noted that, a positive correlation means that the dependent variable will increase as the independent variable increases, and the dependent variable will decrease as the independent variable decreases. The specific relationship may be a multiplication relationship, an addition relationship, or the power of an exponential function, which is determined by actual application. A negative correlation means that the dependent variable will decrease as the independent variable increases, and the dependent variable will increase as the independent variable decreases. It may be a subtraction relationship, a division relationship, etc., which is determined by actual application.
[0077] The class attribution reliability of each pixel can be obtained by constructing an ordered grayscale sequence and a class attribution label sequence for each pixel within a preset neighborhood. The clustering effect of each pixel can be judged by the class attribution reliability, providing a data basis for the subsequent acquisition of reclassified pixels.
[0078] Step S4: obtaining reclassified pixels from the pixels according to the class attribution reliability, obtaining the rust membership of the reclassified pixels according to the distribution of the grayscale values of the pixels within a preset neighborhood of each reclassified pixel; and reclassifying the reclassified pixels according to the rust membership and grayscale values of the reclassified pixels.
[0079] After obtaining the class attribution reliability of each pixel, it is possible to determine whether the pixel is accurately in the category it belongs to based on the class attribution reliability, thereby obtaining the reclassified pixel. The reclassified pixel needs to be reclassified. Since the grayscale value of the reflective pixel is the largest, the grayscale value of the rust pixel is the second, and the grayscale value of the shadow pixel is the smallest, the rust membership of the reclassified pixel can be obtained based on the distribution of the grayscale values of the pixels within the preset neighborhood of each reclassified pixel. Based on the rust membership, it is determined whether the reclassified pixel should be classified into the rust class.
[0080] Preferably, in one embodiment of the present invention, the method for obtaining the rust membership of the reclassified pixel points specifically includes:
[0081] The pixel points whose class attribution reliability is less than the preset reliability threshold are taken as reclassified pixel points; the minimum grayscale value and the maximum grayscale value within the preset neighborhood range of the reclassified pixel points are obtained; the number of pixel points whose grayscale value within the preset neighborhood range is less than or equal to the grayscale value of the central pixel point is taken as the first number, and the number of pixel points whose grayscale value within the preset neighborhood range is greater than or equal to the grayscale value of the central pixel point is taken as the second number; when the minimum grayscale value is greater than or equal to the preset first grayscale threshold, the ratio of the second number to the first number is taken as the rust characteristic value; when the maximum grayscale value is less than the preset first grayscale threshold, the ratio of the first number to the second number is taken as the rust characteristic value; when the minimum grayscale value is less than the preset first grayscale threshold and the maximum grayscale value is greater than or equal to the preset first grayscale threshold, the absolute value of the difference between the ratio of the second number to the first number and the constant 1 is taken as the quantity difference, and the quantity difference is negatively correlated with the sum of the preset second constant to obtain the rust characteristic value; the rust characteristic value is normalized to obtain the rust membership of the reclassified pixel points. The specific expression of the rust membership is:
[0082]
[0083]
[0084] in, Indicates the rust membership of the reclassified pixel; Represents the rust feature value of the reclassified pixel; is the normalization function; represents the number of pixels within a preset neighborhood whose grayscale values are less than or equal to the grayscale value of the central pixel, that is, the first number, which is greater than 0; represents the number of pixels within a preset neighborhood whose grayscale values are greater than or equal to the grayscale value of the central pixel, that is, the second number, which is greater than 0; Indicates the minimum grayscale value within the preset neighborhood; Indicates the maximum grayscale value within the preset neighborhood; represents the preset first grayscale threshold, In one embodiment of the present invention, Set to 127, Set to 0.1.
[0085] In the process of obtaining the rust membership of the reclassified pixels, based on the characteristics that the grayscale value of the reflective pixels is the largest, the grayscale value of the rust pixels is the second, and the grayscale value of the shadow pixels is the smallest, when When , it means that the grayscale value of each pixel in the preset area is large. At this time, the smaller the grayscale value of the reclassified pixel located at the center of the preset neighborhood range is relative to other pixels, the greater the possibility that the reclassified pixel is a rust pixel. Therefore, the second number and the first quantity Ratio As a Rust eigenvalue, The larger the value, the smaller the gray value of the reclassified pixel is relative to other pixels in the preset neighborhood, which means that the reclassified pixel is more likely to be a rust-type pixel, and the larger the rust feature value of the reclassified pixel is; similarly, when , it means that the grayscale value of each pixel in the preset area is small. At this time, the larger the grayscale value of the reclassified pixel located at the center of the preset neighborhood range is relative to other pixels, the greater the possibility that the reclassified pixel is a rust pixel. Therefore, the first number and the second quantity Ratio As a Rust eigenvalue, The larger the value, the greater the gray value of the reclassified pixel is relative to other pixels in the preset neighborhood, which means that the reclassified pixel is more likely to be a rust pixel, and the greater the rust feature value of the reclassified pixel; , it means that there are both reflective pixels and shadow pixels in the preset neighborhood. At this time, the more the gray value of the reclassified pixel located at the center of the preset neighborhood is in the middle relative to other pixels, the greater the possibility that the reclassified pixel is a rust pixel. Indicates the difference between the first quantity and the second quantity, that is, the quantity difference, the quantity difference The smaller the value, the more the gray value of the reclassified pixel is centered relative to other pixels in the preset neighborhood. Therefore, the sum of the quantity difference and the preset second constant is negatively correlated with the inverse proportional function as the rust feature value. The preset second constant It is set to prevent the denominator from being 0; the rust eigenvalues are normalized to obtain the rust membership , the larger the rust membership, the greater the possibility that the reclassified pixel belongs to the rust class.
[0086] After obtaining the rust membership of the reclassified pixel points, the reclassified pixel points can be reclassified according to the rust membership and grayscale value of the reclassified pixel points to improve the clustering effect.
[0087] Preferably, in one embodiment of the present invention, reclassifying the reclassified pixels specifically includes:
[0088] The reclassified pixels whose rust membership is greater than the preset membership threshold are classified as rust, the reclassified pixels whose rust membership is not greater than the preset membership threshold and whose grayscale value is not greater than the preset second grayscale threshold are classified as shadow, and the reclassified pixels whose rust membership is not greater than the preset membership threshold and whose grayscale value is greater than the preset second grayscale threshold are classified as reflection. In one embodiment of the present invention, the preset membership threshold is set to 0.7, and the preset second grayscale threshold is set to 127.
[0089] After reclassifying the reclassified pixels, the accuracy of pixel clustering is improved, and in the subsequent process, the RGB image can be corrected according to each reclassified pixel.
[0090] Step S5: According to the category to which the reclassified pixel in the RGB image belongs and the channel value of the pixel in the preset neighborhood, the gain coefficient of each channel of the central pixel is obtained, and each channel of each pixel is corrected according to the gain coefficient to obtain an RGB corrected image.
[0091] Since the reflective area and shadow area in the RGB image will reduce the accuracy of the rust defect detection result, the automatic white balance algorithm can enhance the RGB image and improve the obviousness of the rust feature in the RGB image. The existing automatic white balance algorithm obtains the gain coefficient of each channel according to the channel components of the pixel point in the RGB image, and adjusts the channel components of the pixel point by the gain coefficient. However, the reflective area and shadow area in the RGB image of the ball screw surface are large, and there will be deviations after being processed by the existing automatic white balance algorithm, and the effect is poor. Therefore, in one embodiment of the present invention, an improved automatic white balance algorithm is used to enhance the RGB image, so that the rust feature is more prominent in the RGB image.
[0092] The automatic white balance algorithm needs to first obtain the gain coefficient of each channel component in the RGB image. In one embodiment of the present invention, the reclassified pixels are reclassified to significantly improve the effect of pixel clustering. Based on the category to which each pixel belongs after reclassification and the channel value of the pixel within a preset neighborhood, the gain coefficient of each channel of the central pixel is obtained, and the channel of each pixel is adjusted by the gain coefficient.
[0093] Preferably, in one embodiment of the present invention, the method for obtaining the gain coefficient specifically includes:
[0094] The maximum value of all channels of all pixels in the preset neighborhood is taken as the channel reference, the average value of each channel of all pixels in the preset neighborhood is taken as the channel mean, and the ratio of the channel reference and the channel mean is taken as the initial gain coefficient of each channel of the central pixel; the gain coefficient of each channel of the central pixel is obtained according to the product of the initial gain coefficient and the preset class gain factor. The specific expression is:
[0095]
[0096] in, Indicates the center pixel of The gain factor of the channel, where Channel available aisle; It represents the maximum value of all channels of all pixels in the preset neighborhood, that is, the channel reference value; Represents all pixels within the preset neighborhood Channel mean of the channel; represents a preset class gain factor. In one embodiment of the present invention, when the pixel point belongs to the reflective class, Set to 1.1, when the pixel belongs to the rust category, Set to 1.3, when the pixel belongs to the reflective category, It is set to 1.5. The preset class gain coefficient can be set by the implementer according to different implementation scenarios and is not limited here.
[0097] In the process of obtaining the gain coefficient of each channel of the central pixel, Represents the initial gain coefficient, and the product of the initial gain coefficient and the preset gain factor is used as the gain coefficient of each channel of the central pixel. The preset class gain factor sets different values according to the different categories to which the pixel belongs, so that the pixel can obtain a more appropriate gain coefficient according to the category to which it belongs.
[0098] After obtaining the gain coefficient of each channel of the pixel point, the channel of each pixel point can be corrected according to the gain coefficient to obtain an RGB corrected image, thereby improving the accuracy of subsequent detection of rust defects.
[0099] Preferably, in one embodiment of the present invention, correcting each channel of a pixel point according to a gain coefficient to obtain an RGB corrected image includes:
[0100] The product of the gain coefficient and each original channel value of each pixel is used as the corrected channel value of each channel of the pixel, and the corrected channel value of each channel of the pixel is used as the channel value of the corresponding channel of the pixel in the RGB image to obtain the RGB corrected image.
[0101] In one embodiment of the present invention, the expression for correcting the channel value is:
[0102]
[0103] in, Represents pixel of The correction channel value of the channel should be noted that when When it exceeds 255, ; Represents pixel of The raw channel value of the channel; Represents pixel of The gain factor of the channel, where Channel available aisle.
[0104] After correcting all the pixels in the RGB image, the corresponding RGB corrected image is obtained. In the RGB corrected image, the rust features are more obvious, the image quality is significantly improved, and the influence of the reflective area and shadow area in the RGB image on the subsequent detection of rust defects is reduced.
[0105] Step S6: clustering the pixels according to the channel values of the pixels in the RGB corrected image, and detecting the surface defects of the ball screw according to the clustering results.
[0106] The quality of the acquired RGB corrected image is significantly improved. The features of the rust part in the RGB corrected image are relatively more obvious in the reflective area and the shadow area, which improves the accuracy of rust defect detection. Therefore, the pixels of the RGB corrected image can be clustered, and the surface defects of the ball screw can be detected according to the clustering results.
[0107] Preferably, in one embodiment of the present invention, detecting surface defects of a ball screw according to clustering results includes:
[0108] The number of rust pixels in the cluster is counted, and the ratio of the number of rust pixels to the total number of pixels is used as the rust specific gravity. If the rust specific gravity is greater than a preset specific gravity threshold, there is a rust defect on the surface of the ball screw. If the rust specific gravity is not greater than the preset specific gravity threshold, there is no rust defect on the surface of the ball screw. In one embodiment of the present invention, the preset specific gravity threshold is set to 0.3.
[0109] It should be noted that, in order to accurately identify the rust pixels in the RGB corrected image, in one embodiment of the present invention, the Chameleon clustering algorithm is used to cluster the pixels in the RGB corrected image. The Chameleon clustering algorithm is a technical means well known to those skilled in the art and will not be described in detail here.
[0110] After completing the detection of rust defects on the surface of the ball screw, it can be determined whether to replace the ball screw based on the test results to ensure that the equipment maintains a high level of accuracy during operation.
[0111] An embodiment of the present invention provides an intelligent detection device for screw surface defects, which includes a memory, a processor and a computer program, wherein the memory is used to store the corresponding computer program, and the processor is used to run the corresponding computer program. When the computer program runs in the processor, it can implement the method described in steps S1 to S6.
[0112] In summary, the embodiment of the present invention first obtains an RGB image and a grayscale image of the surface of a ball screw, clusters the pixels of the RGB image, divides the clusters into a reflection class, a rust class, and a shadow class, obtains a class attribution mark of the pixel according to the cluster in which the pixel is located, obtains a grayscale sequence difference degree according to the difference between the grayscale values of the pixels in the grayscale ordered sequence, obtains a class attribution mark sequence consistency strength according to the distribution of the class attribution marks in the class attribution mark sequence, and obtains the class attribution reliability of the pixel in combination with the grayscale sequence difference degree and consistency strength; obtains reclassified pixels in the image based on the class attribution reliability, obtains the rust membership of the reclassified pixels based on the distribution of the grayscale values of the pixels within a preset neighborhood range of each reclassified pixel, reclassifies the reclassified pixels based on the rust membership and the grayscale value, corrects each channel of the pixel in the RGB image according to the category to which the pixel belongs after reclassification, obtains an RGB corrected image, clusters the RGB corrected image again, and detects surface defects of the ball screw according to the proportion of the number of rust pixels after clustering. The embodiment of the present invention clusters the pixels in the RGB image, analyzes the clustering results, adjusts the categories to which the pixels belong, thereby improving the accuracy of the clustering results, corrects the pixels based on the categories to which the pixels belong, clusters the pixels in the RGB corrected image again, and detects rust defects on the surface of the ball screw according to the clustering results, thereby eliminating the influence of the presence of reflective areas and shadow areas on the identification of rust defects in the image, thereby improving the accuracy of the detection results of ball screw surface defects.
[0113] Screw surface defect image enhancement method embodiment:
[0114] The existing method of surface defect image enhancement is to use the ACE enhancement algorithm to enhance the image and enhance the contrast of the defective part. However, due to the influence of lighting conditions and environmental interference, a large number of reflective areas and shadow areas are prone to appear in the surface image of the ball screw. The features of rust in the reflective area are not obvious. The use of the ACE enhancement algorithm will lead to the loss of high-frequency details. The features between the shadow area and the rust area are similar. The use of the ACE enhancement algorithm will misidentify the shadow area as the rust area, resulting in the loss of some rust details and misidentification when using the ACE enhancement algorithm to enhance the image, which reduces the quality of the enhanced image.
[0115] In order to solve this problem, this embodiment provides a method for enhancing a screw surface defect image, comprising:
[0116] Step S1: obtaining an RGB image and a grayscale image of the surface of the ball screw;
[0117] Step S2: clustering the pixels according to the channel values of the pixels in the RGB image, and obtaining the class attribution label of the pixels according to the clusters to which the pixels belong, wherein the clusters include reflection class, rust class and shadow class;
[0118] Step S3: In the grayscale image, all pixels in a preset neighborhood with the pixel as the center are sorted according to the grayscale value to obtain a grayscale ordered sequence; according to the difference between the grayscale values of the pixels in the grayscale ordered sequence, the degree of difference of the grayscale sequence is obtained; the grayscale value in the grayscale ordered sequence is set as the class attribution mark of the corresponding pixel to obtain a class attribution mark sequence, and according to the distribution of the class attribution mark in the class attribution mark sequence, the consistency strength of the class attribution mark sequence is obtained; according to the grayscale sequence difference degree and the consistency strength, the class attribution reliability of the central pixel is obtained;
[0119] Step S4: obtaining reclassified pixels from the pixels according to the class attribution reliability, obtaining the rust membership of the reclassified pixels according to the distribution of the grayscale values of the pixels within a preset neighborhood of each reclassified pixel; and reclassifying the reclassified pixels according to the rust membership and grayscale values of the reclassified pixels;
[0120] Step S5: Obtain a gain coefficient for each channel of the central pixel according to the category to which the reclassified pixel in the RGB image belongs and the channel value of the pixel within a preset neighborhood range, and correct each channel of each pixel according to the gain coefficient to obtain an RGB corrected image.
[0121] Among them, steps S1 to S5 have been described in detail in the above-mentioned embodiment of the intelligent detection method for screw surface defects, and will not be repeated here.
[0122] The beneficial effects brought by this embodiment are as follows: considering that there is a relatively obvious difference in color between the rust part and the non-rust part in the RGB image of the ball screw surface, the pixels of the RGB image are clustered, and the RGB image mainly contains rust areas, reflective areas and shadow areas, so the clustering clusters are divided into light class, rust class and dark class, and the class attribution mark of the pixel point is obtained according to the clustering cluster where the pixel point is located, which is used to distinguish the pixel point category and provide data support for the subsequent acquisition of class attribution reliability; considering that the existence of light and shadow areas will reduce the accuracy of the clustering results, it is impossible to identify all rust pixels, and it is necessary to judge the clustering results of the pixel points, while the grayscale value of the pixel point in the reflective area is larger, the grayscale value of the pixel point in the shadow area is smaller, and the grayscale value of the pixel point in the rust area is relatively centered, so a preset neighborhood range centered on the pixel point can be established, and a grayscale ordered sequence and a class attribution mark sequence can be obtained, and the degree of difference in the grayscale value in the grayscale ordered sequence and the class attribution mark sequence can be obtained. The consistency of the distribution of class attribution marks in the attribution mark sequence can reflect the accuracy of the clustering results of the central pixel point, so the class attribution reliability of the central pixel point can be obtained by combining the grayscale sequence difference degree and consistency strength, and the accuracy of the pixel point in the category to which it belongs can be judged by the class attribution reliability, which is convenient for the subsequent acquisition of reclassified pixels; since the grayscale value of the rust pixel point in the image is relatively centered compared with the reflective area pixel point and the shadow area pixel point, the rust membership of the reclassified pixel point can be obtained according to the distribution of the grayscale value of the pixel point in the preset neighborhood range of each reclassified pixel point, so as to improve the accuracy of the recognition of the rust pixel point in the subsequent reclassification, reclassify the reclassified pixels, improve the accuracy of the clustering results, provide data support for the subsequent correction of the pixels, correct the pixels according to the obtained gain coefficient, and obtain the RGB corrected image, which enhances the characteristics of the rust in the image, greatly retains the detailed characteristics of the rust defects in the image, and improves the quality of the image.
[0123] 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.
[0124] 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. An intelligent detection method for screw surface defects, characterized in that: The method comprises: Get the RGB image and grayscale image of the ball screw surface; Clustering the pixels according to the channel values of the pixels in the RGB image, and obtaining the class attribution labels of the pixels according to the clusters to which the pixels belong, wherein the clusters include reflection class, rust class and shadow class; In the grayscale image, all pixels in a preset neighborhood with a pixel as the center are sorted according to grayscale values to obtain a grayscale ordered sequence; according to the difference between the grayscale values of the pixels in the grayscale ordered sequence, the degree of difference of the grayscale sequence is obtained; the grayscale value in the grayscale ordered sequence is set as the class attribution mark of the corresponding pixel; a class attribution mark sequence is obtained, and according to the distribution of the class attribution marks in the class attribution mark sequence, the consistency strength of the class attribution mark sequence is obtained; according to the degree of difference of the grayscale sequence and the consistency strength, the class attribution reliability of the central pixel is obtained; Obtain reclassified pixels from the pixels according to the class attribution reliability, obtain the rust membership of the reclassified pixels according to the distribution of the grayscale values of the pixels within a preset neighborhood of each reclassified pixel; and reclassify the reclassified pixels according to the rust membership and grayscale values of the reclassified pixels; Obtain a gain coefficient for each channel of the central pixel according to the category to which the reclassified pixel in the RGB image belongs and the channel value of the pixel within the preset neighborhood, and correct each channel of each pixel according to the gain coefficient to obtain an RGB corrected image; The pixels are clustered according to the channel values of the pixels in the RGB corrected image, and the surface defects of the ball screw are detected based on the clustering results.
2. The intelligent detection method for screw surface defects according to claim 1 is characterized in that: The method for obtaining the grayscale sequence difference degree includes: Taking the absolute value of the difference between the ratio of the grayscale values of adjacent pixels in the grayscale ordered sequence and the constant 1 as the grayscale difference between the adjacent pixels, and normalizing the grayscale difference to obtain a grayscale difference parameter; The average value of all the grayscale difference parameters is used as the grayscale sequence difference degree of the grayscale ordered sequence.
3. The intelligent detection method for screw surface defects according to claim 1 is characterized in that: The method for obtaining the consistency strength of the class attribution marker sequence includes: Obtain a class attribution label matrix, wherein the rows of the class attribution label matrix represent the types of the class attribution labels, the columns of the class attribution label matrix represent the consecutive times of the same class attribution label in the class attribution label sequence, and the elements in the class attribution label matrix represent the number of subsequences that meet the row condition and the column condition; The difference between the number of columns of the class attribution label matrix and the number of columns where each element is located is used as the column number distance of each element, the square of the sum of the column number distance and a preset first constant is used as the column number difference of each element, and the average value of the ratio of all elements in the class attribution label matrix to the column number difference is used as the first characteristic parameter; Sorting the class attribution marks in the class attribution mark sequence according to the sorting method of the grayscale sequence to obtain an ordered sequence of class attribution marks, and taking the number of positions with the same position and the same elements in the class attribution mark sequence and the ordered sequence of class attribution marks as a second characteristic parameter; The product of the first feature parameter and the second feature parameter is used as the consistency strength of the class attribution label sequence.
4. The intelligent detection method for screw surface defects according to claim 1 is characterized in that: The method for obtaining the class attribution reliability of the central pixel point includes: The consistency strength is positively correlated with the class attribution reliability, the grayscale sequence difference degree is negatively correlated with the class attribution reliability, and the value of the class attribution reliability is a normalized value.
5. The intelligent detection method for screw surface defects according to claim 1, characterized in that: The step of obtaining the rust membership of the reclassified pixel points according to the distribution of the grayscale values of the pixel points within the preset neighborhood of each reclassified pixel point comprises: The pixel points whose class attribution reliability is less than a preset reliability threshold are used as the reclassified pixel points; Obtaining the minimum grayscale value and the maximum grayscale value within a preset neighborhood range of the reclassified pixel point; taking the number of pixel points whose grayscale values within the preset neighborhood range are less than or equal to the grayscale value of the central pixel point as the first number, and taking the number of pixel points whose grayscale values within the preset neighborhood range are greater than or equal to the grayscale value of the central pixel point as the second number; When the minimum gray value is greater than or equal to the preset first gray threshold, the ratio of the second quantity to the first quantity is taken as the rust characteristic value; when the maximum gray value is less than the preset first gray threshold, the ratio of the first quantity to the second quantity is taken as the rust characteristic value; when the minimum gray value is less than the preset first gray threshold and the maximum gray value is greater than or equal to the preset first gray threshold, the absolute value of the difference between the ratio of the second quantity to the first quantity and the constant 1 is taken as the quantity difference, and the quantity difference is negatively correlated with the sum of the preset second constant to obtain the rust characteristic value; The rust characteristic value is normalized to obtain the rust membership of the reclassified pixel point.
6. The intelligent detection method for screw surface defects according to claim 1, characterized in that: The reclassifying the reclassified pixel points according to the rust membership and grayscale value of the reclassified pixel points comprises: Classifying the reclassified pixel points whose rust membership is greater than a preset membership threshold as the rust class; Classify the reclassified pixel points whose rust membership is not greater than a preset membership threshold and whose grayscale value is not greater than a preset second grayscale threshold as the shadow class; The reclassified pixel points whose rust membership is not greater than a preset membership threshold and whose grayscale value is greater than a preset second grayscale threshold are classified as the reflective class.
7. The intelligent detection method for screw surface defects according to claim 1 is characterized in that: The method for obtaining the gain coefficient includes: The maximum value of all channels of all pixels within the preset neighborhood is used as a channel reference, the average value of each channel of all pixels within the preset neighborhood is used as a channel mean, and the ratio of the channel reference value to the channel mean is used as an initial gain coefficient of each channel of the central pixel; The gain coefficient of each channel of the central pixel is obtained according to the product of the initial gain coefficient and the preset class gain factor.
8. The intelligent detection method for screw surface defects according to claim 1, characterized in that: Correcting each channel of the pixel point according to the gain coefficient to obtain an RGB corrected image comprises: The product value of the gain coefficient and each original channel value of each pixel is used as the corrected channel value of each channel of the pixel, and the corrected channel value of each channel of the pixel is used as the channel value of the corresponding channel of the pixel in the RGB image to obtain an RGB corrected image.
9. The intelligent detection method for screw surface defects according to claim 1, characterized in that: The detecting of the surface defects of the ball screw according to the clustering results comprises: The number of rust pixels in the cluster is counted, and the ratio of the number of rust pixels to the total number of pixels is taken as the rust proportion. If the rust proportion is greater than the preset proportion threshold, there is a rust defect on the surface of the ball screw. If the rust proportion is not greater than the preset proportion threshold, there is no rust defect on the surface of the ball screw.
10. An intelligent detection device for screw surface defects, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 9 when executing the computer program.
