A method for detecting microstructure defects in alloy metal materials
By constructing a topological network and pathfinding algorithm for alloy metal materials, a deviation index is generated, which solves the misjudgment problem in the detection of microstructure defects in alloy metal materials and improves the detection accuracy.
Patent Information
- Application Number
- CN202611618944.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-20
- Publication Date
- 2026-11-17
AI Technical Summary
Existing technologies have poor performance in detecting microstructure defects in alloy metal materials, especially when distinguishing between mechanical scratches and microcracks, which are prone to misjudgment.
By acquiring the target image, the topological network composed of metal grain boundaries is extracted, segmented into multiple line segments to be detected, and a global feature matrix and a local cost matrix are constructed. Using a pathfinding algorithm and a mutual exclusion allocation mechanism, the deviation index is calculated to determine whether the line segment is a defect.
It effectively reduces the false alarm rate of metallographic micro-defect detection, improves the detection effect of micro-metallographic defects in alloy metal materials, and distinguishes between normal grain boundaries and real defects.
Smart Images

Figure CN123118637A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial testing technology, specifically to a method for detecting microscopic metallographic defects in alloy metal materials. Background Technology
[0002] In the conventional microstructure detection process of alloy metal materials, the sample surface needs to undergo pretreatment processes such as mechanical polishing and chemical etching. After etching, the normal metal grain boundaries will preferentially dissolve, forming low grayscale micro-grooves with a grid distribution on the bright-field two-dimensional digital image. At the same time, the mechanical scratches left by the hard particles on the surface of the polishing consumable dragging the sample surface in one direction, as well as the inherent microcracks caused by the release of internal stress in the material, will also appear as linear low grayscale features with similar grayscale ranges in the image. The high degree of overlap of linear features of different causes at the visual level makes it difficult for traditional visual detection algorithms that rely on local single-point grayscale threshold segmentation or contour edge extraction to accurately identify the true root cause of line segment defects, ultimately resulting in a long-term high false alarm rate for defect detection in industrial fields.
[0003] In the field of linear defect identification, existing engineering processing solutions generally distinguish between straight mechanical scratches and curved microcracks or grain boundary meshes by detecting the geometric straightness of line segments. However, this method has obvious blind spots. In actual alloy metallographic images, some naturally formed grain boundaries, such as twin boundaries, inherently possess straight geometric morphology. If geometric straightness is used as a prerequisite for defect screening, the detection system is highly likely to misidentify a large number of straight twin boundaries that belong to normal metallographic structures as mechanical scratches, leading to misjudgments.
[0004] In other words, the existing technology has poor performance in detecting microstructure defects in alloy metal materials. Summary of the Invention
[0005] The purpose of this invention is to provide a method for detecting microstructure defects in alloy metal materials, which solves the technical problem that the detection effect of microstructure defects in alloy metal materials is poor in the prior art.
[0006] In a first aspect, one embodiment of the present invention provides a method for detecting microstructure defects in alloy metal materials, the method comprising: The target image is acquired, and a topological network composed of metal grain boundaries is extracted from the target image. The topological network is then segmented into multiple line segments to be detected based on the connection nodes in the topological network. The target image is a bright-field metallographic digital image of an alloy metal material. The nodes in the topological network represent grain boundary junctions, and the edges represent grain boundary line segments connecting the grain boundary junctions. For each line segment to be detected, a first node set and a second node set corresponding to the line segment to be detected are determined; wherein, the first node set is used to characterize the set of sampling points distributed along the extension direction of the line segment to be detected; and the second node set is used to characterize the set of grain boundary intersection points adjacent to the line segment to be detected in the topological network. A global feature matrix is constructed based on the target image, and a local cost matrix corresponding to each line segment to be detected is generated based on the global feature matrix. The global feature matrix is used to characterize the pathfinding resistance distribution of pixels at each location in the target image, and the local cost matrix is used to detect the local resistance environment of the bypass path after the line segment to be detected blocks its own connecting channel. Based on the local cost matrix, the path cost between the first node set and the second node set is determined by a pathfinding algorithm to generate a target cost matrix. The target cost matrix is then mutually exclusively assigned to obtain an assigned cost set. The target cost matrix is used to characterize the cumulative path cost required to connect each sampling point in the first node set to each grain boundary intersection point in the second node set. The assigned cost set is used to characterize the path cost combination corresponding to the matching relationship between the first node set and the second node set that minimizes the total path cost under the condition of satisfying one-to-one mutual exclusion constraints. The deviation index is calculated based on the assigned cost set, and the line segment to be detected is determined as a defect based on the deviation index. The deviation index is used to characterize the degree of abnormality of the line segment to be detected deviating from the inherent connectivity rules of the topological network.
[0007] In one embodiment, the step of determining the first node set and the second node set corresponding to each line segment to be detected includes: For each line segment to be detected, coordinate points are extracted at equal intervals along the geometric extension trajectory of the line segment to be detected, with a preset pixel distance constant, to form the first node set; Calculate the geometric centroid of the line segment to be detected, and sort the connecting nodes in the topology network in ascending order according to the Euclidean distance between each connecting node and the geometric centroid. Select a preset number of nodes to form a second node set.
[0008] In one embodiment, the step of constructing a global feature matrix based on the target image includes: A corresponding pixel value is generated based on the gray value of each pixel; whereby the pixel value is equal to the original gray value of the pixel, and the pixel value is used to characterize the magnitude of the passage resistance of the corresponding pixel in the pathfinding algorithm in the target image; The pixel values of all pixels are mapped to corresponding matrix elements based on the spatial location of each pixel in the target image to construct a global feature matrix.
[0009] In one embodiment, the step of generating a local cost matrix corresponding to each line segment to be detected based on the global feature matrix includes: Use the global feature matrix as the initial local cost matrix; The cost value of the pixel position corresponding to the line segment to be detected in the initial local cost matrix is replaced with the preset maximum cost value to obtain the local cost matrix corresponding to each line segment to be detected.
[0010] In one embodiment, the step of determining the path cost between the first node set and the second node set using a pathfinding algorithm based on the local cost matrix to generate the target cost matrix includes: Based on the local cost matrix, for each sampling point in the first node set, the cumulative path cost between the sampling point and each grain boundary junction in the second node set is calculated using a pathfinding algorithm; whereby the cumulative path cost is used to characterize the sum of the costs of the paths traversed from the sampling point to the grain boundary junction. Using the sampling point index in the first node set as the row index and the grain boundary intersection point index in the second node set as the column index, the calculated cumulative path cost is filled into the corresponding matrix element positions to construct the target cost matrix.
[0011] In one embodiment, the step of mutually exclusive allocation of the target cost matrix to obtain the assigned cost set includes: Based on the optimal matching operator, target matching schemes that satisfy the mutual exclusion condition are selected in the target cost matrix. The optimal matching operator is used to characterize the operation rule for solving the matching result that minimizes the total path cost in the target cost matrix. The target matching scheme is used to characterize the optimal assignment relationship in the target cost matrix that establishes a one-to-one mapping with absolute mutual exclusion between the sampling points in the first node set and the grain boundary intersection points in the second node set, and the sum of the costs of all mapped paths reaches the theoretical minimum. Based on the target matching scheme, the path cost value with the same number of sampling points as the first node set is extracted from the target cost matrix to form the assignment cost set.
[0012] In one embodiment, the step of calculating the deviation metric based on the assignment cost set includes: Calculate the sum of all path cost values in the assignment cost set to obtain the total assignment cost; Calculate the standard deviation of the cost value of all paths in the assigned cost set to obtain the cost statistical standard deviation. The deviation index is calculated based on the total assigned cost, the standard deviation of the cost statistics, and the total number of sampling points in the first node.
[0013] In one embodiment, the step of calculating the deviation index based on the total assignment cost, the standard deviation of the cost statistics, and the total number of sampled points in the first node includes: The smoothing standard deviation is obtained by summing the cost statistical standard deviation with the preset non-zero smoothing constant. Calculate the product of the total assignment cost and the smoothing standard deviation to obtain the discrete cost product; Calculate the square of the total number of sampling points in the first node set to obtain the squared value of the node size; The deviation index is obtained based on the ratio of the discrete product of cost to the square of the node size.
[0014] In one embodiment, the step of determining whether a line segment to be inspected is a defect based on a deviation index includes: The deviation index is compared with the preset deviation threshold; If the deviation index is greater than or equal to the preset deviation threshold, the line segment to be detected is determined to be a defective line segment. If the deviation index is less than the preset deviation threshold, the line segment to be detected is determined to be a normal line segment.
[0015] In one embodiment, after determining that the line segment to be detected is a defective line segment, the method further includes: The endpoint distance ratio is obtained by calculating the ratio of the straight-line distance between the endpoints of the defective line segment to the total number of connected pixels. If the ratio of endpoint distances is greater than or equal to the preset straight line discrimination threshold, the defective line segment is classified as a mechanical scratch. If the ratio of endpoint distances is less than the preset straight line discrimination threshold, the defect line segment is classified as a microcrack.
[0016] Secondly, another embodiment of the present invention provides a microstructure defect detection system for alloy metal materials, the system comprising: The acquisition module is used to acquire the target image, extract the topological network composed of metal grain boundaries from the target image, and segment the topological network into multiple line segments to be detected based on the connection nodes in the topological network; wherein, the target image is a bright-field metallographic digital image of the alloy metal material; the nodes in the topological network represent grain boundary junctions, and the edges represent grain boundary line segments connecting the grain boundary junctions; The determination module is used to determine the first node set and the second node set corresponding to each line segment to be detected; wherein, the first node set is used to characterize the set of sampling points distributed along the extension direction of the line segment to be detected; and the second node set is used to characterize the set of grain boundary intersection points adjacent to the line segment to be detected in the topological network. The construction module is used to construct a global feature matrix based on the target image, and generate a local cost matrix corresponding to each line segment to be detected based on the global feature matrix; wherein, the global feature matrix is used to characterize the pathfinding resistance distribution of pixels at each position in the target image; the local cost matrix is used to detect the local resistance environment of the bypass path after the line segment to be detected blocks its own connecting channel; The allocation module is used to determine the path cost between the first node set and the second node set based on the local cost matrix using a pathfinding algorithm, in order to generate a target cost matrix, and to perform mutually exclusive allocation on the target cost matrix to obtain an assigned cost set. The target cost matrix is used to characterize the cumulative path cost required to connect each sampling point in the first node set to each grain boundary intersection point in the second node set. The assigned cost set is used to characterize the path cost combination corresponding to the matching relationship between the first node set and the second node set that minimizes the sum of path costs under the condition of satisfying one-to-one mutual exclusion constraints. The judgment module is used to calculate the deviation index based on the assigned cost set, and to determine whether the line segment to be detected is a defect based on the deviation index; wherein, the deviation index is used to characterize the degree of abnormality of the line segment to be detected deviating from the inherent connectivity rules of the topological network.
[0017] Thirdly, in another embodiment of the present invention, an electronic device is provided, including a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the method described in the first aspect.
[0018] Fourthly, in another embodiment of the present invention, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the method described in the first aspect.
[0019] The present invention has the following beneficial effects: This invention acquires a bright-field metallographic digital image of an alloy metal material as the target image, extracts the topological network formed by the metal grain boundaries, and segments the topological network into multiple line segments to be detected based on the grain boundary intersections. For each line segment to be detected, a first node set composed of sampling points on the line segment and a second node set composed of adjacent grain boundary intersections are obtained. A global feature matrix representing the distribution of pixel pathfinding resistance is constructed, and a local cost matrix blocking the line segment's own connectivity is generated for each line segment to be detected. The path cost between nodes is solved using a pathfinding algorithm to obtain the target cost matrix, and then an assignment cost set is obtained through mutual exclusion allocation. The deviation of the line segment from its inherent connectivity is further calculated. The deviation index is used to determine whether the line segment to be detected is a real defect. This invention uses metallographic image grain boundary topology network analysis to first construct a global pathfinding resistance feature matrix, and then construct a dedicated local cost matrix for each line segment to be detected to block the low-cost connectivity channels of the line segment itself. Combined with pathfinding operation and a one-to-one mutual exclusion allocation mechanism, the topological misalignment characteristics of abnormal line segments are amplified. Based on the deviation index, the normal grain boundary artifacts conforming to the crystal lattice and real defects deviating from the original topology are distinguished. This can avoid the misjudgment problem caused by simply relying on grayscale threshold and geometric straightness, reduce the false alarm rate of metallographic micro-defect detection, and improve the detection effect of micro-metallographic defects in alloy metal materials. Attached Figure Description
[0020] Figure 1 This is a schematic flowchart of a method for detecting microstructure defects in alloy metal materials provided in an embodiment of the present invention. Detailed Implementation
[0021] The specific scheme of the method for detecting microstructure defects in alloy metal materials provided by the present invention will be described in detail below with reference to the accompanying drawings.
[0022] This invention proposes a method for detecting microstructure defects in alloy metal materials. Please refer to [link / reference]. Figure 1 The diagram illustrates a schematic flowchart of a method for detecting microstructure defects in alloy metal materials according to an embodiment of the present invention. The method includes the following steps: Step S1: Acquire the target image, extract the topological network composed of metal grain boundaries from the target image, and divide the topological network into multiple line segments to be detected based on the connection nodes in the topological network; wherein, the target image is a bright-field metallographic digital image of the alloy metal material; the nodes in the topological network represent grain boundary junctions, and the edges represent grain boundary line segments connecting the grain boundary junctions.
[0023] The target image refers to the bright-field metallographic digital image of the alloy metal material acquired by metallographic microscopy equipment. It is the original input image data for defect detection and processing, containing all microscopic morphological information such as grains, grain boundaries, scratches, and microcracks.
[0024] Topological networks refer to the process of adaptive binarization and morphological skeleton refinement of a target image to obtain a single-pixel-width grain boundary skeleton. This skeleton forms an interconnected and interwoven mesh, which is the metal grain boundary topological network. The dark groove-shaped grain boundaries in the network constitute the network's connected skeleton, restoring the connection relationship between the grains of the alloy material.
[0025] Multiple line segments to be detected are obtained by dividing the grain boundary topology network; the grain boundary junction point is the pixel coordinate of the skeleton network with a number of connected branches greater than or equal to 3. As the connection node of the topology network, the pixel erasure and truncation process is performed on the grain boundary junction point, so that the originally continuous connected topology mesh is broken, and multiple independent pixel sequences with disconnected beginning and end are obtained. These independent pixel sequences are the line segments to be detected.
[0026] It should be noted that, in the embodiments of the present invention, the microscopic grain boundary structure of the metallographic image is transformed into a standardized graph structure topology network. Independent line segments to be detected are separated by truncation at the grain boundary intersection points, thereby isolating normal grain boundaries from suspected defect lines. This provides an independent computational subject and a stable topological reference for subsequent differentiation of normal twin boundaries, grain boundaries, scratches, and microcracks, and avoids interference from interconnected lines in subsequent cost quantification calculations.
[0027] Step S2: For each line segment to be detected, determine the first node set and the second node set corresponding to the line segment to be detected; wherein, the first node set is used to characterize the set of sampling points distributed along the extension direction of the line segment to be detected; the second node set is used to characterize the set of grain boundary intersection points adjacent to the line segment to be detected in the topological network.
[0028] For example, the first node set is a set of sampling points inside the line segment, obtained by sequentially extracting coordinate sampling points at preset pixel intervals along the extension trajectory of the line segment to be detected, ensuring that the sampling points can represent the local features of different positions of the line segment; the total number of extracted sampling points is counted. If the total number of nodes is less than or equal to 1, it is determined that the size of the current line segment to be detected is too small, and the subsequent calculation process of the line segment is skipped directly; if the total number of nodes is greater than 1, the extracted coordinate sampling point group is constructed into the first node set. When the number of selectable adjacent grain boundary intersections is less than the number of sampling nodes extracted this time, adaptive truncation is performed, and the corresponding number of sampling points are extracted again at equal intervals along the extension trajectory of the line segment to be detected, updating the first node set so that the number of nodes in the first node set is consistent with the number of nodes in the set of adjacent grain boundary intersections.
[0029] It should be noted that, in the embodiments of the present invention, after updating the first node set, the total number of sampled nodes after the update is re-verified. If the total number of nodes after the update is less than or equal to 1, the current line segment to be detected is determined to be invalid, the subsequent processing flow of the line segment is terminated and the calculation is skipped.
[0030] The second node set consists of a group of grain boundary mesh intersection nodes closest to the centroid of the line segment to be detected, which are used as the endpoint group for subsequent pathfinding calculations. The topology network is a grain boundary mesh obtained by refining the metallographic image through a skeleton. The grain boundary intersection points are pixels on the skeleton with a number of connected branches greater than or equal to 3. The grain boundary intersection points are sorted and filtered according to the Euclidean distance between each grain boundary intersection point and the centroid of the line segment to be detected. The closest grain boundary intersection points are selected to form the second node set, which serves as a reference for judging whether the line segment to be detected is compatible with the original lattice.
[0031] Furthermore, the step of determining the first node set and the second node set corresponding to each line segment to be detected includes: For each line segment to be detected, coordinate points are extracted at equal intervals along the geometric extension trajectory of the line segment to be detected, with a preset pixel distance constant, to form the first node set.
[0032] Among them, the geometric extension trajectory refers to traversing and sampling along the actual arrangement of the line segment pixels, following the direction of the line segment itself, rather than the straight line direction in the image space.
[0033] The preset pixel distance constant refers to a pre-set pixel interval value (e.g., every 5 connected pixels) as the sampling step size.
[0034] Equal-interval extraction of coordinate points refers to extracting pixel coordinates sequentially on a line segment according to a fixed pixel step size.
[0035] Calculate the geometric centroid of the line segment to be detected, and sort the connecting nodes in the topology network in ascending order according to the Euclidean distance between each connecting node and the geometric centroid. Select a preset number of nodes to form a second node set.
[0036] Among them, the geometric centroid refers to the spatial center position of the line segment calculated from the coordinates of all pixels of the line segment to be detected.
[0037] For example, the connection nodes in the topology network are pixel coordinates with a number of connected branches greater than or equal to 3 in the metallographic skeleton network. These pixel coordinates are the intersection nodes of the native grain mesh and can be used as a reference for subsequent calculations.
[0038] Euclidean distance refers to the linear spatial distance between two points in a two-dimensional image coordinate system.
[0039] Ascending sort refers to sorting the nodes from closest to furthest from the centroid of the line segment.
[0040] The preset number of nodes refers to the number of nodes equal to the number of nodes in the first node set, selecting a batch of intersection points closest to the centroid.
[0041] It should be noted that, in the embodiments of the present invention, the sampling matching operation can provide a set of starting points and ending points with equal numbers and spatial proximity matching for the subsequent bipartite graph mutual exclusion assignment pathfinding algorithm, ensuring that the pathfinding sampling points are evenly distributed on the body of the line segment to be detected. At the same time, the nearest native grain boundary nodes are selected as references to avoid the calculation distortion caused by the mismatch in the number of sampling points and the excessive distance of the grain boundary intersection points, thus providing a reliable input basis for the subsequent quantization of the deviation between the line segment and the native lattice topology.
[0042] For example, since the Hungarian mutual exclusion assignment algorithm requires that the number of nodes in the starting set and the ending set must be consistent, and that the line segment itself is used as the pathfinding starting point and the surrounding native grain boundary intersections are used as the real lattice reference, using centroid distance screening can prioritize selecting the nearest nodes that actually participate in the grain network around the line segment, avoiding selecting grain boundary nodes that are too far away or irrelevant to the current line segment topology to participate in the calculation; therefore, in the embodiments of the present invention, coordinates are extracted along the direction of the line segment to be detected at fixed pixel intervals to form an internal starting point set, then the centroid of the line segment is calculated, and the grain boundary intersection nodes are sorted in ascending order of their straight-line distance to the centroid, and the corresponding number of nearest neighbor intersections are selected as the pathfinding ending point set.
[0043] Step S3: Construct a global feature matrix based on the target image, and generate a local cost matrix corresponding to each line segment to be detected based on the global feature matrix; wherein, the global feature matrix is used to characterize the pathfinding resistance distribution of pixels at each position in the target image; the local cost matrix is used to detect the local resistance environment of the bypass path after the line segment to be detected blocks its own connecting channel.
[0044] The global feature matrix is obtained by forward mapping of the grayscale of the target image pixels. Each position in the matrix stores the pathfinding cost of the corresponding pixel. Dark trenches and defects correspond to low cost (low pathfinding resistance), while bright uncorroded grains correspond to high cost (high pathfinding resistance), thus fully representing the pathfinding resistance distribution of all pixel positions in the entire image.
[0045] The local cost matrix is copied from the global feature matrix, and the cost of all pixel coordinates of a single line segment to be detected is forcibly replaced with the maximum bit depth gray level constant M. This matrix blocks the low-cost path of the line segment to be detected and is used to calculate the path resistance of the source node to bypass the line segment and reach the surrounding grain boundary intersection, providing a local resistance calculation environment for the detection of bypass paths.
[0046] The detour path refers to the alternative path that passes through the surrounding grain region and leads from the sampling point inside the line segment to the intersection point of the outer grain boundary when the pathfinding algorithm cannot travel along the line segment to be detected.
[0047] Furthermore, the step of constructing a global feature matrix based on the target image includes: The corresponding pixel value is generated based on the gray value of each pixel; where the pixel value is equal to the original gray value of the pixel, and the pixel value is used to characterize the magnitude of the passage resistance of the corresponding pixel in the pathfinding algorithm in the target image.
[0048] Among them, the gray value of a pixel refers to the original pixel brightness obtained from the two-dimensional coordinate positions of the target metallographic image; dark features such as corrosion grooves, scratches, and cracks have low gray values, while the uncorroded intact grain areas have high gray values.
[0049] Pixel cost refers to the value obtained directly from the original grayscale value. It is used in pathfinding algorithms to characterize the magnitude of the passage resistance at the corresponding pixel position. The lower the cost, the smaller the passage resistance, and the higher the cost, the greater the passage resistance.
[0050] The pixel values of all pixels are mapped to corresponding matrix elements based on the spatial location of each pixel in the target image to construct a global feature matrix.
[0051] It should be noted that, in the embodiments of the present invention, pixel cost values are generated based on the original grayscale of the image and a global feature matrix is constructed. The brightness and darkness visual information of the metallographic image is transformed into a resistance numerical model that can be computed by the pathfinding algorithm. No additional interpolation calculation is required, the original grayscale information is preserved, and a unified underlying matrix carrier is provided for subsequent generation of extreme value replacement cost matrix, A* heuristic path search, and calculation of node connectivity cost, thereby realizing the transformation of image visual features into topological connectivity cost calculation.
[0052] Furthermore, the step of generating a local cost matrix corresponding to each line segment to be detected based on the global feature matrix includes: The global feature matrix is used as the initial local cost matrix.
[0053] The initial local cost matrix refers to the copy of the global feature matrix obtained by directly copying it when calculating for a single line segment to be detected. The pixel cost rewriting operation has not yet been performed, and all cost information of the original global grayscale mapping is retained.
[0054] The cost value of the pixel position corresponding to the line segment to be detected in the initial local cost matrix is replaced with the preset maximum cost value to obtain the local cost matrix corresponding to each line segment to be detected.
[0055] The cost of a pixel location refers to the pathfinding cost corresponding to each coordinate in the matrix, which is derived from the image grayscale. The lower the value, the less resistance the path encounters, and the higher the value, the greater the resistance the path encounters.
[0056] The preset maximum cost value refers to the maximum bit depth grayscale constant (e.g., 255 for an 8-bit image), which represents the highest resistance penalty for pathfinding operations and is used to block the passage at the pixel location.
[0057] It should be noted that, in the embodiments of the present invention, by replicating the global matrix to generate a copy and forcibly rewriting the pixels of the line segment to be detected to a maximum cost value, the inherent low-cost shortcut of the line segment to be detected is blocked, forcing the subsequent pathfinding algorithm to not directly perform connectivity judgment along the line segment itself, but to detour around the outer grain region to complete the path solution. This fundamentally avoids the interference of the line segment's own grayscale features on the connectivity cost calculation, and provides the prerequisite calculation conditions for the subsequent differentiation between native grain boundaries and scratches and cracks that cross grains.
[0058] Step S4: Based on the local cost matrix, the path cost between the first node set and the second node set is determined by the pathfinding algorithm to generate the target cost matrix. The target cost matrix is then mutually exclusively assigned to obtain the assigned cost set. The target cost matrix is used to characterize the cumulative path cost required to connect each sampling point in the first node set to each grain boundary intersection point in the second node set. The assigned cost set is used to characterize the path cost combination corresponding to the matching relationship between the first node set and the second node set that minimizes the total path cost under the condition of satisfying one-to-one mutual exclusion constraints.
[0059] Among them, the pathfinding algorithm (e.g., using the A* heuristic search algorithm) refers to solving the minimum cumulative path cost obtained by accumulating the cost of all pixels traversed during the process of moving from one sampling node to another grain boundary intersection point in the numerical environment of the local cost matrix; when encountering abnormal situations such as no feasible path, a maximum penalty constant is assigned to avoid computational crash.
[0060] Path cost refers to the sum of the cost values of all pixels on the path from a single starting point to a single ending point, calculated by the pathfinding algorithm. It represents the connectivity obstruction cost required to cross the metallographic image space between two points.
[0061] Each element in the target cost matrix stores the cumulative path cost from a sampling point in the first node set to a grain boundary intersection point in the second node set, and completely records the path-finding cost results of all pairwise pairings of start and end points.
[0062] For example, mutual exclusion assignment refers to the optimal matching constraint of the bipartite graph implemented using the Hungarian algorithm, which enforces a one-to-one rule; each sampling point in the first node set can only match a unique grain boundary intersection in the second node set, different sampling points cannot share the same grain boundary intersection, and multiple starting points are prohibited from occupying the same endpoint nearby.
[0063] The assignment cost set refers to a set of path cost constants obtained under the one-to-one mutual exclusion assignment rule (Hungarian algorithm bipartite graph optimal matching). Each element represents a sampling starting point inside the line segment, and the minimum cumulative pathfinding cost to reach the uniquely matched outer grain boundary intersection endpoint after blocking its own line segment channel.
[0064] It should be noted that, in the embodiments of the present invention, the low-cost channels of the line segment itself are blocked in advance by the local cost matrix, and then the complete pairwise cost matrix is obtained by pathfinding. A one-to-one mutually exclusive allocation rule is introduced, abandoning the greedy matching of the nearest, forcing the sampling points of abnormal line segments that do not belong to the original lattice to have to detour to the grain boundary intersection point further away. This amplifies the difference in topological connectivity cost between real defects and normal grain boundaries (including straight twin boundaries), and transforms the originally easily confused grayscale and geometric features into a quantifiable set of costs. This provides a highly discriminative basic statistical data for subsequent calculation of network deviation index and differentiation between normal metallographic artifacts and real damage.
[0065] Further, the step of determining the path cost between the first node set and the second node set based on the local cost matrix using a pathfinding algorithm to generate the target cost matrix includes: Based on the local cost matrix, for each sampling point in the first node set, the cumulative path cost between the sampling point and each grain boundary junction in the second node set is calculated by a pathfinding algorithm; whereby the cumulative path cost is used to characterize the sum of the costs of the path traversed from the sampling point to the grain boundary junction.
[0066] For example, the cumulative path cost can be obtained by using the A* heuristic shortest path search algorithm; the second node set corresponds to the set of neighboring junctions, which is a set of grain boundary reference nodes selected from the grain boundary junctions that are closest to the centroid of the line segment, and is used as the destination group for pathfinding; the cumulative path cost is the independent path parameter, which is the sum of the costs of all pixel positions traversed by the pathfinding path. The cost will increase significantly when the path encounters a high-resistance grain region; the value of the cumulative path cost reflects the degree of connectivity obstruction encountered by the starting point in the process of detouring to the grain boundary reference node. The more complete grains the path passes through, the greater the value of the cumulative path cost.
[0067] Using the sampling point index in the first node set as the row index and the grain boundary intersection point index in the second node set as the column index, the calculated cumulative path cost is filled into the corresponding matrix element positions to construct the target cost matrix.
[0068] For example, the sampling point number of the first node is used as the matrix row, the grain boundary intersection point number of the second node is used as the matrix column, and the cumulative path cost calculated for each pair of start-end points is used as the corresponding element of the matrix; the resulting target cost matrix is constructed, and the path cost results of all pairwise start-end point pairwise ...
[0069] For example, the local cost matrix after extreme value replacement is used as the pathfinding grid environment. All pairwise combinations of all starting points of the first node set and all ending points of the second node set are traversed. For each pair of starting points and ending points, the A* heuristic search is called to solve for the shortest cumulative path cost. If no feasible path is encountered or the iteration exceeds the limit, the maximum penalty constant is assigned. Then, the sampling point index is used as the row and the grain boundary intersection point index is used as the column. The cumulative path cost of each pair is filled into the corresponding row and column positions of the matrix to generate the target cost matrix in the form of a complete square matrix.
[0070] It should be noted that, in the embodiments of the present invention, the spatial image bypass connectivity resistance is transformed into structured two-dimensional matrix data, retaining the path cost information between each pair of internal sampling points and the external grain boundary intersection points, providing a complete input data source for the subsequent Hungarian algorithm to achieve one-to-one mutually exclusive assignment matching, and ensuring that the total cost of different pairing schemes can be quantitatively compared in the future.
[0071] Furthermore, the step of mutually exclusive allocation of the target cost matrix to obtain the assignment cost set includes: Based on the optimal matching operator, target matching schemes that satisfy the mutual exclusion condition are selected in the target cost matrix. The optimal matching operator is used to characterize the operation rule for solving the matching result that minimizes the total path cost in the target cost matrix. The target matching scheme is used to characterize the optimal assignment relationship in the target cost matrix that establishes a one-to-one mapping with absolute mutual exclusion between the sampling points in the first node set and the grain boundary intersection points in the second node set, and the sum of the costs of all mapped paths reaches the theoretical minimum.
[0072] Among them, the optimal matching operator refers to a bipartite graph matching operation rule that takes the target cost matrix as input and solves for the matching result with the minimum total path cost, thereby forcing the mutual exclusion pairing between the source node and the grain boundary intersection point.
[0073] Mutual exclusion condition refers to absolute mutual exclusion constraint between rows and columns, which requires that a sampling point in the first node set can only uniquely match a grain boundary junction in the second node set. Multiple source nodes are not allowed to bind to the same grain boundary junction at the same time, nor is it allowed for one source node to correspond to multiple grain boundary junctions.
[0074] The target matching scheme refers to the pairing result output by the optimal matching operator, which selects a one-to-one assignment mapping relationship from all pairing combinations that satisfy the mutual exclusion condition, and whose sum of the costs of all mapping paths reaches the theoretical minimum value.
[0075] One-to-one mapping means that the sampling points of the first node set correspond one-to-one with the grain boundary intersection points of the second node set, and the source and grain boundary intersection points are uniquely bound in both directions.
[0076] Based on the target matching scheme, the path cost value with the same number of sampling points as the first node set is extracted from the target cost matrix to form the assignment cost set.
[0077] It should be noted that, in the embodiments of the present invention, the optimal matching operator is used to complete the mutually exclusive one-to-one optimal assignment on the target cost matrix, abandoning the greedy matching method of proximity, forcing the sampling points of abnormal line segments to detour around the grain boundary nodes of more distant places, amplifying the path cost penalty for traversing grain-like defects, and extracting the assignment cost set to provide a standardized statistical data source for subsequent calculation of the total cost, standard deviation and network deviation index, thereby improving the numerical distinguishability between normal grain boundaries and real defects.
[0078] For example, since ordinary greedy proximity matching allows multiple sampling points to share the same neighboring grain boundary node, it can mask the real connectivity resistance caused by abnormal line segments crossing grains. However, mutual exclusion one-to-one constraints force each sampling point to be assigned an independent grain boundary intersection point, forcing sampling points at defective locations to choose a more distant path, thereby transforming topological misalignment into a calculable cost. In the embodiments of the present invention, the first node set is used as the source of the bipartite graph and the second node set is used as the target of the bipartite graph. The target cost matrix is input into the optimal matching operator. Among all pairing combinations that satisfy the row and column mutual exclusion one-to-one constraints, the target matching scheme with the smallest cumulative path cost is selected. Then, according to the row and column index of the matching scheme, the path cost at the corresponding position is taken out from the target cost matrix and assembled to form an assignment cost set.
[0079] Step S5: Calculate the deviation index based on the assigned cost set, and determine whether the line segment to be detected is a defect based on the deviation index; wherein, the deviation index is used to characterize the degree of abnormality of the line segment to be detected deviating from the inherent connectivity rules of the topology network.
[0080] Among them, the deviation index refers to a single quantitative value obtained by normalizing the total assigned cost, the standard deviation of the cost statistics, and the total number of sampling points through a fusion formula. It is used to uniformly measure the degree of topological adaptation between line segments and native grain boundary networks.
[0081] For example, the deviation index is compared with a preset deviation threshold to distinguish between normal grain boundaries (including straight twin boundaries) that conform to the crystal lattice and real process / material defects that are outside the crystal lattice.
[0082] The inherent connectivity law of topological networks refers to the connectivity topological relationship inherent in the natural grain boundary grid in alloy metallographic images. Normal grain boundaries can connect with the surrounding grain boundary intersection nodes at low cost, while external damage such as scratches and microcracks cannot conform to the current grid connectivity characteristics.
[0083] The degree of anomaly refers to the magnitude of the misalignment between the line segment to be detected and the original grain grid topology in terms of numerical values. The higher the index value, the less the line segment belongs to the original grain boundary structure.
[0084] Furthermore, the step of calculating the deviation index based on the assignment cost set includes: Calculate the sum of all path cost values in the assignment cost set to obtain the total assignment cost.
[0085] Here, path cost refers to a single element in the assignment cost set, representing the sum of all cross-pixel cost values on the path when, under the extreme value replacement cost matrix environment, any internal sampling node reaches its mutually exclusive assignment peripheral intersection point through A* heuristic search. The dimension is grayscale cost units.
[0086] The total assignment cost refers to the result of adding up the costs of all paths within the assignment cost set. It represents the total absolute pathfinding resistance required for the line segment as a whole to cross the surrounding grains and connect to the natural grain boundary network.
[0087] Calculate the standard deviation of the cost values of all paths in the assigned cost set to obtain the cost statistical standard deviation.
[0088] Among them, the cost statistical standard deviation refers to the standard deviation of the assigned cost set, which is used to measure the degree of dispersion and fluctuation of the cost of each assigned path within the set, reflecting the unevenness of the resistance to the connection of different positions of the line segment to the primary grain boundary.
[0089] The deviation index is calculated based on the total assigned cost, the standard deviation of the cost statistics, and the total number of sampling points in the first node.
[0090] The total number of sampling points in the first node refers to the number of internal sampling point coordinates extracted on a single line segment to be judged according to the equal spacing rule, and is also the number of nodes in the set of adjacent intersection points.
[0091] It should be noted that, in the embodiments of the present invention, by sequentially performing summation, standard deviation dispersion calculation, and product normalization fusion on the path cost set after mutual exclusion assignment, the originally dispersed multiple independent pathfinding costs are compressed into a single quantitative index that is not affected by the absolute length of the line segment. This not only preserves the absolute resistance information of the line segment as a whole traversing the high-cost grain region, but also quantifies the topological distortion characteristics of the uneven connectivity resistance of each part of the line segment. This provides a highly discriminative judgment basis for subsequently eliminating normal grain boundary artifacts and retaining real defects with a fixed threshold.
[0092] Furthermore, the step of calculating the deviation index based on the total assignment cost, the standard deviation of the cost statistics, and the total number of sampled points in the first node includes: The smoothing standard deviation is obtained by summing the cost statistical standard deviation with the preset non-zero smoothing constant.
[0093] The preset non-zero smoothing constant refers to a pre-defined, extremely small positive number (for example, it can take values of 0.0001, 10...). -6 (etc.) are used to provide numerical stability and prevent subsequent calculations from failing in extreme cases where the standard deviation is zero.
[0094] The smoothed standard deviation refers to the corrected standard deviation value. After introducing a non-zero smoothing constant, even in the extreme case where certain special defects (such as straight scratches across high-resistance grains) cause all pathfinding costs to be equal, making the original cost statistical standard deviation calculation result 0, the smoothed standard deviation value is still a non-zero positive number.
[0095] The discrete cost product is obtained by multiplying the sum of the assignment costs by the smoothing standard deviation.
[0096] Among them, the discrete cost product refers to the intermediate computational quantity obtained by multiplying the sum of assigned costs by the standard deviation of cost statistics, while taking into account both the overall pathfinding resistance and the degree of distortion in the distribution of costs for each path.
[0097] Calculate the square of the total number of sampling points in the first node to obtain the squared value of the node size.
[0098] Among them, the node size square value refers to the value obtained by squaring the total number of sampling points, which is used to offset the numerical inflation effect caused by the line segment length and the number of sampling nodes.
[0099] The deviation index is obtained based on the ratio of the discrete product of cost to the square of the node size.
[0100] For example, deviation index It can be represented as: in, This indicates the total cost of assignment. This represents the standard deviation of the cost statistics. This represents a preset non-zero smoothing constant (for example, it can take the value 0.0001). This represents the total number of sampling points in the first node.
[0101] It should be noted that, in the embodiments of the present invention, by multiplying the total resistance by the cost dispersion and then normalizing by the square of the node size, the absolute cost of the path and the cost distribution distortion are integrated into a single dimensionless deviation index, eliminating the numerical deviation caused by different line segment lengths and different numbers of sampling nodes. This can amplify the characteristic differences of abnormal defects that cross grains, and provide a unified and comparable quantitative criterion for distinguishing normal grain boundary artifacts from real damage defects.
[0102] For example, the product of the total assigned cost and the standard deviation of the cost is first calculated to obtain the discrete cost product. Then, the total number of sampling points is squared to obtain the squared value of the node size. Finally, the discrete cost product is divided by the squared value of the node size to output the deviation index. The reason for using the sum multiplied by the standard deviation is that real defects (scratches, microcracks) not only have high overall pathfinding costs, but also have large differences in resistance between different positions of the line segment connecting to the outer grain boundary. Multiplying the two can amplify the abnormal features with high resistance and uneven resistance distribution. However, for grain boundaries that normally conform to the lattice, the total cost and dispersion are at a low level, and the value will not be amplified after multiplication. The square of the total number of nodes is used as the denominator because the more sampling nodes there are, the more the total assigned cost and standard deviation will naturally increase synchronously. Normalization is needed to eliminate the cardinality interference caused by the number of nodes.
[0103] Furthermore, the step of determining whether the line segment to be detected is a defect based on the deviation index includes: The deviation index is compared with the preset deviation threshold.
[0104] The preset deviation threshold refers to a fixed judgment constant determined by analyzing and statistically analyzing the positive and negative sample score distribution using a standard metallographic annotation dataset that includes normal artifacts and real defects. This constant serves as the numerical boundary for distinguishing between normal line segments and defective line segments.
[0105] If the deviation index is greater than or equal to the preset deviation threshold, the line segment to be detected is determined to be a defective line segment.
[0106] For example, a defective line segment refers to a real abnormal damage line segment that has been identified as deviating from the original grain boundary grid and excluding normal grain boundary and twin boundary artifacts after being screened by the network deviation index, including mechanical scratches and microcracks.
[0107] If the deviation index is less than the preset deviation threshold, the line segment to be detected is determined to be a normal line segment.
[0108] Among them, normal line segments refer to the metallographic structure characteristics that conform to the original crystal lattice arrangement of the alloy. They mainly include ordinary curved grain boundaries and straight twin boundaries that are easily misjudged by straightness algorithms. They are artifacts formed by corrosion development and do not need to be alarmed as defects.
[0109] It should be noted that, in the embodiments of the present invention, by comparing the deviation index obtained by fusing topological cost information with the calibrated deviation threshold, the complex metallographic topological connectivity differences can be simplified into a simple numerical judgment, filtering out normal grain boundary artifacts including straight twin boundaries, distinguishing damage that is truly outside the natural lattice, avoiding false alarms caused by relying solely on geometric morphology judgment, and providing reliable screening output for further classification of defects.
[0110] For example, the deviation index of a single line segment to be detected is first read, and the deviation threshold obtained in advance through sample calibration is retrieved for numerical comparison. If the deviation index is greater than or equal to the threshold, the line segment is output as a defective line segment. If the deviation index is less than the threshold, the line segment is determined to be a normal line segment. The reason for using this threshold comparison logic is that the deviation index has integrated the total pathfinding cost and the cost distribution dispersion, quantitatively characterizing the degree of deviation of the line segment from the native crystal network. Positive and negative samples of different samples will form mutually distinguishable numerical intervals. Therefore, a fixed boundary threshold can be used to complete binary classification and simultaneously complete the automated screening of batch images.
[0111] Furthermore, after determining that the line segment to be detected is a defective line segment, the method further includes: The endpoint distance ratio is obtained by calculating the ratio of the straight-line distance between the endpoints of the defective line segment to the total number of connected pixels.
[0112] Among them, the endpoint straight-line distance refers to the Euclidean straight-line distance between the two end points of the defect line segment; if the line segment has no standard double endpoints, the maximum value of the Euclidean distance between all pairs of pixels of the line segment is taken to represent the spatial straight-line span at both ends of the defect.
[0113] The total number of connected pixels refers to the sum of all connected pixels that make up the entire defective line segment, representing the actual physical total length of the defective line, including its detours and bends.
[0114] The endpoint distance ratio is obtained by dividing the straight-line distance between endpoints by the total number of connected pixels. The value range is 0-1, and it is used to quantify the overall curvature and tortuosity of the defective line segment.
[0115] If the ratio of endpoint distances is greater than or equal to a preset straight line discrimination threshold, the defective line segment is classified as a mechanical scratch.
[0116] The preset straight line discrimination threshold refers to a constant obtained by labeling the sample dataset, which serves as the morphological boundary criterion for distinguishing mechanical scratches from microcracks.
[0117] Mechanical scratches refer to linear defects caused by the dragging and scraping of hard particles of polishing consumables on the surface of the sample during the metallographic sample preparation and polishing process. They are close to straight lines in shape with few bends.
[0118] If the ratio of endpoint distances is less than the preset straight line discrimination threshold, the defect line segment is classified as a microcrack.
[0119] Among them, microcracks refer to intrinsic material damage caused by the release of internal stress in the material. The cracks are often tortuous and meandering, with a high degree of curvature in their path.
[0120] It should be noted that, in the embodiments of the present invention, under the premise that artifacts such as normal grain boundaries and twin boundaries have been filtered out, the secondary classification of real defects is achieved by simple geometric ratios. There is no need for complex pathfinding and graph theory operations, the computational overhead is low, and the detection results can be quickly mapped to two different industrial root causes: polishing consumable abnormalities and material damage. This supports the production line to output closed-loop control commands for polishing consumable early warning and material isolation and interception, respectively.
[0121] For example, for a defective line segment that has been confirmed as a real anomaly, first count all connected pixels of the line segment to obtain the total number of connected pixels, and then calculate the straight-line distance between the endpoints of the line segment; divide the straight-line distance between the endpoints by the total number of connected pixels to calculate the endpoint distance ratio; compare the ratio with a pre-calibrated straight-line discrimination threshold, and if the ratio is greater than or equal to the threshold, it is judged as a mechanical scratch, and if the ratio is less than the threshold, it is judged as a microcrack.
[0122] In summary, this invention acquires a bright-field metallographic digital image of an alloy metal material as the target image, extracts the topological network formed by the metal grain boundaries, and segments the topological network into multiple line segments to be detected based on the grain boundary intersections. For each line segment to be detected, a first node set composed of sampling points on the line segment and a second node set composed of adjacent grain boundary intersections are obtained. A global feature matrix characterizing the distribution of pixel pathfinding resistance is constructed, and a local cost matrix blocking the line segment's own connectivity is generated for each line segment to be detected. The path cost between nodes is solved using a pathfinding algorithm to obtain the target cost matrix, and then an assignment cost set is obtained through mutual exclusion allocation. The deviation of the line segment from its inherent connectivity is further calculated. The deviation index of regularity is used to determine whether the line segment to be detected is a real defect. This invention uses metallographic image grain boundary topology network analysis to first construct a global pathfinding resistance feature matrix, and then construct a dedicated local cost matrix for each line segment to be detected to block the low-cost connectivity channels of the line segment itself. Combined with pathfinding operation and a one-to-one mutual exclusion allocation mechanism, the topological misalignment characteristics of abnormal line segments are amplified. Based on the deviation index, the normal grain boundary artifacts conforming to the crystal lattice and real defects deviating from the original topology are distinguished. This can avoid the misjudgment problem caused by simply relying on grayscale threshold and geometric straightness, reduce the false alarm rate of metallographic micro-defect detection, and improve the detection effect of micro-metallographic defects in alloy metal materials.
[0123] This invention proposes a system for detecting microstructure defects in alloy metal materials, the system comprising: The acquisition module is used to acquire the target image, extract the topological network composed of metal grain boundaries from the target image, and segment the topological network into multiple line segments to be detected based on the connection nodes in the topological network; wherein, the target image is a bright-field metallographic digital image of the alloy metal material; the nodes in the topological network represent grain boundary junctions, and the edges represent grain boundary line segments connecting the grain boundary junctions; The determination module is used to determine the first node set and the second node set corresponding to each line segment to be detected; wherein, the first node set is used to characterize the set of sampling points distributed along the extension direction of the line segment to be detected; and the second node set is used to characterize the set of grain boundary intersection points adjacent to the line segment to be detected in the topological network. The construction module is used to construct a global feature matrix based on the target image, and generate a local cost matrix corresponding to each line segment to be detected based on the global feature matrix; wherein, the global feature matrix is used to characterize the pathfinding resistance distribution of pixels at each position in the target image; the local cost matrix is used to detect the local resistance environment of the bypass path after the line segment to be detected blocks its own connecting channel; The allocation module is used to determine the path cost between the first node set and the second node set based on the local cost matrix using a pathfinding algorithm, in order to generate a target cost matrix, and to perform mutually exclusive allocation on the target cost matrix to obtain an assigned cost set. The target cost matrix is used to characterize the cumulative path cost required to connect each sampling point in the first node set to each grain boundary intersection point in the second node set. The assigned cost set is used to characterize the path cost combination corresponding to the matching relationship between the first node set and the second node set that minimizes the sum of path costs under the condition of satisfying one-to-one mutual exclusion constraints. The judgment module is used to calculate the deviation index based on the assigned cost set, and to determine whether the line segment to be detected is a defect based on the deviation index; wherein, the deviation index is used to characterize the degree of abnormality of the line segment to be detected deviating from the inherent connectivity rules of the topological network.
[0124] It should be noted that the system provided in the above embodiments is only an example of the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the computer device can be divided into different functional modules to complete all or part of the functions described above. In addition, the microstructure defect detection system for alloy metal materials and the microstructure defect detection method for alloy metal materials provided in the above embodiments belong to the same concept, and the specific implementation process is detailed in the method embodiments, which will not be repeated here.
Claims
1. A method for detecting microstructure defects in alloy metal materials, characterized in that, The method includes: Acquire a target image, extract a topological network composed of metal grain boundaries from the target image, and segment the topological network into multiple line segments to be detected based on the connection nodes in the topological network; For each line segment to be detected, a first node set and a second node set corresponding to the line segment to be detected are determined; wherein, the first node set is used to characterize the set of sampling points distributed along the extension direction of the line segment to be detected; and the second node set is used to characterize the set of grain boundary intersection points adjacent to the line segment to be detected in the topology network. A global feature matrix is constructed based on the target image, and a local cost matrix corresponding to each of the line segments to be detected is generated based on the global feature matrix; wherein, the global feature matrix is used to characterize the pathfinding resistance distribution of pixels at each position in the target image; and the local cost matrix is used to detect the local resistance environment of the bypass path after the connecting channel of the line segment to be detected is blocked. Based on the local cost matrix, the path cost between the first node set and the second node set is determined by a pathfinding algorithm to generate a target cost matrix. The target cost matrix is then mutually exclusively assigned to obtain an assigned cost set. The target cost matrix is used to characterize the cumulative path cost required to connect each sampling point to each grain boundary junction. The assigned cost set is used to characterize the path cost combination corresponding to the matching relationship that minimizes the total path cost under the constraint conditions. The deviation index is calculated based on the assigned cost set, and the line segment to be detected is determined as a defect based on the deviation index.
2. The method for detecting microstructure defects in alloy metal materials according to claim 1, characterized in that, The step of determining the first node set and the second node set corresponding to each line segment to be detected includes: For each of the line segments to be detected, coordinate points are extracted at equal intervals along the geometric extension trajectory of the line segment to be detected, with a preset pixel distance constant, to form the first node set; Calculate the geometric centroid of the line segment to be detected, and sort the connecting nodes in the topology network in ascending order according to the Euclidean distance between each connecting node and the geometric centroid, and select a preset number of nodes to form the second node set.
3. The method for detecting microstructure defects in alloy metal materials according to claim 1, characterized in that, The step of constructing a global feature matrix based on the target image includes: A corresponding pixel value is generated based on the grayscale value of each pixel; wherein, the pixel value is equal to the original grayscale value of the pixel, and the pixel value is used to characterize the magnitude of the passage resistance of the corresponding pixel in the pathfinding algorithm in the target image; The pixel values of all pixels are mapped to corresponding matrix elements based on the spatial position of each pixel in the target image to construct the global feature matrix.
4. The method for detecting microstructure defects in alloy metal materials according to claim 1, characterized in that, The step of generating a local cost matrix corresponding to each of the line segments to be detected based on the global feature matrix includes: The global feature matrix is used as the initial local cost matrix; The cost value of the pixel position corresponding to the line segment to be detected in the initial local cost matrix is replaced with a preset maximum cost value to obtain a local cost matrix corresponding to each line segment to be detected.
5. The method for detecting microstructure defects in alloy metal materials according to claim 1, characterized in that, The step of determining the path cost between the first node set and the second node set based on the local cost matrix using a pathfinding algorithm to generate the target cost matrix includes: Based on the local cost matrix, for each sampling point in the first node set, the cumulative path cost between the sampling point and each grain boundary junction in the second node set is calculated using a pathfinding algorithm; wherein, the cumulative path cost is used to characterize the sum of the costs of the paths traversed from the sampling point to the grain boundary junction. Using the sampling point index in the first node set as the row index and the grain boundary intersection point index in the second node set as the column index, the calculated cumulative path cost is filled into the corresponding matrix element positions to construct the target cost matrix.
6. The method for detecting microstructure defects in alloy metal materials according to claim 1, characterized in that, The step of mutually exclusive allocation of the target cost matrix to obtain the assigned cost set includes: Based on the optimal matching operator, target matching schemes that satisfy the mutual exclusion condition are selected from the target cost matrix; wherein, the optimal matching operator is used to characterize the operation rule for solving the matching result that minimizes the total path cost in the target cost matrix; the target matching scheme is used to characterize the optimal assignment relationship in the target cost matrix that establishes a one-to-one mapping of absolutely mutually exclusive rows and columns between the sampling points in the first node set and the grain boundary intersection points in the second node set, and the sum of the costs of all mapped paths reaches the theoretical minimum value; Based on the target matching scheme, path cost values with the same number of sampling points as the first node set are extracted from the target cost matrix to form the assignment cost set.
7. The method for detecting microstructure defects in alloy metal materials according to claim 1, characterized in that, The step of calculating the deviation index based on the assignment cost set includes: Calculate the sum of all path cost values in the assignment cost set to obtain the total assignment cost; Calculate the standard deviation of the cost values of all paths in the assigned cost set to obtain the cost statistical standard deviation. The deviation index is calculated based on the total assignment cost, the standard deviation of the cost statistics, and the total number of sampling points in the first node set.
8. The method for detecting microstructure defects in alloy metal materials according to claim 7, characterized in that, The step of calculating the deviation index based on the total assignment cost, the statistical standard deviation of the cost, and the total number of sampled points in the first node set includes: The smoothing standard deviation is obtained by summing the cost statistical standard deviation with a preset non-zero smoothing constant. Calculate the product of the sum of the assignment costs and the smoothing standard deviation to obtain the discrete cost product; Calculate the square of the total number of sampling points in the first node set to obtain the squared value of the node size; The deviation index is obtained based on the ratio of the discrete product of the cost to the square of the node size.
9. The method for detecting microstructure defects in alloy metal materials according to claim 1, characterized in that, The step of determining whether the line segment to be detected is a defect based on the deviation index includes: The deviation index is compared with a preset deviation threshold; If the deviation index is greater than or equal to the preset deviation threshold, the line segment to be detected is determined to be a defective line segment. If the deviation index is less than the preset deviation threshold, the line segment to be detected is determined to be a normal line segment.
10. The method for detecting microstructure defects in alloy metal materials according to claim 9, characterized in that, After determining that the line segment to be detected is a defective line segment, the method further includes: The ratio of the straight-line distance between the endpoints of the defective line segment to the total number of connected pixels is calculated to obtain the endpoint distance ratio. If the ratio of the endpoint distances is greater than or equal to a preset straight line discrimination threshold, the defective line segment is classified as a mechanical scratch. If the ratio of the endpoint distances is less than the preset straight line discrimination threshold, the defect line segment is classified as a microcrack.
