Secondary dendritic crystal arm spacing measurement method based on improved U-shaped convolutional neural network

By using an improved U-shaped convolutional neural network to measure the secondary dendrite arm spacing, the subjectivity and robustness issues of existing measurement methods are resolved, achieving efficient and automated SDAS measurement and improving measurement accuracy and consistency.

CN121746358APending Publication Date: 2026-03-27CITIC DICASTAL CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511956005.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-23
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing methods for measuring the spacing between secondary dendrite arms are highly subjective, inefficient, and have poor repeatability. They cannot be automated and are sensitive to image noise, contrast, and uneven illumination, lacking robustness and making them unsuitable for batch or complex images.

Method used

An improved U-shaped convolutional neural network is used to segment dendrite arms through image quality enhancement processing and an attention mechanism integrated U-shaped convolutional neural network model. The spacing is calculated by combining the automatic cut-off method to achieve fully automated measurement.

Benefits of technology

It realizes a complete automated process from metallographic images to SDAS numerical output, improves measurement efficiency and accuracy, ensures the consistency and objectivity of measurement results, and adapts to the measurement needs of different operators and time points.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121746358A_ABST
    Figure CN121746358A_ABST
Patent Text Reader

Abstract

The invention discloses a secondary dendritic crystal arm spacing measurement method based on an improved U-shaped convolutional neural network, and belongs to the technical field of material science. The method comprises the following steps: acquiring a metallographic image of a metal material containing a secondary dendritic crystal structure; performing image quality enhancement processing on the metallographic image to obtain a preprocessed image; the preprocessed image is input to an improved U-shaped convolutional neural network model, a dendritic crystal arm segmentation probability graph is obtained, and the improved U-shaped convolutional neural network model integrates an attention mechanism in a coding path and a decoding path; carrying out binarization and morphological processing on the dendritic crystal arm segmentation probability graph, and extracting a dendritic crystal arm skeleton image; and based on the dendritic crystal arm skeleton image, calculating the distance between adjacent secondary dendritic crystal arms by adopting an automatic section line method to obtain a secondary dendritic crystal arm distance measurement result. According to the method, rapid and objective measurement of the secondary dendritic crystal arm spacing is realized through the improved U-shaped convolutional neural network integrated with the attention mechanism.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of material science, and in particular relates to a secondary dendrite arm spacing measurement method based on an improved U-shaped convolutional neural network. BACKGROUND

[0002] Secondary dendrite arm spacing (SDAS) is a key microstructure parameter affecting the performance of metal materials, and its accurate measurement is crucial for material research and quality control. Currently, material research is developing towards high-throughput and digitization, and it is urgent to realize the automation and high-precision quantitative analysis of SDAS measurement.

[0003] In the related art, the secondary dendrite arm spacing is measured by manual measurement. However, in the related art, the method is highly subjective, low in efficiency and poor in repeatability, cannot realize automation, and is sensitive to image noise, contrast and uneven illumination, has poor robustness, and is difficult to adapt to batch or complex images. Therefore, there is an urgent need for an intelligent measurement method that can automatically run from the original image to the measurement result and effectively overcome the interference of image quality and the insufficient segmentation accuracy, to meet the demand of modern material intelligent manufacturing for rapid and reliable quantitative analysis of microstructure. SUMMARY

[0004] The present application provides a secondary dendrite arm spacing measurement method based on an improved U-shaped convolutional neural network to solve the above problems. The technical solution is as follows: In a first aspect, a secondary dendrite arm spacing measurement method based on an improved U-shaped convolutional neural network is provided, and the method comprises: obtaining a metallographic image of a metal material containing secondary dendrite structure; performing image quality enhancement processing on the metallographic image to obtain a preprocessed image; inputting the preprocessed image into an improved U-shaped convolutional neural network model to obtain a dendrite arm segmentation probability map, wherein the improved U-shaped convolutional neural network model integrates an attention mechanism in the encoding path and the decoding path; performing binarization and morphological processing on the dendrite arm segmentation probability map to extract a dendrite arm skeleton image; based on the dendrite arm skeleton image, using an automatic cutting line method to calculate the spacing between adjacent secondary dendrite arms to obtain a secondary dendrite arm spacing measurement result.

[0005] In one possible implementation, the image quality enhancement processing includes at least one of denoising processing, contrast enhancement, uneven illumination correction, or size normalization.

[0006] In a possible implementation, the denoising processing adopts a non-local mean denoising algorithm or a three-dimensional block matching algorithm; the contrast enhancement adopts an adaptive histogram equalization algorithm; and the uneven illumination correction adopts a top-hat transformation algorithm or a retinal cortex theory algorithm.

[0007] In a possible implementation, the improved U-shaped convolutional neural network model is a multi-scale attention U-shaped network; the encoding path comprises a channel attention module; the decoding path comprises a spatial attention module; and the encoding path and the decoding path are connected through dense skip connections for feature fusion, and the dense skip connections are used to fuse the feature maps of multiple levels in the encoding path to corresponding levels in the decoding path.

[0008] In a possible implementation, the loss function of the improved U-shaped convolutional neural network model is a combined loss function, which comprises a Dice loss function for measuring segmentation overlap and a focal loss function for solving the class imbalance problem.

[0009] In a possible implementation, the morphological processing comprises a closing operation and noise removal based on connected domain analysis.

[0010] In a possible implementation, the automatic intercepting method comprises the following steps: a plurality of profile lines are arranged on both sides of the dendrite trunk in the dendrite arm skeleton image along a direction perpendicular to the dendrite trunk; the intersection points of each profile line and the dendrite arm skeleton are identified, and the distance between adjacent intersection points is calculated as a local dendrite arm spacing; after statistical analysis of all the local dendrite arm spacings and removal of outliers, the average value of all the local dendrite arm spacings is calculated as the spacing between secondary dendrite arms.

