A method and system for image recognition of contact corrosion
By using image recognition methods to screen the contact rust areas and calculate the surface fading index and comprehensive rust characteristic index, the problems of low efficiency and insufficient accuracy in existing technologies are solved, and efficient and accurate rust detection is achieved to ensure equipment safety.
Patent Information
- Application Number
- CN202411403106.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2044-10-09
AI Technical Summary
Existing contact corrosion detection methods are inefficient and difficult to guarantee accuracy. They cannot effectively identify different types and degrees of corrosion, especially in corrosive environments, affecting the performance and safety of equipment.
An image recognition method is used to screen suspected rust areas through the YOLO algorithm, and the surface fading index and rust comprehensive feature index are calculated. The shape and distribution characteristics of the rust area are identified by combining pixel brightness, Euclidean distance and edge gradient, and the final judgment is made using the rust comprehensive feature index.
The efficiency and accuracy of contact corrosion detection are improved, and the rusted areas can be quickly identified to ensure the safe and reliable operation of the equipment.
Smart Images

Figure CN119295735B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of image recognition, and in particular to a contact corrosion image recognition method and system. BACKGROUND
[0002] In industrial production and equipment maintenance, the state of the contact directly affects the performance and safety of the equipment. During use, especially in corrosive environments, the contact is prone to corrosion. This not only affects the electrical performance of the contact, but also can cause equipment failure and safety hazards. Therefore, timely and accurate detection of contact corrosion has become an important task to ensure the normal operation of the equipment.
[0003] For example, in the use of electrical contacts, it is found that the deposition corrosion of common corrosive media often occurs: when corrosive media are deposited in certain areas of the metal surface, localized corrosion may occur, which are usually circular or irregular in shape. For example, corrosive media generally include sulfides or organic acids, etc. Among them, hydrogen sulfide (H2S) can react with metals to form sulfides, causing corrosion. Organic acids such as acetic acid and citric acid can also promote metal corrosion under certain conditions.
[0004] Traditional contact corrosion detection methods mainly rely on manual visual inspection, which is not only inefficient, but also susceptible to human factors, making it difficult to ensure the accuracy and consistency of the detection results. With the rapid development of computer vision and machine learning technologies, automated detection methods based on image recognition have gradually become a research hotspot. However, existing image recognition methods still face many challenges in the field of contact corrosion detection.
[0005] Contact corrosion has various forms, including rust, patina, and other types of oxides, and the degree of corrosion varies. However, researchers have found that the degree of corrosion can range from mild surface oxidation to severe structural damage. According to different types of oxides, these corrosion forms differ in color, texture, and shape, and are influenced by the deposition corrosion phenomenon of corrosive media, which often has a corresponding relationship between color, texture, and shape. Therefore, based on this phenomenon, it brings complexity to the detection and evaluation of contact corrosion. SUMMARY
[0006] Therefore, there is an urgent need for an efficient, accurate, and adaptable contact corrosion image recognition method to solve the above problems and improve the efficiency and accuracy of contact corrosion detection, ensuring the safe and reliable operation of equipment.
[0007] The purpose of the present application is to provide a contact corrosion image recognition method and system, which solves the above technical problems pointed out in the prior art.
[0008] The application provides a contact corrosion image recognition method, comprising the following operation steps:
[0009] An image of a contact to be detected is acquired, the image of the contact to be detected is preprocessed to obtain a contact grayscale image, and a defect area of the contact grayscale image is acquired to obtain a plurality of suspected areas;
[0010] The pixel point brightness values inside the plurality of suspected areas are clustered to obtain a corrosion area, the surface fading index of each pixel point inside the suspected area is calculated, the corrosion comprehensive feature index of the corrosion area is calculated according to the surface fading index, and the corrosion comprehensive feature index is obtained.
[0011] Whether corrosion exists inside the corrosion area is determined through the corrosion comprehensive feature index, and a final recognition result of the image of the contact to be detected is obtained.
[0012] Preferably, the defect area of the contact grayscale image is acquired to obtain a suspected area, and the specific operation steps are as follows:
[0013] The contact grayscale image is framed through a YOLO algorithm to obtain a plurality of corrosion candidate frames.
[0014] The confidence score of all corrosion candidate frames is evaluated, a confidence score threshold a is set, and whether the confidence score of the corrosion candidate frame is greater than or equal to the confidence score threshold a is determined.
[0015] If not, the corrosion candidate frame is determined to be a normal area.
[0016] If not, the corrosion candidate frame is determined to be a suspected area.
[0017] Preferably, the pixel point brightness values inside the plurality of suspected areas are clustered to obtain a corrosion area, and the specific operation steps are as follows:
[0018] The brightness value of each pixel point in each suspected area is calculated, the brightness values of the pixel points are arranged in descending order, and the pixel point with the highest brightness value is selected as a first pixel point.
[0019] If there are two or more pixel points with the highest brightness value in each suspected area, a pixel point with the highest brightness value is randomly selected as the first pixel point.
[0020] The Euclidean distance between the pixel points in each suspected area is calculated, a preset Euclidean distance threshold r is set, and whether the Euclidean distance between the pixel points is greater than the Euclidean distance threshold r is determined.
[0021] If not, the Euclidean distance between the pixel points beyond the range of the Euclidean distance threshold r is excluded.
[0022] If yes, the Euclidean distance between the pixel points within the Euclidean distance threshold r range is taken as the dense area, as the second pixel point;
[0023] The coordinate position of the second pixel point is determined, and the pixel points within the Euclidean distance threshold r range of the second pixel point are clustered to obtain a pixel point cluster;
[0024] It is judged whether the first pixel point exists in the pixel point cluster, and the pixel point cluster in which the first pixel point exists is taken as the rust area.
[0025] Preferably, the surface fading index of the rust area is calculated according to the brightness values of each pixel point in the suspected area, and the specific operation steps are as follows:
[0026] The coordinates of the first pixel point in the rust area and the coordinates of all the remaining pixel points are determined;
[0027] The distance between the coordinates of the first pixel point and the coordinates of all the remaining pixel points is calculated, and the average distance is obtained;
[0028] The average distance calculation formula is:
[0029]
[0030] In the formula, Q represents the average distance of the pixel points in the rust area; 9i0, j0) represents the coordinates of the first pixel point in the rust area; (i a , j a ) represents the coordinates of the a-th pixel point in the rust area; and v represents the total number of pixel points in the rust area.
[0031] Edge pixel points are searched for in the rust area, the gradient of the edge pixel points is calculated, and the average gradient is calculated according to the gradient of the edge pixel points;
[0032] The average gradient calculation formula is:
[0033]
[0034] In the formula, T represents the average gradient of the edge pixel points in the rust area; Y a represents the gradient of the a-th edge pixel point in the rust area.
[0035] The number of pixel points in the rust area is counted, and the area W of the rust area is calculated according to the number of pixel points;
[0036] The average distance between the first pixel point and all the remaining pixel points, the average gradient of the edge pixel points, and the area of the rust area are multiplied to obtain the surface fading index of the pixel points in the rust area.
[0037] The surface fading index of the pixel points in the rust area is calculated according to the following formula:
[0038] D = e-RxTxW;
[0039] In the formula, D represents the surface fading index of the pixel points in the rust area; R represents the average distance of the pixel points inside the rust area; T represents the average gradient of the edge pixel points in the rust area; W represents the area of the rust area; and e represents a natural constant.
[0040] Preferably, the rust comprehensive feature index is calculated according to the surface fading index, and the specific operation steps are as follows:
[0041] The most edge pixel point of the rust area is obtained, the coordinate position of the most edge pixel point is determined, and the circumscribed rectangle of the rust area is obtained through the coordinate position of the most edge pixel point.
[0042] The diagonal point coordinates of the circumscribed rectangle of the rust area are determined, the diagonal points are connected, and the intersection point is taken as a third pixel point.
[0043] The distance between the third pixel point and all the edge pixel points of the rust area is calculated, the pixel point with the maximum distance is taken as a radius, a circle is formed, and the roundness of the rust area is calculated.
[0044] The roundness of the rust area is calculated according to the following formula:
[0045]
[0046] In the formula, C represents the roundness of the circle of the rust area; A represents the area of the circle of the rust area; and P represents the circumference of the circle of the rust area.
[0047] The rust comprehensive feature index is calculated according to the roundness and the surface fading index.
[0048] Preferably, the rust comprehensive feature index is calculated according to the roundness and the surface fading index, and the specific operation steps are as follows:
[0049] The rust area is converted into an HSL color space, and the standardized value of the surface fading index is calculated.
[0050] The standardized surface fading index is combined with the roundness to preliminarily calculate the rust comprehensive feature index.
[0051] The roundness and the standardized surface fading index are respectively divided into intervals by using a piecewise function.
[0052] determine the corresponding relationship between the roundness interval and the standardized surface fading index interval, and use the corresponding relationship to construct an adjustment function between the roundness and the standardized surface fading index;
[0053] determine the gray level, direction and distance of the pixel points in the rust area, calculate the frequency of the gray values of the neighborhood pixel points in the specified direction and distance for each pixel point in the rust area, and construct a gray level co-occurrence matrix;
[0054] divide each element in the gray level co-occurrence matrix by the sum of all elements to generate a probability matrix;
[0055] extract the texture features of the rust area through the probability matrix;
[0056] perform feature fusion calculation on the texture features and the initially calculated rust comprehensive feature index to obtain a final rust comprehensive feature index.
[0057] Preferably, the final rust comprehensive feature index is obtained by performing feature fusion calculation on the texture features and the initially calculated rust comprehensive feature index, and the specific operation steps are as follows:
[0058] calculate the contrast and uniform value of the texture features;
[0059] perform feature fusion calculation on the contrast and uniform value of the extracted texture features and the initially calculated rust comprehensive feature index to obtain a final rust comprehensive feature index.
[0060] Preferably, the rust area is determined to exist rust by the rust comprehensive feature index, and the final recognition result of the to-be-detected contact image is obtained, and the specific operation steps are as follows:
[0061] a rust comprehensive feature index threshold b is preset, and it is judged whether the rust comprehensive feature index is greater than or equal to the preset rust comprehensive feature index threshold b;
[0062] If yes, the rust area exists rust, and it is determined that the to-be-detected contact image exists contact rust;
[0063] If no, the rust area does not exist rust, and it is determined that the to-be-detected contact image does not exist contact rust.
[0064] Correspondingly, the application also provides an image recognition system for contact rust, which comprises an acquisition module, a detection module and a final recognition module.
[0065] The acquisition module is used for acquiring a to-be-detected contact image, pre-processing the to-be-detected contact image to obtain a contact gray image, and obtaining a defect area from the contact gray image to obtain a plurality of suspected areas.
[0066] The detection module is used for clustering according to the brightness values of the pixels inside the plurality of suspected areas to obtain a rust area; calculating a surface fading index according to the brightness values of the pixels inside the suspected area; and calculating a rust comprehensive feature index of the rust area according to the surface fading index;
[0067] The final recognition module is used for judging whether there is rust inside the rust area according to the rust comprehensive feature index to obtain a final recognition result of the to-be-detected contact image.
[0068] Compared with the prior art, the embodiments of the present application have at least the following technical advantages:
[0069] It can be known from the above-mentioned contact rust image recognition method and system provided by the present application that, in specific application, a to-be-detected contact image is acquired by a collection device for preprocessing of denoising, smoothing and gray-scale processing to obtain a contact gray-scale image; a bounding box is selected for the contact gray-scale image by a YOLO algorithm, and a suspected area possibly containing rust is selected according to the evaluation of a confidence score, so that normal areas without rust can be quickly ruled out, and areas possibly containing rust are screened out, thereby reducing the detection speed of subsequent recognition and increasing the accuracy.
[0070] Further, the brightness values of the pixels inside the suspected area are calculated, the pixel point with the highest brightness value is selected as a first pixel point, as a significant area of brightness, and points to possible rust, thereby determining the target direction of recognition and increasing the recognition efficiency; the Euclidean distances between the pixels inside the suspected area are calculated, whether the pixels are within a Euclidean distance threshold r is determined by the Euclidean distance, the pixels within the Euclidean distance threshold r are selected as second pixel points, the second pixel points and the pixels within the Euclidean distance threshold r are clustered to obtain pixel clustering clusters, and whether the first pixel point exists in the pixel clustering clusters is determined, the rust area is determined by the brightness of the significant area of the first pixel point, so that the rust area can be quickly determined, and the detection accuracy is increased.
[0071] Further, the average distance between the first pixel point in the rust area and the remaining pixel points is obtained; at the same time, the average gradient of the edge pixel points of the rust area and the area of the rust area are calculated; the average distance, the average gradient and the area are multiplied to obtain a surface fading index, the feature of the rust area is determined by the surface fading index, and the density change and the brightness change between the pixel points of the rust area can also be determined.
[0072] Further, the most edge pixel point in the edge pixel point of the rust area is obtained, and an outer rectangle is obtained through the most edge pixel point. An intersection formed by diagonal connection is taken as a third pixel point; a circle is formed according to the distance from the third pixel point to the edge pixel point as a radius, and the roundness of the rust area is obtained. The overall morphology of the rust area and the distribution of the pixel points can be calculated through the roundness.
[0073] Further, the roundness and the surface fading index can reflect the significant features of the rust area. According to the regularity of the roundness, the rust distribution (i.e., the distribution of the pixel points) of the rust area is judged, and the rust comprehensive feature index of the rust area is calculated through the significant brightness of the surface fading index. According to the rust comprehensive feature index, a threshold is effectively set to judge whether the rust area has rust, so as to improve the accuracy and speed of recognizing the contact rust. BRIEF DESCRIPTION OF DRAWINGS
[0074] Figure 1 The overall flowchart of the image recognition method of the contact rust in embodiment one is shown.
[0075] Figure 2 The rust schematic diagram of the image recognition method of the contact rust in embodiment one is shown.
[0076] Figure 3 The flowchart of the rust comprehensive feature index of the image recognition method of the contact rust in embodiment one is shown.
[0077] Figure 4 The schematic diagram of the rust area acquisition of the image recognition method of the contact rust in embodiment one is shown.
[0078] Figure 5 The flowchart of the rust comprehensive feature index acquisition through the matrix of the image recognition method of the contact rust in embodiment one is shown.
[0079] Figure 6 The flowchart of the rust comprehensive feature index calculation through the texture feature of the image recognition method of the contact rust in embodiment one is shown.
[0080] Figure 7 The overall flowchart of the image recognition system of the contact rust in embodiment two is shown.
[0081] Figure 8 The structure schematic diagram of the storage medium applying the image recognition method of the contact rust is shown.
[0082] Label: acquisition module 10; detection module 20; final recognition module 30; processor 1110; communication interface 1120; memory 1130; computer storage medium 1140. DETAILED DESCRIPTION
[0083] The technical solutions of the present application will be described clearly and completely in combination with the drawings. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0084] The present application will be described in further detail below through specific embodiments and in combination with the drawings.
[0085] As shown in the drawings, the present application provides an image recognition method for contact corrosion, comprising the following operation steps: Figure 1
[0086] S10: acquiring a to-be-detected contact image, pre-processing the to-be-detected contact image to obtain a contact grayscale image, and acquiring a defect area from the contact grayscale image to obtain a plurality of suspected areas;
[0087] It should be noted that the to-be-detected image of the contact is collected by the camera equipment, and the to-be-detected contact image is pre-processed. The pre-processing includes denoising, smoothing, and grayscale operations. In order to improve the quality of the to-be-detected contact image, reduce noise and unnecessary details, and enhance the readability of the image, the original image (i.e. the to-be-detected contact image) may contain interference factors, which will affect the subsequent defect detection accuracy. And improve the detection efficiency and accuracy of the subsequent YOLO algorithm to ensure that effective information can be quickly obtained, and the suspected area is obtained by the YOLO algorithm;
[0088] The defect area of the contact grayscale image is acquired to obtain a suspected area, and the specific operation steps are as follows: the contact grayscale image is framed by a candidate frame through the YOLO algorithm to obtain a plurality of corrosion candidate frames; the confidence score of all corrosion candidate frames is evaluated, and a confidence score threshold a is set to determine whether the confidence score of the corrosion candidate frame is greater than or equal to the confidence score threshold a; if not, it is determined that the corrosion candidate frame is a normal area; if not, it is determined that the corrosion candidate frame is a suspected area;
[0089] First, the candidate boxes of the YOLO algorithm are used to select suspected areas of possible rust in the grayscale image of the contact, and the areas where problems may exist are quickly located. The confidence scores of these suspected areas of possible rust are evaluated, and the confidence score threshold is set to judge the screening of suspected areas of possible rust in these rust candidate boxes. These rust candidate boxes with a confidence score greater than or equal to the confidence score threshold a are used as suspected areas of possible rust. In this way, the suspected areas of possible rust can be quickly identified according to the YOLO algorithm, and those suspected areas where rust is unlikely to exist are eliminated, so as to facilitate the subsequent determination of these screened suspected areas of possible rust for more detailed identification, so as to find out whether there is rust; and it also increases the recognition speed and accuracy.
[0090] S20: Clustering the pixel brightness values within the multiple suspected areas to obtain a rusted area; calculating a surface discoloration index (i.e., a surface discoloration index) based on the brightness value of each pixel within the suspected area, and calculating a comprehensive rust characteristic index for the rusted area based on the surface discoloration index;
[0091] It should be noted that in the analysis of rusted areas, the surface fading index is an indicator calculated by combining the average distance between pixels in the rusted area, the average gradient of edge pixels, and the area of the rusted area, and is used to measure the characteristics of the rusted area. The surface fading index reflects the compactness and brightness changes between pixels. Higher brightness usually indicates more severe rust. The rust comprehensive characteristic index measures the shape and distribution characteristics of the rusted area by combining roundness and surface fading index. A roundness close to 1 indicates a regular shape, which usually implies uniform rust distribution. Conversely, a lower roundness may indicate irregular or severe rust. Therefore, these two indicators together provide a comprehensive and in-depth assessment of the rusted area, helping to identify potential serious problems.
[0092] The study found that due to the influence of the deposition corrosion phenomenon of the corrosive medium, certain corrosion products (i.e. rust, such as verdigris and other chemical substances) produced thereby may aggregate on the surface of the above-mentioned contacts and then appear as circular corrosion rust spots.
[0093] S30: judging whether there is rust (patina (copper oxide) etc.) inside the rust area by the comprehensive rust characteristic index, such as Figure 2 As shown), the final recognition result of the contact image to be detected is obtained.
[0094] It should be noted that the preset rust comprehensive feature index threshold b is judged whether the rust comprehensive feature index is greater than or equal to the preset rust comprehensive feature index threshold b; if yes, the rust area exists rust, and it is determined that the contact image to be detected exists contact rust; if not, the rust area has no rust, and it is determined that the contact image to be detected has no contact rust. Through the rust comprehensive feature index, a final judgment can be made on the rust area to obtain whether the rust area exists rust. When the rust comprehensive feature index is greater than a certain degree, the contact to be detected can be detected to exist rust; when the rust comprehensive feature index is lower than a certain threshold, the contact does not exist rust, thereby improving the accuracy and speed of identification.
[0095] Specifically, as shown in the step S20, the pixel point brightness values inside the plurality of suspected areas are clustered to obtain a rust area; the surface fading index is calculated according to the brightness values of each pixel point inside the suspected area, and the rust comprehensive feature index is calculated according to the surface fading index for the rust area. The specific operation steps are as follows: Figure 3
[0096] S21: The brightness value of each pixel point in each suspected area is calculated, and the pixel points are selected in descending order of brightness value, and the pixel point with the highest brightness value is selected as the first pixel point;
[0097] If there are two or more pixel points with the highest brightness value in each suspected area, a pixel point with the highest brightness value is randomly selected as the first pixel point;
[0098] It should be noted that the brightness of each pixel point in the detected suspected area is calculated, and the pixel point with the highest brightness value usually represents the most serious rust; therefore, the pixel point with the highest brightness value is selected as the most obvious area, which points to the possible rust; in this way, the most obvious rust suspected area can be quickly identified, thereby providing a clear target for subsequent analysis and ensuring the accuracy and efficiency of detection;
[0099] S22: The Euclidean distance between the pixel points in each suspected area is calculated, and a preset Euclidean distance threshold r is set; whether the Euclidean distance between the pixel points is greater than the Euclidean distance threshold r is judged;
[0100] If not, the Euclidean distance between the pixel points beyond the Euclidean distance threshold r is excluded;
[0101] If yes, the Euclidean distance between the pixel points within the Euclidean distance threshold r is taken as a dense area, and is taken as a second pixel point;
[0102] It should be noted that the Euclidean distance between adjacent pixel points is calculated to determine the degree of aggregation of the pixel points inside the suspected area of rust; the closer the Euclidean distance between the pixel points, the more likely they are to be part of the same object in terms of brightness (i.e., they may be rust), and by filtering out these dense areas, potential rust points (i.e., rust points refer to rusted areas on the surface of metal materials due to oxidation or corrosion. These points are usually characterized by color changes, rough or concave surfaces, and may cause problems such as reduced metal strength and structural damage) can be identified; the density of pixel points within the rust area enhances the ability to recognize rust areas, effectively eliminating unrelated and scattered pixel points;
[0103] And by excluding pixel points that exceed the Euclidean distance threshold r, only pixel points that are close to each other and have similar characteristics can be retained, thereby more accurately identifying dense areas, which helps to reduce the impact of noise and irrelevant data and improves the effectiveness of clustering and the accuracy of subsequent analysis; retaining pixel points within the Euclidean distance threshold r range can more effectively gather potential cluster centers or similar areas;
[0104] S23: Determine the coordinate position of the second pixel point and cluster the pixel points within the Euclidean distance threshold r range of the second pixel point to obtain a pixel point cluster;
[0105] Determine whether the first pixel point exists within the pixel point cluster, and use the pixel point cluster in which the first pixel point exists as a rust area;
[0106] It should be noted that in clustering, whether the highest brightness value pixel point (i.e., the first pixel point) selected at the beginning is in the clustered pixel point cluster determines the effectiveness of the pixel point cluster, and ultimately forms a collection of rust areas, which may contain rust points; determining that the highest brightness value pixel point is in the cluster helps to confirm that the area indeed has obvious rust characteristics (as explained in step S21, the highest brightness value pixel point represents the severity of rust and may also represent similar rust in nearby areas); the highest brightness value pixel point usually corresponds to the severity of rust, so if the first pixel point is in the pixel point cluster, it means that the surrounding pixel points may also have similar rust characteristics, and the pixel point cluster is used as a rust area, as shown in Figure 4 which can effectively concentrate analysis and detection, ensuring that potential serious problems are not missed, thereby improving the accuracy and efficiency of detection.
[0107] S24: Determine the coordinates of the first pixel point within the rust area and the coordinates of all other pixel points;
[0108] Calculate the distance between the coordinates of the first pixel point and the coordinates of all other pixel points, and obtain the average distance;
[0109] The average distance calculation formula is:
[0110]
[0111] In the formula, Q represents the average distance of the pixel points inside the rust area; (i0, j0) represents the coordinates of the first pixel point in the rust area (i.e. the pixel point with the highest brightness value); (ia, ja) represents the coordinates of the a-th pixel point in the rust area; and v represents the total number of pixel points in the rust area; a a
[0112] Find the edge pixel points in the rust area, calculate the gradient of the edge pixel points, and calculate the average gradient according to the gradient of the edge pixel points;
[0113] The average gradient calculation formula is:
[0114]
[0115] In the formula, T represents the average gradient of the edge pixel points in the rust area; Y a represents the gradient of the a-th edge pixel point in the rust area;
[0116] Count the number of pixel points inside the rust area, and calculate the area W of the rust area according to the number of pixel points (i.e. calculating the area according to the number of pixel points is well known and will not be described in detail);
[0117] S25: Multiply the average distance between the first pixel point and all other pixel points, the average gradient of the edge pixel points, and the area of the rust area to obtain the surface fading index of the pixel points in the rust area;
[0118] The calculation formula of the surface fading index of the pixel points in the rust area is:
[0119] D = e-RxTxW;
[0120] In the formula, D represents the surface fading index of the pixel points in the rust area; R represents the average distance of the pixel points inside the rust area; T represents the average gradient of the edge pixel points in the rust area; W represents the area of the rust area; and e represents the natural constant;
[0121] It should be noted that the average distance Q between the first pixel point in the rust area and all the remaining pixel points is calculated, and the smaller the average distance Q, the more closely the pixel points in the rust area are distributed and the smaller the distribution density (i.e., the distance between the pixel points is small, which may indicate that the rust area has a high distribution density; at the same time, if the average distance Q is large, the pixel points in the rust area are distributed more loosely, which may indicate that the rust area has a low distribution density); at the same time, the surface fading index D of the pixel points in the rust area is larger; the larger the average gradient T of the edge pixel points in the rust area, the higher the brightness value of the pixel points on the edge of the rust area, so that the edge feature of the surface fading index of the pixel points in the rust area is more prominent (i.e., if the average gradient T is small, the brightness change of the edge may not be obvious, and the edge feature is weak); at the same time, the surface fading index D of the pixel points in the rust area is larger; the more the total number of pixel points in the rust area, the larger the area of the rust area, and also indicates that the brightness value of the rust area obtained after clustering of the pixel points is higher, which indicates that there is more possibility of rust; at the same time, the surface fading index D of the pixel points in the rust area is larger; the larger the surface fading index D of the pixel points in the rust area, the greater the tightness of the pixel points in the rust area, and the greater the density between the pixel points, which may indicate that there is a large possibility of rust in the rust area;
[0122] S26: Obtain the most edge pixel point of the rust area, determine the coordinate position of the most edge pixel point, and obtain the circumscribed rectangle of the rust area through the coordinate position of the most edge pixel point;
[0123] The diagonal point coordinates of the circumscribed rectangle of the rust area are determined, the diagonal points are connected, and the intersection point is taken as a third pixel point (i.e., as a center point);
[0124] The distance between the third pixel point and all the edge pixel points of the rust area is calculated, the pixel point with the maximum distance is found as a radius, a circle is formed, and the roundness of the rust area is calculated;
[0125] The roundness calculation formula of the rust area is:
[0126]
[0127] In the formula, C represents the roundness of the circle of the rust area (i.e., the roundness, which generally ranges from 0 to 1; the closer to 1, the more regular the shape; the closer to 0, the more irregular the shape); A represents the area of the circle of the rust area; and P represents the circumference of the circle of the rust area.
[0128] The roundness and the surface fading index are calculated to obtain a rust comprehensive feature index.
[0129] It should be noted that for the identified rust area, the edge detection algorithm is used to extract the most edge pixel points, and the edge pixel points can clearly depict the outline of the area, which is helpful for subsequent use of the coordinates of the most edge pixel points to calculate the circumscribed rectangle of the rust area, so as to obtain a smallest rectangular frame completely surrounding the rust area; the coordinates of the two opposite corners of the circumscribed rectangle are calculated, the two opposite corners are connected, the intersection point of the connection is found, and the intersection point is determined as the center point (i.e. the third pixel point) of the rust area; the center point is used to calculate the roundness, so that the roundness calculation is more accurate and reflects the overall shape of the rust area; the distances of all pixel points in the rust area to the center point are calculated, the maximum distance is found as the radius, and the radius value of the rust area is obtained; the radius is a key index for calculating the roundness, and can reflect the pixel point distribution of the area;
[0130] In the above technical solution, the purpose of calculating the roundness is to evaluate the shape characteristics of the rust area. For example, the closer the roundness is to 1, the closer the shape is to a circle; and a lower roundness may indicate that the shape of the rust area is irregular. By analyzing the roundness, the severity of the rust can be identified.
[0131] The reason for calculating the rust comprehensive feature index by using the roundness and the surface discoloration index is that these two features can reflect the shape and texture of the rust area. The roundness measures the regularity of the shape, and the higher the roundness, the closer the shape is to a circle, which usually indicates that the rust is evenly distributed. The surface discoloration index reflects the purity of the color, which affects the visual rust degree and severity (i.e. the tightness and density of the pixel points in the rust area can highlight the surface discoloration index, and because the pixel points are too concentrated, the brightness of the rust area is too prominent, and when the contact produces rust, the surface of the contact will appear deep color rust (iron oxide), patina (copper oxide) and the like (i.e. rust, rust includes iron rust, patina, etc.); therefore, the surface discoloration index can reflect the color of the rust, i.e. the severity of the rust); by combining the roundness and the surface discoloration index, the characteristics of the rust area can be more comprehensively evaluated, so as to effectively identify and analyze the severity of the rust, and thus calculate the rust comprehensive feature index. The more severe the rust, the larger the rust comprehensive feature index.
[0132] Specifically, as shown in FIG. 26, in step S26, the rust comprehensive feature index is calculated according to the roundness and the surface discoloration index, and the specific operation steps are as follows: Figure 5
[0133] S261: converting the rust area into HSL color space to calculate the standardized value of the surface discoloration index; the standardization formula is as follows:
[0134]
[0135] In the formula, C actual represents the surface discoloration index of the rust area.min represents the minimum surface discoloration index among all pixel points in the rust area; C max represents the maximum surface discoloration index among all pixel points in the rust area;
[0136] The normalized surface discoloration index is combined with the roundness to preliminarily calculate a rust comprehensive feature index:
[0137] R pre =k1·(1-C)+k2·S;
[0138] In the formula, k1 and k2 represent weight coefficients, reflecting the relative influence of the roundness and the normalized surface discoloration index;
[0139] It should be noted that in the above formula, (1-C) represents that the higher the roundness C, the more regular the shape, and (1-C) represents the irregularity of the shape. The higher the irregularity value, the more irregular the shape of the rust area, thereby increasing the rust comprehensive feature index. k1(1-C) represents the influence of the roundness on the rust comprehensive feature index. If the roundness is low, the rust comprehensive feature index will increase, reflecting the irregularity of the shape of the rust area. k2·S represents the influence of the surface discoloration index on the rust comprehensive feature index. The higher the surface discoloration index, the greater the rust comprehensive feature index, reflecting the degree of color and severity of rust;
[0140] HSL (hue, surface discoloration index, and brightness) is more suitable for color analysis. Because in HSL, the surface discoloration index S represents the purity of the color, the higher the value, the brighter the color, and the lower the color. In the rust area, there may be multiple colors, and a single surface discoloration index value may not accurately reflect the overall characteristics of the area. Moreover, the initial calculation of the rust comprehensive feature index can filter out rust areas that need further analysis, reducing the computational burden of subsequent analysis and improving efficiency;
[0141] S262: using a piecewise function to respectively divide the roundness and the normalized surface discoloration index into intervals;
[0142] determining the corresponding relationship between the roundness interval and the normalized surface discoloration index interval, and using the corresponding relationship to construct an adjustment function between the roundness and the normalized surface discoloration index;
[0143] It should be noted that, first, the value ranges of roundness C and surface fading index S are determined; for example, the range of roundness C is 0 to 1; the range of surface fading index S is 0 to 1; according to actual conditions, the values of roundness and surface fading index are divided into several intervals, for example, roundness C includes irregular 0.0-0.3, medium regular 0.3-0.7, and regular 0.7-1.0; surface fading index S includes low surface fading index 0.0-0.3, medium surface fading index 0.3-0.7, and high surface fading index 0.7-1.0;
[0144] The corresponding relationships between the roundness C and the surface fading index S of the divided intervals are respectively found: low roundness and low surface fading index, medium roundness and medium surface fading index, and high roundness and high surface fading index;
[0145] The corresponding relationship adjustment strategy defined for each interval of roundness C and surface fading index S, for example: for low roundness and low surface fading index (C≤0.3, S≤0.3): R adjusted =R pre 0.5; for medium roundness and medium surface fading index (0.3 <C≤0.7,0.3<S≤0.7):R adjusted =R pre (1+(S-0.5)); For high roundness and high surface fading index (C>0.7, S>0.7): R adjusted =R pre ·e (S-0.5) In the above formula, the surface fading index S ranges from 0 to 1, 0.5 represents a medium surface fading index, and 0.5 is used as a reference point to distinguish between low surface fading index and high surface fading index; 0.5 is used to calculate the increment or adjustment range; for example, the formula R adjusted =R pre (1+(S-0.5)) indicates that when the saturation S is above 0.5, the rust comprehensive characteristic index increases; when it is below 0.5, the rust comprehensive characteristic index decreases. 0.5 is used as the cutoff point to help more accurately reflect the characteristic changes of the rust area, allowing adjustments to adapt to different surface fading index conditions.
[0146] In rust detection, a low roundness often indicates an irregular shape, while a low surface discoloration index may indicate a less noticeable color or mild rust. Therefore, different adjustment strategies need to be designed for different intervals to accurately reflect the characteristics of the rusted area.
[0147] Low roundness and low surface discoloration index: when both are low, the rust area is usually irregular in shape and not obvious in color, which may indicate a lighter degree of rust, so the value of the rust comprehensive feature index needs to be reduced to reflect this feature; medium roundness and medium surface discoloration index: such areas may show some degree of rust, with changes in shape and color.
[0148] The adjustment strategy can introduce a linear increment based on the surface discoloration index, so that the rust comprehensive feature index increases as the surface discoloration index increases, reflecting the gradual increase in rust; high roundness and high surface discoloration index: indicating that the rust area is regular and the color is obvious, usually meaning a heavier degree of rust; using an exponential function can make the rust comprehensive feature index increase rapidly to emphasize the severity of the rust; exponential growth can more sensitively reflect changes in the surface discoloration index, adapting to the strong changes in the rust area;
[0149] In practical applications, the shape and color change of rust are usually complex; by designing adjustment strategies for different feature ranges, these strategies can be continuously optimized according to actual data feedback, so that the rust comprehensive feature index can more accurately reflect the true situation;
[0150] S263: Determine the gray level, direction, and distance of the pixel points in the rust area (i.e., using multiple directions to capture texture features in different directions, enhancing the description of regional features; select the direction according to the specific application, for example: if the texture of the rust area is mainly along a certain direction, preferentially select that direction; the distance is 1 pixel, i.e., calculate the relationship between the current pixel point and its adjacent pixel points; the above "distance" is not the Euclidean distance, but indicates the spatial relationship between two pixels in the rust area, the spatial interval used when calculating the relationship between adjacent pixels, which is usually measured in pixels and combined with a specific direction to generate texture features; in the gray level co-occurrence matrix, the distance value is 1 (i.e., using adjacent pixel points as a reference)); calculate the frequency of the gray values of the neighborhood pixel points in the specified direction and distance for each pixel point in the rust area (i.e., for direction 0°, the frequency "refers to the number of times a specific pixel point gray value combination appears in the image), and construct a gray level co-occurrence matrix;
[0151] Divide each element in the gray level co-occurrence matrix by the sum of all elements to generate a probability matrix (i.e., the probability matrix can more intuitively represent the distribution of information. For example, a certain pair of gray levels has a high probability of occurrence, which can be inferred that there are obvious texture features in the rust area; when calculating texture features (such as contrast, uniformity), using a probability matrix can more accurately reflect the texture complexity of the rust area, reducing the numerical instability caused by the excessively large frequency range of the original pixel gray values, thereby improving the stability of the algorithm in subsequent feature extraction and processing);
[0152] S264: extracting texture features from the corroded area using the probability matrix;
[0153] The texture features are combined with the initially calculated corrosion comprehensive feature index to obtain a final corrosion comprehensive feature index.
[0154] It should be noted that the rusted area has been converted to the HSL color space in step S261. Although the shape and color of the rusted area are important, the roundness and surface fading index alone may not fully reflect the characteristics of the rust. Different types of rust may have different surface textures. For example, light rust may appear as a smooth surface, while severe rust may have a rough, granular texture. Therefore, texture features can better reflect the complexity and changes of the rusted surface.
[0155] The grayscale levels of pixels in the rusted area are determined by constructing a grayscale co-occurrence matrix. The frequency of occurrence of the grayscale values of each pixel in the neighborhood direction and distance is calculated for each pixel. A probability matrix is then constructed based on each element in the grayscale co-occurrence matrix. The texture features of the rusted area are extracted using the probability matrix, which reduces the effects of brightness changes or different grayscale distributions in the rusted area, making the extracted texture features more stable and reliable.
[0156] Incorporating texture features into the calculation of the comprehensive rust characteristic index allows for a more comprehensive calculation of the final comprehensive rust characteristic index for the rust area. For example, a rusted area may have a high roundness but a very rough texture, which may be overlooked by a single indicator (i.e., roundness, surface fading index, contrast, and uniformity). By combining texture features, the true condition of the rusted area can be more accurately determined.
[0157] Specifically, if Figure 6 As shown, in step S264, the texture features and the initially calculated rust comprehensive feature index are subjected to feature fusion calculation to obtain the final rust comprehensive feature index. The specific operation steps are as follows:
[0158] S2641: Calculates the contrast of texture features (i.e., by calculating the contrast, the change in grayscale intensity of the rusted area can be evaluated, and the roughness of the texture can also be reflected) and the uniformity value (i.e., by calculating the uniformity, the smoothness of the rusted area can be reflected; the higher the uniformity value, the smoother the texture);
[0159] The formula for calculating contrast is:
[0160] Contrast=∑ i,j (ij) 2 P(i,j);
[0161] where i and j represent different gray levels in the image, usually ranging from 0 to 255; P(ij) is an element in the gray level co-occurrence matrix (GLCM), representing the frequency of pixel pairs with gray values of i and j; (i-j) 2 represents the square of the difference between the gray levels i and j;
[0162] It should be noted that (i-j) 2 , the larger the difference, the larger the square value, reflecting the gray difference between the two pixel points, and the contrast of the overall image can be obtained; the higher the contrast, the more obvious the texture and details in the image, because the gray difference between pixels is larger; on the contrary, low contrast means that the rust area is relatively flat and has less detail;
[0163] The formula for calculating the uniformity value is:
[0164]
[0165] where P(ij) is an element in the gray level co-occurrence matrix (GLCM), representing the frequency of pixel pairs with gray values of i and j; |i-j| represents the absolute difference between the gray values;
[0166] It should be noted that |i-j| represents the absolute difference between the gray values, which is different from the square difference in the contrast formula, and here the absolute value is taken, emphasizing the size of the difference; the term 1+|i-j| is to avoid division by zero, while increasing the weight of smaller differences; the uniformity measures the smoothness of the gray distribution in the rust area; high uniformity means that the gray values of adjacent pixels are similar, indicating that the surface of the rust area is relatively smooth; low uniformity means that there are large gray differences in the rust area;
[0167] S2642: Perform feature fusion calculation on the contrast and uniformity values of the extracted texture features and the initial calculated rust comprehensive feature index to obtain the final rust comprehensive feature index;
[0168] The formula for calculating the final rust comprehensive feature index is:
[0169] R=(R pre +k3·Contrast+k4·Homogeneity)·R adjusted ;
[0170] where R represents the final rust comprehensive feature index; R pre represents the initial rust comprehensive feature index calculated by the roundness and the normalized surface fading index; k3 and k4 represent the weight coefficients;
[0171] In the above feature fusion calculation process, the emphasis is on fusing other important features (such as contrast, uniform value, etc.) collected into the aforementioned one calculation operation model, and then performing "feature fusion calculation" to output a final rust comprehensive feature index.
[0172] It should be noted that the rust comprehensive feature index calculated initially is added with the contrast and uniform value of the texture feature, that is, the uniformity, to calculate the rust comprehensive feature index (that is, the texture feature extracted in the rust area is integrated into the rust comprehensive feature index calculated initially), and the texture feature includes contrast, uniform value, energy, and entropy. The contrast and uniform value are added because the contrast describes the difference between the gray levels in the rust area, can reflect the texture roughness of the rust area, and high contrast usually means that there are obvious edges and texture changes in the rust area, which can reflect the severity of the rust;
[0173] The uniform value is added to measure the similarity of the gray values in the rust area, and high uniformity indicates that the gray level change in the area is small, which usually corresponds to less rust or a smoother surface. The uniformity is helpful for identifying the stability of the rust area and can effectively improve the identification speed. Different rust conditions may exhibit different contrast and uniformity. For example, some rust areas may have complex shapes and obvious gray changes, while other rust areas may be more uniform. Therefore, by adding the contrast and uniformity, the rust comprehensive feature index can be calculated more flexibly.
[0174] The reason why the energy and entropy of the texture feature are not used to calculate the final rust comprehensive feature index is that adding energy and entropy may increase the complexity of the calculation, especially when processing large-scale images, which may affect the processing speed and real-time performance. If the existing texture features (such as contrast and uniformity) can already well describe the features of the rust area, introducing energy and entropy may cause information redundancy, which may reduce the effectiveness of the calculation. In some specific applications, more attention may be paid to some texture features (such as contrast and uniformity), and the influence of energy and entropy may not be considered.
[0175] Embodiment Two
[0176] As shown in Figure 7 Correspondingly, the present application also provides an image recognition system for contact rust, which comprises an acquisition module 10, a detection module 20, and a final recognition module 30.
[0177] The acquisition module 10 is used to acquire a contact image to be detected, pre-processes the contact image to be detected to obtain a contact gray image, and acquires a defect area from the contact gray image to obtain a plurality of suspected areas.
[0178] The detection module 20 is used for clustering according to the pixel brightness values inside the plurality of suspected areas to obtain a rust area; calculating a surface fading index according to the brightness values of each pixel inside the suspected area, and calculating a rust comprehensive feature index of the rust area according to the surface fading index;
[0179] The final recognition module 30 is used for judging whether there is rust inside the rust area according to the rust comprehensive feature index to obtain a final recognition result of the to-be-detected contact image.
[0180] Embodiment three
[0181] In another aspect, the embodiment three based on the image recognition method for contact rust provided in the inventive embodiment one further provides a computer storage medium 1140 (referred to as storage medium). As shown in the figure, the computer storage medium structure framework provided in the embodiment three of the application includes: Figure 8
[0182] The memory 1130 is used for storing a computer program;
[0183] The communication interface 1120 is used for connecting the memory 1130 with the processor 1110;
[0184] The processor 1110 is used for executing the computer program to realize the image recognition method for contact rust provided in any combination of the above-mentioned embodiments.
[0185] In summary, the image recognition method for contact rust and the system provided in the application example, through the acquisition device, the to-be-detected contact image is obtained for preprocessing of denoising, smoothing and gray scale to obtain a contact gray image; the YOLO algorithm is used to frame the candidate frame of the contact gray image, according to the evaluation of the confidence score, the suspected area which may exist rust is selected, so that the normal area which does not exist rust can be quickly ruled out, and the area which may exist rust is screened out, the detection speed of subsequent recognition is reduced, and the accuracy is increased;
[0186] Further, the brightness values of the pixel points in the suspected area are calculated, the pixel point with the highest brightness value is selected as the first pixel point, and the pixel point with the highest brightness value is selected as the first pixel point. The significant area of brightness points to the possible existence of corrosion, clearly identifies the target direction, and increases the identification efficiency; and the Euclidean distance between the pixel points in the suspected area is calculated, and the Euclidean distance threshold r is used to determine whether the pixel points are within the Euclidean distance threshold r. The pixel points within the Euclidean distance threshold r are used as the second pixel point, the second pixel point and the pixel points within the Euclidean distance threshold r are clustered, the pixel point clustering cluster is obtained, and it is determined whether the first pixel point exists in the pixel point clustering cluster. The brightness of the significant area of the first pixel point is used to determine the corrosion area, so that the corrosion area can be quickly determined, and the detection accuracy is increased;
[0187] Further, the average distance between the first pixel point in the corrosion area and the remaining pixel points is obtained; at the same time, the edge pixel points of the corrosion area are found to calculate the average gradient and the area of the corrosion area; the average distance is multiplied by the average gradient and the area to obtain the surface fading index. The surface fading index is used to determine the characteristics of the corrosion area, and the density change and brightness change between the pixel points in the corrosion area are also determined.
[0188] Further, the most edge pixel point in the edge pixel point of the corrosion area is obtained, the circumscribed rectangle is obtained through the most edge pixel point, and the intersection point formed by the diagonal connection is used as the third pixel point; the distance from the third pixel point to the edge pixel point is used as the radius to form a circle, and the roundness of the corrosion area is obtained. The overall morphology of the corrosion area and the distribution of the pixel points can be calculated by calculating the roundness.
[0189] Further, the roundness and the surface fading index can reflect the significant features of the corrosion in the corrosion area. According to the regularity of the roundness, the corrosion distribution (i.e. the distribution of the pixel points) of the corrosion area is judged, and the surface fading index is calculated by the significant brightness in the corrosion area to calculate the corrosion comprehensive feature index of the corrosion area. According to the corrosion comprehensive feature index, an effective threshold is set to determine whether the corrosion area exists corrosion, and the accuracy and speed of identifying the contact corrosion are improved.
[0190] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; those skilled in the art can modify the technical solutions described in the above embodiments, or replace some or all of the technical features with equivalent ones; and these modifications or replacements do not change the essence of the corresponding technical solutions beyond the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for image recognition of contact corrosion, characterized in that: The following steps are included: Acquire a contact image to be detected, pre-process the contact image to be detected to obtain a contact grayscale image; acquire a defect area from the contact grayscale image to obtain multiple suspected areas; Clustering the pixels within the multiple suspected areas according to their brightness values to obtain a rusted area; calculating a surface fading index based on the brightness values of each pixel within the suspected area, and calculating a comprehensive rust characteristic index for the rusted area based on the surface fading index; The steps of calculating the surface fading index based on the brightness value of each pixel point inside the suspected area and calculating the comprehensive rust characteristic index of the rusted area based on the surface fading index are as follows: Calculate the brightness value of each pixel in the suspected area, sort the pixels in descending order according to their brightness values, and select the pixel with the highest brightness value as the first pixel; The surface fading index of the pixels in the rusted area is obtained by multiplying the average distance between the first pixel and all other pixels, the average gradient of the edge pixels, and the area of the rusted area. Calculating a comprehensive rust characteristic index based on the roundness of the rusted area and the surface fading index; The presence of rust in the rust region is determined by using the comprehensive rust characteristic index to obtain a final recognition result of the contact image to be detected.
2. The image recognition method for contact corrosion according to claim 1, characterized in that: The defect area is obtained from the contact grayscale image to obtain the suspected area. The specific operation steps are as follows: Performing candidate frame selection on the contact grayscale image using a YOLO algorithm to obtain multiple rust candidate frames; Evaluate the confidence scores of all rust candidate frames, set a confidence score threshold a, and determine whether the confidence score of the rust candidate frame is greater than or equal to the confidence score threshold a; If not, the rust candidate frame is determined to be a normal area; If not, the rust candidate frame is determined to be a suspected area.
3. The image recognition method for contact corrosion according to claim 2, characterized in that: Clustering is performed based on the brightness values of the pixels within the multiple suspected areas to obtain the rusted areas. The specific steps are as follows: If there are two or more pixels with the highest brightness values in each suspected area, randomly select a pixel with the highest brightness value as the first pixel; Calculate the Euclidean distance between the pixels in each suspected area, and preset the Euclidean distance threshold r; determine whether the Euclidean distance between the pixels is greater than the Euclidean distance threshold r; If not, the Euclidean distances between pixels that exceed the Euclidean distance threshold r are excluded; If so, the Euclidean distance between the pixels within the Euclidean distance threshold r is taken as the dense area and used as the second pixel; Determine the coordinate position of the second pixel point, cluster the pixels within a Euclidean distance threshold r of the second pixel point to obtain a pixel point cluster; It is determined whether a first pixel point exists in the pixel point cluster, and the pixel point cluster in which the first pixel point exists is regarded as a rust area.
4. The image recognition method for contact corrosion according to claim 3, characterized in that: The surface fading index is calculated based on the brightness value of each pixel in the suspected area. The specific steps are as follows: Determine the coordinates of the first pixel point and the coordinates of all other pixel points in the rust area; Calculating the distance between the coordinates of the first pixel and the coordinates of all other pixel points, and obtaining an average distance; The average distance calculation formula is: ; Where Q represents the average distance of pixels inside the rusted area; Expressed as the coordinates of the first pixel in the rust area; It is represented as the coordinate of the ath pixel in the rust area; v is represented as the total number of pixels in the rust area; Searching for edge pixel points in the corroded area, calculating gradients for the edge pixel points, and calculating an average gradient based on the gradients of the edge pixel points; The average gradient calculation formula is: ; Where T represents the average gradient of edge pixels in the rust area; It is expressed as the gradient of the ath edge pixel in the rust area; Counting the number of pixels inside the corroded area, and calculating the area W of the corroded area based on the number of pixels; The calculation formula for the surface fading index of the pixel points in the rust area is: D=e-Q T W; Where D is the surface fading index of pixels within the rusted area; Q is the average distance between pixels within the rusted area; T is the average gradient of edge pixels within the rusted area; W is the area of the rusted area; and e is a natural constant.
5. The image recognition method for contact corrosion according to claim 4, characterized in that: The rust comprehensive characteristic index is calculated for the rusted area based on the surface fading index. The specific steps are as follows: Obtaining the outermost pixel point of the rusted area, determining the coordinate position of the outermost pixel point, and obtaining the circumscribed rectangle of the rusted area according to the coordinate position of the outermost pixel point; Determine the coordinates of the diagonal points of the circumscribed rectangle of the rusted area, connect the diagonal points, and use the intersection point as the third pixel point; Calculating the distance between the third pixel and all edge pixels of the rusted area, finding the pixel with the largest distance as the radius, forming a circle, and calculating the roundness of the rusted area; The calculation formula for the roundness of the rusted area is: ; Wherein, C represents the circularity of the corroded area; A represents the area of the corroded area; P represents the circumference of the corroded area; The comprehensive rust characteristic index is calculated based on the roundness of the rusted area and the surface fading index.
6. The image recognition method for contact corrosion according to claim 5, characterized in that: The rust comprehensive characteristic index is calculated according to the roundness and the surface fading index. The specific steps are as follows: Convert the rusted area into HSL color space and calculate the standardized value of the surface fading index; The standardized surface fading index is combined with the roundness to initially calculate the comprehensive rust characteristic index: Using a piecewise function to divide the roundness and the normalized surface fading index into intervals respectively; Determining a correspondence between a roundness interval and a normalized surface fading index interval, and constructing an adjustment function between the roundness and the normalized surface fading index using the correspondence; Determine the grayscale level, direction, and distance of pixels within the rust area; calculate the frequency of grayscale values of neighboring pixels within the specified direction and distance for each pixel within the rust area, and construct a grayscale co-occurrence matrix; Dividing each element in the gray-level co-occurrence matrix by the sum of all elements to generate a probability matrix; Extracting texture features from the corroded area using the probability matrix; The texture features are combined with the initially calculated corrosion comprehensive feature index to obtain a final corrosion comprehensive feature index.
7. The image recognition method for contact corrosion according to claim 6, characterized in that: The texture features are combined with the initially calculated corrosion comprehensive feature index to obtain a final corrosion comprehensive feature index. The specific steps are as follows: Calculate the contrast and uniformity of texture features; The contrast and uniformity of the extracted texture features are combined with the initially calculated rust comprehensive feature index to obtain the final rust comprehensive feature index.
8. The image recognition method for contact corrosion according to claim 7, characterized in that: The presence of rust inside the rust area is determined by using the comprehensive rust characteristic index to obtain the final recognition result of the contact image to be detected. The specific operation steps are as follows: Preset a comprehensive corrosion characteristic index threshold b, and determine whether the comprehensive corrosion characteristic index is greater than or equal to the preset comprehensive corrosion characteristic index threshold b; If yes, then the rusted area is rusted, and it is determined that the contact image to be detected has contact rust; If not, the rusted area is not rusted, and it is determined that there is no contact rust in the contact image to be detected.
9. An image recognition system for contact corrosion, characterized in that: include: Acquisition module; detection module; final recognition module; The acquisition module is used to acquire the contact image to be detected, and pre-process the contact image to be detected to obtain a contact grayscale image; Acquire defect areas from the contact grayscale image to obtain multiple suspected areas; The detection module is used to cluster the brightness values of the pixels within the multiple suspected areas to obtain the rusted areas; calculate the surface fading index based on the brightness values of each pixel within the suspected areas, and calculate the comprehensive rust characteristic index of the rusted areas based on the surface fading index; The steps of calculating the surface fading index based on the brightness value of each pixel point inside the suspected area and calculating the comprehensive rust characteristic index of the rusted area based on the surface fading index are as follows: Calculate the brightness value of each pixel in the suspected area, sort the pixels in descending order according to their brightness values, and select the pixel with the highest brightness value as the first pixel; The surface fading index of the pixels in the rusted area is obtained by multiplying the average distance between the first pixel and all other pixels, the average gradient of the edge pixels, and the area of the rusted area. Calculating a comprehensive rust characteristic index based on the roundness of the rusted area and the surface fading index; The final recognition module is used to determine whether there is rust inside the rust area according to the comprehensive rust characteristic index, and obtain a final recognition result of the contact image to be detected.
Citation Information
Patent Citations
Strip steel red rust defect detection method based on artificial intelligence
CN113554629A
Battery box production defect detection method based on image processing
CN118096761A