Titanium wire uniformity detection method and device based on image recognition
Through the adaptive edge detection threshold strategy, the edge detection threshold is adjusted to solve the problem of missing edge information under complex lighting conditions and improve the accuracy and reliability of titanium wire coiling uniformity detection.
Patent Information
- Application Number
- CN202410837394.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-06-26
AI Technical Summary
The existing technology uses fixed gradient thresholds for edge detection under complex lighting conditions, resulting in low accuracy in titanium wire coiling uniformity detection, and edge information is easily missed.
The adaptive edge detection threshold strategy is adopted to calculate the initial edge detection threshold and connectability degree of pixels, adjust the edge detection threshold, and re-detect the edge to improve detection accuracy.
It effectively overcomes the limitations of the fixed threshold method, reduces the loss of edge information, improves the accuracy and adaptability of edge detection, and makes the titanium wire coiling uniformity detection results more accurate and reliable.
Smart Images

Figure CN118397027B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to a titanium wire uniformity detection method and device based on image recognition. Background Art
[0002] As a high-performance material, titanium wire has shown wide application potential in many fields, especially in aerospace, medical health, chemical manufacturing, automotive industry, electronic technology and sports equipment manufacturing, due to its excellent corrosion resistance, high strength, low density, non-magnetic, high biocompatibility and low impedance to ultrasound. In order to optimize the logistics and storage of titanium wire, coiling is usually adopted to improve space utilization, reduce transportation costs, improve operating efficiency and avoid damage caused by entanglement during handling. The ideal coiling state requires the titanium wire to be closely arranged and evenly distributed, so as to minimize the potential risk of damage.
[0003] It has become a trend to use image recognition technology to detect the uniformity of the surface of coiled titanium wire. For example, the patent application document with publication number CN111489341A discloses a method for detecting tangled wires in wire coils, including real-time acquisition of the winding grayscale image of the wire in the process of winding the wire around the wire coil; dividing the region of interest in the winding grayscale image; using the edge detection operator to perform gradient calculations on each pixel point in the region of interest, identify the edge line of the winding area in the region of interest, and determine whether the number of straight line segments contained in the edge line is greater than 2. If so, there are tangled wires on the wire coil.
[0004] However, when the above scheme uses the edge detection operator to identify the edge line, the edge detection operator adopts a fixed gradient threshold strategy to define the edge in the image. This approach exposes limitations in actual operation, especially under inconsistent lighting conditions. The fixed threshold strategy may cause the edge information of the lower grayscale area in the image to be omitted, thereby affecting the accurate judgment of the distribution of pixel points at the edge of the titanium wire, resulting in errors in the edge detection results, and further affecting the accuracy of the uniformity detection of the coiled titanium wire. Summary of the invention
[0005] In order to solve the problem that edge detection using a fixed gradient threshold is easily affected by light, resulting in inaccurate edge detection results, and the uniformity detection results of coiled titanium wire are less accurate, the present invention proposes a titanium wire uniformity detection method and device based on image recognition. The specific scheme is as follows:
[0006] In one aspect, the present invention provides a titanium wire uniformity detection method based on image recognition, comprising:
[0007] Collect an image to be detected of the coiled titanium wire, preset a standard edge detection threshold, and calculate an initial edge detection threshold of the pixel point according to the standard edge detection threshold and the relative deviation between the grayscale value and the grayscale mean of the pixel point of the image to be detected, wherein the initial edge detection threshold is negatively correlated with the relative deviation;
[0008] Performing initial edge detection based on the initial edge detection threshold to obtain multiple edge connected domains, and calculating the connectivity between any two edge connected domains according to the curvature difference and overlap degree of the two domains, wherein the connectivity is negatively correlated with the curvature difference and positively correlated with the overlap degree, and the overlap degree is the ratio of the number of overlapping pixels between the two domains to the total number of pixels between the two domains;
[0009] The initial edge detection threshold of the overlapping pixels is adjusted using the connectivity degree, the adjusted edge detection threshold is negatively correlated with the connectivity degree, edge detection is performed again after adjustment, and whether the coiled titanium wire is uniform is determined based on the edge detection result.
[0010] The beneficial effect is that the present invention performs edge detection by adaptively setting the edge detection threshold of each pixel point, and adjusts the initial edge detection threshold of the overlapping pixels of each two edge connected domains according to the connectivity of the two edge connected domains in the edge detection result, and re-performs edge detection. The obtained edge detection result effectively overcomes the limitations of the fixed threshold method under complex lighting conditions, reduces the omission of edge information, improves the accuracy of edge detection, makes the detection result more comprehensive and reliable, and can more accurately reflect the uniformity state of titanium wire winding through precise uniformity detection.
[0011] Preferably, the adjusted edge detection threshold satisfies the following relationship:
[0012] ,in, and are the serial numbers of the edge connected domains, is the sequence number of overlapping pixels, For the The edge connected domain and The edge connected domain The initial edge detection threshold of overlapping pixels, For the The edge connected domain and The edge connected domain The edge detection threshold after the overlapped pixels are adjusted. For the The edge connected domain and The connectivity degree of the edge connected domain.
[0013] The beneficial effect is that this adjustment strategy dynamically optimizes the detection threshold of pixel points according to the degree of connectivity between edge connected domains, thereby improving the adaptability and accuracy of edge detection, thereby significantly enhancing the ability to distinguish and recognize subtle structures in complex image analysis.
[0014] Preferably, the degree of connectivity satisfies the following relationship:
[0015] ,in, and are the serial numbers of the edge connected domains, For the The edge connected domain and The connectivity degree of the edge connected domain, For the The mean curvature of all pixels in the edge connected domain, For the The mean curvature of all pixels in the edge connected domain, For the The edge connected domain and The degree of overlap of the edge connected domains, is a linear normalization function.
[0016] The beneficial effect is that the similarity of the curvature mean of the edge connected domains and the overlap degree of the edge connected domains are comprehensively considered to quantify the connectivity between the connected domains, thereby effectively improving the accuracy of image edge recognition.
[0017] Preferably, judging whether the coiled titanium wire is uniform according to the final edge detection result includes:
[0018] The slope chain codes of all edge connected domains are aligned in length, and the mean of the slope chain codes of all edge connected domains is calculated, and the difference method is used to obtain the difference between the slope chain code of each edge connected domain and the mean of the slope chain code; if the difference is less than or equal to a preset difference threshold, the edge connected domain is used as the target edge connected domain, otherwise, it is not used as the target edge connected domain; the ratio of the number of the target edge connected domain to the number of all edge connected domains is used as the uniformity of the titanium wire; a uniformity threshold is preset, and if the uniformity of the coiled titanium wire is greater than the uniformity threshold, the coiled titanium wire is evenly distributed; otherwise, the coiled titanium wire is unevenly distributed.
[0019] Preferably, the edge detection further comprises: calculating an evaluation index of the edge detection according to the cumulative value of the connectivity degree of all any two edge connected domains and the quantitative difference between the number of the edge connected domains and the theoretical number, wherein the evaluation index is negatively correlated with the cumulative value and the quantitative difference; obtaining the evaluation index of the initial edge detection and evaluation index for re-edge detection ,like , the edge detection threshold after adjustment of the overlapping pixels is used as the final edge detection threshold of the overlapping pixels, otherwise, the edge detection threshold before adjustment of the overlapping pixels is used as the final edge detection threshold of the overlapping pixels; edge detection is performed based on the final edge detection threshold of the overlapping pixels.
[0020] The beneficial effects are: constructing an evaluation index for edge detection structure, using the index to guide the edge detection optimization process, fine-tuning the edge detection threshold of overlapping pixels, enhancing the adaptability of edge detection and the distinction of image details, and improving the overall analysis quality.
[0021] Preferably, the evaluation index of the edge detection satisfies the following relationship:
[0022]
[0023] In the formula, is the evaluation index of the edge detection, and are the serial numbers of the edge connected domains, is the total number of edge connected domains, is the theoretical number of edge connected domains, For the The edge connected domain and The connectivity degree of the edge connected domain, is the normalization function.
[0024] The beneficial effect is that this evaluation index effectively reflects the integrity of edge detection and improves the reliability of the results by comprehensively considering the deviation between the degree of connectivity between edge connected domains actually detected and theoretical expectations.
[0025] Preferably, the initial edge detection threshold of the pixel point ,in, is the pixel number, For the The initial edge detection threshold of pixels, is the standard edge detection threshold used for edge detection of the image to be detected, For the The relative deviation between the grayscale value of each pixel and the grayscale mean of the image to be detected.
[0026] Preferably, the method for presetting the standard edge detection threshold is: obtaining a gradient map of the image to be detected, obtaining a gradient threshold using the Otsu threshold method, and using the gradient threshold as a standard edge detection threshold for edge detection of the image to be detected.
[0027] On the other hand, the present invention also provides a titanium wire uniformity detection device based on image recognition, comprising: a processor and a memory, the processor and the memory are coupled, the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the titanium wire uniformity detection device performs any step of the titanium wire uniformity detection method.
[0028] The present invention has the following effects:
[0029] The present invention effectively overcomes the limitations of the method of edge detection based on a fixed gradient threshold under complex lighting conditions, reduces the omission of edge information, and improves the accuracy of edge detection, making the edge detection result more accurate, comprehensive and reliable, thereby improving the accuracy of uniformity identification of the coiled titanium wire, which is conducive to early problem discovery, guiding process adjustments, and ensuring the quality of the coiled titanium wire. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0031] Figure 1 It is a schematic flow chart of the method of the present invention;
[0032] Figure 2 FIG. 4 is a flow chart of edge detection according to another embodiment of the present invention. DETAILED DESCRIPTION
[0033] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0034] The specific implementation of the present invention is described in detail below with reference to the accompanying drawings. Figure 1 , a titanium wire uniformity detection method based on image recognition includes steps S1-S4, which are as follows:
[0035] S1: Collect the image of the coiled titanium wire to be inspected.
[0036] The first step in detecting the uniformity of titanium wire is to accurately capture the image of the coiled state of the titanium wire through a high-resolution industrial camera. The industrial camera has a high dynamic range, high sensitivity and fast response capability, which can ensure that clear and detailed images can be captured under different lighting conditions. The coiled titanium wire is similar to a titanium wire wound around the outer diameter surface of a roller. This embodiment is equivalent to the camera facing the outer diameter surface of the roller to collect the outer circle surface image of the coiled titanium wire.
[0037] In order to facilitate the subsequent analysis of the collected images, this step preprocesses them. The specific preprocessing method includes graying. The surface image of the outer circle of the coiled titanium wire is grayed, and the color information of each pixel is converted into a single gray value to obtain a grayscale image. The grayscale image is used as the image to be detected of the coiled titanium wire, which provides a basis for subsequent detection and analysis.
[0038] S2: Preset a standard edge detection threshold, and calculate an initial edge detection threshold for the pixel according to the standard edge detection threshold and a relative deviation between the grayscale value and the grayscale mean of the pixel of the image to be detected.
[0039] In the process of image detection, especially when processing titanium wire images in industrial scenarios, uneven lighting conditions are a common challenge. The existence of reflective areas and shadow areas generated by lighting causes the grayscale values of certain areas in the image to be abnormally high or low, respectively. Regardless of whether the grayscale is abnormally high or low, it will directly affect the performance of the edge detection algorithm, especially the gradient-based edge detection method such as Canny edge detection. If the edge detection method based on gradient threshold is used for edge detection, the grayscale is oversaturated in the reflective area, and the lighting may cause the original subtle edge details to be "flattened", which is manifested as a weakened or even disappeared gradient. As a result, the edges of these areas may become blurred or even invisible in the edge detection results. On the contrary, in the shadow area, insufficient light causes the grayscale value to be generally low, and the originally clear edge becomes difficult to identify due to the reduced gradient, which also leads to a decrease in the accuracy of edge detection, which is manifested as broken or missing edges, and discontinuous edge connected domains are produced in the edge detection results.
[0040] Therefore, in order to ensure the integrity and accuracy of edge detection, reduce the negative impact of uneven lighting, and thus improve the robustness of edge detection in complex lighting environments, this step proposes an adaptive threshold strategy. Based on the standard edge detection threshold of the image to be detected, an initial edge detection threshold is set for each pixel, which improves the ability to recognize the edges of the image to be detected under the influence of lighting.
[0041] The preset standard edge detection threshold refers to setting the standard edge detection threshold for edge detection of the image to be detected, specifically including:
[0042] By obtaining the gradient image of the image to be detected to capture the drastic degree of grayscale changes in the image, the Otsu algorithm is used to analyze the gradient image and automatically find the optimal threshold as the standard edge detection threshold for edge detection of the image to be detected. The advantage of the Otsu algorithm is that it can effectively adapt to the gradient distribution under different lighting conditions.
[0043] According to the standard edge detection threshold and the relative deviation between the grayscale value and the grayscale mean of the pixel of the image to be detected, the initial edge detection threshold of the pixel is calculated, and the calculation formula is:
[0044]
[0045] In the formula, is the pixel number, For the The initial edge detection threshold of pixels, is the standard edge detection threshold used for edge detection of the image to be detected, For the The relative deviation between the gray value of the pixel point and the gray mean of the image to be detected is equal to , For the The gray value of a pixel, is the grayscale mean of the image to be detected, is a linear normalization function to ensure that the calculation result falls within a reasonable range. is the standard edge detection threshold used for edge detection of the image to be detected.
[0046] Through the operation of this step, edge detection is further refined, and an initial edge detection threshold is customized for each pixel point to realize the process of adaptive initial edge detection threshold. The initial edge detection threshold for edge detection of each pixel point is dynamically adjusted. In order to adapt to the changes in lighting conditions in different areas of the image to be detected, whether it is a high grayscale value area or a low grayscale value area generated by lighting, the deviation from the overall grayscale mean of the image to be detected is large. Therefore, when the grayscale value of a pixel point deviates greatly from the overall grayscale mean of the image to be detected, the edge detection threshold of the pixel point is lowered to improve the detection sensitivity of edge detection of the pixel point under lighting conditions, thereby effectively reducing the omission of edge information.
[0047] When the relative deviation between the grayscale of a pixel and the average grayscale of the whole image is larger, it means that the pixel may be caused by the illumination (too dark or too bright) area. Then, by reducing the edge detection threshold of the pixel, the sensitivity of these pixels to edge detection can be increased, and the loss of edge information caused by uneven illumination can be reduced. It can be seen that the initial edge detection threshold is negatively correlated with the relative deviation, and for the relative deviation between the grayscale value and the grayscale mean of all pixels, this step performs linear normalization processing on it, and converts the relative deviation between the grayscale value and the grayscale mean of each pixel into a value between 0 and 1, ensuring that the initial edge detection threshold of the pixel fluctuates within a reasonable range, and realizing the dynamic setting of the initial edge detection threshold of the pixel, which will not lead to an increase in noise in the image, but also reduces the missed detection of edges to a certain extent, effectively solving the problem of edge detection under uneven illumination conditions, and improving the accuracy and robustness of detection.
[0048] S3: Performing initial edge detection based on the initial edge detection threshold to obtain multiple edge connected domains, and calculating the connectivity between any two edge connected domains according to the curvature difference and overlap degree between the two.
[0049] Among them, edge detection is to use the initial edge detection threshold of each pixel point calculated by S2 to perform edge detection on the image to be detected. At this time, edge detection no longer uses a single fixed threshold to determine the edge, but is based on the initial edge detection threshold of each pixel point for edge detection. Even in areas with complex and changeable lighting conditions in the image to be detected, the edge information can be accurately captured to obtain multiple edge connected domains in the image to be detected. Since each titanium wire has two long edges, each titanium wire will generate two edge connected domains in the edge detection result in the image to be detected.
[0050] The initial edge detection is based on the edge detection threshold edge detection of each pixel, and the edge detection result is obtained. However, this method does not fully consider all complex situations. For some areas with higher or lower grayscale due to lighting, especially in those areas where the gradient of the titanium wire edge is significantly reduced due to lighting conditions, in these areas, even if the grayscale value of the pixel point does not deviate much from the grayscale mean of the entire image, the gradient attenuation of the pixel point may be far beyond expectations (the gradient change of the pixel point is more drastic than the grayscale change), resulting in the edge detection results obtained according to the S2-S3 method (by analyzing the grayscale change). There may still be incomplete situations, and the edge detection results need to be further optimized.
[0051] This step takes into account the natural characteristics of the titanium wire edge, that is, the titanium wire edge is usually displayed as a continuous line segment with similar curvature in morphology in the image. The edge detection result can be optimized by analyzing the curvature similarity and spatial connectivity of the edge connected domain. If the curvature of the edge connected domain shows a high degree of similarity as a whole, it means that they may belong to different parts of the same real titanium wire edge. However, the curvature similarity alone is not enough to accurately judge the actual spatial connectivity of these edge connected domains. Therefore, the position distribution of each edge connected domain is characterized by the curve fitting method, and the overlapping pixel points are obtained by curve fitting. The degree of overlap of the edge connected domain is calculated, and their connectivity is verified from the perspective of spatial position.
[0052] Among them, the degree of connectivity between any two edge connected domains is calculated based on the curvature difference and overlap between them, including:
[0053] (1) Obtaining overlapping pixel points: Since the edge of the titanium wire has the characteristics of being higher at both ends and lower in the middle, a quadratic function model is used to approximate these edges in order to perform curve fitting more accurately, thereby jointly evaluating the connectivity of the edge connected domain in terms of position and shape. Therefore, a coordinate system is constructed with the horizontal direction of the image to be detected as the horizontal axis and the vertical direction as the vertical axis to obtain the coordinate position of each pixel point in each edge connected domain. The coordinate positions of all pixel points in each edge connected domain are fitted using the least squares method to obtain the fitting curve of each edge connected domain, and the overlapping pixel points on the fitting curve are taken as the overlapping pixel points of the two edge connected domains.
[0054] (2) Calculate the degree of overlap: The degree of overlap is equal to the ratio of the number of overlapping pixels in the two edge connected domains to the total number of pixels in the two edge connected domains.
[0055] (3) Obtain the curvatures of the pixels of the two edge connected domains and the mean curvature of the pixels of each edge connected domain. The mean curvature can reflect the morphological characteristics of the edge connected domain.
[0056] (4) Calculating the degree of connectivity, wherein the degree of connectivity is negatively correlated with the curvature difference and positively correlated with the degree of overlap.
[0057] Specifically, if the number of overlapping pixel points on the fitting curves of two edge connected domains is greater, the degree of overlap of the two edge connected domains is higher and their positions are more similar; if the overall curvatures of the two edge connected domains are more similar, their shapes are more similar and they are more likely to belong to the edges of the same turn of actual titanium wire. Therefore, in this step, two edge connected domains are selected each time, and the degree of overlap and overall curvature of the two are analyzed to obtain the connectivity of the two. The higher the connectivity, the more likely it is that the two are to belong to the edges of the same turn of actual titanium wire.
[0058] Therefore, the connectivity of these two edge connected domains is calculated according to the following formula:
[0059]
[0060] In the formula, and are the serial numbers of the edge connected domains, For the The edge connected domain and The connectivity degree of the edge connected domain, For the The mean curvature of all pixels in the edge connected domain, For the The mean curvature of all pixels in the edge connected domain, For the The edge connected domain and The degree of overlap of the edge connected domains, is the linear normalization function, Indicates the initial edge detection result of the image to be detected. The edge connected domain and The overall curvature difference of the edge connected domains, Indicates the initial edge detection result of the image to be detected. The edge connected domain and The overall curvature similarity of the edge connected domains is The edge connected domain and The higher the overall curvature similarity of the edge connected domains, the more similar the shapes of the two edge connected domains are, and the higher the degree of connectivity. For the The edge connected domain and The higher the overlap, the more similar the positions of the two edge connected domains are, and the higher the degree of connectivity is.
[0061] To summarize, this step selects any two edge connected domains in the edge detection results. The selection can be performed multiple times, and two edge connected domains are selected each time. The connectivity of the two selected edge connected domains is calculated according to the method of this step, and the connectivity of all any two edge connected domains in the edge detection results can be obtained.
[0062] S4: adjusting the initial edge detection threshold of the overlapping pixels using the connectivity degree, re-performing edge detection after the adjustment, and determining whether the coiled titanium wire is uniform according to the edge detection result.
[0063] This step specifically includes the following operations:
[0064] (1) The initial edge detection threshold of overlapping pixels is adjusted according to the following relationship to obtain the adjusted edge detection threshold:
[0065]
[0066] In the formula, and are the serial numbers of the edge connected domains, is the sequence number of overlapping pixels, For the The edge connected domain and The edge connected domain The initial edge detection threshold of overlapping pixels, For the The edge connected domain and The edge connected domain Overlapping pixels ( The edge detection threshold after adjusting the number of overlapping pixels is For the The edge connected domain and The connectivity degree of the edge connected domain.
[0067] When the titanium wire image The edge connected domain and When the degree of connectivity of the two edge connected domains is high, the two edge connected domains are more likely to be two disconnected edge connected domains formed by missed detection of the same real edge. The fitting curve obtained by curve fitting of the two edge connected domains is equivalent to restoring a completed edge connected domain formed by the two disconnected edge connected domains. The overlapping pixels on the fitting curves of the two edge connected domains are the missed parts in the edge detection process. Therefore, the initial edge detection threshold of the overlapping pixels is adjusted. The edge detection threshold of the overlapping pixels in the fitting curves of the two connected domains is negatively correlated with the degree of connectivity of the two connected domains. When the formula The larger it is, the more likely it is that the two connected domains belong to the same real edge. Therefore, the gradient threshold corresponding to the overlapping pixels of the two edge connected domains is reduced, making them more sensitive to edge detection and easier to identify, reducing missed detections in edge detection and increasing the accuracy of edge detection.
[0068] Here, the initial edge detection threshold of overlapping pixels is adjusted to obtain the adjusted edge detection threshold of all overlapping pixels. The significance lies in that by increasing or decreasing the edge detection sensitivity of overlapping pixels, that is, the edge detection sensitivity of overlapping pixels in two connected domains, the edge information that may be missed due to illumination or image quality can be more accurately captured. Moreover, for any two edge connected domains, the initial edge detection threshold of their overlapping pixels can be adjusted according to their connectivity, thereby adjusting the initial edge detection threshold of all overlapping pixels in the initial edge detection result.
[0069] (2) Re-perform edge detection: Edge detection can be performed only on the overlapping pixels with the adjusted edge detection threshold to see whether they are still overlapping after the threshold is adjusted. Edge detection can also be performed on all pixels. The edge detection result obtained is consistent with the result of edge detection only on the overlapping pixels. The reason is that the initial edge detection threshold of pixels other than the overlapping pixels is not adjusted. If edge detection is performed on them, the result obtained is consistent with the initial edge detection. Therefore, in this step, edge detection can be performed only on the overlapping pixels or on all pixels. The results of the two methods are the same.
[0070] (3) Judging whether the coiled titanium wire is uniform based on the edge detection result is as follows:
[0071] Firstly, the slope chain codes of all edge connected domains were aligned to a uniform length to eliminate the analysis bias caused by the different sizes of connected domains. This preprocessing step ensured the fairness and consistency of the subsequent analysis. Then, the mean of all aligned slope chain codes was calculated. This mean was used as a global reference indicator to reflect the average tendency of the overall titanium wire arrangement.
[0072] Then, the difference method is used to quantify the difference between the slope chain code of each individual edge connected domain and the overall mean. The advantage of the difference method is that it can intuitively reveal the degree of deviation between individual characteristics and the overall pattern, so as to evaluate the consistency of the arrangement direction of the titanium wires on both sides of each edge connected domain. If the difference between the slope chain code of a connected domain and the mean exceeds the preset difference threshold, the difference threshold is set to 0.5 in this embodiment. It is believed that when the difference exceeds 0.5, it indicates that the arrangement direction of the titanium wires on both sides of the edge connected domain is significantly different from the overall trend, that is, the arrangement direction is not similar; otherwise, it is believed that the arrangement of the titanium wires on both sides of the edge connected domain is highly consistent with the overall trend, and the edge connected domain is regarded as the target edge connected domain. This screening process is essentially a preliminary screening of uniformity, aiming to identify those edge connected domains that are most consistent with the overall arrangement pattern.
[0073] Next, by calculating the ratio of the number of target edge-connected domains to the total number of all edge-connected domains, a quantitative indicator that directly reflects the uniformity of the titanium wire was obtained, namely the uniformity of the coiled titanium wire. The greater the uniformity, the more edge-connected domains show an arrangement pattern consistent with the whole, thus inferring that the uniformity of the coiled titanium wire is better.
[0074] Finally, the uniformity index obtained above is compared with the pre-set uniformity threshold to determine whether the titanium wire is evenly distributed. The uniformity threshold in this embodiment is 0.8. When the calculated uniformity is greater than or equal to this threshold, it can be concluded that the coiled titanium wire is evenly distributed as a whole, which means that the production process has reached the expected high standards; on the contrary, if the uniformity index fails to reach this threshold, it is considered that there is uneven arrangement of the titanium wire, indicating that the production process or detection parameters need to be adjusted and optimized to ensure the stability of product quality.
[0075] In another embodiment, in order to ensure the accuracy of edge detection, the present invention also establishes a comprehensive evaluation system, which can be applied to the edge detection process of S4. The system is not only based on the degree of connectivity between edge connected domains, but also fully considers the difference between the total number of detected edge connected domains and the total number of actual titanium wire edges in the original image. The difference between the two reflects the degree of matching between the detection result and the actual degree, thereby imposing reasonable constraints on the connectivity of the connected domain to prevent misjudgment caused by excessive segmentation or unnecessary connection. Through this series of considerations and optimization measures, the performance evaluation standard of the edge detection algorithm can be effectively improved to ensure that the detection result not only accurately reflects the actual situation of the titanium wire edge, but also maintains consistency with the real scene in structure. Specifically including:
[0076] (1) According to the cumulative value of the connectivity degree of all two arbitrary edge connected domains and the difference between the number of edge connected domains and the theoretical number, the evaluation index of the edge detection is calculated. The calculation formula is:
[0077]
[0078] In the formula, is the evaluation index of the edge detection, and are the serial numbers of the edge connected domains, is the total number of edge connected domains in the edge detection results, is the theoretical number of edge-connected domains. The theoretical number of edge-connected domains is based on the specific structure of the coiled titanium wire. Theoretically, the total number of turns of the outer circle of the coiled titanium wire is N. In the collected surface image, each turn of the titanium wire should form two edges. Therefore, the total number of edge-connected domains should be N+1 in theory, that is, , For the The edge connected domain and The connectivity degree of the edge connected domain, is the normalization function.
[0079] In this formula, It reflects the degree of difference in the number of connected domains of the titanium wire edges in the edge detection results and the actual titanium wire edges. When the number of connected domains in the edge detection results is less than the number of actual titanium wire edges, it means that some edges are not detected. When the number of connected domains in the edge detection results is greater than the number of actual titanium wire edges, it means that some edges are detected as disconnected edges, and the disconnected parts are exactly the undetected parts. Therefore, the greater the degree of difference in quantity, the more cases of missed edge detection or incorrect segmentation in the edge detection results, the unsatisfactory edge detection results, and the lower the evaluation index. Conversely, the smaller the difference in quantity, the more consistent the edge detection results are with the theoretical number of turns, and the better the edge detection effect. It can be seen that the degree of difference in quantity and the evaluation index are negatively correlated.
[0080] The numerator of this formula reflects the matching degree between the number of edge connected domains in the edge detection result and the number of real edges. The higher the matching degree, the fewer missed edge lines in the edge detection result and the more ideal the edge detection result. In other words, the matching degree is positively correlated with the evaluation index.
[0081] The denominator of this formula represents the cumulative value of the connectivity of any two edge connected domains in the edge detection results. The larger the cumulative value, the higher the connectivity of the connected domains in the edge detection results. For example, the same complete connected domain is detected as two disconnected edge connected domains in the edge detection results. The more such cases occur, the less ideal the edge detection result is. Conversely, the better the edge detection effect is, that is, the evaluation index and the cumulative value are negatively correlated.
[0082] In summary, when the evaluation index is higher, it indicates that the number of connected domains in the edge detection result is not only consistent with the actual number of turns in theory, but also the connected domains are complete. The normal displayed result (the accumulated value of the degree of connectivity is small) reflects less edge omissions or incorrect segmentation, and the edge detection result is closer to the ideal state. Otherwise, the edge detection result has a large error.
[0083] (2) The evaluation index is used to guide the adjustment process of the initial edge detection threshold of overlapping pixels to obtain more accurate edge detection results.
[0084] In this step, the uniformity of the coiled titanium wire was thoroughly tested and evaluated through an iterative and optimized process to ensure the accuracy and reliability of the test results, such as Figure 2 As shown in, specifically:
[0085] S41: Obtaining evaluation indicators for initial edge detection ;
[0086] S42: Obtain overlapping pixel points of every two edge-connected domains, and obtain an initial edge detection threshold for each overlapping pixel point;
[0087] S43: Using the connectivity degree of the two edge connected domains, the initial edge detection thresholds of all overlapping pixels are adjusted.
[0088] S44: performing edge detection again according to the adjusted detection threshold;
[0089] S45: Recalculate the edge detection evaluation index based on the edge detection results 1;
[0090] S46: If , indicating that the adjustment in S43 is reasonable, and the edge detection effect is improved after the adjustment. Therefore, the edge detection threshold after the adjustment of each overlapping pixel point is used as the final edge detection threshold of the overlapping pixel point; on the contrary, if , indicating that the adjustment in S43 is unreasonable, and the edge detection effect is reduced after the adjustment. Therefore, the edge detection threshold (initial edge detection threshold) before adjustment of each overlapping pixel point is used as the final edge detection threshold of the overlapping pixel point. At this point, the adjustment of the two edge connected domains in step S42 is completed;
[0091] S47: In the edge detection result of S45, continue to select another two edge connected domains, repeat steps S42 to S46, and adjust the initial edge detection threshold of the overlapping pixels of the two edge connected domains selected each time, until the initial edge detection threshold of the overlapping pixels of all edge connected domains is adjusted, and the final edge detection threshold of all overlapping pixels is obtained;
[0092] S48: Obtaining a final edge detection result based on a final edge detection threshold of overlapping pixels of all edge connected domains, that is, performing edge detection according to the final edge detection threshold of all overlapping pixels to obtain a final edge detection result, that is, a more accurate edge detection result.
[0093] The present invention also provides a titanium wire uniformity detection device based on image recognition. The present invention also provides a titanium wire uniformity detection device based on image recognition, comprising: a processor and a memory, the processor and the memory are coupled, the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the titanium wire uniformity detection device executes any step of the titanium wire uniformity detection method to perform uniformity detection on the coiled titanium wire to ensure the quality of the coiled titanium wire.
[0094] In the description of this specification, "plurality" or "several" means at least two, such as two, three or more, etc., unless otherwise clearly and specifically defined.
[0095] Although this specification has shown and described a number of embodiments of the present invention, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art will conceive of many modifications, changes and alternatives without departing from the ideas and spirit of the present invention. It should be understood that in the practice of the present invention, various alternatives to the embodiments of the present invention described herein may be employed.
Claims
1. A titanium wire uniformity detection method based on image recognition, characterized in that: include: Collect an image to be detected of the coiled titanium wire, preset a standard edge detection threshold, and calculate an initial edge detection threshold of the pixel point according to the standard edge detection threshold and the relative deviation between the grayscale value and the grayscale mean of the pixel point of the image to be detected, wherein the initial edge detection threshold is negatively correlated with the relative deviation; Performing initial edge detection based on the initial edge detection threshold to obtain multiple edge connected domains, and calculating the connectivity between any two edge connected domains according to the curvature difference and overlap degree of the two domains, wherein the connectivity is negatively correlated with the curvature difference and positively correlated with the overlap degree, and the overlap degree is the ratio of the number of overlapping pixels between the two domains to the total number of pixels between the two domains; The initial edge detection threshold of the overlapping pixel points is adjusted using the connectivity degree, and the adjusted edge detection threshold is negatively correlated with the connectivity degree. After the adjustment, edge detection is performed again, and whether the coiled titanium wire is uniform is judged according to the edge detection result, including: aligning the lengths of the slope chain codes of all edge connected domains, and calculating the mean of the slope chain codes of all edge connected domains, and using the difference method to obtain the difference between the slope chain code of each edge connected domain and the mean of the slope chain code; if the difference is less than or equal to a preset difference threshold, the edge connected domain is used as the target edge connected domain, otherwise, it is not used as the target edge connected domain; the ratio of the number of the target edge connected domain to all edge connected domains is used as the uniformity of the titanium wire; a uniformity threshold is preset, and if the uniformity of the coiled titanium wire is greater than the uniformity threshold, the coiled titanium wire is evenly distributed; otherwise, the coiled titanium wire is unevenly distributed; The edge detection further includes: calculating the evaluation index of the edge detection according to the cumulative value of the connectivity degree of all two arbitrary edge connected domains and the quantitative difference between the number of the edge connected domains and the theoretical number, wherein the evaluation index is negatively correlated with the cumulative value and the quantitative difference; obtaining the evaluation index of the initial edge detection and evaluation index for re-edge detection ,like , using the edge detection threshold after the adjustment of the overlapping pixels as the final edge detection threshold of the overlapping pixels, otherwise, using the edge detection threshold before the adjustment of the overlapping pixels as the final edge detection threshold of the overlapping pixels; performing edge detection based on the final edge detection threshold of the overlapping pixels; The evaluation index of the edge detection satisfies the following relationship: ; In the formula, is the evaluation index of the edge detection, and are the serial numbers of the edge connected domains, is the total number of edge connected domains, is the theoretical number of edge connected domains, For the The edge connected domain and The connectivity degree of the edge connected domain, is the normalization function; The adjusted edge detection threshold satisfies the following relationship: ,in, and are the serial numbers of the edge connected domains, is the sequence number of overlapping pixels, For the The edge connected domain and The edge connected domain The initial edge detection threshold for overlapping pixels, For the The edge connected domain and The edge connected domain The edge detection threshold after the overlapped pixels are adjusted. For the The edge connected domain and The degree of connectivity of the edge connected domains; The degree of connectivity satisfies the following relationship: ,in, and are the serial numbers of the edge connected domains, For the The edge connected domain and The connectivity degree of the edge connected domain, For the The mean curvature of all pixels in the edge connected domain, For the The mean curvature of all pixels in the edge connected domain, For the The edge connected domain and The degree of overlap of the edge connected domains, is a linear normalization function; The initial edge detection threshold of the pixel ,in, is the pixel number, For the The initial edge detection threshold of pixels, is the standard edge detection threshold used for edge detection of the image to be detected, For the The relative deviation between the grayscale value of each pixel and the grayscale mean of the image to be detected.
2. The titanium wire uniformity detection method based on image recognition according to claim 1 is characterized in that: The method for presetting the standard edge detection threshold is: A gradient map of the image to be detected is obtained, a gradient threshold is obtained using the Otsu threshold method, and the gradient threshold is used as a standard edge detection threshold for edge detection of the image to be detected.
3. Titanium wire uniformity detection device based on image recognition, characterized in that: include: A processor and a memory, wherein the processor and the memory are coupled, and the memory stores program instructions. When the program instructions stored in the memory are executed by the processor, the titanium wire uniformity detection device executes the method according to any one of claims 1 to 2.