[0011] In a possible implementation, the outliers are removed by using the Laplace criterion.

[0012] In a possible implementation, the metal material comprises an aluminum alloy, a high-temperature alloy or a steel material.

[0013] In a second aspect, an improved U-shaped convolutional neural network-based secondary dendrite arm spacing measurement device is provided, and the device comprises: an acquisition module configured to acquire a metal material metallographic image containing a secondary dendrite structure; a preprocessing module configured to perform image quality enhancement processing on the metallographic image to obtain a preprocessed image; a segmentation module configured to input the preprocessed image into an improved U-shaped convolutional neural network model to obtain a dendrite arm segmentation probability map, wherein the improved U-shaped convolutional neural network model integrates an attention mechanism in an encoding path and a decoding path; an extraction module configured to perform binarization and morphological processing on the dendrite arm segmentation probability map to extract a dendrite arm skeleton image; The computing module is configured to calculate the spacing between adjacent secondary dendrite arms based on the dendrite arm skeleton image by using an automatic intercepting method to obtain a secondary dendrite arm spacing measurement result.

[0014] In a third aspect, a computer device is provided, and the computer device includes a processor and a memory, and the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor, so that the computer device implements the secondary dendrite arm spacing measurement method based on the improved U-shaped convolutional neural network according to the first aspect.

[0015] In a fourth aspect, a non-transitory computer-readable storage medium is provided, and the non-transitory computer-readable storage medium stores at least one computer program, and the at least one computer program is loaded and executed by a processor, so that the computer implements the secondary dendrite arm spacing measurement method based on the improved U-shaped convolutional neural network according to the first aspect.

[0016] The technical scheme provided in the present application at least brings the following beneficial effects: The technical scheme provided in the present application completes the complete automatic process from the original metallographic image input to the SDAS numerical output by sequentially executing the image acquisition, preprocessing, intelligent segmentation, post-processing and automatic calculation and measurement steps, and gets rid of the dependence on manual calibration or repeated parameter adjustment. The process significantly shortens the single measurement time and can meet the high-throughput demand of large-scale batch image processing. The core improved U-shaped convolutional neural network model integrates the attention mechanism in the encoding and decoding paths, so that it can adaptively focus on the key dendrite arm features in the image, especially enhances the recognition and segmentation ability of the slender and fuzzy edge, and thus obtains a high-precision dendrite arm segmentation probability map. The entire measurement process is driven by the preset algorithm and the trained model, so that different operators and different time points can obtain highly consistent results when measuring the same batch of samples, which improves the objectivity and comparability of the measurement data and is beneficial to standardization and quality control. BRIEF DESCRIPTION OF DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0018] Figure 1 is a flowchart of a secondary dendrite arm spacing measurement method based on an improved U-shaped convolutional neural network provided by the present application; Figure 2is a schematic diagram of a metallographic image of a metal material containing secondary dendrite structure provided by the present application; Figure 3 is a schematic diagram of a preprocessed image provided by the present application; Figure 4 is a structural schematic diagram of an improved U-shaped convolutional neural network provided by the present application; Figure 5 is a secondary dendrite arm labeling diagram provided by the present application; Figure 6 is a dendrite arm segmentation probability diagram provided by the present application; Figure 7 is a dendrite arm skeleton image provided by the present application; Figure 8 is a contrast schematic diagram of SDAS automatic measurement and manual measurement provided by the present application; Figure 9 is a structural schematic diagram of a secondary dendrite arm spacing measurement device based on an improved U-shaped convolutional neural network provided by the present application. DETAILED DESCRIPTION

[0019] In order to make the purpose, technical scheme and advantages of the present application clearer, the present application will be described in further detail below with reference to the drawings.

[0020] It should be noted that the terms "first", "second", etc. (if any) in the specification of the present application are used to distinguish similar objects, and do not necessarily mean a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. The implementation described in the following exemplary embodiments does not represent all implementations consistent with the present application. Rather, they are only examples of the application consistent with some aspects of the application.

[0021] The performance of a metal material is closely related to its microstructure, among which the secondary dendrite arm spacing is a key quantitative parameter representing the degree of solidification structure refinement, which directly affects the strength, toughness and service reliability of the material. In the research and production process of high-end materials such as aluminum alloy and high-temperature alloy, the rapid and accurate measurement of SDAS has irreplaceable value for process optimization, performance prediction and quality control.

[0022] With the development of intelligent manufacturing and material digitization, automatic and high-precision quantitative analysis of microstructure has become an urgent need in the industry. However, the SDAS measurement method in the related technology has obvious limitations. The manual visual measurement method is inefficient, subjective and has poor repeatability. The digital image processing method in the related technology is highly dependent on parameter adjustment and is sensitive to image noise, uneven contrast and other quality problems, and has insufficient robustness.

[0023] The application provides a secondary dendrite arm spacing measurement method based on an improved U-shaped convolutional neural network, which can solve the above problems.

[0024] Referring to Figure 1 , Figure 1 A flowchart of a secondary dendrite arm spacing measurement method based on an improved U-shaped convolutional neural network is provided. The secondary dendrite arm spacing measurement method based on the improved U-shaped convolutional neural network includes but is not limited to the following steps 101-105.

[0025] Step 101, obtaining a metallographic image of a metal material containing secondary dendrite structure.

