Test paper color change quantitative identification method based on improved MSRCR and random forest

Through the improved MSRCR algorithm and the quantitative identification method of test strip color change with random forest, the problem of inaccurate and low efficiency of naked eye recognition in cable thermal stability test is solved, and the automation and quantitative analysis of test strip color change recognition is realized, which improves the detection efficiency and Data utilization.

CN119274001AActive Publication Date: 2025-01-07JIANGSU SUPERVISION & INSPECTION INST FOR PROD QUALITY

Patent Information

Application Number
CN202411788918.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-06
Publication Date
2025-01-07
Estimated Expiration
2044-12-06

AI Technical Summary

Technical Problem

In the existing cable thermal stability test, the detection results of the naked eye identification test strips are inaccurate, the detection efficiency is low, and the data utilization is insufficient, which affects the reliability and efficiency of the test results.

Method used

The improved multi-scale adaptive gain MSRCR algorithm combined with random forest quantitative identification method for test strip color change, and the camera collects test strip photos of different states, performs image enhancement and normalization processing, adaptive color recovery, positioning and segmentation of test strip areas. Features are extracted and random forest algorithms are used to accurately test the degree of color discoloration.

Benefits of technology

The automation of test strip color change recognition is achieved, the inspection efficiency is improved, subjectivity is reduced, and quantitative test strip color change degree parameters are provided, which can more comprehensively analyze the test data, and improve the reliability and efficiency of the test.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119274001A_ABST
    Figure CN119274001A_ABST
Patent Text Reader

Abstract

The invention discloses an improved MSRCR and random forest-based test paper color change quantitative recognition method, which comprises the following steps of: acquiring test paper photos in different states as target images by using a camera, adaptively enhancing the images by using an improved MSRCR algorithm to improve the recognition stability, and finally, integrating a plurality of decision trees by using a random forest algorithm to realize the color change quantitative recognition of the test paper. The color change degree of the test paper is accurately tested. The machine vision technology is introduced, the improved MSRCR algorithm is combined with the random forest, automation of test paper color change recognition is achieved, the efficiency of inspection work is remarkably improved, and the problems that a traditional method is low in inspection efficiency, high in subjectivity and insufficient in data utilization are effectively solved. Experimental results show that the method is superior to a traditional method in evaluation indexes such as contrast, information entropy and peak signal-to-noise ratio, and the random forest model is excellent in performance and small in error when the color change degree of the test paper is tested.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a test paper color change quantitative identification method based on improved MSRCR and random forest, and belongs to the technical field of cable thermal stability performance detection. Background Art

[0002] The chemical stability of cable raw materials is of vital importance to the performance, reliability and safety of cables. High chemical stability means that cable raw materials can resist corrosion from chemicals in the environment, such as acids, alkalis, salts, etc., thereby ensuring that the cable has stable performance during long-term use and is not prone to aging or damage. Stable chemical properties help maintain the electrical properties of cables, such as resistivity, insulation strength, etc., to ensure the reliability and efficiency of signal transmission; chemically unstable raw materials may release harmful substances under certain conditions, posing a threat to the environment and human health. Raw materials with high chemical stability can reduce this risk and ensure the safety of cables during use; in emergency situations such as fires, chemically stable cable materials can reduce the release of toxic fumes.

[0003] The existing technology usually uses thermal stability test to evaluate the chemical stability of cable raw materials. This test focuses on monitoring the chemical changes of cable materials in an oil bath environment, especially focusing on the release rate of acidic substances. The current cable thermal stability test has the following main disadvantages: 1. The inspectors’ frequent observation process limits their ability to conduct other tests at the same time, significantly reducing the overall inspection efficiency.

[0004] 2. When judging whether the test paper has changed color, the inspector mainly relies on visual observation. This method is obviously subjective and it is difficult to ensure the consistency of the judgment standards among different inspectors, which may affect the reliability of the test results.

[0005] 3. The test data only include whether there is color change and the color change time. Although the test can be completed according to the standard, the data is not fully utilized, and no further analysis and evaluation is conducted on the test itself and the test materials. Summary of the invention

[0006] The purpose of the present invention is to provide a method for quantitatively identifying test paper color change based on improved MSRCR and random forest, so as to solve the technical problems of inaccurate detection results of test paper color change by naked eye and low detection efficiency in cable thermal stability test in the prior art.

