Visual inspection method for slag inclusion defects in crankshaft casting process
Patent Information
- Application Number
- CN202611333071.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-31
- Publication Date
- 2026-09-25
AI Technical Summary
由于该类方法未能纳入铸造冷却过程中的热应力演变数据,导致检测手段仅依赖于图像本身所呈现的静态信息,难以识别那些未完全暴露在图像表层或因表面干扰而模糊不清的夹渣缺陷
[0038]本发明中,通过主应力场的连续时间点数据构建轴颈根部与曲柄圆角区域的应力扰动定位图,并引入主应力方向角差判定方法,在冷却过程中能够提前识别潜在扭转扰动区域,有助于弥补传统图像信息获取手段在热应力演变维度上的缺失。经仿射变换将该应力信息映射至图像空间后,融合灰度梯度方向与应力方向间夹角关系,进一步对图像结构进行响应性分析,使图像处理不仅停留在视觉层面,更具备结构应力语义解读能力。在此基础上,通过主应力方向与冷却形变量的耦合分析,提取形变量曲率变化率并追踪连续形变路径,可实现对夹渣边界路径的高度拟合识别,克服传统轮廓提取受噪声和光照影响大的问题。结合灰度均值梯度与突变频率判定灰度衰减趋势,并引入主应力持续扰动趋势作为判断依据,形成多维度交叉验证的夹渣区域标记方式,提升了对缺陷真实存在性与可视区域边界的精准识别能力。整体逻辑以应力演变分析为起点,融合图像灰度结构变化与物理形变特征,贯穿应力扰动识别、图像响应映射、形变追踪与边界标注各环节,使夹渣缺陷检测从图像静态分析转向结构演变理解,增强了对复杂铸造缺陷的感知与识别效果。
Smart Images