[0026] First, a suitable sample is taken from a representative part (for example, a key stress area of a casting or a specific position for solidification research) of the metal material product or ingot to be analyzed. Then, the sample is prepared according to the standard preparation process of metallography, which usually includes: inlaying (if necessary), coarse grinding, fine grinding, polishing, and appropriate chemical or electrolytic etching. For example, for aluminum alloy (such as A356), the sample can be ground and mechanically polished to a mirror surface according to the national standard GB / T 13298-2015, and then etched with a specific etchant (such as 0.5% hydrofluoric acid solution) for a short time to clearly show the outline of the dendrites, so that the secondary dendrite arm structure can be fully highlighted. The prepared sample surface should be smooth, clean, and the dendrite structure should be clear and identifiable, without obvious preparation defects such as scratches, tails or etching pits, to ensure that the subsequent collected images can truly and completely reflect the original microstructure of the material. Optionally, the metal material is not limited in the embodiments of the application, for example, aluminum alloy, high-temperature alloy or steel material, etc. containing secondary dendrite structure.

[0027] The prepared metallographic sample is placed on the stage of a metallographic microscope (e.g., ZEISS Observer.A1m, ZEISS inverted metallographic microscope). By adjusting the light source, diaphragm and focal length of the microscope, a field of view is found on the ocular lens or display screen, in which the structure is clear, the secondary dendrite arms are developed typically and the distribution is relatively uniform. In order to meet the requirements of resolution and details for subsequent algorithm processing, it is usually necessary to collect at an appropriate magnification, for example, 50 to 200 times, to ensure that the width of a single secondary dendrite arm occupies enough pixels in the image, thereby providing a basis for accurate segmentation. The collected image should be a digital image, which can be a 24-bit true color (RGB) image or an 8-bit grayscale image. In order to retain sufficient organizational detail information, it is recommended that the image resolution be no less than 2048x1536 pixels. The collected image is the metallographic image of the metal material containing secondary dendrite structure described in the present application. For example Figure 2 An exemplary schematic diagram of a metallographic image of a metal material containing secondary dendrite structure.

[0028] Step 102, image quality enhancement processing is performed on the metallographic image to obtain a preprocessed image.

[0029] During the collection process, the original metallographic image often has problems such as noise, insufficient contrast, uneven illumination, inconsistent size and effective area, etc., due to factors such as device noise, sample surface state, illumination conditions, etc., which directly affect the performance of subsequent algorithms. In this step, a series of automatic image processing operations are performed to correct and enhance the above problems one by one.

[0030] Optionally, the image quality enhancement processing includes at least one of denoising processing, contrast enhancement, uneven illumination correction, or size normalization.

[0031] For example, the denoising processing adopts a non-local mean denoising algorithm (Non-Local Means Denoising) or a three-dimensional block matching algorithm (Block Matching 3D, BM3D). In order to deal with the inherent electronic noise of the image collection system and the possible preparation flaw noise, an advanced filtering algorithm is used to smooth the background while retaining the dendrite edge details to the maximum extent. For example, a non-local mean denoising algorithm can be used, which calculates the weighted average between similar pixel blocks in the image to reduce noise, effectively maintaining the edge structure; or a three-dimensional block matching algorithm can be used, which performs collaborative filtering on similar image blocks in the transform domain, and performs well in noise suppression and detail preservation.

[0032] Exemplarily, the contrast enhancement adopts an adaptive histogram equalization algorithm (CLAHE). To solve the problem that the gray difference between the dendrite and the matrix in the metallographic image may not be obvious, an adaptive method is used to enhance the local contrast. A typical approach is to use the adaptive histogram equalization algorithm. The algorithm divides the image into several small blocks, performs histogram equalization on each small block independently, and avoids the problem of noise amplification caused by excessive enhancement of local regions by limiting the contrast, thereby significantly highlighting the outline and texture details of the dendrite arms.

[0033] Exemplarily, the uneven illumination correction adopts a top-hat transformation algorithm (Top-Hat) or a Retinex algorithm. In view of the phenomenon that the image center may be bright, the periphery may be dark, or local reflection may be uneven due to the microscope light source, a corresponding algorithm is used for illumination field correction. For example, the top-hat transformation algorithm can be used. This algorithm extracts and removes the slowly changing background brightness by subtracting the result of the morphological opening operation from the original image, thereby achieving uniformization. Another feasible solution is the Retinex algorithm, which simulates the separation mechanism of the human eye visual system for illumination and reflection, can estimate and remove the illumination component from the image, and restore the original reflection characteristics of the object.

[0034] To ensure the consistency of the input of the neural network model, the image needs to be uniformly scaled to a fixed size (for example, 512x512 pixels or 1024x1024 pixels). At the same time, to avoid the interference of the disorganized background area at the edge of the image on the segmentation, the center cropping or other automatic identification of the effective area can be used to ensure that the input image focuses on the part containing the complete dendrite structure.

[0035] After the above one or more processing steps, the obtained image is a preprocessed image, for example Figure 3 is a schematic diagram of a preprocessed image. The image is optimized and standardized in terms of noise level, contrast, illumination uniformity, and input specification, effectively reducing the complexity of subsequent analysis and directly improving the accuracy and stability of the final segmentation and measurement.

[0036] Step 103: input the preprocessed image into the improved U-shaped convolutional neural network model to obtain a dendrite arm segmentation probability map, and the improved U-shaped convolutional neural network model integrates an attention mechanism in the encoding path and the decoding path.

[0037] Referring to Figure 4An improved U-shaped convolutional neural network structure diagram. The improved U-shaped convolutional neural network model is a multi-scale attention U-shaped network, and the improved U-shaped convolutional neural network model is based on the classic U-Net network architecture for targeted enhancement. It adopts a symmetrical U-shaped encoder-decoder structure: the encoder path gradually extracts and compresses the multi-level abstract features of the image through convolution and downsampling operations; the decoder path gradually restores the spatial size of the feature map through upsampling and convolution operations, and finally outputs a segmentation map with the same size as the input image. Feature fusion is performed between the two paths through a skip connection. Attention mechanisms are integrated into the encoding path and the decoding path of the model. The design aims to solve the challenges specific to dendrite arm segmentation in metallographic images: dendrite arms are long and slender in shape, have low edge contrast, are not clearly distinguished from the background, and have a small pixel ratio.