[0007] The present invention adopts the following technical solution: a quantitative identification method of test paper color change based on improved MSRCR and random forest, which comprises the following steps: S1. The camera collects photos of the test paper in different states as target images. The photos of the test paper in different states include photos of the test paper with different light intensities, different discoloration states, and different discoloration areas, as well as photos of the same test paper taken at different positions and angles; S2. Each target image is enhanced and normalized by the improved multi-scale adaptive gain MSRCR. The specific steps are as follows: S2.1. Enhance the edge information in the image through the SSR algorithm, remove the low-frequency illumination part in the original image, and leave the high-frequency component corresponding to the original image: As the incident light shines on the reflective object, it is reflected by the reflective object to form reflected light that enters the human eye. The final image is expressed as the following formula: (1) In formula (1), R(x, y) represents the reflective property of the object, that is, the intrinsic property of the image; L(x, y) represents the incident light image, the original image is S(x, y), the reflected image is R(x, y), and the brightness image is L(x, y), and formula (2) can be obtained: (2) In formula (2), F(x, y) is the center surround function, which is convolved with S(x, y) and can be expressed as: (3) In formula (3), E is the Gaussian surround scale, is the scale, and its value must satisfy: (4) S2.2, based on the SSR algorithm, the Gaussian center surround function is added to develop a multi-scale MSR algorithm, the formula is: (5) In formula (5), K is the number of Gaussian center surround functions, Represents the scale parameter corresponding to the Gaussian center surround function, 0< <1, and + +……+ =1; S2.3. Based on MSR, a color restoration factor C is added to adjust the defect of color distortion caused by contrast enhancement in local areas of the image. The formula is: (6) (7) (8) in, Indicates The color restoration factor of each channel is used to adjust the color ratio of the three channels in the RGB color channel; Indicates An image with multiple channels; f represents the mapping function of the color space; β is the gain constant; α is the controlled nonlinear intensity; S2.4, Adaptive color restoration factor to improve the MSRCR algorithm, assuming Indicates The image of channels, =R, G, B, design the following adaptive color restoration factor C, the steps are: Step S2.4.1: Use the Sobel operator to calculate the gradient of the image in the x and y directions and , calculate the gradient magnitude: (9) Step S2.4.2, define a function f(G(x, y)) related to the gradient amplitude G(x, y), and use this function to redefine the adaptive color restoration factor C, which can be expressed as: (10) Wherein, the exp part of formula (10) is a Gaussian function, which is used to adjust the color restoration factor according to the gradient amplitude G(x,y); and are the mean and standard deviation of the gradient magnitude G(x,y) respectively; the second half of formula (10) is the contrast enhancement part, which is used to enhance the color restoration factor according to the local contrast, and L(x,y) is the local brightness component of the image; and are the mean and standard deviation of the local brightness L(x,y); Step S2.4.3, using the new adaptive color restoration factor C of formula (10) to replace formula (7) as the new color factor of MSRCR, calculating the Laplacian operator Laplacian of the image, obtaining the high-frequency component, enhancing the high-frequency component, and then adding the enhanced high-frequency component back to the original image, adjusting the sharpening intensity to increase the clarity of the image; S3, based on the Euclidean distance and Otsu dichotomy method, the test paper positioning and target area segmentation of the enhanced image are completed. The specific steps are as follows: Automatically locate the target test paper area in a large scene image: traverse the Euclidean distances of each pixel (R, G, B) in the image with the pure red point (255, 0, 0) and the pure yellow point (255, 255, 0). The Euclidean distance of the test paper pixel color is significantly different from the Euclidean distance of the surrounding environment pixels. Therefore, the Euclidean distances corresponding to these pixels are binary classified using the Otsu maximum inter-class variance method, and the smaller one is taken as the target pixel point; and the Otsu method is continued to be used for binary classification in the target pixel points, which can finely distinguish the color-changing red area and the yellow area; then, continue to traverse the Euclidean coordinate distances between these pixels, and cluster the closest distances on the same test paper into a group; finally, a minimum inner orthogonal rectangle is used to realize the frame selection of the target area, and the framed area is the test paper positioning area; S4. Use the Euclidean distance in the RGB color space to analyze the degree to which the color of the pixel in the test paper positioning area gradually changes from yellow to red. The Euclidean distance in the RGB color space is defined as: (15) , are the RGB values ​​of color A respectively; , are the RGB values ​​of color B respectively; According to formula (15), the following five features are extracted for each target image: Feature 1: The average Euclidean distance Ly between the target image and pure yellow (255,255,0); Feature 2: The average Euclidean distance Lr of the target image from pure red (255, 0, 0); Feature 3: Parameter P=Ly / Lr; Feature 4: The closest Euclidean distance Lymin between the target image and pure yellow (255,255,0); Feature 5: The closest Euclidean distance Lrmin between the target image and pure red (255, 0, 0); Feature 5: The closest Euclidean distance Lrmin between the target image and pure red (255,0,0); S5. An experienced experimenter scores the degree of color change of the test paper photograph collected in step (1). If the experimenter believes that there is no color change, it is scored as 0. If the test paper changes color, it is scored on a scale of 1 to 10. The scoring is based on the degree of color change observed by the experimenter and the ratio of the visually observed color change area to the entire area of ​​the test paper. The higher the degree of color change and the larger the ratio of the color change area to the entire area of ​​the test paper, the higher the score. The scoring result target and all the features extracted in step (4) are made into a data set; S6. Random forest training and testing: The data set is imported into the random forest algorithm for training, and the trained random forest algorithm is used to perform color change test on the test paper photos to be identified.

[0008] In step S2.2, there are three Gaussian center surround functions, namely, high, medium, and low Gaussian center surround functions of different scales, K=3, and =1 / 3; =15; =80; =200.

[0009] In step S5, the color change degree of the test paper photo is scored by experienced experimenters, and finally the average of the scores of three experimenters is taken as the final score of the test paper photo.

[0010] The dataset is in csv format.

[0011] In step S1, the number of test paper photos in different states collected is 1000. The data set obtained in step S5 contains 1000 test paper photo data, of which 700 test paper photo data are used for random forest training and 300 test paper photo data are used for random forest testing.

[0012] In step S6, during random forest training, the random forest parameters are optimized as follows: S6.1, Weighted Random Forest: Give higher weights to important features, making them more likely to be selected during the tree construction process. When calculating the mean square error (MSE) of the child nodes, the contribution of each feature is weighted. The formula is: (16) in, It is a feature The weight of is the actual value, is the test value; S6.2, Weighted Information Splitting Criterion: When using the random forest algorithm in a regression task, if it is known that some features are highly correlated with the target parameter, while other features are not highly correlated, optimization is performed by the following steps: In weighted information gain, the contribution of each feature is multiplied by its weight; for each candidate split, the reduction in impurity before and after the split is calculated and multiplied by the weight of the feature, expressed as: (17) in, is the weight of feature A, Impurity(D) is the impurity of the dataset, is the data set of the child node v after splitting; Follow the above steps to optimize the regression forest parameters and import the dataset for training.

