Laser marking character segmentation method based on residual and feature block attention
By introducing an attention-residual feature extraction unit and a feature block attention mechanism into the ResNet18 encoder, and optimizing the loss function, the segmentation accuracy problem of laser-marked characters under high noise and low contrast is solved, achieving higher accuracy and faster character segmentation.
Patent Information
- Application Number
- CN202211713446.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-27
- Publication Date
- 2026-03-03
- Estimated Expiration
- 2042-12-27
AI Technical Summary
Existing laser marking character segmentation methods have low segmentation accuracy and are difficult to effectively extract character targets when faced with high noise, low contrast and complex backgrounds.
We adopt an encoder structure based on ResNet18, combined with attention-residual feature extraction unit and feature block attention mechanism, and optimize the loss function through multiple supervision modules to improve segmentation accuracy and speed.
It improves the segmentation accuracy and speed of laser-coded characters, and can better handle character segmentation under complex backgrounds and low contrast conditions, with higher segmentation accuracy and faster reasoning speed.
Smart Images

Figure CN115953784B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a laser character segmentation method based on residual and feature block attention, belonging to the field of industrial inspection image processing. Background Technology
[0002] Laser marking technology is widely used for printing characters on metal workpieces and marking production dates on food can packaging. However, due to factors such as inconsistent laser generator quality, uncertain operating parameters, and the burning effect of high-temperature lasers on metal, the marked characters are prone to high noise and low contrast defects, significantly affecting the segmentation and extraction of character targets in automated inspection processes. Therefore, it is necessary to study a laser marking character segmentation method that can overcome the problems of high noise and low contrast.
[0003] Early methods for character segmentation mainly included threshold segmentation and gray-scale clustering, supplemented by statistical and matching model-based methods to complete subsequent character classification. Template matching was used for date character recognition on dairy packaging (Sun Xiaona, Liu Jichao, Gao Guohua. Vision-based defect detection technology for date inkjet printing on dairy packaging [J]. Food and Machinery, 2018, 34(10):100-103+108.), "Ma Ling, Luo Xiaoshu, Jiang Pinqun. Research on dot matrix character recognition based on template matching and support vector machine [J]. Computer Engineering and Applications, 2020, 56(04):134-139." proposed combining template matching with support vector machine (SVM) for high-precision recognition of dot matrix characters. Both methods use the maximum inter-class variance (OTSU) method for character segmentation, which has high signal-to-noise ratio requirements for the target image, poor robustness when there is background interference, and low segmentation accuracy for characters with slight brightness changes. "Lin Dongting, Cheng Yang, Ouyang, et al. A dot matrix character segmentation method based on dot fusion features [J]. Manufacturing Automation, 2021, 43(08): 52-57." This paper utilizes improved adaptive thresholding to remove noise and optimizes character segmentation under uneven brightness conditions. Simultaneously, the combination of Gaussian difference scale space and maximum entropy segmentation (Zhang Jiacai, Zhang Liangli, Zeng Fei. Adaptive thresholding method for dot-printed character images on steel billet surface [J]. Modern Electronics Technology, 2021, 44(19): 49-54.) has also been used to eliminate the complex background of printed characters on metal surfaces. However, traditional methods have relatively simple feature perception and extraction methods, resulting in limited performance. Therefore, fusing multiple features or establishing a high-precision segmentation model that can automatically extract deep features is crucial for character segmentation in complex situations.
[0004] To further improve the accuracy and efficiency of segmentation network models, researchers have proposed directly improving the encoding and decoding structure of end-to-end segmentation models. The U-Net, based on the encoding and decoding structure, is an end-to-end segmentation model that can achieve good results without relying on large sample sizes (Ronneberger O, Fischer P, Brox TU-net: Convolutional networks for biomedical image segmentation[C] / / Proceedings of the 18th International Conference on MICCAI, Cham, Switzerland: Springer, 2015:234-241.). However, the original UNet model uses ordinary double convolutions in the downsampling path, resulting in some loss of detail. Furthermore, as the number of downsampling layers increases, network degradation and unstable gradient backpropagation lead to poor segmentation performance. Figure 1 As shown, (a) is the original image; (b) is the character details; (c) is the Otsu method segmentation result; and (d) is the original UNet segmentation result. Summary of the Invention
[0005] To improve the speed and accuracy of laser-coded character segmentation, this invention provides a laser-coded character segmentation method based on residual and feature block attention. The technical solution is as follows:
[0006] The first objective of this invention is to provide a laser-coded character segmentation method, comprising:
[0007] Step 1: Downsampling encoding stage;
[0008] The ResNet18 encoder backbone is constructed using four cascaded attention-residual feature extraction units to downsample the image to be segmented, while a 1×1 convolution is introduced to reduce the number of encoder output feature channels.
[0009] Step 2: Upsampling decoding stage;
[0010] Image upsampling is performed using bilinear interpolation to make it the same size as the feature map to be stitched. After the feature maps are stitched, two 3×3 convolutions are performed to fuse the features of the deencoder and restore the image information. Each layer has a side output.
[0011] Step 3: Input the side output of each layer into the multi-supervision module to perform loss calculation and gradient backpropagation with the ground truth to improve segmentation accuracy and network convergence speed; finally, use one upsampling and 1×1 convolution to restore the image size and number of channels to the original image size and number of channels, and output the final segmented binary image.
[0012] Optionally, the attention-residual feature extraction unit includes: two residual structures and one feature block attention mechanism;
[0013] The residual structure comprises two sets of sequentially connected convolutional layers, BN layers, and ReLU function layers;
[0014] The feature block attention mechanism is connected after the two residual structures, and is sequentially connected to the CAM channel attention mechanism and the 4GD-SAM feature block spatial attention mechanism.
[0015] Optionally, the implementation steps of the feature block attention mechanism include:
[0016] Step 11: Using the Channel Attention Mechanism (CAM), global high-level semantic features of the input feature map are extracted by performing global average pooling and global max pooling on the channel dimension. Then, channel compression and expansion are performed on each channel using a Multilayer Perceptron (MLP). Features between channels are tracked and filtered using weight learning. Finally, a Sigmoid activation is applied to generate the channel attention weight descriptor M. c (F), the calculation method is as follows:
[0017]
[0018] Where F is the input feature map, σ is the Sigmoid function, and W1 and W0 are the channel transformation weight matrices of the multilayer perceptron;
[0019] Step 12: Divide the input feature map into 4 equal blocks along the channel dimension, and then perform average pooling and max pooling on each sub-feature independently to form an 8-channel feature map. The formula is as follows, where chunk represents the channel segmentation:
[0020] F'=chunk c / 4 (F) (3)
[0021] Step 13: Finally, perform channel concatenation, convolution, and activation to form the final feature-labeled spatial attention descriptor M. 4GD-S (F), the specific calculation is as follows:
[0022]
[0023] Where cat represents channel concatenation, and the kernel size is a variable k.
[0024] Optionally, the multi-supervision module sets four side outputs in the last layer of the encoder and the first three layers of the decoder, extracting five feature maps of different semantic levels from the final result; and upsampling to the same size as the original image, using an improved BID loss function to calculate the loss; finally, the five losses are summed to obtain the final loss value.
[0025] The improved BID loss function is:
[0026] l bid =A·l bce +B·l IoU +C·l dice
[0027] Among them, l bce Let l be the value of the cross-entropy loss function. IoU Let l be the IoU loss function value. dice Let A, B, and C be the Dice loss function values, and let A, B, and C be the weighting coefficients of the three loss functions, respectively.
[0028] Optionally, the weighting coefficients A, B, and C of the three loss functions are in a ratio of 2:1:1.
[0029] Optionally, the kernel size of the convolutional layer in the residual structure is 3.
[0030] Optionally, the convolution kernel sizes used for the four scale-level feature maps of the 4GD-SAM from top to bottom are 7, 7, 3, and 3, respectively.
[0031] The second objective of this invention is to provide a laser character segmentation system, comprising:
[0032] At least one storage medium storing at least one instruction set for segmenting an image containing laser-coded characters; and at least one processor communicatively connected to the at least one storage medium.
[0033] When the laser character segmentation system is running, the at least one processor reads the at least one instruction set and implements the laser character segmentation method described above.
[0034] Optionally, it also includes an image acquisition device for acquiring images of the laser-coded characters to be detected and segmented.
[0035] Optionally, a display device may also be included for outputting the final segmentation result.
[0036] The beneficial effects of this invention are:
[0037] To address the challenges of low segmentation accuracy in laser-etched characters due to complex backgrounds, low contrast, high noise, and fine strokes, this invention proposes a high-precision laser-etched character segmentation model based on Res18-UNet and residual attention mechanisms. An attention residual unit is proposed based on the ResNet18 backbone network to improve network performance while reducing network parameters. A feature block attention mechanism incorporating an improved SAM is designed. Building upon the existing spatial attention-based global pooling, channel numbers are divided into blocks before pooling and concatenation, reducing the loss of stroke details caused by uneven attention due to excessive abstraction, thus effectively improving segmentation accuracy. A multi-supervision module incorporating an improved BID Loss is designed to further enhance segmentation performance and accelerate the training and convergence speed of the entire segmentation network. Comparative experiments with other methods demonstrate higher segmentation accuracy and faster inference speed for character images under complex conditions. This model has significant reference value and promising industrial application prospects for segmentation scenarios with similar conditions. Attached Figure Description
[0038] 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.
[0039] Figure 1 It shows the laser-coded character image and the existing segmentation results.
[0040] Figure 2 This is a flowchart of the laser character segmentation method of the present invention.
[0041] Figure 3 This is the overall framework diagram of the Res18-UNet model of this invention.
[0042] Figure 4 This is a structural diagram of the attention-residual feature extraction unit of the present invention.
[0043] Figure 5 This is a structural diagram of the feature block attention mechanism of the present invention.
[0044] Figure 6 This is a structural diagram of the multi-monitoring module of the present invention.
[0045] Figure 7 This is the Grad-CAM attention distribution heatmap of the present invention.
[0046] Figure 8 This is a line graph showing the model training performance of the present invention using BID Loss (2:1:1) with and without DS.
[0047] Figure 9 This is a comparison chart of the results of the method of this invention with other segmentation methods. Detailed Implementation
[0048] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.
[0049] Example 1:
[0050] This embodiment provides a laser-coded character segmentation method, including:
[0051] Step 1: Downsampling encoding stage;
[0052] The ResNet18 encoder backbone is constructed using four cascaded attention-residual feature extraction units to downsample the image to be segmented, while a 1×1 convolution is introduced to reduce the number of encoder output feature channels.
[0053] Step 2: Upsampling decoding stage;
[0054] Image upsampling is performed using bilinear interpolation to make it the same size as the feature map to be stitched. After the feature maps are stitched, two 3×3 convolutions are performed to fuse the features of the deencoder and restore the image information. Each layer has a side output.
[0055] Step 3: Input the side output of each layer into the multi-supervision module to perform loss calculation and gradient backpropagation with the ground truth to improve segmentation accuracy and network convergence speed; finally, use one upsampling and 1×1 convolution to restore the image size and number of channels to the original image size and number of channels, and output the final segmented binary image.
[0056] Example 2:
[0057] This embodiment provides a laser character segmentation method based on residual and feature block attention. The method flow is described in [link to method details]. Figure 2 The image feature extraction section incorporates an attention-residual unit. This unit's feature block attention mechanism adds an improved 4GD-SAM feature block spatial attention mechanism to enhance weak stroke features. The upsampling path employs a multi-supervision module that integrates an improved loss function, improving network convergence, suppressing interference, and enhancing effective feature extraction. Finally, a decoder performs binary reconstruction of the feature image to achieve significant segmentation.
[0058] The character high-precision segmentation model algorithm Res18-UNet proposed in this embodiment is as follows: Figure 3 As shown, the specific implementation steps include:
[0059] Step 1. In the encoder structure of this model, four efficient attention-residual feature extraction units (A-Runits) are designed to replace the original convolutional downsampling, which together form the backbone structure of the ResNet18 encoder, improving the model's segmentation accuracy while reducing network parameters. At the same time, 1×1 convolutions are introduced to reduce the number of encoder output feature channels, which facilitates the concatenation of feature maps in the same layer of the encoder and decoder, balances the semantic level of the concatenated features, and improves the efficiency of semantic information fusion.
[0060] Step 2. In the upsampling decoding stage, bilinear interpolation is used to upsample the image so that it has the same size as the feature map to be stitched. After the feature maps are stitched, two 3×3 convolutions are performed to fuse the features of the deencoder and restore the image information. Each layer has a side output.
[0061] Step 3. Input the side outputs of each layer into the multi-supervised module (DS module) to perform loss calculation and gradient backpropagation with the ground truth to improve segmentation accuracy and network convergence speed. Finally, use one upsampling and 1×1 convolution to restore the image size and number of channels to the original image size and number of channels, and output the final segmented binary image.
[0062] Specifically, in this embodiment, the attention-residual feature extraction unit (AR unit) is as follows: Figure 4 As shown, the network consists of two residual structures (Res-blocks) on the left and one feature-grouped attention mechanism on the right, used for feature extraction and downsampling. Each residual structure comprises two convolutions, a batch normalization (BN) layer, and a ReLU (Revised Linear Unit) function, with a convolution kernel size of 3. The BN layer transforms the samples into a normal distribution with a mean of 0 and a variance of 1, optimizing network convergence and improving gradient vanishing in cases of uneven image sampling. The ReLU function enables the convolution output to fit nonlinearities, improving the network's generalization ability. The two residual structures are then connected to... Figure 4 The improved feature block attention mechanism on the right side adds CAM channel attention and the 4GD-SAM feature block spatial attention of this invention in sequence to complete the feature selection and enhancement of channels and space, so as to improve the segmentation accuracy.
[0063] More specifically, the feature block attention mechanism in this embodiment is as follows: Figure 5As shown. Due to the high noise around laser-etched characters and the problems of weak features and low contrast, this invention designs an improved feature block attention mechanism to enhance important features and suppress interfering features such as noise. Characters differ from other semantic segmentation objects in that their stroke features are weak, while the details at stroke endpoints and transitions are rich and varied. The original spatial attention mechanism performs global averaging and max pooling on all feature channels, resulting in excessive feature abstraction. Using this in character segmentation leads to the loss of character details and a decrease in segmentation accuracy. Based on these problems, the feature block attention mechanism of this invention consists of channel attention (CAM) and an improved feature block spatial attention mechanism (4GD-SAM) based on the elongated characteristics of characters. First, invalid information is initially filtered out in the channel dimension. Then, in the spatial dimension, a feature block strategy is used to further enhance the effective feature representation of low-contrast, weak characters while suppressing interference from invalid information. The calculation method is as follows:
[0064]
[0065] Where F is the input feature map. M represents the matrix multiplication at corresponding positions. 4GD-S The descriptor representing feature block spatial attention 4GD-SAM, M C The specific implementation steps of the descriptor feature block attention mechanism representing channel attention CAM are as follows:
[0066] Step 1. Using Channel Attention CAM, global high-level semantic features of each channel are extracted by performing global average pooling and global max pooling on the input feature map along the channel dimension. Then, a multilayer perceptron (MLP) is used to perform channel compression and expansion. Weight learning is employed to track and filter inter-channel features. Finally, a sigmoid activation is used to generate the channel attention weight descriptor M. c (F), the calculation method is as follows:
[0067]
[0068] Where σ is the Sigmoid function, and W1 and W0 are the channel transformation weight matrices of the multilayer perceptron.
[0069] Step 2. Divide the input feature map into 4 equal blocks along the channel dimension, and then perform average pooling and max pooling on each sub-feature independently to form an 8-channel feature map. The formula is as follows, where chunk represents the channel segmentation:
[0070] F'=chunk c / 4 (F) (3)
[0071] Step 3. Finally, perform channel concatenation, convolution, and activation to form the final feature-labeled spatial attention descriptor M4GD-S(F). The specific calculation is as follows:
[0072]
[0073] Where `cat` represents channel concatenation, and the kernel size is variable `k`. In this embodiment, the 4GD-SAM convolution kernel sizes used in the four scale-level feature maps from top to bottom are 7, 7, 3, and 3, respectively, to adapt to the feature map size and semantic level of the corresponding level, preserving character detail features as much as possible, and ultimately improving segmentation accuracy. The feature block strategy reduces the feature abstraction level of the global operation of the original SAM method to a certain extent, better preserving the detailed texture information of characters, while improving the uniformity of spatial attention distribution. This avoids problems such as stroke deformation and connection breakage caused by overly abstract features, as well as noise missegmentation or missing character information caused by uneven attention distribution, thus improving segmentation accuracy.
[0074] To optimize network convergence and further improve segmentation accuracy, this embodiment designs a multi-supervision module (DS module) that integrates an improved loss function. For example... Figure 6 As shown, four side outputs are set in the last layer of the encoder and the first three layers of the decoder, extracting five feature maps of different semantic levels from the final result. These maps are upsampled to the same size as the original image and then used with the label (GT) to calculate the loss using an improved BID loss function. Finally, the five losses are summed to obtain the final loss value. In the figure, 'up' represents bilinear interpolation upsampling, and 'S' is the sigmoid function. The commonly used loss function in semantic segmentation is the cross-entropy (BCE) loss function. However, the BCE loss function has certain limitations when faced with imbalanced positive and negative samples. The IoU loss function and the Dice loss function can focus more attention on the foreground, increasing the overall probability value of the foreground region, but they are prone to false positives in detailed structures. This can be compensated for by the smoothing effect of the BCE loss function on all pixels. The three complement each other to achieve optimal results.
[0075] This embodiment fuses the cross-entropy loss function, IoU loss function, and Dice loss function into BIDLoss, replacing the cross-entropy loss function, and uses a multi-supervision mechanism to optimize the training process, wherein:
[0076]
[0077]
[0078]
[0079] In equations (5), (6), and (7), y represents the label value. To predict the output value, "smooth" is used to prevent the addition of a minimum value when the numerator and denominator are both zero. Therefore, the BID Loss in this embodiment is obtained as shown in equation (8):
[0080] l bid =A·l bce +B·l IoU +C·l dice (8)
[0081] In the above equation, A, B, and C are the weighting coefficients of the three loss functions. In this invention, the ratio is 2:1:1. According to equations (6) and (7), the IoU and Dice loss functions are between 0 and 1, and tend to 0 as the number of iterations increases. However, the value of the BCE loss function is always greater than them, so it can be ensured that there are still enough gradients to drive the learning process, thereby optimizing the overall training effect and further improving the segmentation accuracy.
[0082] To further illustrate the beneficial effects of the present invention, an experiment was conducted. Following the segmentation method designed in this invention, the effectiveness of the laser character segmentation algorithm was tested based on a self-built dataset.
[0083] The test environment was as follows: Windows 10 operating system, PyTorch 1.10.0 deep learning framework, and Intel Core i9-12900k CPU and GeForce RTX 3090 GPU.
[0084] The dataset consists of grayscale images of laser-engraved characters on the bottom of aluminum cans, captured by an industrial camera on a can-filling production line of a well-known domestic automation equipment company. The images are 1280×960 pixels in size. 688 of these images, representing the more difficult segmentation, were selected and divided into 560 training images and 128 test images. Each image corresponds to a labeled ground truth (GT) binary image. Cross-validation was used during training, with 15% of the training images randomly selected as the validation set in each iteration for more detailed monitoring of training performance. After multiple hyperparameter adjustments, the network model of this invention adopted a batch size of 6, 200 training epochs, and Adam as the optimizer. The initial learning rate was set to 0.001, automatically decaying to 0.00005 during training. Under these hyperparameters, the network training converged in 5 hours and 40 minutes.
[0085] The experimental setup designed for this invention is as follows:
[0086] Ablation Experiment 1: Performance comparison of AR unit using ResNet with different numbers of layers as global backbone network;
[0087] Ablation Experiment 2: Performance comparison before and after the presence or absence of the attention module;
[0088] Ablation Experiment 3: Comparison of the impact of different loss functions and the presence or absence of multiple supervision mechanisms on network performance.
[0089] Comparative experiments: Comparative experiments were conducted with nine other image segmentation algorithms, including Otsu's double thresholding method, adaptive thresholding segmentation + connected component denoising, Gaussian difference scale space + maximum entropy method, and methods applied to medical segmentation, including UNe, UNet++, MSR+UNet, RA-UNet, improved UNet, and RV-GAN. The comprehensive performance of the algorithms was evaluated from the perspectives of segmentation accuracy and algorithm efficiency.
[0090] Analysis of the results of ablation experiment 1:
[0091] For the segmentation network model proposed in this invention, while keeping other structures and parameters unchanged, the AR unit globally uses ResNet14 (with 2,2,2 residual structures), ResNet18 (with 2,2,2,2 residual structures), and ResNet34 (with 3,4,6,3 residual structures) as the backbone network for ablation experiments. The experimental results are shown in Table 1. Although ResNet14 has a slight speed improvement of 1.4 FPS (images processed per second) compared to ResNet18, the mIoU, Dice coefficient, and F1 score decreased by 1.6%, 0.9%, and 1.0%, respectively. ResNet34 is inferior to ResNet18 in both segmentation accuracy and speed. ResNet18 has a moderate number of layers, achieving the best segmentation accuracy while also balancing execution speed, resulting in the best performance.
[0092] Table 1. Performance impact of different backbone networks
[0093]
[0094] Note: The bold text in all tables in this manual represents the optimal value for the corresponding column.
[0095] Analysis of the results of ablation experiment 2:
[0096] This invention designs a feature block attention mechanism and proposes 4GD-SAM to better adapt it to feature extraction of character images. Based on these improvements, comparative experiments were conducted under three conditions: without an attention module, using a CBAM module, and using the improved 4GD-SAM feature block attention mechanism of this invention, verifying the rationality of the attention mechanism. To better analyze the network attention performance after the SAM improvement, this experiment used the Grad-CAM method to visualize the output convolutional layers in the network. Grad-CAM is based on gradient calculation after backpropagation of network layers. The color distribution in the generated heatmap represents the network's attention distribution to the image. The calculation method is as follows:
[0097]
[0098] Where A represents a certain layer, k represents the k-th channel of A, and c represents the category c. Representative targeting A k The weights were determined. Attention was visualized for four images in this experiment, and the results are as follows: Figure 7 As shown, (a) is the original image; (b) without attention mechanism; (c) CBAM module; (d) feature block attention mechanism in this invention.
[0099] The experimental results are shown in Table 2:
[0100] Table 2. Impact of the Attention Module on Network Performance
[0101]
[0102] The data results show that the model using the CBAM module performs slightly better than the model without attention, while the model using the feature block attention mechanism incorporating the 4GD-SAM of this invention outperforms both. The Grad-CAM heatmap clearly demonstrates that, compared to the original SAM, the method of this invention not only makes the network attention more evenly focused on the character itself, strengthening the attention to the character as a whole and reducing character omissions due to uneven attention, but also distributes even, slight attention to areas around the bottom of the can where characters might appear, avoiding over-segmentation of noise caused by uneven attention to the surrounding areas resulting from the lack of attention or the CBAM module. This is thanks to the 4GD-SAM feature block strategy, which mitigates excessive feature abstraction and better preserves the concentrated attention to character detail areas and the even, slight attention to surrounding areas where characters might appear.
[0103] Analysis of the results of ablation experiment 3:
[0104] The multi-supervision module (DS module) and the improved loss function settings have a significant impact on network performance. The former mainly affects network convergence performance, while the latter has a greater impact on the final segmentation accuracy. The loss function of the algorithm in this invention, BID Loss, is a fusion of BCE Loss, IoU Loss, and Dice Loss. The latter two describe the overlap rate between the segmentation result and the ground truth and have certain similar meanings. Therefore, we intend to set weighting coefficients to amplify the influence of BCE Loss and balance the influence of the latter two. Thus, in this experiment, the weighting coefficients A, B, and C are set to 1:1:1 and 2:1:1, respectively, and the performance is compared with that of BCE Loss alone. At the same time, the group with better performance is further compared with the multi-supervision module by adding multi-supervision to compare the impact of the multi-supervision module on network performance.
[0105] The results of each method are shown in Table 3, where the BID Loss with a weight coefficient of 2:1:1 achieved the best performance. Based on this, a DS mechanism was added to monitor the training process. The training performance with and without the DS mechanism (the relationship between the number of epochs and Dice) is shown in Table 3. Figure 8 It can be seen that the training convergence speed is faster with DS than without DS. Table 3 uses the number of convergence epochs as a quantitative indicator to describe the convergence speed. The number of convergence epochs here refers to the number of epochs required to reach the 99% maximum Dice coefficient. Without DS, 102 epochs are required, while with DS, only 56 epochs are required. However, the final segmentation accuracy achieved by both methods is almost the same. The results show that the segmentation performance of BID Loss (2:1:1) is the best, and the convergence speed is faster with DS.
[0106] Table 3. Impact of loss function and multiple supervision on network performance
[0107]
[0108] Comparative analysis of experimental results:
[0109] To verify the performance of the segmentation method of this invention, a comparative experiment with other advanced methods was conducted. The experimental results are presented in Table 4, where the number of parameters (Params) and floating-point computation (FLOPs) are used to measure the complexity of the network structure and the efficiency of the algorithm. The inputs were calculated based on the size of the laser-marked character dataset on the bottom of the tank in this invention. The actual processing speed under the experimental hardware is expressed in FPS (including I / O time). The results show that the method of this invention has the best segmentation accuracy and the fastest processing speed among the compared methods, indicating that the introduction of the residual module not only improves the network performance but also reduces the network complexity. At the same time, the introduction of 1×1 convolution also reduces the number of network parameters.
[0110] Table 4 Performance Comparison of Different Segmentation Methods
[0111]
[0112]
[0113] Figure 9 The figures show the comparative experimental results of four test set sample images, where (a) original image; (b) GT; (c) Otsu's double threshold method; (d) adaptive threshold segmentation + connected component denoising; (e) Gaussian difference scale space + maximum entropy method; (f) UNet; (g) UNet++; (h) MSR+UNet; (i) RA-UNet; (j) improved UNet; (k) RV-GAN; and (l) the method of this invention.
[0114] To more clearly illustrate the segmentation results, the ROI (Region of Interest) in Figure (a) is used for display. The segmentation methods used for character encoding, unable to extract deep semantic information, failed to effectively overcome low contrast and noise issues, generally resulting in missing characters and severe noise. In medical segmentation methods, both the original UNet and the UNet combined with MSR exhibited slight noise and missing strokes. UNet++ showed significant ambient noise, while RA-UNet and the improved UNet also showed a small number of missing strokes. RV-GAN, as a better method for retinal vessel segmentation, preserved character details well, but its noise removal effect was poor. The segmentation result of the method in this invention is closest to the true value.
[0115] Some steps in the embodiments of the present invention can be implemented using software, and the corresponding software program can be stored in a readable storage medium, such as an optical disc or a hard disk.
[0116] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A laser-coded character segmentation method, characterized in that, The laser-coded character segmentation method includes: Step 1: Downsampling encoding stage; The ResNet18 encoder backbone is constructed using four cascaded attention-residual feature extraction units to downsample the image to be segmented, while a 1×1 convolution is introduced to reduce the number of encoder output feature channels. Step 2: Upsampling decoding stage; Image upsampling is performed using bilinear interpolation to make it the same size as the feature map to be stitched. After the feature maps are stitched, two 3×3 convolutions are performed to fuse the features of the deencoder and restore the image information. Each layer has a side output. Step 3: Input the side output of each layer into the multi-supervision module and perform loss calculation and gradient backpropagation with the ground truth to improve segmentation accuracy and network convergence speed; finally, use one upsampling and 1×1 convolution to restore the image size and number of channels to the original image size and number of channels, and output the final segmentation binary image. The attention-residual feature extraction unit includes: two residual structures and one feature block attention mechanism; The residual structure comprises two sets of sequentially connected convolutional layers, BN layers, and ReLU function layers; The feature block attention mechanism is connected after the two residual structures, and is sequentially connected to: the CAM channel attention mechanism and the 4GD-SAM feature block spatial attention mechanism. The implementation steps of the feature block attention mechanism include: Step 11: Using the Channel Attention Mechanism (CAM), global high-level semantic features of the input feature map are extracted by performing global average pooling and global max pooling on the channel dimension. Then, channel compression and expansion are performed on each channel using a Multilayer Perceptron (MLP). Features between channels are tracked and filtered using weight learning. Finally, a Sigmoid activation is applied to generate the channel attention weight descriptor M. c (F), the calculation method is as follows: Where F is the input feature map, σ is the Sigmoid function, and W1 and W0 are the channel transformation weight matrices of the multilayer perceptron; Step 12: Divide the input feature map into 4 equal blocks along the channel dimension, and then perform average pooling and max pooling on each sub-feature independently to form an 8-channel feature map. The formula is as follows, where chunk represents the channel segmentation: F'=chunk c / 4 (F) (3) Step 13: Finally, perform channel concatenation, convolution, and activation to form the final feature-labeled spatial attention descriptor M. 4GD-S (F), the specific calculation is as follows: Where cat represents channel concatenation, and the kernel size is a variable k.
2. The laser-coded character segmentation method according to claim 1, characterized in that, The multi-supervision module sets four side outputs in the last layer of the encoder and the first three layers of the decoder, extracting five feature maps of different semantic levels from the final result; and upsampling to the same size as the original image, using an improved BID loss function to calculate the loss; finally, the five losses are summed to obtain the final loss value. The improved BID loss function is: l bid =A·l bce +B·l IoU +C·l dice Among them, l bce Let l be the value of the cross-entropy loss function. IoU Let l be the IoU loss function value. dice Let A, B, and C be the Dice loss function values, and let A, B, and C be the weighting coefficients of the three loss functions, respectively.
3. The laser marking character segmentation method according to claim 2, characterized in that, The weighting coefficients A, B, and C of the three loss functions are in a ratio of 2:1:
1.
4. The laser-coded character segmentation method according to claim 1, characterized in that, The kernel size of the convolutional layer in the residual structure is 3.
5. The laser coding character segmentation method according to claim 1, characterized in that, The convolution kernel sizes used in the four scale-level feature maps of the 4GD-SAM from top to bottom are 7, 7, 3, and 3, respectively.
6. A laser-coded character segmentation system, characterized in that, The laser-coded character segmentation system includes: At least one storage medium storing at least one instruction set for segmenting an image containing laser-coded characters; and at least one processor communicatively connected to the at least one storage medium. When the laser character segmentation system is running, the at least one processor reads the at least one instruction set and implements the laser character segmentation method as described in any one of claims 1-5.
7. The laser character segmentation system according to claim 6, characterized in that, It also includes an image acquisition device for acquiring images of laser-coded characters to be detected and segmented.
8. The laser character segmentation system according to claim 6, characterized in that, It also includes a display device for outputting the final segmentation results.
Citation Information
Patent Citations
Automatic segmentation method for residual UNet rectal cancer tumor magnetic resonance image
CN112785617A
Skin lesion segmentation method based on convolution attention model
CN113744178A