[0038] Figure 4 In particular, the multi-scale attention upsampling and segmentation mapping part is marked, which corresponds to the specific implementation module of the decoding path and the final output layer: MSAB1, MSAB2, MSAB3 are multi-scale attention blocks, which are the core of the upsampling module at different levels in the decoding path. Each MSAB block integrates a spatial attention mechanism (such as CBAM) and an upsampling operation, and its multi-scale feature is reflected in the fusion of feature information from multiple corresponding levels in the encoding path through dense skip connections, so that deep semantics and shallow details can be used simultaneously when restoring details. AB1, AB2 are attention blocks, which correspond to modules in the encoding path that integrate channel attention mechanisms (such as SE Block), used for adaptive weighting of the channel dimension during feature extraction. CONV represents a standard convolution layer, which is the basic operation unit for constructing each encoding block, decoding block, and output layer.

[0039] Feature connection in Figure 2 In particular, the multi-scale attention upsampling and segmentation mapping part is marked, which corresponds to the specific implementation module of the decoding path and the final output layer: MSAB1, MSAB2, MSAB3 are multi-scale attention blocks, which are the core of the upsampling module at different levels in the decoding path. Each MSAB block integrates a spatial attention mechanism (such as CBAM) and an upsampling operation, and its multi-scale feature is reflected in the fusion of feature information from multiple corresponding levels in the encoding path through dense skip connections, so that deep semantics and shallow details can be used simultaneously when restoring details. AB1, AB2 are attention blocks, which correspond to modules in the encoding path that integrate channel attention mechanisms (such as SE Block), used for adaptive weighting of the channel dimension during feature extraction. CONV represents a standard convolution layer, which is the basic operation unit for constructing each encoding block, decoding block, and output layer.

[0040] The encoding path includes a channel attention module. The attention mechanism introduced in the encoding path enables the model to adaptively evaluate the importance of different feature channels when extracting features. It can learn and enhance feature channels that contribute more to identifying dendrite arms, while suppressing feature channels related to background or noise. Optionally, the encoder consists of 5 downsampling blocks, each containing: 2 3x3 convolution layers (with ReLU activation); 1 2x2 max pooling layer (stride = 2); a channel attention module (SE Block) is inserted at the end of each downsampling block to adaptively enhance key channel features, suppress irrelevant background channels, and enhance dendrite-related feature channel responses.

[0041] The spatial attention module is included in the decoding path. The attention mechanism introduced in the decoding path acts on the spatial dimension of the feature map. A spatial weight map can be dynamically generated according to the feature content, focusing on activating the regions of the corresponding dendrite arm edge, tip and other key spatial positions in the feature map, and weakening the irrelevant background regions. It helps to accurately locate and outline the low-contrast dendrite arm profile when reconstructing the segmentation details, effectively reducing the ambiguity and uncertainty of the segmentation boundary. Optionally, the decoder is composed of 5 up-sampling blocks, each block including: 1 2x2 transpose convolution layer (stride = 2, for up-sampling); jump connection fusion: splicing (Concatenate) the feature map of the corresponding encoder layer with the current decoder feature map; 2 3x3 convolution layers (with ReLU activation); the spatial attention module (CBAM) is inserted at the end of each up-sampling block, which focuses on the dendrite edge region, enhances the spatial positioning ability of the dendrite arm edge and small structure, and reduces the segmentation ambiguity.

[0042] Optionally, the features are fused between the encoding path and the decoding path through dense jump connections. The dense jump connection is used to fuse the feature maps of multiple levels in the encoding path to the corresponding levels in the decoding path. The dense jump connection for fusing the feature maps of multiple levels in the encoding path to the corresponding levels in the decoding path is an improvement of the jump connection in the standard U-shaped network, aiming to optimize the transmission and fusion strategy of feature information between the encoder and the decoder, to solve the problems of poor structure continuity and detail loss in the segmentation of complex and slender targets (such as secondary dendrite arms).

[0043] In the standard U-Net, the jump connection usually directly splices the output feature map of a certain layer of the encoder to the input of the corresponding layer of the decoder. The one-to-one connection method provides detail supplement, but when processing multi-level and multi-scale structures, the information flow may not be sufficient. The dense jump connection adopted by the present application enhances this. The core mechanism is that a certain up-sampling block (for example, the i-th layer) in the decoding path, when fusing features, not only receives the feature map from the same level (the i-th layer) in the encoding path, but also receives the feature map from one or more shallower levels (for example, the i-1-th layer, the i-2-th layer) in the encoding path. In actual operation, the feature map from the shallower level, because of its higher resolution and possibly different number of channels, will first pass through a 1x1 convolution layer to adjust the number of channels and compress the features, and then be spliced or superimposed with the feature map of the same level.

[0044] Thus, the multi-scale feature fusion is realized: the decoder can obtain and fuse the features from different depths, different abstract levels and different spatial precisions of the encoder at each stage of reconstructing the target region. The deep features provide strong semantic guidance to ensure that the decoder "knows" what to generate; the middle and shallow features provide rich geometric and texture details to ensure that the decoder "can" accurately generate the shape and boundary of the target. The information flow and gradient propagation are enhanced: the additional connection paths form a denser information network, which helps to alleviate the gradient vanishing problem during training and allows the shallow features to more directly affect the final segmentation result.

[0045] For structures such as secondary dendrite arms, it is crucial to ensure the continuity of the segmentation. The dense skip connection injects more rich multi-level spatial context information, so that the decoder can better judge and connect those parts that may appear blurred or broken in a single level feature when recovering details at each level of upsampling, thereby significantly improving the segmentation accuracy of the continuity of the slender structure of the dendrite arm. A secondary dendrite arm is shown in FIG. 2. Figure 5

[0046] Therefore, the dense skip connection ensures that multi-level information from macro semantics to micro details can work together in the final segmentation map generation process through an efficient and dense feature reuse mechanism.