[0013] In the data set, the importance of the five features is ranked as follows: P ≥ Lrmin ≥ Ly ≥ Lymin ≥ Lr.

[0014] In the data set, the importance of the five features is: P is 0.35, Lrmin is 0.25, Ly is 0.2, Lymin is 0.1, and Lr is 0.1.

[0015] Beneficial effects of the present invention: The present invention combines the improved MSRCR algorithm with the random forest. The improved MSRCR algorithm can adaptively enhance images and improve recognition stability, while the random forest algorithm accurately tests the degree of test paper discoloration by integrating multiple decision trees, showing good performance. The present invention realizes the automation of test paper color change recognition by introducing machine vision technology, significantly improves the efficiency of inspection work, and effectively solves the problems of low inspection efficiency, strong subjectivity and insufficient data utilization in traditional methods. The present invention provides a new and efficient test paper color change quantitative analysis method for cable thermal stability test, which is not only suitable for the recognition of test paper color change in cable thermal stability test, but also can be applied to test paper color change recognition in other fields, providing a useful reference and reference for similar problems in other fields.

[0016] The advantages of the present invention are: 1. By introducing machine vision technology, the test identification process is automated, getting rid of the constraints of manual visual judgment, thereby significantly improving the efficiency of inspection work; 2. The improved MSRCR algorithm can adaptively enhance images under different lighting conditions. The device is more robust to ambient light, so the recognition stability is stronger; 3. The random forest algorithm is an integrated method of decision trees, which usually has better generalization ability and test accuracy than a single decision tree. The color change problem of the test strip is converted into a regression problem. The color change degree is regarded as a continuous value in the range of 0 to 10, and the value can be directly output as a quantitative representation of the color change degree; 4. Quantitative parameters of the test paper color change degree are conducive to further characterizing the trend of the test paper color change speed and extracting more data information from the thermal stability test, such as the prediction of the color change time of the same sample in the same batch based on hypothesis testing and the quantitative evaluation of the thermal stability of different samples. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 It is the comparison diagram of the original image, MSRCR, and improved MSRCR effect of the large scene image A; Figure 2 It is the comparison chart of the original image, MSRCR and improved MSRCR effect of test strips B, C and D; Figure 3 It is the original image, the red and yellow detection of the test strip, the test strip pixel clustering and the test strip position positioning process image; Figure 4 It is the feature parameters and target evaluation table corresponding to each target image; Figure 5 It is a scatter plot of actual value target and test value; Figure 6 It is a ranking diagram of the importance of each parameter. DETAILED DESCRIPTION

[0018] The present invention is described in detail below with reference to the accompanying drawings and specific principles.

[0019] A method for quantitatively identifying color change of a test paper based on improved MSRCR and random forests according to an embodiment of the present invention comprises the following steps: S1. The camera collects photos of the test paper in different states as target images. The photos of the test paper in different states include photos of the test paper with different light intensities, different discoloration states, and different discoloration areas, as well as photos of the same test paper taken at different positions and angles; Theoretically, the more target images the better, but since there are too many images, the workload of making the data set later is too large, so in this embodiment, 1000 test paper photos are used as target images.

[0020] S2. Each target image is enhanced and normalized through the improved multi-scale adaptive gain MSRCR. The purpose of this step is to enhance and normalize the target image so that the color of the test paper under different lighting conditions can show the original color of the test paper without being affected by external lighting, so as to form a unified standard for subsequent processing.

[0021] The improved multi-scale adaptive gain MSRCR (Multi-Scale Retinex with Color Restore) algorithm of the present invention is an image enhancement algorithm, which is improved on the basis of the traditional Retinex algorithm, especially in color restoration. The MSRCR algorithm is based on the Retinex theory, which believes that the color of an object is determined by the object's ability to reflect long-wave (red), medium-wave (green) and short-wave (blue) light, rather than by the absolute value of the reflected light intensity. The MSRCR algorithm enhances the dynamic range of the image through multi-scale Retinex processing, and adjusts the color distortion that may be caused by the enhancement processing through the color restoration factor. The algorithm is widely used in the field of image enhancement and normalization. In the study of haze image enhancement, the haze image is enhanced by HE and improved MSRCR respectively, and then weighted fusion is performed according to certain image fusion rules, which effectively improves the defogging effect of the haze image, but there may be problems with algorithm stability and robustness. In the study of the image enhancement algorithm for power equipment, an improved Retinex image enhancement method is used to address the problems of halo phenomenon, color distortion, etc. that exist in the traditional MSRCR algorithm when processing power equipment images. The original image is converted to the frequency domain through Fourier transform and then convolution calculation is performed to obtain the reflection component of the original image. Combined with histogram equalization processing, the halo phenomenon is effectively eliminated. However, the applicability of the improved algorithm in processing other types of images (such as natural scene images) and the possible complexity of frequency domain transformation calculations are not mentioned.