Figure CN122820732A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a visual detection method for inclusion defects in the crankshaft casting process. Background Technology
[0002] Image processing technology encompasses methods and techniques for acquiring, analyzing, and recognizing image data. Its core content involves digitally encoding, segmenting, extracting features, and performing pattern recognition on images to achieve accurate identification and classification of target objects. In industrial applications, image processing is widely used for inspection and monitoring in production processes, particularly in manufacturing stages such as casting, welding, and assembly. Visual analysis techniques are used to inspect the surface and internal structure of workpieces to support the identification and management of defects during manufacturing.
[0003] The visual inspection method for inclusion defects in crankshaft casting refers to a detection method that targets inclusion defects that may form during crankshaft casting. This involves acquiring images of the crankshaft surface or cross-section, preprocessing the images, and then identifying and classifying the defect areas based on their features. The technical aspects covered include using an industrial camera to acquire images of the casting surface, performing threshold segmentation on the images to highlight inclusion areas, employing edge detection operators to identify defect boundaries, and determining inclusion defects through geometric feature parameter analysis.
[0004] Existing technologies rely on threshold segmentation and edge extraction from casting surface images, using geometric parameters for defect identification, which has several shortcomings. Because these methods fail to incorporate thermal stress evolution data during the casting cooling process, detection relies solely on static information presented by the image itself, making it difficult to identify inclusion defects that are not fully exposed on the image surface or are blurred due to surface interference. Furthermore, traditional edge detection has limited recognition capabilities when there is significant noise or insignificant grayscale changes, easily leading to inconsistent boundary extraction and low defect recognition rates. In practical applications, inclusion defects, due to their complex and diverse morphologies, often resemble other casting textures or residues, making them prone to misjudgment or missed detection. Taking cast crankshafts as an example, the complex structure of the crank fillet and journal root makes it easier to form stress concentration areas. Traditional methods cannot provide early warnings or precise marking for high-risk areas, hindering early intervention and accurate defect location, thus affecting overall quality control and production stability. Summary of the Invention
[0005] To address the technical problems existing in the prior art, embodiments of the present invention provide a visual inspection method for inclusion defects in the crankshaft casting process, comprising the following steps:
[0006] To achieve the above objectives, the present invention adopts the following technical solution: a visual inspection method for inclusion defects in the crankshaft casting process, comprising the following steps:
[0007] S1: Obtain principal stress field data of journal root and crank fillet during crankshaft cooling stage using finite element method, calculate principal stress direction angle difference at continuous time points to identify principal stress mutation points, mark areas exceeding the direction angle threshold as torsional disturbance areas, and construct stress disturbance location map;
[0008] S2: Map the stress disturbance location map to the image coordinate grid through affine transformation, obtain the gray-level gradient direction and principal stress direction of the corresponding image region and calculate the angle difference to generate an image structure mapping map;
[0009] S3: Based on the image structure mapping, filter pixels with an angle difference exceeding the threshold of the principal stress direction as stress interference points, obtain the principal stress direction and crankshaft cooling deformation corresponding to the stress interference points, calculate the curvature change rate of the deformation, identify continuous deformation regions and connect them to the path, and output the slag inclusion boundary path set.
[0010] S4: Based on the slag inclusion boundary path set, extract the corresponding image grayscale sequence, analyze the grayscale mean gradient and the frequency of abrupt change points to determine the grayscale attenuation trend, combine the corresponding principal stress data to determine whether there is a continuous disturbance trend of principal stress, mark the areas where both exist simultaneously, and generate a visual area map of slag inclusion defects.
[0011] S5: Based on the visible area map of the inclusion defect, obtain the principal stress direction and the corresponding image texture direction of the extension path and calculate the included angle. Filter the paths whose included angle does not reach the principal stress texture threshold. Combine the gray-scale mean gradient to filter out the paths with abrupt changes in direction and gradient breakage. Output the inclusion defect penetration path recognition map.
[0012] As a further embodiment of the present invention, the stress disturbance location map includes the distribution of abrupt change points in the principal stress direction, the region where the direction angle exceeds the limit, and the coordinate set of the torsional disturbance boundary; the image structure mapping map includes the image gray-level gradient direction field, the principal stress direction mapping field, and the distribution map of the direction angle difference; the inclusion boundary path set specifically includes the stress disturbance edge trajectory, the gray-level abnormal path, and the path continuity marker; the inclusion defect visible area map includes the gray-level attenuation area layer, the disturbance trend area marker, and the multi-dimensional feature fusion and superposition image; and the inclusion defect penetration path identification map specifically includes the principal stress texture direction deviation path, the gray-level continuous path, and the pixel trajectory set of the inclusion penetration path.
[0013] As a further aspect of the present invention, the specific steps of S1 are as follows:
[0014] S101: The principal stress field data at the journal root and crank fillet of the crankshaft cooling stage are obtained by finite element method, and the principal stress tensor at each moment in the stress field data is extracted in the coordinate system to obtain the principal stress direction angle sequence between consecutive time points.
[0015] S102: Based on the principal stress direction angle sequence value, extract the principal stress direction angle change between adjacent time points, compare it with the set direction angle threshold, filter the time point position index that exceeds the direction angle threshold and map it to the stress field spatial position to generate a principal stress change position index set.
[0016] S103: Call the principal stress mutation location index set, extract the principal stress direction change vectors of all mutation time points in the corresponding region in the original principal stress field data, and perform spatial clustering to form the boundary of the disturbance region to obtain the stress disturbance location map.
[0017] As a further aspect of the present invention, the directional angle threshold is determined by extracting the frequency of the statistical distribution of the principal stress direction angle change values, dividing the fluctuation amplitude in the angle change sequence into intervals, and combining the frequency proportion of the fluctuation concentration area with the range of change gradient amplitude.
[0018] As a further aspect of the present invention, the specific steps of S2 are as follows:
[0019] S201: Based on the stress disturbance location map, extract the physical coordinate values of multiple boundary points in the disturbance region, apply a two-dimensional affine transformation parameter set, map them to the corresponding positions in the image coordinate grid, and generate an image spatial mapping region group.
[0020] S202: Call each image region in the image space mapping region group and collect grayscale image information. At the same time, extract the image intensity change and calculate the grayscale derivatives in the horizontal and vertical directions. Calculate the gradient direction angle of each point in the image based on the derivative ratio.
[0021] S203: Calculate the angle difference between the gradient direction angle and the principal stress direction angle at the corresponding position in the original coordinates of the disturbance region, and assign the value to the pixel point in the corresponding image coordinate grid to obtain the image structure mapping map.
[0022] As a further aspect of the present invention, the specific steps of S3 are as follows:
[0023] S301: Based on the image structure mapping, extract the angle difference values corresponding to all pixels, compare them point by point with the set principal stress direction threshold, filter out pixels whose angle difference exceeds the principal stress direction threshold, and extract the corresponding image coordinate positions to generate a set of stress interference pixels.
[0024] S302: Call the set of stress interference pixels, match the principal stress direction information at the corresponding position, and obtain the deformation at the same position during the crankshaft cooling process. Perform first derivative operation on the deformation at adjacent interference points, calculate the rate of change of multiple interference point positions, and obtain the deformation curvature change rate sequence.
[0025] S303: Based on the positional distribution of the continuous fluctuation segment of the rate of change in the deformation curvature change rate sequence, the path reconstruction is performed on the adjacent interference points, the connection is performed by the connectivity principle of adjacent points in the pixel space, and each closed path is aggregated according to the topological relationship to generate a slag inclusion boundary path set.
[0026] As a further aspect of the present invention, the principal stress direction threshold is determined by statistically analyzing the angle difference between the principal stress direction and the gray-scale gradient direction of all pixels in the image structure mapping image, constructing a frequency distribution curve of the angle difference, and extracting the inflection point position of the slope of the curve.
[0027] As a further aspect of the present invention, the specific steps of S4 are as follows:
[0028] S401: Based on the set of slag inclusion boundary paths, extract the pixel gray value sequence of the corresponding path in the image, calculate the mean change amplitude of the gray value sequence corresponding to each path, and calculate the overall fluctuation density according to the frequency of abrupt change points in the change amplitude to obtain the gray value change trend characteristics.
[0029] S402: Call the coordinate position corresponding to the grayscale change trend feature, extract the continuous change value of the principal stress direction at the same position, filter the principal stress point marker corresponding area whose principal stress change is continuously greater than the direction disturbance reference value, and obtain the principal stress disturbance area set;
[0030] S403: Based on the regions where coordinates overlap between the set of principal stress disturbance regions and the grayscale change trend features, extract the set of overlapping position points and generate a corresponding marker mask layer in the image pixel space, and fuse the mask layer with the original image to establish a visual region map of slag inclusion defects.
[0031] The directional disturbance reference value is set by the time angle increment in the continuous change sequence of the principal stress direction.
[0032] As a further aspect of the present invention, the specific steps of S5 are as follows:
[0033] S501: Based on the visible area map of the inclusion defect, extract the pixel position sequence covered by the extended path in the image, obtain the corresponding principal stress direction value and texture direction, calculate the angle between the two, filter the path segments whose angle value does not reach the principal stress texture threshold, and generate a principal stress texture direction deviation path group.
[0034] S502: Call the principal stress texture direction deviation path group, calculate the derivative change of the gray value mean of continuous pixels and extract the position of the change abruptly, determine whether the interval of the principal stress direction abruptly in the corresponding path is continuous, remove the path segments with gray value breaks or direction abruptly, and obtain a continuous texture path set.
[0035] S503: Based on the continuous texture path set, redraw the path in the image coordinate grid, draw the path mask according to the pixel connectivity, aggregate all path masks, and superimpose them onto the original image channel to generate a binary highlight display image, and obtain the slag inclusion defect penetration path recognition image.
[0036] The principal stress texture threshold is set by extracting the angle between the principal stress direction and the image texture direction at all locations along the extension path.
[0037] Compared with the prior art, the advantages and positive effects of the present invention are as follows:
[0038] In this invention, a stress disturbance location map of the journal root and crank fillet region is constructed using continuous time-point data of the principal stress field. A principal stress direction angle difference determination method is introduced, enabling early identification of potential torsional disturbance regions during cooling, thus compensating for the lack of thermal stress evolution dimensions in traditional image information acquisition methods. After mapping this stress information to the image space via affine transformation, the angle relationship between the gray-level gradient direction and the stress direction is fused to further perform responsive analysis of the image structure, enabling image processing to go beyond the visual level and possess the ability to interpret structural stress semantics. Based on this, through the coupled analysis of principal stress direction and cooling deformation, the curvature change rate of the deformation is extracted and the continuous deformation path is tracked, achieving a high degree of fitting recognition of inclusion boundary paths, overcoming the problem of traditional contour extraction being greatly affected by noise and illumination. Combining the gray-level mean gradient and abrupt change frequency to determine the gray-level decay trend, and introducing the continuous disturbance trend of principal stress as a judgment criterion, a multi-dimensional cross-validation inclusion region marking method is formed, improving the accurate identification capability of the actual existence of defects and the boundaries of visible areas. The overall logic starts with stress evolution analysis, integrates image grayscale structure changes and physical deformation characteristics, and runs through each stage of stress disturbance recognition, image response mapping, deformation tracking and boundary annotation. This enables the detection of inclusion defects to shift from static image analysis to understanding structural evolution, thereby enhancing the perception and recognition of complex casting defects. Attached Figure Description
[0039] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0040] Figure 1 This is a schematic diagram of the steps of the present invention;
[0041] Figure 2 This is a detailed schematic diagram of S1 of the present invention;
[0042] Figure 3 This is a detailed schematic diagram of S2 of the present invention;
[0043] Figure 4 This is a detailed schematic diagram of S3 of the present invention;
[0044] Figure 5 This is a detailed schematic diagram of S4 of the present invention;
[0045] Figure 6 This is a detailed schematic diagram of S5 of the present invention. Detailed Implementation
[0046] The technical solution of the present invention will now be described with reference to the accompanying drawings.
[0047] In embodiments of the present invention, words such as "exemplarily," "for example," etc., are used to indicate that something is an example, illustration, or description. Any embodiment or design described as "exemplary" in the present invention should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of the word "exemplary" is intended to present the concept in a concrete manner. Furthermore, in embodiments of the present invention, the meaning expressed by "and / or" can be both, or either one.
[0048] In the embodiments of this invention, the terms "image" and "picture" may sometimes be used interchangeably. It should be noted that, without emphasizing the distinction between them, they convey the same meaning. Similarly, the terms "of," "corresponding (relevant)," and "corresponding" may sometimes be used interchangeably. It should be noted that, without emphasizing the distinction between them, they convey the same meaning.
[0049] In this embodiment of the invention, sometimes a subscript such as W1 may be written in a non-subscript form such as W1. When the difference is not emphasized, the meaning they express is the same.
[0050] To make the technical problems, technical solutions and advantages of the present invention clearer, a detailed description will be given below in conjunction with the accompanying drawings and specific embodiments.
[0051] Please see Figure 1 This invention provides a visual inspection method for inclusion defects in the crankshaft casting process, comprising the following steps:
[0052] S1: Obtain principal stress field data of journal root and crank fillet during crankshaft cooling stage using finite element method, calculate principal stress direction angle difference at continuous time points to identify principal stress mutation points, mark areas exceeding the direction angle threshold as torsional disturbance areas, and construct stress disturbance location map;
[0053] S2: Map the stress disturbance location map to the image coordinate grid through affine transformation, obtain the gray-level gradient direction and principal stress direction of the corresponding image region and calculate the angle difference to generate an image structure mapping map;
[0054] S3: Based on the image structure mapping, filter pixels with an angle difference exceeding the threshold of the principal stress direction as stress interference points, obtain the principal stress direction and crankshaft cooling deformation corresponding to the stress interference points, calculate the curvature change rate of the deformation, identify continuous deformation regions and connect them to the path, and output the slag inclusion boundary path set.
[0055] S4: Extract the corresponding image grayscale sequence based on the slag inclusion boundary path set, analyze the grayscale mean gradient and the frequency of abrupt change points to determine the grayscale decay trend, combine the corresponding principal stress data to determine whether there is a continuous disturbance trend of principal stress, mark the areas where both exist at the same time, and generate a visual area map of slag inclusion defects.
[0056] S5: Extract the corresponding image grayscale sequence based on the slag inclusion boundary path set, analyze the grayscale mean gradient and the frequency of abrupt change points to determine the grayscale decay trend, combine the corresponding principal stress data to determine whether there is a continuous disturbance trend of principal stress, mark the areas where both exist simultaneously, and generate a visual area map of slag inclusion defects.
[0057] The stress disturbance location map includes the distribution of abrupt change points in the principal stress direction, the region where the direction angle exceeds the limit, and the coordinate set of the torsional disturbance boundary. The image structure mapping map includes the image gray-level gradient direction field, the principal stress direction mapping field, and the distribution map of the direction angle difference. The inclusion boundary path set specifically includes the stress disturbance edge trajectory, the gray-level abnormal path, and the path continuity marker. The inclusion defect visible area map includes the gray-level attenuation area layer, the disturbance trend area marker, and the multi-dimensional feature fusion and overlay image. The inclusion defect penetration path identification map specifically includes the principal stress texture direction deviation path, the gray-level continuous path, and the pixel trajectory set of the inclusion penetration path.
[0058] Please see Figure 2 The specific steps of S1 are as follows:
[0059] S101: The principal stress field data at the journal root and crank fillet of the crankshaft cooling stage are obtained by finite element method, and the principal stress tensor at each moment in the stress field data is extracted in the coordinate system to obtain the principal stress direction angle sequence between consecutive time points.
[0060] The thermo-mechanical coupling behavior of a 42CrMo steel crankshaft during quenching and cooling was simulated using finite element analysis software. Mesh refinement was performed in region A at the journal root and region B at the crank fillet, with an average size of 0.5 mm. The initial cooling temperature was set to 850°C, the cooling medium to be quenching oil at 60°C, and the convective heat transfer coefficient to be 1500 watts per square kelvin. The total simulation duration was 30 seconds, with a time step of 0.1 seconds. After the analysis, stress data for node N101 in region A was extracted from the results file. Taking a time point t equal to 1.0 seconds as an example, the six stress components in the Cartesian coordinate system were obtained: normal stress in the x-direction is 350.5 MPa, normal stress in the y-direction is 210.8 MPa, normal stress in the z-direction is 150.2 MPa, shear stress in the xy plane is 80.4 MPa, shear stress in the yz plane is 30.1 MPa, and shear stress in the zx plane is 50.6 MPa. The components form a 3x3 symmetric stress tensor. Solving for the eigenvalues of this tensor yields a maximum principal stress of 395.7 MPa. The eigenvectors corresponding to the principal stress values are the principal direction vectors, which, after normalization, have components of (0.854, 0.491, 0.178). The angle between the projection of the principal direction vector onto the OXY plane and the positive X-axis is calculated using the arctangent of the ratio of the y-component to the x-component, resulting in 29.88 degrees. Similarly, at t = 1.1 seconds, the principal direction angle at node N101 is calculated to be 30.54 degrees. At t = 1.2 seconds, due to the martensitic transformation, the stress state changes, and the calculated principal direction vector becomes (-0.351, -0.912, 0.213), corresponding to a principal direction angle of 248.95 degrees. This process is applied to all nodes in regions A and B, covering all 300 time steps, thereby generating a continuous time-point principal stress direction angle sequence containing 300 angle values for each node.
[0061] S102: Based on the principal stress direction angle sequence value, extract the principal stress direction angle change between adjacent time points, compare it with the set direction angle threshold, filter the time point position index that exceeds the direction angle threshold and map it to the stress field spatial position to generate a principal stress change position index set.
[0062] Based on the generated principal stress direction angle sequence for each node, the changes in principal stress direction angles between adjacent time points are extracted. Taking the angle sequence {29.88 degrees, 30.54 degrees, 248.95 degrees, 249.15 degrees} of node N101 from 1.0 to 1.4 seconds as an example, the absolute value of the angle change between adjacent time points is calculated. At t = 1.1 seconds, the angle change is the absolute value of the difference between 30.54 degrees and 29.88 degrees, i.e., 0.66 degrees. At t = 1.2 seconds, the angle change is the absolute value of the difference between 248.95 degrees and 30.54 degrees, i.e., 218.41 degrees. At t = 1.3 seconds, the angle change is the absolute value of the difference between 249.15 degrees and 248.95 degrees, i.e., 0.20 degrees. Subsequently, the calculated angle change values are compared with the set direction angle threshold. The threshold is set with reference to the quenching physical simulation experiment for 42CrMo steel. Experimental results show that in the non-phase transformation stage, the maximum angular change in the principal stress direction caused by thermal stress is 6.2 degrees; while in the martensitic phase transformation stage, the angular changes all exceed 200 degrees. To effectively distinguish between these two states, the directional angle threshold is set to 50 degrees. The angular change sequence of node N101 is compared with the 50-degree threshold: 0.66 degrees is less than 50 degrees; 218.41 degrees exceeds 50 degrees; 0.20 degrees is less than 50 degrees. The screening results determine that the time point t equals 1.2 seconds is the point of abrupt change in the principal stress direction. The node number N101 is associated with the time step index 12 where the abrupt change occurs, forming a tuple (N101, 12). This screening process is applied to all relevant nodes, traversing all time steps, generating a set of indices containing all nodes where abrupt changes in the principal stress direction occur and the corresponding time point principal stress abrupt change location.
[0063] S103: Call the principal stress mutation location index set, extract the principal stress direction change vector of all mutation time points in the corresponding region in the original principal stress field data, and perform spatial clustering to form the boundary of the disturbance region to obtain the stress disturbance location map.
[0064] The generated principal stress mutation location index set is used to extract the principal stress direction change vector at the moment of mutation from the acquired original principal stress field data. For each tuple in the index set, such as (N101, 12), the maximum principal stress direction vector of the node at the mutation time t = 1.2 seconds and the previous time point t = 1.1 seconds is extracted. The principal direction vector of node N101 at t = 1.2 seconds is (-0.351, -0.912, 0.213), and at t = 1.1 seconds it is (0.849, 0.501, 0.175). By subtracting the components of the latter from the corresponding components of the former, the principal stress direction change vector is calculated as (-1.200, -1.413, 0.038). This operation is performed on all elements in the index set to obtain a dataset containing the locations, times, and corresponding direction change vectors of all mutation points. Next, a density-based spatial clustering algorithm is applied to the locations of the nodes where mutations occurred to identify spatially continuous perturbation regions. The algorithm's neighborhood radius is set to 1.5 mm, three times the average model size of 0.5 mm. The minimum number of neighborhood points required to form a high-density region is set to 4. The clustering process begins with an unvisited mutation node and searches for other mutation nodes within its 1.5 mm radius. If the total number of nodes in its neighborhood is not less than 4, the node is marked as a core point and forms a new cluster with the nodes in its neighborhood, labeled as Cluster 1. This process is recursively performed on newly added nodes within the cluster until the cluster can no longer expand. Nodes that do not meet the density conditions are marked as noise points. After clustering, spatially adjacent nodes with the same cluster label constitute a stress perturbation region. Finally, on the 3D model of the crankshaft, node regions belonging to different clusters are highlighted with different colors to generate a stress perturbation location map.
[0065] Please see Figure 3 The specific steps of S2 are as follows:
[0066] S201: Based on the stress disturbance location map, extract the physical coordinate values of multiple boundary points in the disturbance region, apply a two-dimensional affine transformation parameter set, map them to the corresponding positions in the image coordinate grid, and generate an image spatial mapping region group;
[0067] Extract the boundary points of the perturbation region of cluster 1 within the stress perturbation location map. Taking one boundary point P1 as an example, its physical coordinates in the crankshaft model coordinate system are (50.2, 120.5, -30.1), in millimeters. To map it to a two-dimensional image space, coordinate dimensionality reduction is first performed, taking its projected coordinates P1 on the XY plane, i.e., (50.2, 120.5). Set the size of the target image coordinate grid to 512*512 pixels. To completely map the physical coordinates of all boundary points of "cluster 1" to a specific area of the image grid, such as a 200*200 pixel area, two-dimensional affine transformation parameters need to be set. First, determine the bounding box of the physical coordinates of "cluster 1", with the X coordinate range being 50.0, 70.0 mm and the Y coordinate range being 120.0, 140.0 mm. Calculate the scaling factor. The horizontal scaling factor is the width of the target image area divided by the width of the physical area, i.e., 200 pixels / (70.0 - 50.0) mm = 10 pixels / mm; the vertical scaling factor is similarly 200 pixels / (140.0 - 120.0) mm = 10 pixels / mm. Next, set the translation amount to map the physical coordinate origin (50.0, 120.0) to the (100, 100) pixel position in the image coordinate grid. According to the transformation formula: image coordinates = scaling factor × (physical coordinates - physical coordinate origin) + image coordinate origin, transform point P1 (50.2, 120.5). Its image X coordinate is 10 × (50.2 - 50.0) + 100 = 102; its image Y coordinate is 10 × (120.5 - 120.0) + 100 = 105. Therefore, physical point P1 is mapped to the (102, 105) position in the image coordinate grid. Repeat this process for all boundary points of "Cluster 1" and other perturbation regions to generate multiple independent image spatial mapping regions, which together constitute an image spatial mapping region group.
[0068] S202: Call each image region in the image space mapping region group and collect grayscale image information. At the same time, extract the image intensity change and calculate the grayscale derivatives in the horizontal and vertical directions. Calculate the gradient direction angle of each point in the image based on the derivative ratio.
[0069] The generated image spatial mapping region group is used, and this region corresponds to "Cluster 1". The grayscale information of the actual crankshaft metallographic image corresponding to this region is collected. This metallographic image has been registered and aligned with the physical coordinate system of the crankshaft model. Taking the mapping point (102, 105) and its 3x3 neighborhood in S201 as an example, the collected 8-bit grayscale value (range 0-255) matrix is: first row {100, 105, 200}, second row {102, 110, 205}, third row {104, 115, 210}. To calculate the gradient direction at the center pixel (102, 105), the image intensity change is first extracted. This is done by calculating the grayscale derivatives of the center point in the horizontal and vertical directions. The calculation of the horizontal grayscale derivative is achieved by subtracting the grayscale value of the left pixel from the grayscale value of the pixel to its right, i.e. The vertical grayscale derivative is calculated by subtracting the grayscale value of the pixel above it from the grayscale value of the pixel below it. Then, the gradient direction angle at that point is calculated based on the ratio of these two derivatives. This angle is calculated using the arctangent function of the ratio of the vertical derivative to the horizontal derivative. Specifically, it is calculated to be 5.54 degrees. The angle represents the direction in which the grayscale value of the pixel changes the fastest. The entire process of grayscale information acquisition, horizontal and vertical grayscale derivative calculation, and gradient direction angle calculation is repeated for each pixel within the "Cluster 1" mapping region.
[0070] S203: Calculate the angle difference between the gradient direction angle and the principal stress direction angle at the corresponding position in the original coordinates of the perturbation region, and assign the value to the pixel point in the corresponding image coordinate grid to obtain the image structure mapping map.
[0071] Based on the calculated gradient direction angles of each pixel and the principal stress direction angles corresponding to the original physical coordinates of the perturbation region, the angle difference between the two is calculated. Taking the aforementioned image coordinate point (102, 105) as an example, it corresponds to the physical coordinate point P1 (50.2, 120.5, -30.1). The principal stress direction data of P1 in the finite element model is obtained through spatial interpolation or finding the nearest node. The principal stress direction angle of the node N305 closest to P1 at the moment of principal stress abrupt change (t=1.2 seconds) is found to be 35.0 degrees. The gradient direction angle of the pixel, calculated in S202, is 5.54 degrees. The angle difference between these two angles is calculated, and its absolute value is taken. The difference is used as a new value and assigned to the pixel at position (102, 105) in the image coordinate grid. This process is applied to all pixels within the image spatial mapping region: for each pixel, its corresponding physical coordinates are found, the principal stress direction angle at the abrupt change is retrieved, and then the difference is calculated with the pixel's image gradient direction angle. All calculated angle differences form a new two-dimensional array with the same dimensions as the image coordinate grid. Visualizing this two-dimensional array yields the image structure mapping. The brightness or color value of each pixel in the image represents the degree of consistency between the location's physical microstructure orientation and the simulated predicted principal stress direction.
[0072] Please see Figure 4 The specific steps of S3 are as follows:
[0073] S301: Based on the image structure mapping, extract the angle difference values corresponding to all pixels, compare them point by point with the set principal stress direction threshold, filter out pixels whose angle difference exceeds the principal stress direction threshold, extract the corresponding image coordinate positions, and generate a set of stress interference pixels.
[0074] The angle difference value is extracted by traversing each pixel in the generated image structure map. Taking pixel (150, 180) as an example, the angle difference value extracted from the image is 45.8 degrees. This value is compared with the preset principal stress direction threshold. The threshold is set based on the comparative analysis of metallographic experiments and finite element simulations. Multiple groups of 42CrMo steel samples containing artificial non-metallic inclusions and defect-free control samples were prepared. Metallographic microstructure was observed on all samples, and finite element simulations were performed on the same areas. The calculated average angle difference between the simulated principal stress direction and the actual grain orientation in the defect-free area was 8.5 degrees, with a maximum value not exceeding 15 degrees. At the inclusion boundary, due to the abrupt change in material properties leading to stress field distortion, the average angle difference was 48.2 degrees, with a minimum value not less than 40 degrees. To effectively distinguish between the normal microstructure area and the area disturbed by inclusions, the principal stress direction threshold was set to 30 degrees. This value is twice the maximum angle difference of 15 degrees in the defect-free area, and has a sufficient distinguishing interval between it and the minimum angle difference of 40 degrees at the inclusion boundary. The angle difference of 45.8 degrees at pixel (150, 180) is compared with the threshold of 30 degrees. Since 45.8 degrees is greater than 30 degrees, this pixel is determined to be a stress interference point. The image coordinates (150, 180) are recorded. Conversely, for the aforementioned pixel (102, 105), the angle difference is 29.46 degrees, which is less than 30 degrees, so it is not filtered. This comparison and filtering process is repeated for all pixels in the image structure map. The coordinates of all pixels with angle differences exceeding 30 degrees are collected to form a stress interference pixel set.
[0075] S302: Call the set of stress interference pixels, match the principal stress direction information at the corresponding position, and obtain the deformation at the same position during the crankshaft cooling process. Perform first derivative operation on the deformation at adjacent interference points, calculate the rate of change of multiple interference point positions, and obtain the deformation curvature change rate sequence.
[0076] The generated set of stress interference pixels is invoked. For each pixel in the set, the image coordinates are first mapped back to the physical coordinates of the crankshaft model using the affine transformation relationship established in S201. Taking stress interference pixel A (150, 180) and its adjacent interference pixel B (151, 180) as examples, they are mapped to physical coordinates PA (65.0, 138.0) and PB (65.1, 138.0) respectively, in millimeters. Then, the total equivalent plastic deformation at these two physical locations at the end of the cooling process is extracted from the finite element analysis result database in S101. The deformation at PA is found to be 0.008, and the deformation at PB is 0.012. Next, the first derivative of the deformation at these two adjacent interference points is calculated, i.e., the rate of change of the deformation relative to the spatial position is calculated. This calculation is achieved by dividing the difference in deformation between the two points by the physical distance between them. The difference in deformation is 0.012 - 0.008 = 0.004. The physical distance between the two points is 0.1 mm. The rate of change is 0.004 divided by 0.1, resulting in 0.04. This dimensionless value is the rate of change of curvature of the deformation at the location. For all adjacent pairs of interfering points in the pixel set, this process is repeated along the horizontal and vertical directions, calculating one or more rate of change values for each interfering point. All calculated rate of change values constitute a sequence of rates of change of curvature of the deformation.
[0077] S303: Based on the positional distribution of the continuous fluctuation segment of the rate of change in the deformation curvature change rate sequence, the path reconstruction is performed on the adjacent interference points. The connection is performed by the connectivity principle of adjacent points in the pixel space, and each closed path is aggregated according to the topological relationship to generate the slag inclusion boundary path set.
[0078] Based on the generated deformation curvature change rate sequence, continuous fluctuations in the rate of change are identified. A change rate value is considered to be drastic when it exceeds a preset deformation change rate threshold. The threshold is set based on gradient analysis of the normal plastic deformation zone and the defect zone. In the finite element model, in regions far from inclusions, the gradient value (i.e., change rate) of the equivalent plastic strain does not exceed 0.015. However, at the interface between inclusions and the matrix, due to deformation inconsistency, the gradient value is higher than 0.03. Therefore, the deformation change rate threshold is set to 0.03. In the aforementioned calculation, the change rate between point A and point B is 0.04, which is greater than 0.03, indicating drastic deformation at this point. Accordingly, path reconstruction is performed on adjacent interference points with change rates exceeding 0.03. Starting from an interference point A (150, 180), a search is conducted to determine if there are any pixels in the neighborhood that are also interference points and have a deformation change rate exceeding 0.03 with respect to point A. If a point B (151, 180) that satisfies the conditions is found, then A is connected to B. Next, using B as the current point, the search continues in its neighborhood for the next point C that satisfies the conditions, and this connection is made. This process continues until the path can no longer be extended or returns to the starting point, forming a closed path. The pixels in each closed path are topologically sorted according to their connection order, forming an ordered list of coordinates. All ordered lists of coordinates for identified closed paths are aggregated to generate the slag inclusion boundary path set.
[0079] Please see Figure 5 The specific steps of S4 are as follows:
[0080] S401: Based on the set of slag inclusion boundary paths, extract the pixel gray value sequence of the corresponding path in the image, calculate the mean change amplitude of the gray value sequence corresponding to each path, and calculate the overall fluctuation density based on the frequency of abrupt change points in the change amplitude to obtain the gray value change trend characteristics.
[0081] Based on the generated set of inclusion boundary paths, grayscale analysis is performed on each path. Taking "Path 1" in the path set as an example, the path consists of an ordered list of 120 pixel coordinates, starting at coordinates (150, 180). First, in the original metallographic grayscale image, the corresponding 8-bit grayscale values are extracted point by point according to the coordinate order of "Path 1," forming a grayscale value sequence of length 120. For example, the first 10 values of the sequence are: {85, 88, 86, 150, 155, 148, 92, 90, 89, 87}. Next, the mean change of the grayscale sequence is calculated. A sliding window with a width of 5 pixels is used for the calculation. The window starts from the first point of the sequence, and the average of the 5 grayscale values within the window is calculated. The mean of the first window {85, 88, 86, 150, 155} is 112.8. The window then slides back one pixel, and the mean of the second window {88, 86, 150, 155, 148} is 125.4. The absolute value of the difference between the means of these two adjacent windows is calculated, i.e., |125.4 - 112.8| = 12.6. This process is repeated along the entire sequence, generating a sequence of mean variation amplitudes. Subsequently, the overall fluctuation density is calculated based on the frequency of abrupt changes in the mean variation amplitude sequence. A point is considered an abrupt change point if the mean variation amplitude exceeds a preset grayscale variation threshold. The threshold is set based on statistical analysis of a large number of metallographic images. In a uniform martensitic matrix region, the 95th percentile of the mean variation amplitude of the grayscale sequence extracted along any path is less than 5.0 for a 5-pixel window. At the interface between non-metallic inclusions and the matrix, it is greater than 20.0. To reliably identify the interface, the grayscale variation threshold is set to 15.0. The calculated mean change amplitude of 12.6 is compared with the threshold of 15.0. Since 12.6 is less than 15.0, the point is not counted as a mutation point. In subsequent calculations, a mean change amplitude of 25.3 at a certain location is counted as a mutation point. The mean change amplitude sequence corresponding to the entire "Path 1" is traversed, and the number of all points exceeding 15.0 is counted, set to 8. Finally, the overall fluctuation density is calculated, which is the total number of mutation points divided by the total path length. For "Path 1", its fluctuation density is 8 divided by 120, resulting in 0.067 (unit: points / pixel). This value is the grayscale change trend feature of "Path 1". This process is repeated for all paths in the slag inclusion boundary path set to generate a grayscale change trend feature value for each path.
[0082] S402: Call the coordinate position corresponding to the grayscale change trend feature, extract the continuous change value of the principal stress direction at the same position, filter the principal stress point marking corresponding area where the principal stress change is continuously greater than the direction disturbance reference value, and obtain the principal stress disturbance area set;
[0083] The grayscale change trend characteristics and corresponding coordinate positions are calculated during the call. Taking "Path 1" as an example, the fluctuation density is 0.067, which exceeds the preset density benchmark of 0.05 used to judge significant changes. Therefore, all 120 pixel coordinates of "Path 1" are extracted. For each coordinate, it is mapped back to the physical coordinates in the finite element model through the affine transformation relationship of S201, and the continuous change sequence of principal stress direction angles of the physical position during the entire cooling process (0 to 30 seconds, a total of 300 time steps) is retrieved from the analysis results of S101. Taking the point (150, 180) on the path as an example, the principal stress direction angle sequence is {25.1°, 25.3°, ..., 29.8°, 33.5°, 38.0°, 41.2°, ..., 45.0°}. Next, points where the principal stress change is continuously greater than the direction disturbance benchmark value are selected. The process for setting the directional perturbation baseline values is as follows: First, a stable region far from any stress concentration and phase transition front is selected in the finite element model, and the complete principal stress direction angle time series of 100 nodes is extracted. For each series, the angle increment between adjacent time steps is calculated, i.e., the time angle increment. A total of 29,900 angle increment values generated by these 100 nodes in all 300 time steps are counted and their distribution is analyzed.
[0084] Table 1. Statistics on Time Angle Increment in Stable Regions
[0085]
[0086] As shown in Table 1, in the stable region, the time angle increment is less than 2.45 degrees 99% of the time. To reliably identify anomalous disturbances caused by local non-uniform deformation, and to filter out normal fluctuations in numerical calculations, the reference value for directional disturbance is set to 2.5 degrees.
[0087] The angle increments of adjacent time steps in the angle sequence of point (150, 180) are compared with 2.5 degrees. For example, within a certain time period, the angle increments are {..., 0.2°, 4.5°, 3.7°, 4.5°, 3.2°, 0.8°, ...}. Among these, the angle increments of four consecutive time steps (4.5°, 3.7°, 4.5°, 3.2°) are all greater than 2.5 degrees. A duration criterion is set: the number of time steps exceeding the baseline value must reach three or more. The four consecutive time steps here meet this criterion. Therefore, point (150, 180) is marked as a persistent perturbation point. This process is repeated for all points on "Path 1," and the coordinates of all marked persistent perturbation points are collected to form a principal stress perturbation region. The same analysis is performed on all paths with significant grayscale fluctuations; all the formed principal stress perturbation regions together constitute the principal stress perturbation region set.
[0088] S403: Based on the coordinate overlap between the principal stress disturbance region set and the grayscale change trend characteristics, extract the set of overlapping position points and generate a corresponding marker mask layer in the image pixel space. Then, fuse the mask layer with the original image to establish a visual region map of slag inclusion defects.
[0089] The reference value for directional disturbance is set by the time angle increment in the continuous sequence of statistical principal stress direction changes;
[0090] Based on the generated principal stress disturbance region set and the generated grayscale change trend features (and their associated original path coordinates), regions where the two overlap in coordinates are extracted. Specifically, the intersection operation is performed on all pixel coordinates in the principal stress disturbance region set and the pixel coordinates of all paths with a grayscale fluctuation density exceeding 0.05. For example, the point (150, 180) marked in S402 is also a point on "Path 1," and the fluctuation density of "Path 1" is 0.067 (greater than 0.05), therefore point (150, 180) is determined to be an overlapping location. All pixel coordinates obtained through this intersection operation are aggregated to form the overlapping location point set. Next, a corresponding marked mask layer is generated in the image pixel space. A four-channel (RGBA) image layer with the same size as the original metallographic image (e.g., 512x512 pixels) and initially set to fully transparent is created. All pixels are initially set to (0, 0, 0, 0), where the last component represents complete transparency. Then, each coordinate in the overlapping location point set is traversed. For coordinates (150, 180), the pixel value at the corresponding position on the mask layer is modified. It is set to a semi-transparent red, i.e., (255, 0, 0, 128), where 128 represents 50% opacity. This process is repeated for all overlapping locations, generating a mask layer with a semi-transparent red marker in the specific area. Finally, this generated mask layer is fused with the original metallographic grayscale image. The fusion process uses the alpha mixing algorithm. For each pixel location in the image, the displayed color is calculated by weighting the color of the original image and the color of the mask layer according to the transparency of the mask layer. At overlapping locations, since the mask layer is semi-transparent red, the displayed pixels will be the effect of the original grayscale image overlaid with a red filter. At other locations, since the mask layer is fully transparent, the pixels of the original image will remain unchanged. Through this fusion operation, a visual map of the inclusion defect area is established.
[0091] Please see Figure 6 The specific steps of S5 are as follows:
[0092] S501: Based on the visible area map of inclusion defects, extract the pixel position sequence covered by the extended path in the image, obtain the corresponding principal stress direction value and texture direction, calculate the angle between the two, filter the path segments whose angle value does not reach the principal stress texture threshold, and generate the principal stress texture direction deviation path group.
[0093] Based on the generated visual map of inclusion defects, all extended paths marked with semi-transparent red are extracted. Taking one extended path, "Path A," consisting of 150 pixels, as an example, the sequence of pixel positions covered by the path is extracted. For each pixel in the sequence, the following operations are performed: First, the principal stress direction value corresponding to the physical location in the finite element model is obtained; second, the texture direction in the metallographic image is obtained. For example, the coordinates of the 10th pixel P10 on the path are (210, 235). Querying the result data of S101, the corresponding principal stress direction value is found to be 55.3 degrees. Simultaneously, according to the calculation method of S202, the image gradient direction of the pixel, i.e., the texture direction, is obtained, which is 48.1 degrees. The angle between these two, i.e., the absolute value of the difference, is calculated: |55.3 - 48.1| = 7.2 degrees. This calculation is applied to all 150 pixels on Path A, generating a sequence of angle values of length 150.
[0094] Next, the sequence of included angle values is compared with the principal stress texture threshold to filter out path segments whose included angle values do not reach the threshold. The process of setting the principal stress texture threshold is as follows: First, on all marked extension paths in the visible area map of the inclusion defect, the included angle values between the principal stress direction and the image texture direction at a total of 5000 locations are extracted. Statistical analysis is then performed on the included angle values.
[0095] Table 2. Statistics of the directional angle values on the extension path.
[0096]
[0097] As shown in Table 2, the included angle values are widely distributed. Regions with lower included angle values, specifically below the 25th quantile of 9.2 degrees, indicate a high degree of consistency between the principal stress direction and the microstructure texture direction. This is the physical basis for the ease with which cracks propagate along specific crystal planes or phase boundaries. To screen for potential penetration paths, the principal stress texture threshold is set to 10.0 degrees, slightly higher than the 25th quantile. The included angle value sequence of path A is compared with the 10.0-degree threshold. Taking point P10 as an example, the included angle value of 7.2 degrees does not reach 10.0 degrees. Setting the included angle values of pixels 8 to 25 on path A to be less than 10.0 degrees, while the included angle values of pixels 7 and 26 are greater than 10.0 degrees, the continuous segment consisting of pixels 8 to 25 is selected as a principal stress texture direction deviation path segment. This process is performed on all extended paths, and all selected path segments collectively generate a principal stress texture direction deviation path group.
[0098] S502: Call the principal stress texture direction deviation path group, calculate the derivative change of the gray-scale mean of continuous pixels and extract the position of the change abruptly, determine whether the interval of the principal stress direction abruptly in the corresponding path is continuous, remove the path segments with gray-scale breaks or direction abruptly, and obtain the continuous texture path set.
[0099] The generated principal stress texture direction deviation path group is invoked. For each path segment within the group, a dual check of grayscale continuity and principal stress direction continuity is performed. Taking a path segment B containing 30 pixels as an example, the derivative change of the mean grayscale value of consecutive pixels is first calculated. A sliding window with a width of 3 pixels moves along the path segment, and the average grayscale value within the window is calculated. For example, the window {P4, P5, P6} centered on the 5th point on path segment B has grayscale values {90, 92, 95} and a mean of 92.3. The window {P5, P6, P7} centered on the 6th point has grayscale values {92, 95, 160} and a mean of 115.7. The difference between the mean values of these two adjacent windows is calculated, i.e., 115.7 - 92.3 = 23.4. This derivative change is compared with a preset grayscale breakage threshold of 20.0. The threshold is set based on the statistical analysis of grayscale gradients within continuous grains and at grain boundaries and inclusion boundaries in metallographic images. 20.0 is the boundary value distinguishing between smooth transitions within grains and abrupt changes across boundaries. Since 23.4 is greater than 20.0, a grayscale abrupt change, i.e., a grayscale break, is determined to exist between pixels P6 and P7. Simultaneously, the continuity of the intervals between abrupt changes in principal stress directions within this path segment is assessed. The principal stress direction value sequence of all pixels on path segment B is extracted. For example, the principal stress direction values for points 4 to 7 are {40.1°, 42.5°, 44.8°, 65.2°}. The change in direction between adjacent points is calculated: 2.4 degrees for points 4 to 5, 2.3 degrees for points 5 to 6, and 20.4 degrees for points 6 to 7. The change is compared to the direction abrupt change threshold of 5.0 degrees. The threshold is set to twice the directional disturbance reference value of 2.5 degrees in S402 to identify severe spatial directional torsion. The first two changes were both less than 5.0 degrees, while the change from point 6 to point 7, at 20.4 degrees, far exceeded 5.0 degrees, indicating a sudden change in principal stress direction. Finally, unqualified path segments were removed based on the judgment results. For "path segment B," because it was detected with both grayscale breakage and abrupt change in direction between points 6 and 7, the path segment was removed from the set. Only path segments that did not exhibit grayscale breakage throughout their entire length and whose principal stress direction changes between any adjacent points were less than 5.0 degrees were retained. All retained path segments together formed a continuous texture path set.
[0100] S503: Based on the continuous texture path set, redraw the path in the image coordinate grid, draw the path mask according to the pixel connectivity, aggregate all path masks, and superimpose them onto the original image channel to generate a binary highlight display image, and obtain the slag inclusion defect penetration path recognition image.
[0101] The principal stress texture threshold is set by extracting the angle between the principal stress direction and the image texture direction at all locations along the extension path.
[0102] Based on the obtained set of continuous texture paths, the paths are redrawn in the image coordinate grid. First, a blank image with the exact same size as the original metallographic image and all pixel values of 0 (black) is created as the canvas for the path mask. Then, each path in the set of continuous texture paths is traversed. Taking "Path C" as an example, the path consists of a series of continuous pixel coordinates {(301, 350), (302, 351), (303, 351), ...}. On the path mask canvas, the value of the pixel corresponding to the coordinates is changed from 0 to 255 (white). To ensure the visual continuity of the path, the octet principle is used to connect adjacent pixels. For example, between points (301, 350) and (302, 351), not only are these two pixels set to white, but all pixels on the shortest octet path connecting them (in this case, the two points themselves) are also set to white. This process is performed along the entire "Path C", thus drawing a clear white path on the mask.
[0103] This drawing process is applied to all paths in the continuous texture path set. All paths are drawn on the same path mask canvas. After this process is complete, the white traces of all the finally identified penetration paths are aggregated on the canvas, forming a complete path mask. The mask is a binary image, where white pixels (value 255) represent the identified inclusion defect penetration paths, and black pixels (value 0) represent the background. Finally, this path mask is superimposed on the original metallographic grayscale image channels to generate a binary highlight display image. The specific fusion process is as follows: Create a new three-channel color image. Iterate through each pixel coordinate (x, y) of the image. Query the pixel value of the path mask at (x, y). If the value is 255 (white), then write a preset highlight color value, such as bright green (0, 255, 0), at (x, y) in the new image. If the pixel value of the path mask is 0 (black), then the grayscale value of the original grayscale image at (x, y) is written to the (x, y) position of the new image, and copied to three channels, for example (G, G, G), where G is the original grayscale value. After this operation, the resulting image is the slag inclusion defect penetration path recognition map, in which all the identified penetration paths are clearly highlighted in bright green.
[0104] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A visual inspection method for inclusion defects in the crankshaft casting process, characterized in that, Includes the following steps: S1: Obtain principal stress field data of journal root and crank fillet during crankshaft cooling stage using finite element method, calculate principal stress direction angle difference at continuous time points to identify principal stress mutation points, mark areas exceeding the direction angle threshold as torsional disturbance areas, and construct stress disturbance location map; S2: Map the stress disturbance location map to the image coordinate grid through affine transformation, obtain the gray-level gradient direction and principal stress direction of the corresponding image region and calculate the angle difference to generate an image structure mapping map; S3: Based on the image structure mapping, filter pixels with an angle difference exceeding the threshold of the principal stress direction as stress interference points, obtain the principal stress direction and crankshaft cooling deformation corresponding to the stress interference points, calculate the curvature change rate of the deformation, identify continuous deformation regions and connect them to the path, and output the slag inclusion boundary path set. S4: Extract the corresponding image grayscale sequence based on the slag inclusion boundary path set, analyze the grayscale mean gradient and abrupt change frequency to determine the grayscale decay trend, combine with the corresponding principal stress data to determine whether there is a continuous principal stress disturbance trend, mark the areas where both exist simultaneously, and generate a visual area map of slag inclusion defects.
2. The visual inspection method for inclusion defects in the crankshaft casting process according to claim 1, characterized in that, The stress disturbance location map includes the distribution of abrupt change points in the principal stress direction, the region where the direction angle exceeds the limit, and the coordinate set of the torsional disturbance boundary. The image structure mapping map includes the image gray-level gradient direction field, the principal stress direction mapping field, and the distribution map of the direction angle difference. The inclusion boundary path set specifically includes the stress disturbance edge trajectory, the gray-level abnormal path, and the path continuity marker. The inclusion defect visible area map includes the gray-level attenuation area layer, the disturbance trend area marker, and the multi-dimensional feature fusion and overlay image.
3. The visual inspection method for inclusion defects in the crankshaft casting process according to claim 1, characterized in that, The specific steps of S1 are as follows: S101: The principal stress field data at the journal root and crank fillet of the crankshaft cooling stage are obtained by finite element method, and the principal stress tensor at each moment in the stress field data is extracted in the coordinate system to obtain the principal stress direction angle sequence between consecutive time points. S102: Based on the principal stress direction angle sequence value, extract the principal stress direction angle change between adjacent time points, compare it with the set direction angle threshold, filter the time point position index that exceeds the direction angle threshold and map it to the stress field spatial position to generate a principal stress change position index set. S103: Call the principal stress mutation location index set, extract the principal stress direction change vectors of all mutation time points in the corresponding region in the original principal stress field data, and perform spatial clustering to form the boundary of the disturbance region to obtain the stress disturbance location map.
4. The visual inspection method for inclusion defects in the crankshaft casting process according to claim 3, characterized in that, The directional angle threshold is set by extracting the frequency of the statistical distribution of the principal stress direction angle change values, dividing the fluctuation amplitude in the angle change sequence into intervals, and combining the frequency proportion of the fluctuation concentration area with the range of change gradient amplitude.
5. The visual inspection method for inclusion defects in the crankshaft casting process according to claim 1, characterized in that, The specific steps of S2 are as follows: S201: Based on the stress disturbance location map, extract the physical coordinate values of multiple boundary points in the disturbance region, apply a two-dimensional affine transformation parameter set, map them to the corresponding positions in the image coordinate grid, and generate an image spatial mapping region group. S202: Call each image region in the image space mapping region group and collect grayscale image information. At the same time, extract the image intensity change and calculate the grayscale derivatives in the horizontal and vertical directions. Calculate the gradient direction angle of each point in the image based on the derivative ratio. S203: Calculate the angle difference between the gradient direction angle and the principal stress direction angle at the corresponding position in the original coordinates of the disturbance region, and assign the value to the pixel point in the corresponding image coordinate grid to obtain the image structure mapping map.
6. The visual inspection method for inclusion defects in the crankshaft casting process according to claim 1, characterized in that, The specific steps for S3 are as follows: S301: Based on the image structure mapping, extract the angle difference values corresponding to all pixels, compare them point by point with the set principal stress direction threshold, filter out pixels whose angle difference exceeds the principal stress direction threshold, and extract the corresponding image coordinate positions to generate a set of stress interference pixels. S302: Call the set of stress interference pixels, match the principal stress direction information at the corresponding position, and obtain the deformation at the same position during the crankshaft cooling process. Perform first derivative operation on the deformation at adjacent interference points, calculate the rate of change of multiple interference point positions, and obtain the deformation curvature change rate sequence. S303: Based on the positional distribution of the continuous fluctuation segment of the rate of change in the deformation curvature change rate sequence, the path reconstruction is performed on the adjacent interference points, the connection is performed by the connectivity principle of adjacent points in the pixel space, and each closed path is aggregated according to the topological relationship to generate a slag inclusion boundary path set.
7. The visual inspection method for inclusion defects in the crankshaft casting process according to claim 6, characterized in that, The principal stress direction threshold is determined by statistically mapping the angle difference between the principal stress direction and the gray-level gradient direction of all pixels in the image structure map, constructing a frequency distribution curve of the angle difference, and extracting the inflection point position of the slope of the curve.
8. The visual inspection method for inclusion defects in the crankshaft casting process according to claim 1, characterized in that, The specific steps of S4 are as follows: S401: Based on the set of slag inclusion boundary paths, extract the pixel gray value sequence of the corresponding path in the image, calculate the mean change amplitude of the gray value sequence corresponding to each path, and calculate the overall fluctuation density according to the frequency of abrupt change points in the change amplitude to obtain the gray value change trend characteristics. S402: Call the coordinate position corresponding to the grayscale change trend feature, extract the continuous change value of the principal stress direction at the same position, filter the principal stress point marker corresponding area whose principal stress change is continuously greater than the direction disturbance reference value, and obtain the principal stress disturbance area set; S403: Based on the regions where coordinates overlap between the set of principal stress disturbance regions and the grayscale change trend features, extract the set of overlapping position points and generate a corresponding marker mask layer in the image pixel space, and fuse the mask layer with the original image to establish a visual region map of slag inclusion defects. The directional disturbance reference value is set by the time angle increment in the continuous change sequence of the principal stress direction.
9. The visual inspection method for inclusion defects in the crankshaft casting process according to claim 1, characterized in that, The method further includes: S5: Based on the visual area map of the inclusion defect, obtain the principal stress direction and the corresponding image texture direction of the extension path and calculate the included angle. Filter the path whose included angle does not reach the principal stress texture threshold. Combine the grayscale mean gradient to filter out the path with abrupt change in direction and gradient breakage. Output the inclusion defect penetration path recognition map. The inclusion defect penetration path identification map specifically includes the main stress texture direction deviation path, grayscale continuous path, and inclusion penetration path pixel trajectory set.
10. The visual inspection method for inclusion defects in the crankshaft casting process according to claim 9, characterized in that, The specific steps of S5 are as follows: S501: Based on the visible area map of the inclusion defect, extract the pixel position sequence covered by the extended path in the image, obtain the corresponding principal stress direction value and texture direction, calculate the angle between the two, filter the path segments whose angle value does not reach the principal stress texture threshold, and generate a principal stress texture direction deviation path group. S502: Call the principal stress texture direction deviation path group, calculate the derivative change of the gray value mean of continuous pixels and extract the position of the change abruptly, determine whether the interval of the principal stress direction abruptly in the corresponding path is continuous, remove the path segments with gray value breaks or direction abruptly, and obtain a continuous texture path set. S503: Based on the continuous texture path set, redraw the path in the image coordinate grid, draw the path mask according to the pixel connectivity, aggregate all path masks, and superimpose them onto the original image channel to generate a binary highlight display image, and obtain the slag inclusion defect penetration path recognition image. The principal stress texture threshold is set by extracting the angle between the principal stress direction and the image texture direction at all locations along the extension path.