[0047] In specific operation, the obtained standardized preprocessed image (for example, a gray-scale image with a size of HxWx1) is input into the trained improved U-shaped convolutional neural network model. After the model performs forward inference, a single-channel dendrite arm segmentation probability map with the same size as the input is output. The value of each pixel in the probability map is between 0 and 1, representing the confidence that the pixel position belongs to the "dendrite arm" category. The probability map is the direct basis for subsequent binary decision and geometric measurement, and the accuracy of the probability map directly determines the accuracy of the final SDAS measurement.

[0048] Optionally, the loss function of the improved U-shaped convolutional neural network model is a combined loss function, which includes a Dice loss function for measuring segmentation overlap and a focal loss function for solving the class imbalance problem.

[0049] This design is a special optimization for the two core challenges of dendrite arm pixel ratio being extremely small and target edge being blurred in the dendrite arm segmentation task of metallographic images. Instead of using a single general loss function, the Dice loss function and the focal loss function are combined to form a combined loss function for training by weighted summation, so as to guide the model to learn more effectively.

[0050] ​The core function of the Dice loss function is to directly measure the overlap between the model's predicted segmentation area and the true labeled area. Its calculation method is: 1-(2*|predicted area∩true area|) / (|predicted area|+|true area|). This loss function is particularly sensitive to the segmentation performance of small target objects. In a metallographic image, the dendrite arms as foreground targets usually have a total area much smaller than the background. Using the Dice loss can force the model to actively match and cover these sparse foreground pixels during training, effectively ensuring the integrity of the segmented dendrite arms in structure and avoiding the misjudgment of small dendrite arms as background, which leads to missed detection.

[0051] The focal loss function is a modified form of the standard cross-entropy loss, used to solve the problem of extreme imbalance between foreground and background classes. The core mechanism is to introduce an adjustable modulation factor, which automatically reduces the contribution weight of samples that have been correctly classified by the model and have high confidence (such as a large number of background pixels) to the total loss, while relatively increasing the loss weight of difficult-to-classify samples (such as pixels with fuzzy dendrite arm edges, pixels similar to the background gray level). This allows the model to focus more "attention" on learning how to correctly distinguish these difficult but critical pixels during training, thereby significantly improving the discrimination and segmentation accuracy of difficult regions such as dendrite arm edges. FL=-α t (1-p t )ᵞlog(p t ), where p t is the predicted probability, α t =0.8, and ᵞ=2.

[0052] When training the improved U-shaped convolutional neural network, the above two loss functions are linearly combined with preset weights (for example, Dice loss weight α=0.6, focal loss weight β=0.4) to form the total loss function: Loss(total)=α*Dice Loss+β*Focal Loss.

[0053] The Dice loss mainly drives from the macro-structure level, ensuring that the predicted dendrite arm region as a whole coincides with the true region as much as possible, preventing structure breakage or loss. The focal loss drives from the micro-pixel level, forcing the model to attack and overcome difficulties, accurately determine the ownership of each boundary pixel, and sharpen the segmentation edges.

[0054] The Dice loss provides the correct structure learning direction for the model, while the focal loss enhances the learning ability of details and difficulties in this direction. The combined strategy works together to enable the model to overcome the special difficulties of metallographic image segmentation, and ultimately trains a segmentation network that achieves a better balance between the integrity of the dendrite arms and the accuracy of the boundaries, providing a guarantee for subsequent high-precision geometric measurement.

[0055] The training method of the improved U-shaped convolutional neural network model is not limited in the embodiments of the present application, and the following steps are optionally provided for understanding: To train the model, a dedicated metallographic image dataset was constructed. This dataset contains over 1000 images of A356 aluminum alloy samples prepared by standard metallographic methods, ensuring that typical secondary dendrite morphology is covered.

[0056] Gold standard annotation: Each image in the dataset was independently annotated at the pixel level by multiple experienced material experts, and the secondary dendrite arm area was accurately outlined to generate a binary mask image. To obtain the most reliable training target, the intersection of multiple expert annotation results was used as the final gold standard mask to maximize the elimination of personal subjective bias and ensure the consistency, objectivity, and authority of the annotation.

[0057] Data augmentation: To improve the robustness and generalization ability of the model, random data augmentation was applied to the input images and corresponding gold standard masks during training, including: random rotation (any angle from 0° to 360°), horizontal or vertical flipping, random brightness adjustment (variation range ±20%), and addition of a small amount of Gaussian noise (standard deviation σ=0.01). These operations simulate the angle, illumination, and noise changes that may occur during actual image acquisition, allowing the model to learn to ignore these irrelevant disturbances and focus on the essential features of the dendrite arms.

[0058] The MSA-Unet model was supervised trained using the following configuration and process: Training hyperparameters: The AdamW optimizer was used, with an initial learning rate of 1e-4 and a weight decay of 1e-4. The cosine annealing scheduling strategy was used to dynamically adjust the learning rate. The batch size for each training iteration was set to 8, and the model was trained for a total of 100 rounds.

[0059] Loss function: The target function used for training was a combination loss function, specifically a weighted sum of the Dice loss function and the focal loss function, to optimize the overall overlap of the segmented regions and address the extreme class imbalance problem between foreground and background pixels.

[0060] After training, the model performance was quantitatively evaluated on an independent validation set. The core evaluation indicators used and their results are as follows: Dice coefficient: greater than 0.91. This indicator directly reflects the overlap between the model's predicted segmentation region and the gold standard region, with a higher value indicating better segmentation integrity. Intersection over Union: greater than 0.83. This indicator is another widely used measure of segmentation accuracy, further verifying the accuracy of the model's prediction. Edge localization error: less than 2 pixels. This indicator specifically evaluates the average distance between the predicted segmentation boundary and the true boundary, indicating that the model's positioning of the dendrite arm edge has reached sub-pixel level high precision.