[0022] Thermal stability tests usually take a long time, and the ambient light changes significantly. In addition, the temperature difference often produces fog on the test tube wall, which affects the test paper observation. Therefore, a pre-image processing algorithm is needed that can adjust the brightness without affecting the color, so that the image can maintain a good visual effect under various lighting conditions; it can effectively maintain and restore the original color of the image, so that the image is bright and natural while the brightness is enhanced; it can significantly enhance the contrast of the image, especially in the areas where there are shadows or highlights in the image, which can better show the details and improve the clarity and visual effect of the image. Based on this, this step is optimized based on the MSRCR algorithm. The specific steps are: S2.1. This step is to enhance the edge information in the image through the SSR algorithm, remove the low-frequency illumination part in the original image, and leave the high-frequency component corresponding to the original image: First, the single-scale SSR (SingleScaleRetinex) algorithm, the basic algorithm of the MSRCR algorithm, is derived. The image can be regarded as an incident image and a reflected image. As the incident light shines on the reflective object, it is reflected by the reflective object to form reflected light that enters the human eye. The final image is expressed as the following formula: (1) In formula (1), R(x, y) represents the reflective property of the object, that is, the intrinsic property of the image, which should be retained to the greatest extent; L(x, y) represents the incident light image, which determines the dynamic range that the image pixels can reach and should be removed as much as possible; the illumination image is assumed to be a spatially smooth image, the original image is S(x, y), the reflected image is R(x, y), and the brightness image is L(x, y), and formula (2) can be obtained: (2) In formula (2), F(x, y) is the center surround function, which is convolved with S(x, y) and can be expressed as: (3) In formula (3), E is the Gaussian surround scale, is the scale, and its value must satisfy: (4) From formulas (1) to (4), it can be seen that the convolution in the SSR algorithm is the calculation of the incident image. Its physical meaning is to calculate the change of illumination in the image by calculating the weighted average of the pixel point and the surrounding area, and remove L(x, y) to retain only the S(x, y) attribute. The center surround function F(x, y) uses a low-pass function, so that the algorithm can calculate the low-frequency part of the incident image corresponding to the original image. The low-frequency illumination part is removed from the original image, leaving the high-frequency component corresponding to the original image. Therefore, the SSR algorithm can better enhance the edge information in the image.

[0023] S2.2, based on the SSR algorithm, the Gaussian center surround function is added to develop a multi-scale MSR algorithm, the formula is: (5) In formula (5), K is the number of Gaussian center surround functions. When K = 1, MSR degenerates to SSR. Represents the scale parameter corresponding to the Gaussian center surround function, 0< <1, and + +……+ =1; In this embodiment, in order to ensure that the advantages of the three scales of SSR, high, medium and low, are combined, K=3. Formula (5) is a decomposition of formula (2) into three scales. The number of Gaussian center surround functions is three, namely, Gaussian center surround functions of different scales, high, medium and low. The specific meaning of the scale here is: the high scale usually corresponds to a smaller Gaussian surround function scale parameter, which means that the Gaussian surround function has a smaller spatial extension range, so it mainly captures high-frequency detail information in the image, such as edges and textures; the medium scale corresponds to a moderate Gaussian surround function scale parameter, which can balance the high-frequency details and low-frequency information in the image, maintain certain edge details, and reflect the overall illumination changes of the image; the low scale corresponds to a larger Gaussian surround function scale parameter, which mainly captures low-frequency information in the image, such as a large range of illumination changes, which helps to achieve image dynamic range compression.

[0024] And in order to balance the three scales of high, medium and low, =1 / 3; based on experimental experience =15, =80, =200, corresponding to their respective Gaussian surround scales.

[0025] S2.3, although the performance of MSR is better than that of SSR, there is still a color cast effect. For this reason, an MSR method with color restoration, MSRCR (Multi-Scale Retinex with Color Restoration), is proposed. MSRCR adds a color restoration factor C on the basis of MSR to adjust the defect of color distortion caused by contrast enhancement in local areas of the image. Its formula is: (6) (7) (8) in, The meaning is The image of the channel; j takes three values ​​1, 2, 3, which means the three channels of the image Perform summation; N=3; Indicates The color restoration factor of each channel is used to adjust the color ratio of the three channels in the RGB color channel; Indicates The image has channels; f represents the mapping function of the color space; β is the gain constant; α is the controlled nonlinear strength; according to the experimental empirical data, α=β=1.5.

[0026] S2.4, MSRCR algorithm uses the color restoration factor C to adjust the proportional relationship between the three color channels (RGB color channels, RED, GREEN, BLUE) in the original image (Formula (8)), so as to highlight the information of the relatively dark area and eliminate the defect of image color distortion.

[0027] The local contrast of the processed image is improved, and the brightness is similar to the real scene. Under people's visual perception, the image appears more realistic. However, the MSRCR algorithm has many empirical parameters, such as α and β in formula (8), which depend on parameter adjustment and affect the software implementation and generalization to a certain extent. In addition, when processing the strong light and shadow transition area, the MSRCR algorithm may not be able to perfectly estimate the illumination, resulting in the appearance of halo phenomenon. Based on the above problems, the present invention proposes an algorithm for improving the MSRCR with an adaptive color restoration factor. Assume that Indicates Channel images ( =R, G, B), design the following adaptive color restoration factor C, the steps are: Step S2.4.1: Use the Sobel operator to calculate the gradient of the image in the x and y directions and , calculate the gradient magnitude: (9) Step S2.4.2, define a function f(G(x, y)) related to the gradient amplitude G(x, y), and use this function to redefine the adaptive color restoration factor C, which can be expressed as: (10) Wherein, the exp part of formula (10) is a Gaussian function, which is used to adjust the color restoration factor according to the gradient amplitude G(x,y); and are the mean and standard deviation of the gradient magnitude G(x,y), which can be calculated in a local area of ​​the image (such as a small window); the characteristic of this function is that when G(x,y) is close to When G(x,y) is far away from This helps reduce color restoration in edge and detail areas (where gradient magnitude is large) while increasing color restoration in smooth areas (where gradient magnitude is small).

