A method for detecting double gold sheets of protectors based on machine vision
By acquiring the preprocessing and feature value calculation of the bimetallic surface image, the CLAHE algorithm parameters are adaptively adjusted, which solves the detection deviation problem caused by light interference and improves the accuracy of bimetallic corrosion detection.
Patent Information
- Application Number
- CN202510732887.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-04
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2045-06-04
AI Technical Summary
In the prior art, when the surface corrosion of the bimetallic sheet is detected by using a CNN neural network, the interference of reflected light causes deviations in detection results, affecting the detection accuracy.
By acquiring the bimetallic surface image, pre-processing and threshold segmentation, the grayscale brightness and edge texture feature values of the segmented area are obtained, the lighting interference evaluation coefficient is calculated, and the cropping parameters of the CLAHE algorithm are adaptively adjusted, image enhancement is performed, and lighting interference is eliminated.
The accuracy of surface corrosion detection of bimetallic sheets is improved, the characteristics of corrosion areas in the image are enhanced, noise interference is reduced, and the accuracy of detection results is improved.
Smart Images

Figure CN120259288B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image enhancement, and in particular to a method for detecting double gold sheets of a protector based on machine vision. Background Art
[0002] The double gold strip (bimetallic strip) of a protector is a core component that works based on the principle of thermal expansion. It is widely used in electrical equipment and household appliances. Its function is to achieve overload protection and temperature control through the characteristics of temperature-sensitive sensors. Therefore, its quality problems will directly affect the overheat protection function of the equipment. Because bimetallic strips are generally composed of two metals with different thermal expansion coefficients (such as nickel-manganese alloy + nickel-iron alloy), although this type of material has high thermal sensitivity and resistivity, its inherent corrosion resistance is poor. In addition, the difference in alloy composition leads to galvanic corrosion in corrosive media, and the metal layer with lower potential (anode) will accelerate corrosion. At the same time, the material is more sensitive to high temperature and high humidity environments and corrosive gases, which will aggravate the severity of metal surface corrosion. Therefore, accurately identifying and detecting surface corrosion problems is crucial for the quality inspection and evaluation of bimetallic strips.
[0003] In the existing technology, surface corrosion detection and positioning of bimetallic strips are performed through the CNN neural network in machine learning. The specific process is: training a binary classification model to automatically learn corrosion features to determine whether there is corrosion in the currently collected surface image of the bimetallic strip. However, in the actual processing process, due to the presence of free electrons on the surface of this type of metal, the incident light will be effectively concentrated and reflected back to produce a metallic luster phenomenon on its surface, causing the surface image to have uneven brightness or shadow effect, which in turn causes the characteristics of the corrosion area to change or weaken, resulting in a large deviation in the corrosion results detected using the CNN neural network.
[0004] Therefore, how to eliminate the interference of reflected light and improve the accuracy of detecting surface corrosion of bimetallic strips using CNN neural network has become an urgent problem to be solved. Summary of the Invention
[0005] In view of this, an embodiment of the present invention provides a method for detecting double metal strips of a protector based on machine vision to solve the problem of how to eliminate the interference of reflected light and improve the accuracy of detecting surface corrosion of the bimetallic strip using a CNN neural network.
[0006] An embodiment of the present invention provides a method for detecting double gold sheets of a protector based on machine vision, the method comprising the following steps:
[0007] Acquire a surface image of the bimetallic strip, pre-process the surface image to obtain a grayscale image; perform threshold segmentation on the grayscale image to obtain at least one segmented region;
[0008] For any segmented area, obtain the regional grayscale brightness eigenvalue based on the grayscale value distribution of the pixels in the segmented area, obtain the edge texture eigenvalue based on the grayscale co-occurrence matrix of the segmented area and the gradient value of each edge pixel, and obtain the evaluation coefficient of the illumination interference of the segmented area based on the regional grayscale brightness eigenvalue and the edge texture eigenvalue;
[0009] Obtaining an evaluation coefficient for each segmented region, obtaining an adaptive cropping parameter for performing contrast-limited adaptive histogram equalization on each segmented region based on the evaluation coefficient for each segmented region, and performing image enhancement on each segmented region in the grayscale image based on the adaptive cropping parameter to obtain an enhanced grayscale image;
[0010] The enhanced grayscale image is used to obtain a corrosion detection result in the bimetallic strip.
[0011] Preferably, obtaining the regional grayscale brightness characteristic value according to the grayscale value distribution of the pixels in any segmented region includes:
[0012] Obtaining an overall grayscale distribution evaluation value based on the grayscale value of each pixel in any of the segmented areas; constructing a grayscale value change curve for any of the segmented areas, wherein the horizontal axis of the grayscale value change curve is the grayscale value and the vertical axis is the number of pixels, and obtaining a histogram distribution evaluation value based on the fluctuation characteristics of the grayscale value change curve;
[0013] A regional grayscale brightness characteristic value is obtained according to the maximum value between the overall grayscale distribution evaluation value and the histogram distribution evaluation value.
[0014] Preferably, obtaining the overall grayscale distribution evaluation value according to the grayscale value of each pixel in any segmented area includes:
[0015] According to the grayscale value of each pixel point in any segmented area, the grayscale value mean is calculated, and the ratio of the grayscale value mean to the maximum grayscale value is used as the overall grayscale distribution evaluation value.
[0016] Preferably, obtaining a histogram distribution evaluation value according to the fluctuation characteristics of the gray value change curve includes:
[0017] Obtaining a local maximum peak point in the grayscale value change curve, sorting the ordinate value of each local maximum peak point in descending order to obtain a ordinate value sequence, and using the local maximum peak points corresponding to the first two elements in the ordinate value sequence as the peak points to be analyzed;
[0018] Calculating the absolute value of the grayscale value difference according to the grayscale value corresponding to each peak point to be analyzed, obtaining the absolute value of the difference between the absolute value of the grayscale value difference and a preset reference grayscale difference value, and normalizing the absolute value of the difference using a preset exponential function to obtain a corresponding normalized value;
[0019] The ratio of the sum of the number of pixels corresponding to all peak points to be analyzed to the total number of pixels in any segmented area is obtained, and a weighted sum is performed on the ratio and the normalized value to obtain a histogram distribution evaluation value.
[0020] Preferably, obtaining the edge texture feature value according to the gray level co-occurrence matrix of any segmented area and the gradient value of each edge pixel point includes:
[0021] Obtaining a gray level co-occurrence matrix of any of the segmented regions, and obtaining a texture distribution feature evaluation value of any of the segmented regions according to the gray level co-occurrence matrix;
[0022] Perform edge detection on any of the segmented areas to obtain an initial edge, perform edge discontinuity repair on the initial edge using curve fitting to obtain a complete edge, and obtain an edge distribution feature evaluation value of any of the segmented areas based on the number of edge pixels on the initial edge and the gradient value of each edge pixel on the complete edge;
[0023] An edge texture feature value is obtained according to the average of the texture distribution feature evaluation value and the edge distribution feature evaluation value.
[0024] Preferably, obtaining the texture distribution feature evaluation value of any segmented region according to the gray level co-occurrence matrix includes:
[0025] The entropy value of the gray-level co-occurrence matrix is obtained, and the entropy value is normalized using a hyperbolic tangent function to obtain a normalized entropy value. The difference between a constant 1 and the normalized entropy value is recorded as a texture distribution feature evaluation value.
[0026] Preferably, obtaining the edge distribution feature evaluation value of any segmented area according to the number of edge pixels of the initial edge and the gradient value of each edge pixel of the complete edge includes:
[0027] Calculate the quantity ratio between the number of edge pixels of the initial edge and the number of edge pixels of the complete edge, calculate the gradient value mean of all edge pixels of the complete edge, normalize the gradient value mean to obtain a normalized mean, perform weighted summation on the quantity ratio and the normalized mean to obtain a weighted summation result, and record the difference between a constant 1 and the weighted summation result as the edge distribution feature evaluation value of any segmented area.
[0028] Preferably, obtaining the evaluation coefficient of illumination interference of any segmented region according to the regional grayscale brightness characteristic value and the edge texture characteristic value includes:
[0029] The average of the regional grayscale brightness characteristic value and the edge texture characteristic value is recorded as the evaluation coefficient of the illumination interference of any segmented region.
[0030] Preferably, obtaining the adaptive cropping parameters when performing contrast-limited adaptive histogram equalization on each segmented region according to the evaluation coefficient of each segmented region includes:
[0031] For any segmented area, if the evaluation coefficient of any segmented area is less than or equal to the preset evaluation coefficient threshold, the first piecewise function is used to obtain the adaptive clipping parameters when the restricted contrast adaptive histogram equalization is performed on any segmented area, wherein the calculation expression of the first piecewise function is: , represents the adaptive cropping parameters, represents the evaluation coefficient, and 0.5 represents the evaluation coefficient threshold.
[0032] Preferably, the step of obtaining the adaptive cropping parameters for performing contrast-limited adaptive histogram equalization on each segmented region according to the evaluation coefficient of each segmented region further includes:
[0033] If the evaluation coefficient of any segmented area is greater than the preset evaluation coefficient threshold, the adaptive clipping parameter for the restricted contrast adaptive histogram equalization of any segmented area is obtained by using the second piecewise function, wherein the calculation expression of the second piecewise function is: .
[0034] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0035] The present invention obtains a surface image of a bimetallic strip, pre-processes the surface image to obtain a grayscale image; performs threshold segmentation on the grayscale image to obtain at least one segmented area; for any segmented area, obtains a regional grayscale brightness eigenvalue based on the grayscale value distribution of pixel points in the any segmented area, obtains an edge texture eigenvalue based on the grayscale co-occurrence matrix of the any segmented area and the gradient value of each edge pixel point, and obtains an evaluation coefficient of illumination interference of the any segmented area based on the regional grayscale brightness eigenvalue and the edge texture eigenvalue; obtains an evaluation coefficient of each segmented area, obtains an adaptive clipping parameter when performing contrast-limited adaptive histogram equalization on each segmented area based on the evaluation coefficient of each segmented area, performs image enhancement on each segmented area in the grayscale image based on the adaptive clipping parameter to obtain an enhanced grayscale image; and uses the enhanced grayscale image to obtain a corrosion detection result in the bimetallic strip. Among them, the surface image of the bimetallic strip is adaptively divided into multiple segmented areas through the Otsu method, and the adaptive cropping parameters of each segmented area are obtained when the surface image is subjected to limited contrast adaptive histogram equalization based on the evaluation coefficient of the degree of light interference of each segmented area. When the light interference is severe, the cropping parameters are increased to enhance the detail contrast, and when the light interference is light, the cropping parameters are reduced to avoid excessive enhancement of a small amount of noise, so that the enhanced image can reflect more effective information, thereby improving the accuracy of surface corrosion detection of the bimetallic strip based on the enhanced image. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. 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 any creative work.
[0037] Figure 1 This is a flow chart of a method for detecting double gold sheets of a protector based on machine vision provided in the first embodiment of the present invention;
[0038] Figure 2 Schematic diagram of a bimetallic strip provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0039] The embodiments of the present disclosure are described in detail below, and examples of the embodiments are shown in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and intended to be used to explain the present disclosure, but should not be understood as limiting the present disclosure.
[0040] It should be noted that the terms "first," "second," and the like in the specification of the present disclosure and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure.
[0041] In order to illustrate the technical solution of the present invention, specific embodiments are provided below.
[0042] See also Figure 1 , is a flow chart of a method for detecting double gold sheets of a protector based on machine vision provided in the first embodiment of the present invention, such as Figure 1 As shown, the method may include:
[0043] Step S101 , obtaining a surface image of the bimetallic strip, preprocessing the surface image to obtain a grayscale image; performing threshold segmentation on the grayscale image to obtain at least one segmented region.
[0044] The embodiment of the present invention sets the light source position and light source angle on the detection platform for shooting such as Figure 2 The surface image of the bimetallic strip shown in the figure requires the following setup: select an LED or halogen light source, ensure good light source stability and adjustable brightness, and set the light source to the side or above the detection platform. The light source angle is generally 35 to 45 degrees higher than the subject (this is the default industry standard parameter setting, which can be adjusted according to specific circumstances). This will create a small amount of shadow on the subject, which relatively enhances the three-dimensional effect. The height of the light source should be higher than the subject's eye level, but be careful not to be too high to avoid excessive shadows.
[0045] After setting the light source position and angle, use a high-resolution industrial camera to capture the surface image of the bimetallic strip to ensure that more detailed features of the bimetallic strip's surface can be captured. During the shooting process, it is necessary to adjust the camera's focal length, exposure time and other parameters to ensure that the surface image with the best image quality is obtained. It is worth noting that when shooting the surface image of the bimetallic strip, ensure that the surface on the detection platform is flat and unobstructed.
[0046] After obtaining the surface image of the bimetallic strip, the surface image is preprocessed to obtain a grayscale image. The specific preprocessing process is: first use denoising algorithms such as Gaussian filtering and median filtering to eliminate the noise in the image, and then grayscale the image to obtain the corresponding grayscale image. This preprocessing method can reduce the subsequent calculation amount and ensure the quality of the grayscale image to the greatest extent.
[0047] The contrast-limited adaptive histogram equalization (CLAHE) algorithm is an image enhancement technique designed to improve local contrast in an image while avoiding excessive noise amplification. A variant of adaptive histogram equalization (AHE), CLAHE avoids the excessive noise amplification that AHE can cause by limiting the increase in contrast. The basic idea of CLAHE is to divide the image into multiple non-overlapping blocks, perform histogram equalization on each block, and then combine the equalization results of these blocks through interpolation to form the final enhanced image.
[0048] In the embodiment of the present invention, considering the presence of free electrons on the surface of the bimetallic strip, the incident light will be effectively concentrated and reflected back during image acquisition to produce a metallic luster phenomenon on the surface, resulting in uneven brightness or shadow effects in the grayscale image, causing the characteristics of the corrosion area to change or weaken. Therefore, the CLAHE algorithm is used to enhance the grayscale image, and the enhanced grayscale image is used to perform corrosion detection on the bimetallic strip.
[0049] Typically, the CLAHE algorithm divides an image into multiple non-overlapping small blocks. However, in order to detect corrosion areas, the embodiment of the present invention needs to enhance the corrosion features in the grayscale image. Therefore, the embodiment of the present invention uses the Otsu Adaptive Threshold Segmentation (OTSU) algorithm to perform threshold segmentation on the grayscale image to obtain at least one segmented area to separate the foreground and background in the grayscale image. The OTSU algorithm is a method for automatically calculating the threshold. It maximizes the inter-class variance to find the optimal segmentation threshold, and divides the image into the foreground and background. The inter-class variance between the two parts is maximized and the intra-class variance is minimized. The OTSU algorithm is a prior art and will not be described in detail here.
[0050] After obtaining all the segmented regions, each segmented region can also be preprocessed. The specific process is to use morphological opening operations to eliminate isolated noise points, and then use morphological closing operations to fill holes, optimize region boundaries, and perform regional optimization on each segmented region. The preprocessing process belongs to the existing technology and will not be described in detail here.
[0051] Step S102: For any segmented area, the regional grayscale brightness eigenvalue is obtained according to the grayscale value distribution of the pixels in any segmented area, the edge texture eigenvalue is obtained according to the grayscale co-occurrence matrix of any segmented area and the gradient value of each edge pixel, and the evaluation coefficient of the illumination interference of any segmented area is obtained according to the regional grayscale brightness eigenvalue and the edge texture eigenvalue.
[0052] The CLAHE algorithm has a key parameter called "clipLimit," which is referred to as the clipping parameter in this embodiment. It sets the threshold for grayscale distribution in the histogram. When the number of pixels at a certain grayscale level exceeds this threshold, the excess pixels are clipped and evenly distributed across other grayscale levels. This limits contrast increases and prevents excessive noise amplification. When using the CLAHE algorithm for image enhancement, the enhancement effect depends largely on the choice of the clipping parameter. Smaller values limit contrast enhancement, thereby reducing noise amplification, while larger values enhance contrast but may introduce more noise. However, the selection of the clipping parameter is typically empirical, and different clipping parameter settings may be required for different images and application scenarios. Therefore, to eliminate light interference on the bimetallic strip surface and improve the grayscale image enhancement effect of the CLAHE algorithm, this embodiment sets adaptive clipping parameters for each segmented region based on the pixel information contained in each segmented region to meet the requirements of the current application scenario.
[0053] When the light reflection is too strong, the contrast between the corrosion area and the normal metal area in the grayscale image decreases, which will mask the corrosion details or cause the morphology of the corrosion area to be distorted. Therefore, in an embodiment of the present invention, the evaluation is first performed by judging the change in the internal grayscale distribution of each segmented area. For example, assuming that any segmented area is an overexposed area, the local or overall grayscale value of the segmented area is close to saturation (such as 255) and loses details. The light interference does not completely cover the segmented area, and its local area is close to saturation. If it is completely covered, its overall area is close to saturation. Secondly, the blurring degree of the internal texture of each segmented area (uneven lighting causes the rough texture of the corrosion area, such as pitting and intergranular corrosion, to be smoothed) and edge fracture (reflection or shadow causes discontinuity of the corrosion boundary, and breakpoints appear in Canny edge detection) can be analyzed to comprehensively analyze the evaluation coefficient of the light interference of each segmented area. The larger the evaluation coefficient, the greater the degree of light interference.
[0054] Taking any segmented area as an example, the method for obtaining the evaluation coefficient of the illumination interference of any segmented area is as follows:
[0055] (1) According to the gray value distribution of pixels in any segmented area, the regional gray brightness feature value is obtained.
[0056] Specifically, first, the grayscale value mean is calculated according to the grayscale value of each pixel in any segmented area, and the ratio of the grayscale value mean to the maximum grayscale value is used as the overall grayscale distribution evaluation value, wherein the calculation formula of the overall grayscale distribution evaluation value is:
[0057]
[0058] in, Represents the overall grayscale distribution evaluation value, represents the number of pixels in any segmented area I, represents the grayscale value of the i-th pixel in any segmented area I, and 255 represents the maximum grayscale value.
[0059] It should be noted that, the larger the mean grayscale value of any segmented region I is, the stronger the degree of light interference that any segmented region I may be subjected to, and the larger the corresponding overall grayscale distribution evaluation value.
[0060] Then, a grayscale value variation curve for each segmented region is constructed, where the horizontal axis of the grayscale value variation curve represents the grayscale value and the vertical axis represents the number of pixels. A binary search method is used to obtain the local maximum peak point in the grayscale value variation curve, which is a prior art technique and will not be further described here. The ordinate values of each local maximum peak point are sorted in descending order to obtain a sequence of ordinate values. The local maximum peak points corresponding to the first two elements of the ordinate value sequence are selected as the peak points to be analyzed.
[0061] Calculating the absolute value of the grayscale value difference according to the grayscale value corresponding to each peak point to be analyzed, obtaining the absolute value of the difference between the absolute value of the grayscale value difference and a preset reference grayscale difference value, and normalizing the absolute value of the difference using a preset exponential function to obtain a corresponding normalized value;
[0062] The ratio of the sum of the number of pixels corresponding to all peak points to be analyzed to the total number of pixels in any segmented area is obtained, and a weighted sum is performed on the ratio and the normalized value to obtain a histogram distribution evaluation value.
[0063] Among them, the calculation formula of the histogram distribution evaluation value is:
[0064]
[0065] in, represents the histogram distribution evaluation value, represents the first weight, Indicates the number of pixels corresponding to the first peak point to be analyzed. Indicates the number of pixels corresponding to the second peak point to be analyzed. represents the total number of pixels in any segmented area I, represents the second weight, represents an exponential function with a natural constant as base, Indicates the grayscale value corresponding to the first peak point to be analyzed, Indicates the grayscale value corresponding to the second peak point to be analyzed, Represents the reference grayscale difference value, Indicates the sign of the difference value.
[0066] It should be noted that The larger the value is, the more dominant the two peak points to be analyzed are in the gray value change curve, the higher the number of pixels, the gray value in any segmented area I is severely differentiated, the illumination interference is not completely covered, and the area is close to saturation. The corresponding histogram distribution evaluation value is larger. The larger the value, the greater the interval between the two peak points to be analyzed. The larger the peak distance, the easier it is to distinguish the two peak points. Based on experimental statistics, The default value is 50, which is used to measure the grayscale difference between the two peak points to be analyzed. The smaller the value is, the closer the grayscale difference between the two peak points to be analyzed is to the constant The smaller the difference between them, the less complete the illumination interference is, the closer it is to local saturation, and the larger the corresponding histogram distribution evaluation value is. Considering that the histogram distribution evaluation value is expanded from two dimensions, the weights of the two dimensions are set to be the same, so set , which is not displayed here and can be adjusted according to actual conditions.
[0067] Finally, the regional grayscale brightness characteristic value is obtained according to the maximum value between the overall grayscale distribution evaluation value and the histogram distribution evaluation value, wherein the calculation formula of the regional grayscale brightness characteristic value is: , represents the regional grayscale brightness characteristic value of any segmented region I, Represents the maximum function.
[0068] It should be noted that if the light interference is completely covered, the overall gray value of any segmented area I is close to saturation. The closer it is to 1; if the light interference is not completely covered, any segmented area I is locally close to saturation. The closer it is to 1, the more serious the polarization of pixel grayscale values appears in any segmented area I, which is manifested as an obvious double-peak feature in the grayscale value change curve. The maximum value of the two calculation results is finally selected to indicate that any of the conditions is met. It can be considered that there is overexposure caused by light interference, and the degree of light interference is large.
[0069] (2) The edge texture feature value is obtained based on the gray level co-occurrence matrix of any segmented area and the gradient value of each edge pixel.
[0070] Specifically, the gray level co-occurrence matrix of any segmented area is obtained, the entropy value of the gray level co-occurrence matrix is obtained, the entropy value is normalized using a hyperbolic tangent function to obtain a normalized entropy value, and the difference between the constant 1 and the normalized entropy value is recorded as the texture distribution feature evaluation value.
[0071] Among them, the calculation expression of the texture distribution feature evaluation value is:
[0072]
[0073] in, Represents the texture distribution feature evaluation value, 1 represents a constant, represents the hyperbolic tangent function, It represents the entropy value of the gray-level co-occurrence matrix, which belongs to the prior art and will not be described here.
[0074] It should be noted that the entropy value can describe the randomness and complexity of the grayscale distribution in any segmented area I. The larger the entropy value, the more complex the texture inside any segmented area I. If any segmented area I is disturbed by light, uneven light will cause the rough texture of the area, such as pitting and intergranular corrosion, to be smoothed, and the texture features will be simpler. Therefore, the larger the entropy value, the smaller the degree of light interference in any segmented area I, and the smaller the corresponding texture distribution feature evaluation value.
[0075] Use the Canny operator to perform edge detection on any of the segmented areas to obtain an initial edge, use curve fitting to repair edge discontinuities on the initial edge to obtain a complete edge, calculate the quantity ratio between the number of edge pixels of the initial edge and the number of edge pixels of the complete edge, calculate the mean gradient value of all edge pixels of the complete edge, normalize the mean gradient value to obtain a normalized mean, perform weighted summation on the quantity ratio and the normalized mean to obtain a weighted summation result, and record the difference between a constant 1 and the weighted summation result as the edge distribution feature evaluation value of any of the segmented areas.
[0076] Among them, the calculation formula of the marginal distribution feature evaluation value is:
[0077]
[0078] in, Represents the marginal distribution feature evaluation value, 1 represents a constant, represents the first weight coefficient, Indicates the number of edge pixels of the initial edge, The number of edge pixels representing a complete edge, represents the second weight coefficient, represents the normalization function, The mean gradient value of all edge pixels representing a complete edge.
[0079] It should be noted that reflections or shadows can cause discontinuities in the region boundaries, so breakpoints will appear during Canny edge detection. The larger the ratio of the two, the stronger the continuity of the initial edge, the less obvious the fracture characteristics, the less interference caused by the care, and the smaller the corresponding edge distribution characteristic evaluation value; The larger the value, the clearer the edge, the less interference is caused by the light, and the smaller the corresponding edge distribution feature evaluation value. Since the edge distribution feature evaluation value is based on the edge feature analysis of two dimensions, it is set There is no restriction here and it can be set according to actual situation.
[0080] Then, the edge texture feature value is obtained according to the mean of the texture distribution feature evaluation value and the edge distribution feature evaluation value, wherein the edge texture feature value The calculation formula is:
[0081]
[0082] (3) Obtaining an evaluation coefficient of illumination interference for any segmented region based on the regional grayscale brightness eigenvalue and the edge texture eigenvalue. Preferably, the mean of the regional grayscale brightness eigenvalue and the edge texture eigenvalue is recorded as the evaluation coefficient of illumination interference for any segmented region. A larger mean value indicates a greater degree of illumination interference for any segmented region, and a corresponding larger evaluation coefficient.
[0083] Similarly, the evaluation coefficient of each segmented area affected by light interference is obtained.
[0084] Step S103: Obtain an evaluation coefficient for each segmented region, obtain adaptive cropping parameters for performing contrast-limited adaptive histogram equalization on each segmented region based on the evaluation coefficient for each segmented region, perform image enhancement on each segmented region in the grayscale image based on the adaptive cropping parameters, and obtain an enhanced grayscale image.
[0085] When the image is subject to severe illumination interference, the cropping parameters should be increased to enhance detail contrast. When the image is subject to less illumination interference, the cropping parameters should be decreased to avoid excessive enhancement of small amounts of noise. Therefore, the embodiment of the present invention obtains an adaptive cropping parameter for each segmented region based on the evaluation coefficient of each segmented region, which is used to limit contrast adaptive histogram equalization. The specific acquisition method is as follows:
[0086] For any segmented area, if the evaluation coefficient of any segmented area is less than or equal to the preset evaluation coefficient threshold, the first piecewise function is used to obtain the adaptive clipping parameters when the restricted contrast adaptive histogram equalization is performed on any segmented area, wherein the calculation expression of the first piecewise function is: , represents the adaptive cropping parameters, represents the evaluation coefficient, and 0.5 represents the evaluation coefficient threshold.
[0087] If the evaluation coefficient of any segmented area is greater than the preset evaluation coefficient threshold, the adaptive clipping parameter for the restricted contrast adaptive histogram equalization of any segmented area is obtained by using the second piecewise function, wherein the calculation expression of the second piecewise function is: .
[0088] It should be noted that the common cropping parameter setting standards are: the lower cropping parameter range is: [1%, 10%], and the upper cropping parameter range is [20%, 40%]. The embodiment of the present invention can achieve smooth control by constructing a piecewise function (a first piecewise function and a second piecewise function), while ensuring that the cropping parameter increases monotonically when the evaluation coefficient increases. When the evaluation coefficient is 0, the minimum value of the corresponding cropping parameter is 1%, and when the evaluation coefficient is 1, the maximum value of the corresponding cropping parameter is 40%. When the calculation results of the first piecewise function and the second piecewise function are decimals, one decimal place is retained or rounded down to obtain the final adaptive cropping parameter.
[0089] At this point, the adaptive cropping parameters of each segmented region in the grayscale image can be obtained, and then contrast-limited adaptive histogram equalization is performed on each segmented region in the grayscale image according to the adaptive cropping parameters of each segmented region to obtain an enhanced grayscale image. It is worth noting that after obtaining the segmented regions, the embodiment of the present invention optimizes the cropping parameters in the contrast-limited adaptive histogram equalization algorithm, while the other steps remain unchanged. The contrast-limited adaptive histogram equalization algorithm belongs to the prior art and will not be described in detail here.
[0090] Step S104: Obtain corrosion detection results in the bimetallic strip using the enhanced grayscale image.
[0091] After obtaining the enhanced grayscale image, the enhanced grayscale image is used as the input of the trained CNN neural network model, and the corresponding output is the corrosion detection result of the bimetallic strip surface, which is used to evaluate the quality of the bimetallic strip. For example, the more surface corrosion areas of the bimetallic strip are detected and the larger the area, the worse the quality of the corresponding bimetallic strip. The general training process of the CNN neural network model is: collect image samples containing corroded areas and uncorroded areas as a training set, construct a CNN model with a network structure including a convolutional layer, a pooling layer and a fully connected layer, and use the training set to train the CNN model. At least the loss function is completely converged to obtain a trained CNN model. It is worth noting that the training of the CNN model belongs to the existing technology and will not be described in detail here.
[0092] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention, and should all be included in the scope of protection of the present invention.
Claims
1. A method for detecting double gold sheets of a protector based on machine vision, characterized in that: The method comprises: Acquire a surface image of the bimetallic strip, pre-process the surface image to obtain a grayscale image; perform threshold segmentation on the grayscale image to obtain at least one segmented region; For any segmented area, obtain the regional grayscale brightness eigenvalue based on the grayscale value distribution of the pixels in the segmented area, obtain the edge texture eigenvalue based on the grayscale co-occurrence matrix of the segmented area and the gradient value of each edge pixel, and obtain the evaluation coefficient of the illumination interference of the segmented area based on the regional grayscale brightness eigenvalue and the edge texture eigenvalue; Obtaining an evaluation coefficient for each segmented region, obtaining an adaptive cropping parameter for performing contrast-limited adaptive histogram equalization on each segmented region based on the evaluation coefficient for each segmented region, and performing image enhancement on each segmented region in the grayscale image based on the adaptive cropping parameter to obtain an enhanced grayscale image; obtaining a corrosion detection result in the bimetallic strip using the enhanced grayscale image; The obtaining of a regional grayscale brightness characteristic value according to the grayscale value distribution of pixels in any segmented region includes: Obtaining an overall grayscale distribution evaluation value based on the grayscale value of each pixel in any of the segmented regions; constructing a grayscale value change curve for any of the segmented regions, wherein the horizontal axis of the grayscale value change curve is the grayscale value and the vertical axis is the number of pixels; and obtaining a histogram distribution evaluation value based on the fluctuation characteristics of the grayscale value change curve; and obtaining a regional grayscale brightness characteristic value based on the maximum value between the overall grayscale distribution evaluation value and the histogram distribution evaluation value; Obtaining edge texture feature values according to the gray level co-occurrence matrix of any segmented region and the gradient value of each edge pixel point includes: Obtain a gray level co-occurrence matrix of any of the segmented areas, and obtain a texture distribution feature evaluation value of any of the segmented areas based on the gray level co-occurrence matrix; perform edge detection on any of the segmented areas to obtain an initial edge, perform edge discontinuity repair on the initial edge using curve fitting to obtain a complete edge, calculate a quantity ratio between the number of edge pixels of the initial edge and the number of edge pixels of the complete edge, calculate a mean gradient value of all edge pixels of the complete edge, normalize the mean gradient value to obtain a normalized mean, perform weighted summation on the quantity ratio and the normalized mean to obtain a weighted summation result, and record the difference between a constant 1 and the weighted summation result as the edge distribution feature evaluation value of any of the segmented areas; obtain an edge texture feature value based on the texture distribution feature evaluation value and the mean of the edge distribution feature evaluation value; The step of obtaining, according to the evaluation coefficient of each segmented region, an adaptive clipping parameter when performing contrast-limited adaptive histogram equalization on each segmented region comprises: For any segmented area, if the evaluation coefficient of any segmented area is less than or equal to the preset evaluation coefficient threshold, the first piecewise function is used to obtain the adaptive clipping parameters when the restricted contrast adaptive histogram equalization is performed on any segmented area, wherein the calculation expression of the first piecewise function is: , represents the adaptive cropping parameters, represents the evaluation coefficient, and 0.5 represents the evaluation coefficient threshold; if the evaluation coefficient of any segmented area is greater than the preset evaluation coefficient threshold, the adaptive clipping parameter for the restricted contrast adaptive histogram equalization of any segmented area is obtained by using the second piecewise function, wherein the calculation expression of the second piecewise function is: .
2. The method for detecting double gold sheets of a protector based on machine vision according to claim 1, characterized in that: The step of obtaining an overall grayscale distribution evaluation value based on the grayscale value of each pixel in any segmented area includes: According to the grayscale value of each pixel point in any segmented area, the grayscale value mean is calculated, and the ratio of the grayscale value mean to the maximum grayscale value is used as the overall grayscale distribution evaluation value.
3. The method for detecting double gold sheets of a protector based on machine vision according to claim 1, characterized in that: The step of obtaining a histogram distribution evaluation value based on the fluctuation characteristics of the grayscale value change curve includes: Obtaining a local maximum peak point in the grayscale value change curve, sorting the ordinate value of each local maximum peak point in descending order to obtain a ordinate value sequence, and using the local maximum peak points corresponding to the first two elements in the ordinate value sequence as the peak points to be analyzed; Calculating the absolute value of the grayscale value difference according to the grayscale value corresponding to each peak point to be analyzed, obtaining the absolute value of the difference between the absolute value of the grayscale value difference and a preset reference grayscale difference value, and normalizing the absolute value of the difference using a preset exponential function to obtain a corresponding normalized value; The ratio of the sum of the number of pixels corresponding to all peak points to be analyzed to the total number of pixels in any segmented area is obtained, and a weighted sum is performed on the ratio and the normalized value to obtain a histogram distribution evaluation value.
4. The method for detecting double gold sheets of a protector based on machine vision according to claim 1, characterized in that: The obtaining of the texture distribution feature evaluation value of any segmented region according to the gray level co-occurrence matrix includes: The entropy value of the gray-level co-occurrence matrix is obtained, and the entropy value is normalized using a hyperbolic tangent function to obtain a normalized entropy value. The difference between a constant 1 and the normalized entropy value is recorded as a texture distribution feature evaluation value.
5. The method for detecting double gold sheets of a protector based on machine vision according to claim 1, characterized in that: Obtaining an evaluation coefficient of illumination interference on any segmented region based on the region grayscale brightness characteristic value and the edge texture characteristic value includes: The average of the regional grayscale brightness characteristic value and the edge texture characteristic value is recorded as the evaluation coefficient of the illumination interference of any segmented region.
Citation Information
Patent Citations
Method for detecting surface defects of autoclave mold
CN118196081A