[0061] The above evaluation results show that the improved U-shaped convolutional neural network model trained by the process can meet the needs of high-precision and high-robustness pixel-level segmentation of secondary dendrite arms in metallographic images, and provides a reliable core module for subsequent full-automatic and high-precision SDAS measurement. Based on the improved U-shaped convolutional neural network model, a dendrite arm segmentation probability map as shown in Figure 6 may be obtained.

[0062] In step 104, the dendrite arm segmentation probability map is binarized and morphologically processed to extract a dendrite arm skeleton image. The purpose is to convert the continuous probability map output by the model into a clear binary structure representation that can be used for accurate geometric measurement, and through morphological optimization and skeletonization, a topological skeleton representing the center line of the dendrite arm is extracted, laying a foundation for subsequent automatic measurement of the spacing, as shown in a dendrite arm skeleton image as shown in Figure 7 .

[0063] The specific implementation process successively includes the following core operations: Binarization processing: In the dendrite arm segmentation probability map output by the model, each pixel value represents the confidence that the point belongs to the dendrite arm (the value range is 0 to 1). In order to obtain a deterministic segmentation region, a threshold needs to be set for binarization decision. Usually, pixels with a probability value greater than or equal to a predetermined threshold (for example, 0.5) are determined as foreground (dendrite arm) and assigned a value of 1 (white); pixels below the threshold are determined as background (matrix) and assigned a value of 0 (black). Thus, a binary segmentation mask image is obtained, in which the white connected region represents the identified dendrite arm.

[0064] Morphological processing: Morphological processing includes closing operation and noise removal based on connected domain analysis. Due to the possible existence of small noise, irregular boundary or local voids in the segmentation probability map, direct skeleton extraction on the binary image may produce burrs, fractures or inaccurate branches. Therefore, morphological processing is needed to optimize the shape of the binary mask image. Morphological closing operation: first dilate and then erode. This can fill the small holes or narrow fractures that may exist in the dendrite arm region, smooth the boundary, and connect adjacent regions that are broken due to discontinuous segmentation, thereby ensuring the continuity of the dendrite arm structure, which is particularly important for slender structures.

[0065] Noise removal based on connected domain analysis: Calculate the pixel area of all white connected regions in the binary image. Small connected domains with an area less than a predetermined threshold (for example, 50 pixels) are determined as noise or non-target structures and are removed. This can effectively remove small-area artifacts generated during segmentation and purify the dendrite arm main body region.

[0066] Skeletonization is performed on the morphologically optimized binary mask image. The skeletonization algorithm iteratively erodes the boundary pixels until the target region is simplified to single-pixel wide lines while preserving its original topology and connectivity. The extracted skeleton image accurately preserves the centerline geometry and topological connectivity of each dendrite arm. In the skeleton image, each dendrite arm is no longer represented by its actual width, but by a single-pixel line that runs through its center, which greatly facilitates the next step of intersection-based geometric measurement.

[0067] Through the above sequential operations, this step realizes the conversion from soft probability segmentation to hard binary decision, and then to refined geometric structure representation. The final dendrite arm skeleton image has clear structure, low noise, and good continuity, which is the necessary and standardized input data for performing high-precision and automated intercept line method measurement of secondary dendrite arm spacing.

[0068] Step 105, based on the dendrite arm skeleton image, the automatic intercept line method is used to calculate the spacing between adjacent secondary dendrite arms, and the secondary dendrite arm spacing measurement result is obtained.

[0069] Specifically, the execution process of the automatic intercept line method is as follows: In the dendrite arm skeleton image, a plurality of section lines are set on both sides of the dendrite trunk in a direction perpendicular to the dendrite trunk; the intersection points of each section line and the dendrite arm skeleton are identified, and the distance between adjacent intersection points is calculated as the local dendrite arm spacing; after removing outliers, the average value of all local dendrite arm spacings is calculated as the spacing between secondary dendrite arms.

[0070] In the dendrite arm skeleton image, the direction of the dendrite trunk to which the secondary dendrite arms grow needs to be determined first. The trunk is usually a primary dendrite arm, which appears as a relatively continuous and through-field main skeleton line. After determining the direction of the trunk, a series of parallel straight lines, called section lines, are automatically drawn on both sides of the trunk (i.e., the region where the secondary dendrite arms grow) in a direction perpendicular to the trunk with a fixed spatial step (e.g., every 10 to 20 pixels). These section lines will intersect with each secondary dendrite arm skeleton grown from the trunk.

[0071] For each section line, the algorithm detects its intersection points with all secondary dendrite arm skeletons. Since the skeleton is single-pixel wide, each dendrite arm usually only produces one intersection point on a section line (which represents the center point of the dendrite arm at this section position). The algorithm sorts all intersection points on the same section line according to their coordinate positions along the section line.

[0072] Subsequently, the distance between two adjacent intersection points on the profile is calculated. This distance is the local center-to-center distance between two adjacent secondary dendrite arms at this particular profile position, i.e. a local SDAS measurement. By traversing all profile lines, tens to hundreds of such local distance measurements are obtained, forming a measurement sample set.

[0073] Statistical analysis is performed on all obtained local dendrite arm distance measurements. First, to exclude significantly abnormal data points possibly caused by skeleton crossing, noise residue or edge effect, outlier rejection is needed. Then, the arithmetic mean of the valid local distance samples after outlier rejection is calculated, which is defined as the secondary dendrite arm distance measurement result of the current analysis field of view. Alternatively, the outlier rejection is performed using the Rousseeuw criterion, i.e. values outside ±3σ are rejected.