[0028] The second half of formula (10) is the contrast enhancement part, which is a simple linear transformation used to enhance the color restoration factor according to the local contrast. L(x,y) is the local brightness component of the image, which can be obtained by Gaussian blur. and are the mean and standard deviation of the local brightness L(x,y), also calculated in the local area. When higher, the output of this part is increased, thus enhancing color recovery. This helps to recover more color information in areas with low contrast, such as shadows or dark areas.

[0029] Step S2.4.3, use the new adaptive color restoration factor C of formula (10) to replace formula (7) as the new color factor of MSRCR, calculate the Laplacian operator Laplacian of the image, obtain the high-frequency component, enhance the high-frequency component, and then add the enhanced high-frequency component back to the original image, and adjust the sharpening intensity to increase the clarity of the image.

[0030] The experimental verification of step S2 is as follows: The original image, MSRCR and improved MSRCR algorithm were compared, and the results were evaluated by three evaluation indicators: image contrast, information entropy and peak signal-to-noise ratio.

[0031] 1) The calculation formula of contrast is as follows: (11) In the formula , is the grayscale difference between adjacent pixels, The grayscale difference between adjacent pixels is The pixel distribution probability. Contrast can directly represent the vividness of the image. The greater the contrast, the brighter the color.

[0032] 2) The calculation formula of information entropy is as follows: (12) In formula (12), Represents grayscale value The probability of appearing in an image, information entropy reflects the amount of information in the image. The larger the information entropy value, the richer the detailed information contained in the image.

[0033] 3) Peak signal-to-noise ratio (PSNR) is used to evaluate the fidelity of image processing. The larger the PSNR value, the higher the image fidelity. The calculation formula is: (13) Among them, MSE is the mean square error of the pixel values ​​after the original image I and the processed image K (both with sizes of m×n) are grayed out, and the expression is: (14) To characterize the versatility, we select large scene image A and test paper target images B, C, and D for comparison and analysis of the original image, MSRCR, and improved MSRCR algorithms. Figure 1 , Figure 2 As shown. Figure 1 , Figure 2 It can be seen that while the improved MSRCR algorithm significantly enhances the color, it does not change the main color tone of the original image as much as the initial MSRCR algorithm. In particular, scene A is a dark environment, and scene B is a strong environment, but the improved MSRCR algorithm restores and enhances the color of the test paper, with significant effects.

[0034] The evaluation results of each scene are shown in Table 1: From the data in Table 1, it can be observed that the improved MSRCR algorithm has shown significant improvement effects in the three evaluation indicators of contrast, information entropy and peak signal-to-noise ratio (PSNR). Specifically, for all test images A, B, C and D, the improved MSRCR algorithm has greatly improved the contrast value compared with the original image and the traditional MSRCR algorithm, which means that the difference between light and dark in the image is more obvious and the image details are more prominent. At the same time, the increase in information entropy indicates that the improved algorithm can retain more information when processing the image, making the image content richer and more delicate. In addition, in terms of peak signal-to-noise ratio, the performance of the improved MSRCR algorithm has also been improved, indicating that the algorithm effectively reduces noise interference during the image enhancement process and improves the overall quality of the image. In summary, the improved MSRCR algorithm performs well in improving image visual effects and retaining image information.

[0035] Table 1 Evaluation results of test images A, B, C, and D under different algorithms image algorithm Contrast Entropy Peak Signal-to-Noise Ratio (PSNR) A Original image 46.51 6.59 —— A MSRCR 48.81 6.67 27.28 A Improved MSRCR 55.65 6.93 27.27 B Original image 20.95 5.91 —— B MSRCR 38.10 6.75 27.19 B Improved MSRCR 47.82 7.21 27.64 C Original image 26.01 6.22 —— C MSRCR 39.12 6.84 27.61 C Improved MSRCR 43.18 7.14 28.09 D Original image 16.21 5.34 —— D MSRCR 25.62 6.05 27.87 D Improved MSRCR 28.75 6.59 27.95

[0036] S3. During the actual test and original data collection, the sample is photographed. The original image captured by the camera contains useless information such as the background. That is to say, the initial image must be a large scene image containing the external environment similar to scene A. The direct target studied in this article is the test paper area shown in Figures B, C, and D. Therefore, it is necessary to first automatically locate the target test paper area in the large scene image, that is, remove the background information of the original photo and only retain the test paper area.

[0037] Therefore, this step completes the test paper positioning and target area segmentation of the enhanced image based on the Euclidean distance and Otsu dichotomy method. The specific steps are: Automatically locate the target test paper area in large scene images: traverse the Euclidean distances of each pixel (R, G, B) in the image with the pure red point (255, 0, 0) and the pure yellow point (255, 255, 0). The Euclidean distance of the test paper pixel color is significantly different from the Euclidean distance of the surrounding environment pixels. Therefore, the Euclidean distances corresponding to these pixels are classified into two categories using the Otsu maximum inter-class variance method, and the smaller one is taken as the target pixel; and the Otsu method is continued to be used for binary classification in the target pixel, which can finely separate the color-changing red area and the yellow area; then, continue to traverse the Euclidean coordinate distances between these pixels, and cluster the closest distances on the same test paper into a group; finally, a minimum inner orthogonal rectangle is used to select the target area, and the selected area is the test paper positioning area. This process is as follows Figure 3 As shown, Figure 3 In the middle, the first left is the original image, the second left is the positioning of the reddest area and the yellowest area, the second right is the positioning of the same test paper area, and the first right is the smallest inner rectangle of the same test paper.