[0074] In addition, statistical analysis can also provide auxiliary statistical quantities such as standard deviation, maximum value, minimum value, etc. of the result, to assess the uniformity of the structure. Exemplarily, profile lines are taken every 15 pixels along the direction perpendicular to the main stem on both sides of the dendrite stem, and the distance between adjacent dendrites is calculated; after outlier rejection (outside ±3σ), the average SDAS of the image is 31.38 μm, and the standard deviation is 4.2 μm, which is consistent with the average value 31.88 μm measured by professional technicians.

[0075] Through the above-mentioned automated process, a (or a set of) quantitative SDAS value is finally output. The result is objective and repeatable, directly based on the real geometric information of the image, completely avoiding the subjective bias of manual measurement, and the processing speed is much faster than the traditional method. This measurement result can be used as a direct basis for material research, process optimization and quality control, realizing intelligent and high-precision conversion from metallographic image to key microstructure parameters.

[0076] Alternatively, the above-mentioned process is encapsulated as an automated software system, supporting batch image processing, outputting CSV format measurement results, and providing a visual interface for user interaction and verification. Exemplarily, a PyQt5 graphical interface is developed, supporting drag-and-drop import, batch processing, and result export; it is deployed on a laboratory server with an average processing speed of 2.8 seconds per image. See also Figure 8 Fig. 1 shows a comparison between SDAS automatic measurement and manual measurement, Figure 8 Fig. 1A is an output result of SDAS automatic measurement, Figure 8 Fig. 1B is an output result of manual measurement, and it can be seen that the two are similar.

[0077] In summary, the technical scheme provided by the application fundamentally replaces traditional manual visual measurement and semi-automatic image processing methods by constructing a complete automatic process including image preprocessing, improved neural network segmentation, post-processing and automatic calculation, realizes full-automatic processing from metallographic image input to interval result output, greatly improves the measurement efficiency, and completely eliminates the errors caused by human subjectivity, ensuring the consistency and objectivity of the results.

[0078] The improved U-shaped convolutional neural network focuses on the slender and low-contrast dendrite arm features adaptively by integrating channel and spatial attention mechanisms in the encoding and decoding paths, and using dense skip connections and a combined loss function designed specifically for metallographic images, effectively overcoming the defects of standard models in complex metallographic image segmentation, such as blurring and loss of details, thereby achieving sub-pixel level segmentation accuracy under the quantitative indicators of a Des coefficient greater than 0.91 and an edge positioning error less than 2 pixels, laying a solid foundation for final high-precision interval measurement.

[0079] The comprehensive application of image preprocessing techniques such as BM3D denoising and CLAHE enhancement effectively improves the input image quality and enhances the robustness of the method to noise, uneven illumination and other actual imaging conditions, while the interval calculation rules based on skeleton images and automatic cutting lines provide stable and repeatable geometric measurement means; finally, the method not only verifies effectively for specific alloys (such as A356 aluminum alloy), but also has good generality and scalability in its core architecture and process design, which can be migrated to other metal material systems or similar microstructure quantitative analysis tasks, providing an efficient and reliable digital analysis tool for material research and industrial quality control.

[0080] Referring to Figure 9 , Figure 9 An improved U-shaped convolutional neural network-based secondary dendrite arm interval measurement device is provided for the embodiments of the application, as shown in Figure 9 The device comprises: The acquisition module 901 is configured to acquire a metal material metallographic image containing a secondary dendrite structure. Optionally, the metal material includes an aluminum alloy, a high-temperature alloy or a steel material.

[0081] The preprocessing module 902 is configured to perform image quality enhancement processing on the metallographic image to obtain a preprocessed image.

[0082] Optionally, the image quality enhancement processing includes at least one of denoising processing, contrast enhancement, uneven illumination correction or size normalization.

[0083] Optionally, the denoising processing adopts a non-local mean denoising algorithm or a three-dimensional block matching algorithm; the contrast enhancement adopts an adaptive histogram equalization algorithm; and the uneven illumination correction adopts a top-hat transformation algorithm or a retina cortex theory algorithm.

[0084] The segmentation module 903 is configured to input the preprocessed image into an improved U-shaped convolutional neural network model to obtain a dendrite arm segmentation probability map, and the improved U-shaped convolutional neural network model integrates an attention mechanism in an encoding path and a decoding path.

[0085] Optionally, the improved U-shaped convolutional neural network model is a multi-scale attention U-shaped network; the encoding path includes a channel attention module; the decoding path includes a spatial attention module; and the encoding path and the decoding path are connected through a dense skip connection for feature fusion, and the dense skip connection is configured to fuse feature maps at multiple levels in the encoding path to corresponding levels in the decoding path.

[0086] Optionally, a loss function of the improved U-shaped convolutional neural network model is a combined loss function, and the combined loss function includes a Dice loss function for measuring segmentation overlap and a focal loss function for solving a class imbalance problem.

[0087] The extraction module 904 is configured to binarize and perform morphological processing on the dendrite arm segmentation probability map to extract a dendrite arm skeleton image.

[0088] Optionally, the morphological processing includes a closing operation and noise removal based on connected domain analysis.

[0089] The calculation module 905 is configured to calculate, based on the dendrite arm skeleton image, a distance between adjacent secondary dendrite arms by using an automatic intercepting line method to obtain a secondary dendrite arm distance measurement result.

[0090] Optionally, the automatic intercepting line method includes: setting a plurality of profile lines in a direction perpendicular to a dendrite trunk on both sides of the dendrite trunk in the dendrite arm skeleton image; identifying intersection points of each profile line and the dendrite arm skeleton, and calculating distances between adjacent intersection points as local dendrite arm distances; and performing statistical analysis on all the local dendrite arm distances, removing outliers, and calculating an average value of all the local dendrite arm distances as the distance between the adjacent secondary dendrite arms. Exemplarily, the outliers are removed by using the Laplace criterion.