[0038] The basic principle of test strip positioning and target area segmentation is: the Euclidean distance of the test strip pixel color (regardless of whether it changes color or not) is significantly different from the Euclidean distance of the surrounding environment pixels. Therefore, pure red (255,0,0) and pure yellow (255,255,0) are used as target pixels, and the RGB channel values ​​of all pixels in the image and the Euclidean distance of these two points are calculated. The part closest to red can be regarded as the reddened area of ​​the test strip, and the area closest to yellow can be regarded as the undiscolored area of ​​the test strip, that is, the yellow area. Figure 3 The second picture on the left shows the effect. The purpose of this step is to find all the pixel areas belonging to the test paper. Then, all the pixel points belonging to the test paper in the picture are clustered according to the information of the specific position coordinates of the photo. The purpose of this step is to distinguish how many test papers there are in the original picture, that is, Figure 3 The second right side shows the effect. Finally, a minimum inner orthogonal rectangle is used to select the target area. Figure 3 Right display.

[0039] S4. Use the Euclidean distance in the RGB color space to analyze the degree of color change from yellow to red in the test paper positioning area. The principle is to calculate the distance between the RGB value of each pixel and the RGB value of pure yellow and red, and then judge the degree of color change based on the average distance between each pixel in the image and the standard pixel. Define the Euclidean distance in the RGB color space as: (15) , are the RGB values ​​of color A respectively; , are the RGB values ​​of color B respectively; According to formula (15), the following five features are extracted for each target image: Feature 1: The average Euclidean distance Ly between the target image and pure yellow (255,255,0); Feature 2: The average Euclidean distance Lr of the target image from pure red (255, 0, 0); Feature 3: Parameter P=Ly / Lr; Feature 4: The closest Euclidean distance Lymin between the target image and pure yellow (255,255,0); Feature 5: The closest Euclidean distance Lrmin between the target image and pure red (255, 0, 0).

[0040] S5. An experienced experimenter scores the color change degree of the test paper photos collected in step (1). If the experimenter thinks there is no color change, it is scored 0 points. If the test paper changes color, it is scored on a scale of 1 to 10. The scoring is based on: the color change degree visually observed by the experimenter (usually the color change of the test paper is a process of orange-red-purple) and the area ratio of the visually observed color change area to the entire test paper. The higher the color change degree and the larger the area ratio of the color change area to the entire test paper, the higher the score value. In this step, the color change degree of the test paper photos is scored by experienced experimenters, and the average of the scores of the three experimenters is finally taken as the final score of the test paper photo. The scoring result target and all the features extracted in step (4) are made into a data set; the data set is in csv format. The data set obtained in step S5 contains 1000 test paper photo data, of which 700 test paper photo data are used for the next random forest training and 300 test paper photo data are used for the next random forest test.

[0041] The OpenCV programming is used to perform scoring and preliminary statistics of the five features of eight test paper target images in different states. The results are as follows: Figure 4 As shown in the table, from Figure 4 As can be seen in the figure, there is no perfect linear relationship between a single parameter and the target evaluation. However, the Ly and P values ​​have a certain correlation with the target evaluation. In particular, when the Ly value is small and the P value is also small, the target evaluation is low or zero. When the Ly value increases and the P value deviates from 1, the target evaluation tends to be high. Logically, the above parameters should have a relationship with the color change degree of the test paper, so random forests can be used to deeply explore the intrinsic relationship of the above parameters.

[0042] S6. Random forest training and testing: The data set was imported into the random forest algorithm for training, and the trained random forest algorithm was used to test the color change degree of the test paper photos to be identified. The 700 sets of data obtained were used for training, and 300 sets of data were used for verification, and finally a random forest decision system was formed.

[0043] Random Forest is an integrated learning method that constructs multiple decision trees and votes or averages their results to obtain the final test value. The main advantage of this method is that by integrating multiple models, it can effectively deal with the overfitting problem and improve the test accuracy and generalization ability of the model. The target score in the dataset of the random forest model in this step is obtained by averaging the manual scores of three experienced experimenters. It aims to simulate the decision-making process of human experts and can be regarded as an expert system in the field of artificial intelligence.

[0044] When using the random forest algorithm in regression tasks, the existing random forest regression (RFR) builds multiple decision trees and divides the feature space in each tree, and finally improves the test accuracy by integrating the test results of each tree. If it is known that some features (such as 1 or 2) are closely related to the target parameters, while other features are not closely related, the random forest parameters can be optimized by the following steps, as follows: S6.1, Weighted Random Forest: Give higher weights to important features, making them more likely to be selected during the tree construction process. When calculating the mean square error (MSE) of the child nodes, the contribution of each feature is weighted. The formula is: (16) in, It is a feature The weight of is the actual value, is the test value; S6.2, weighted information splitting criterion: Traditional information gain measures the reduction in uncertainty in a dataset after splitting using a certain feature. In weighted information gain, the contribution of each feature can be multiplied by its weight to focus more on important features. For each candidate split, the reduction in impurity before and after the split is calculated and multiplied by the weight of the feature, expressed as: (17) in, is the weight of feature A, Impurity(D) is the impurity of the dataset, is the data set of the child node v after splitting; According to the above steps, the regression forest parameters are optimized and the data set is imported for training. The final data is shown in Table 2 and Figures 5 and 6 shown.