[0091] In an exemplary embodiment, a computer device is also provided, which includes a processor and a memory having at least one computer program stored therein. The at least one computer program is loaded and executed by one or more processors to enable the computer device to implement any of the above-mentioned secondary dendrite arm distance measurement methods based on the improved U-shaped convolutional neural network.

[0092] In the example embodiment, a non-transitory computer readable storage medium is also provided, and the non-transitory computer readable storage medium stores at least one computer program, which is loaded and executed by a processor of a computer device to enable the computer to implement any of the above-mentioned methods for measuring secondary dendrite arm spacing based on the improved U-shaped convolutional neural network.

[0093] In a possible implementation manner, the computer readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, or the like.

[0094] Those skilled in the art can understand that, Figures 1-9 The structures shown in the foregoing embodiments do not constitute a limitation on the structures of the present application, and can include more or fewer components than those shown, or combine certain components, or adopt different component arrangements.

[0095] It should be understood that "multiple" referred to herein means two or more. The "and / or" describes the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B can mean that A exists alone, A and B exist together, and B exists alone. The character " / " generally represents that the associated objects before and after it are in an "or" relationship.

[0096] The above is only an example embodiment of the present application, and is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.

Claims

1. A method for measuring the spacing between secondary dendrite arms based on an improved U-shaped convolutional neural network, characterized in that, The method includes: Acquire metallographic images of metallic materials containing secondary dendrite structures; The metallographic image is subjected to image quality enhancement processing to obtain a preprocessed image; The preprocessed image is input into an improved U-shaped convolutional neural network model to obtain a dendrite arm segmentation probability map. The improved U-shaped convolutional neural network model integrates an attention mechanism in the encoding and decoding paths. The dendrite arm segmentation probability map is binarized and morphologically processed to extract the dendrite arm skeleton image; Based on the dendrite arm skeleton image, the spacing between adjacent secondary dendrite arms is calculated using the automatic cut-out method, and the measurement results of the secondary dendrite arm spacing are obtained.

2. The method for measuring the spacing between secondary dendrite arms based on an improved U-shaped convolutional neural network according to claim 1, characterized in that, The image quality enhancement process includes at least one of noise reduction, contrast enhancement, illumination non-uniformity correction, or size normalization.

3. The method for measuring the spacing between secondary dendrite arms based on an improved U-shaped convolutional neural network according to claim 2, characterized in that, The denoising process employs a nonlocal mean denoising algorithm or a three-dimensional block matching algorithm; the contrast enhancement employs an adaptive histogram equalization algorithm; and the illumination non-uniformity correction employs a top-hat transformation algorithm or a retinal-cortical theory algorithm.

4. The method for measuring the spacing between secondary dendrite arms based on an improved U-shaped convolutional neural network according to claim 1, characterized in that, The improved U-shaped convolutional neural network model is a multi-scale attention U-shaped network; The encoding path includes a channel attention module; The decoding path includes a spatial attention module; The encoding path and the decoding path are fused through dense skip connections, which are used to fuse feature maps from multiple levels in the encoding path to the corresponding level in the decoding path.

5. The method for measuring the spacing between secondary dendrite arms based on an improved U-shaped convolutional neural network according to claim 4, characterized in that, The loss function of the improved U-shaped convolutional neural network model is a combined loss function, which includes a Dess loss function for measuring segment overlap and a focus loss function for solving the class imbalance problem.

6. The method for measuring the spacing between secondary dendrite arms based on an improved U-shaped convolutional neural network according to claim 1, characterized in that, The morphological processing includes closing operations and noise removal based on connected component analysis.

7. The method for measuring the spacing between secondary dendrite arms based on an improved U-shaped convolutional neural network according to claim 1, characterized in that, The automatic line cutting method includes: In the dendrite arm skeleton image, multiple cross-sectional lines are set on both sides of the dendrite trunk along a direction perpendicular to the dendrite trunk; Identify the intersection points of each section line with the dendrite arm framework, and calculate the distance between adjacent intersection points as the local dendrite arm spacing; Statistical analysis was performed on all local dendrite arm spacings. After removing outliers, the average value of all local dendrite arm spacings was calculated as the spacing between the secondary dendrite arms.

8. The method for measuring the spacing between secondary dendrite arms based on an improved U-shaped convolutional neural network according to claim 7, characterized in that, The outliers were removed using the Raida criterion.

9. The method for measuring the spacing between secondary dendrite arms based on an improved U-shaped convolutional neural network according to any one of claims 1-8, characterized in that, The metallic material includes aluminum alloy, high-temperature alloy or steel.

10. A device for measuring the spacing between secondary dendrite arms based on an improved U-shaped convolutional neural network, characterized in that, The device includes: The acquisition module is used to acquire metallographic images of metallic materials containing secondary dendrite structures; The preprocessing module is used to perform image quality enhancement processing on the metallographic image to obtain a preprocessed image; The segmentation module is used to input the preprocessed image into an improved U-shaped convolutional neural network model to obtain a dendrite arm segmentation probability map. The improved U-shaped convolutional neural network model integrates an attention mechanism in the encoding and decoding paths. The extraction module is used to perform binarization and morphological processing on the dendrite arm segmentation probability map to extract the dendrite arm skeleton image; The calculation module is used to calculate the spacing between adjacent secondary dendrite arms based on the dendrite arm skeleton image using an automatic cut-out method, and obtain the secondary dendrite arm spacing measurement result.

11. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing at least one computer program, which is loaded and executed by the processor to enable the computer device to implement the secondary dendrite arm spacing measurement method based on an improved U-shaped convolutional neural network as described in any one of claims 1 to 9.

12. A non-transient computer-readable storage medium, characterized in that, The non-transient computer-readable storage medium stores at least one computer program, which is loaded and executed by a processor to enable the computer to implement the secondary dendrite arm spacing measurement method based on the improved U-shaped convolutional neural network as described in any one of claims 1 to 9.