[0045] In the data set, the importance of the five features is ranked as follows: P ≥ Lrmin ≥ Ly ≥ Lymin ≥ Lr. Figure 6 As shown in the figure, the importance of the five features is: P is 0.35, Lrmin is 0.25, Ly is 0.2, Lymin is 0.1, and Lr is 0.1.

[0046] Table 2 Evaluation results of performance parameters of random forest model (MSE) - Mean Squared Error R^2Score - coefficient of determination (MAE) - Mean Absolute Error Median absolute error 0.15 0.85 0.35 0.25

[0047] As can be seen from Table 2, the test value is close to the actual value (target); The data in Table 2 shows that MSE = 0.15: This value is relatively small, indicating that the overall test error of the model is not large. However, since MSE is more sensitive to larger errors, this value may still be affected by some larger errors; R^2 = 0.85: This value is relatively high, indicating that the model can explain 85% of the variability in the data. This is a good result, indicating that the model does a fairly good job of fitting the data; MAE = 0.35: This value is larger than MSE because MAE measures absolute error rather than squared error. Nevertheless, this value is still relatively small, indicating that the test error of the model is not large in most cases. MAE = 0.35: This value is larger than MSE because MAE measures absolute error rather than squared error. Despite this, this value is still relatively small, indicating that the test error of the model is not large in most cases.

[0048] In summary, the quantitative identification method of test paper color change based on improved MSRCR and random forest is suitable for the quantitative study of test paper color change in cable thermal stability test. The improved MSRCR algorithm can adaptively enhance the image and improve the recognition stability, while the random forest algorithm accurately tests the degree of test paper color change by integrating multiple decision trees, showing good performance. The present invention realizes the automation of test paper color change identification by introducing machine vision technology, significantly improves the efficiency of inspection work, and effectively solves the problems of low inspection efficiency, strong subjectivity and insufficient data utilization in traditional methods. The present invention not only provides a new and efficient test paper color change quantitative analysis method for cable thermal stability test, but also provides a useful reference and reference for similar problems in other fields.

Claims

1. A quantitative identification method for test paper color change based on improved MSRCR and random forest, characterized in that: It includes the following steps: S1. The camera collects photos of the test paper in different states as target images. The photos of the test paper in different states include photos of the test paper with different light intensities, different discoloration states, and different discoloration areas, as well as photos of the same test paper taken at different positions and angles; S2. Each target image is enhanced and normalized by the improved multi-scale adaptive gain MSRCR. The specific steps are as follows: S2.

1. Enhance the edge information in the image through the SSR algorithm, remove the low-frequency illumination part in the original image, and leave the high-frequency component corresponding to the original image: As the incident light shines on the reflective object, it is reflected by the reflective object to form reflected light that enters the human eye. The final image is expressed as the following formula: (1) In formula (1), R(x, y) represents the reflective property of the object, that is, the intrinsic property of the image; L(x, y) represents the incident light image, the original image is S(x, y), the reflected image is R(x, y), and the brightness image is L(x, y), and formula (2) can be obtained: (2) In formula (2), F(x, y) is the center surround function, which is convolved with S(x, y) and can be expressed as: (3) In formula (3), E is the Gaussian surround scale, is the scale, and its value must satisfy: (4) S2.2, based on the SSR algorithm, the Gaussian center surround function is added to develop a multi-scale MSR algorithm, the formula is: (5) In formula (5), K is the number of Gaussian center surround functions, Represents the scale parameter corresponding to the Gaussian center surround function, 0< <1, and + +……+ =1; S2.

3. Based on MSR, a color restoration factor C is added to adjust the defect of color distortion caused by contrast enhancement in local areas of the image. The formula is: (6) (7) (8) in, Indicates The color restoration factor of each channel is used to adjust the color ratio of the three channels in the RGB color channel; Indicates An image with multiple channels; f represents the mapping function of the color space; β is the gain constant; α is the controlled nonlinear intensity; S2.4, Adaptive color restoration factor to improve the MSRCR algorithm, assuming Indicates The image of channels, =R,G,B, design the following adaptive color restoration factor C, the steps are: Step S2.4.1: Use the Sobel operator to calculate the gradient of the image in the x and y directions and , calculate the gradient magnitude: (9) Step S2.4.2, define a function f(G(x, y)) related to the gradient amplitude G(x, y), and use this function to redefine the adaptive color restoration factor C, which can be expressed as: (10) Wherein, the exp part of formula (10) is a Gaussian function, which is used to adjust the color restoration factor according to the gradient amplitude G(x,y); and are the mean and standard deviation of the gradient magnitude G(x,y) respectively; the second half of formula (10) is the contrast enhancement part, which is used to enhance the color restoration factor according to the local contrast, and L(x,y) is the local brightness component of the image; and are the mean and standard deviation of the local brightness L(x,y); Step S2.4.3, using the new adaptive color restoration factor C of formula (10) to replace formula (7) as the new color factor of MSRCR, calculating the Laplacian operator Laplacian of the image, obtaining the high-frequency component, enhancing the high-frequency component, and then adding the enhanced high-frequency component back to the original image, adjusting the sharpening intensity to increase the clarity of the image; S3, based on the Euclidean distance and Otsu dichotomy method, the test paper positioning and target area segmentation of the enhanced image are completed. The specific steps are as follows: Automatically locate the target test paper area in a large scene image: traverse the Euclidean distances of each pixel (R, G, B) in the image with the pure red point (255, 0, 0) and the pure yellow point (255, 255, 0). The Euclidean distance of the test paper pixel color is significantly different from the Euclidean distance of the surrounding environment pixels. Therefore, the Euclidean distances corresponding to these pixels are binary classified using the Otsu maximum inter-class variance method, and the smaller one is taken as the target pixel point; and the Otsu method is continued to be used for binary classification in the target pixel points, which can finely distinguish the color-changing red area and the yellow area; then, continue to traverse the Euclidean coordinate distances between these pixels, and cluster the closest distances on the same test paper into a group; finally, a minimum inner orthogonal rectangle is used to realize the frame selection of the target area, and the framed area is the test paper positioning area; S4. Use the Euclidean distance in the RGB color space to analyze the degree to which the color of the pixels in the test paper positioning area gradually changes from yellow to red. The Euclidean distance in the RGB color space is defined as: (15) , are the RGB values ​​of color A respectively; , are the RGB values ​​of color B respectively; According to formula (15), the following five features are extracted for each target image: Feature 1: The average Euclidean distance Ly between the target image and pure yellow (255,255,0); Feature 2: The average Euclidean distance Lr of the target image from pure red (255, 0, 0); Feature 3: Parameter P=Ly / Lr; Feature 4: The closest Euclidean distance Lymin between the target image and pure yellow (255,255,0); Feature 5: The closest Euclidean distance Lrmin between the target image and pure red (255,0,0); S5. An experienced experimenter scores the degree of color change of the test paper photograph collected in step (1). If the experimenter believes that there is no color change, it is scored as 0. If the test paper changes color, it is scored on a scale of 1 to 10. The scoring is based on the degree of color change observed by the experimenter and the ratio of the visually observed color change area to the entire area of ​​the test paper. The higher the degree of color change and the larger the ratio of the color change area to the entire area of ​​the test paper, the higher the score. The scoring result target and all the features extracted in step (4) are made into a data set; S6. Random forest training and testing: The data set is imported into the random forest algorithm for training, and the trained random forest algorithm is used to perform color change test on the test paper photos to be identified.

2. The method for quantitatively identifying color change of test paper based on improved MSRCR and random forest according to claim 1, characterized in that: In step S2.2, there are three Gaussian center surround functions, namely, high, medium, and low Gaussian center surround functions of different scales, K=3, and =1 / 3; =15; =80; =200.

3. The method for quantitatively identifying color change of test paper based on improved MSRCR and random forest according to claim 1, characterized in that: In step S5, the color change degree of the test paper photo is scored by experienced experimenters, and finally the average of the scores of three experimenters is taken as the final score of the test paper photo.

4. The method for quantitatively identifying color change of test paper based on improved MSRCR and random forest according to claim 1, characterized in that: The dataset is in csv format.

5. The method for quantitatively identifying color change of test paper based on improved MSRCR and random forest according to claim 1, characterized in that: In step S1, the number of test paper photos in different states collected is 1000. The data set obtained in step S5 contains 1000 test paper photo data, of which 700 test paper photo data are used for random forest training and 300 test paper photo data are used for random forest testing.

6. The method for quantitatively identifying color change of test paper based on improved MSRCR and random forest according to claim 1, characterized in that: In step S6, during random forest training, the random forest parameters are optimized as follows: S6.1, Weighted Random Forest: Give higher weights to important features, making them more likely to be selected during the tree construction process. When calculating the mean square error (MSE) of the child nodes, the contribution of each feature is weighted. The formula is: (16) in, It is a feature The weight of is the actual value, is the test value; S6.2, Weighted Information Splitting Criterion: When using the random forest algorithm in a regression task, if it is known that some features are highly correlated with the target parameter, while other features are not highly correlated, optimization is performed by the following steps: In weighted information gain, the contribution of each feature is multiplied by its weight; for each candidate split, the reduction in impurity before and after the split is calculated and multiplied by the weight of the feature, expressed as: (17) in, is the weight of feature A, Impurity(D) is the impurity of the dataset, is the data set of the child node v after splitting; Follow the above steps to optimize the regression forest parameters and import the dataset for training.

7. The method for quantitatively identifying color change of test paper based on improved MSRCR and random forest according to claim 6, characterized in that: In the data set, the importance of the five features is ranked as follows: P ≥ Lrmin ≥ Ly ≥ Lymin ≥ Lr.

8. The method for quantitatively identifying color change of test paper based on improved MSRCR and random forest according to claim 7, characterized in that: In the data set, the importance of the five features is: P is 0.35, Lrmin is 0.25, Ly is 0.2, Lymin is 0.1, and Lr is 0.1.

Citation Information

Patent Citations

  • Urine examination method, mobile terminal and computer-readable storage medium

    CN109241970A

  • An automatic identification method for physiological indexes of urinalysis test paper

    CN109800777A

  • A remote sensing image retrieval method based on nonlinear dimension reduction and sparse representation

    CN109815357A

  • Immunochromatography concentration detection method and system based on machine learning

    CN112071423A

  • Classifying biological samples using automated image analysis

    US20180211380A1

Cited By

  • High-frequency welded pipe defect detection method and system based on machine vision

    CN120107268A

  • Test paper concentration detection method and system

    CN122312622A