A tooth image segmentation method combined with a SAM2 algorithm
By combining the deep learning model DE-SAM with the SAM2 algorithm, and utilizing the TSA module to enhance spatial awareness and the HCPM module to strengthen local details, the problem of blurred boundaries in tooth and alveolar bone segmentation is solved, achieving high-precision and automated tooth image segmentation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SOUTHWEST PETROLEUM UNIV
- Filing Date
- 2026-03-13
- Publication Date
- 2026-05-12
AI Technical Summary
Existing tooth and alveolar bone segmentation techniques struggle to distinguish blurred boundaries in CBCT images, leading to adhesion between tooth roots and bone or loss of fine bone structure. Furthermore, traditional models lack targeted optimization for dental anatomical features, failing to meet the high precision requirements of clinical practice.
The deep learning model DE-SAM based on the SAM2 algorithm is adopted, which combines the TSA module to enhance spatial awareness and long-range dependence, the HCPM module to enhance local details, and the AMFB module to perform adaptive multi-scale feature fusion. The model training is optimized through a multi-task loss function.
It improves the accuracy and boundary consistency of tooth and alveolar bone segmentation, reduces missegmentation, has a strong ability to preserve edge details, achieves end-to-end automated segmentation, and improves segmentation efficiency.
Smart Images

Figure CN121837302B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and specifically to a tooth image segmentation method combining the SAM2 algorithm. Background Technology
[0002] In digital oral medicine diagnosis and treatment, accurate segmentation of teeth and alveolar bone is a crucial step in orthodontic, implant, and maxillofacial surgery planning. CBCT is widely used due to its high spatial resolution, but existing segmentation techniques face significant challenges in processing such images. First, the complex anatomical structure and blurred boundaries are major pain points. The gray values of alveolar bone and tooth roots in CBCT images are extremely similar, and the periodontal ligament space is extremely fine. Existing techniques often cannot distinguish this blurred boundary well, leading to adhesion between the tooth root and bone in the segmentation results, or the loss of the fine bone structure of the alveolar ridge crest in the process of segmenting the tooth. Second, long-range dependence and insufficient spatial perception are also issues. Teeth have specific anatomical arrangement patterns, and the crown and root apex of a single tooth span a large spatial distance. Traditional convolutional neural networks are limited by local receptive fields and struggle to capture this long-range geometric dependence. This often results in fragmented segmentation results for slender tooth roots or an inability to correctly distinguish overlapping areas of adjacent teeth. In addition, existing large models have poor adaptability to medical features. Although models such as SAM have strong generalization ability, they lack targeted optimization for dental anatomical features. Directly applying existing models often results in rough performance in edge details, which cannot meet the requirements of high precision in clinical practice. Summary of the Invention
[0003] In view of this, this invention proposes a tooth image segmentation method combined with the SAM2 algorithm. This method trains an end-to-end deep learning model (Dento SAM, DE-SAM) for accurate segmentation of teeth and alveolar bone. Its core encoder is built based on SAM2 (Segment Anything Model 2), which effectively captures global semantic information and local structural details in dental images through multi-layer feature extraction. At the end of the encoder, the model introduces a dual-branch feature enhancement structure: on the one hand, the TSA (Token Spatial Attention) module explicitly models spatial geometric relationships and long-range dependencies through position encoding and relevance embedding, enhancing the overall perception ability of complex tooth morphology and alveolar bone boundaries; on the other hand, the HCPM (Hybrid Convolutional Perception Module) module combines multi-scale convolution, deconvolution, and batch normalization operations, and integrates the BAM (Bilinear Attention Module) attention mechanism to achieve efficient aggregation of local detail enhancement and contextual information, highlighting the fine structure of the tooth root and the density variation characteristics of the alveolar bone. In the decoding and upsampling stages, the model further uses AMFB (Adaptive MultiScale Fusion Block) to adaptively fuse the multi-layer features of the SAM encoder with the upsampled features of the corresponding scale, dynamically balancing the contributions of features at different scales, and achieving collaborative modeling of global semantics and local details. This improves the accuracy and boundary consistency of tooth and alveolar bone segmentation, and tooth image segmentation is performed based on this model.
[0004] To solve at least one of the above-mentioned technical problems, the present invention provides a tooth image segmentation method combining the SAM2 algorithm, comprising the following steps:
[0005] Step S1: Obtain the dental image sequence to be segmented and perform standardization preprocessing;
[0006] Step S2: Input the preprocessed image into the deep learning model, and encode and enhance local features through the encoder;
[0007] Step S3: Decode the encoded and enhanced features and perform cross-scale multi-feature fusion to restore the spatial resolution of the image and generate a segmentation mask to complete the model construction;
[0008] Step S4: Input the dataset into the model for supervised training;
[0009] Step S5: Use the trained model for segmentation of the dental image to be tested;
[0010] In step S2, the core encoder of the deep learning model is built based on SAM2, and TSA and HCPM modules are set in parallel branches at the end of the encoder.
[0011] The TSA module enhances the model's spatial awareness and long-range dependency modeling capabilities. By introducing positional encoding to explicitly embed the spatial coordinate information of each feature point, it enables the model to accurately understand the geometric distribution and relative positional relationships of teeth within the jawbone. Its core calculation formula is shown below:
[0012]
[0013] In the formula, Q , K , V These represent the query, key, and value matrices, respectively. The scaling factor is represented by `Attention()`; the attention mechanism function is represented by `Softmax()`; and the normalization function is represented by `Softmax()`. Represents the transpose of the key matrix;
[0014] The HCPM module includes parallel deep convolution and standard convolution to extract features from different receptive fields. The deep convolution is used to efficiently capture local details of enamel texture and root morphology, while the standard convolution is used to integrate features of alveolar bone density distribution areas. The HCPM module also includes a BAM submodule to calculate the collaborative weights of channels and spatial dimensions of key anatomical structures in dental images.
[0015] The core calculation formula for the HCPM module is shown below:
[0016]
[0017] In the formula, This represents the features after standard convolution processing; This represents the standard convolution operation; This represents the features after dilated convolution. This represents the dilation convolution operation; This indicates that the fused feature is obtained by adding the features from standard convolution and dilated convolution; Represents input features; This represents the attention weights generated by the BAM submodule; This represents the sigmoid activation function; This represents pointwise convolution; Pointwise convolution that represents vertical compression; Pointwise convolution represents horizontal compression; Indicates element weighting; This indicates the output characteristics of HCPM.
[0018] The technical effects achieved by this invention are:
[0019] 1. This invention effectively improves segmentation accuracy. Through global modeling of the TSA module and local enhancement of the HCPM module, this method outperforms traditional segmentation methods in all indicators on the test dataset and can reduce missegmentation of complex anatomical structures.
[0020] 2. The method in this invention has a stronger ability to preserve edge details. Thanks to the targeted extraction of boundary region features by the HCPM module and the introduction of Boundary Loss, the edges of the segmentation results of gray-scale blurred regions such as root apex and alveolar crest are more continuous and clear, which improves the structural breakage or adhesion problems commonly found in traditional methods.
[0021] 3. This method achieves end-to-end automated segmentation without the need for cumbersome manual preprocessing or complex postprocessing steps. Compared with manual and semi-automatic segmentation, it improves segmentation efficiency and has good potential for clinical application. Attached Figure Description
[0022] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained from these drawings without creative effort.
[0023] Figure 1 This is a flowchart of the tooth image segmentation method combined with the SAM2 algorithm in this invention.
[0024] Figure 2 This is a diagram of the overall architecture of the DE-SAM model of this invention.
[0025] Figure 3 This is a diagram of the AMFB module architecture of the present invention.
[0026] Figure 4 This is the final segmentation result of the experiment. Detailed Implementation
[0027] The present invention will be further described in detail below with reference to the embodiments and accompanying drawings.
[0028] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention. Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention.
[0029] A tooth image segmentation method combining the SAM2 algorithm includes the following steps:
[0030] Step S1: Obtain the dental image sequence to be segmented and perform standardization preprocessing;
[0031] The first step of this method is to acquire and standardize the dental CBCT (cone beam computed tomography) image sequence to be segmented. This step is fundamental to subsequent high-precision segmentation. Since raw CBCT data is typically in DICOM format and contains a large amount of background unrelated to anatomical structures and metal artifacts, directly inputting it into the model would waste computational resources and affect segmentation accuracy. Therefore, the process first performs windowing on the raw images to remove extremely high and low grayscale values, thus preserving the regions of interest containing teeth and alveolar bone. Next, to enhance the contrast between the alveolar bone trabecular structure and the tooth root, a contrast-limited adaptive histogram equalization algorithm is used to enhance the image and highlight bone texture. Finally, all processed image slices are adjusted to a uniform resolution. After this series of preprocessing operations, the raw data is transformed into high-quality standard tensors, which are then input into the subsequent network.
[0032] Step S2: See Figure 1 The preprocessed image is input into the deep learning model, where it is encoded and local feature enhanced by the encoder.
[0033] The core encoder of the deep learning model is built based on SAM2. At the end of the encoder, parallel branches include TSA and HCPM modules. The basic image processing flow is as follows: First, the image is input into the SAM2 iambeencoder to obtain four feature maps of different sizes. The smallest feature map is then input into the TSA and HCPM modules respectively. After feature enhancement by these two modules, the outputs of TSA, HCPM, and the smallest feature map from SAM2 are fused. This fused feature map is then upsampled to become the third largest feature map, which is then fused with the original third largest feature map from SAM2 into AFMB to obtain the final third largest feature map. This process is repeated to obtain the second and largest feature maps. Finally, the first, second, and third largest feature maps are upsampled by different factors to output the final result.
[0034] The preprocessed image is input into the DE-SAM model, where it first undergoes feature extraction via an encoder. For example... Figure 2 As shown, the input image undergoes layers of convolution and Transformer blocks in the encoder to generate feature maps of different scales. This process maps the image from the original pixel space to a high-dimensional feature space. To overcome the shortcomings of traditional encoders in capturing long-range dependencies in medical images, this embodiment introduces a token space attention module for global feature enhancement at the deep feature output of the encoder.
[0035] The TSA module is designed to allow the model to explicitly perceive the geometric distribution of teeth within the jawbone. In this step, the model first adds explicit spatial location encoding to the input feature map, ensuring that each feature point carries its absolute coordinates within the original anatomical structure, enabling it to accurately understand the geometric distribution and relative positional relationships of teeth within the jawbone. Subsequently, the TSA module utilizes a self-attention mechanism to calculate global correlations, dynamically capturing long-distance feature dependencies, thereby effectively addressing the loss of alveolar bone microstructural features caused by the locality of convolution operations. Its multi-head attention architecture further allows the model to focus on feature patterns in different subspaces in parallel, strengthening the response of key regions through a weighted aggregation mechanism, improving the contour accuracy and structural consistency for challenging segmentation targets such as tooth edges, apical regions, and alveolar ridge crests. The specific calculation process is as follows:
[0036] First, the query, key, and value tensors are generated using linear projection, as shown in the following equation:
[0037]
[0038] in The core formula for the learnable weight matrix is as follows:
[0039]
[0040] In the formula, Q , K , V These represent the query, key, and value matrices, respectively. The scaling factor is represented by `Attention()`; the attention mechanism function is represented by `Softmax()`; and the normalization function is represented by `Softmax()`. Represents the transpose of the key matrix;
[0041] Through this calculation, the model establishes a semantic connection between any two pixels in the image and outputs enhanced features containing global spatial location information, effectively solving the problem of easy breakage at slender tooth roots.
[0042] To address the segmentation challenges caused by blurred boundaries and similar gray levels between teeth and alveolar bone while the encoder extracts features, this invention performs parallel local feature enhancement in the intermediate feature layer of the encoder. This step is accomplished through a hybrid convolutional perceptual module. For example... Figure 2 As shown in the HCPM section, this module receives intermediate layer features. And it performs in-depth mining through three parallel branches: Branch one utilizes Standard convolution extracts region density features; branch two uses depth convolution with a dilation rate greater than 1 to expand the receptive field and capture high-frequency texture details; branch three uses a bilinear attention mechanism to generate spatial and channel attention maps.
[0043] The HCPM module includes parallel deep convolutions and standard convolutions to extract features from different receptive fields. Deep convolutions are used to efficiently capture local details of enamel texture and root morphology, while standard convolutions are used to integrate features of alveolar bone density distribution areas. The module first uses parallel deep convolutions and standard convolutions to extract features from different receptive fields: deep convolutions efficiently capture local details such as enamel texture and root morphology, while standard convolutions integrate features of alveolar bone density distribution areas. Then, multi-channel information is dynamically fused through pointwise convolutions, significantly enhancing feature representation capabilities.
[0044] The HCPM module also includes a BAM submodule, which calculates the collaborative weights of the channel and spatial dimensions of key anatomical structures in dental images. By using a bilinear attention mechanism to calculate the collaborative weights of the channel and spatial dimensions, it prioritizes key anatomical structures such as the root apex and alveolar ridge crest, suppressing irrelevant background interference. This enables HCPM to adaptively enhance the feature response of the tooth-alveolar bone boundary region, solving the segmentation difficulties caused by similar gray levels and blurred boundaries, and ultimately improving the model's recognition accuracy and robustness for complex oral structures.
[0045] In this step, the mathematical expression of the HCPM module follows the core calculation formula shown below:
[0046]
[0047] In the formula, This represents the features after standard convolution processing; This represents the standard convolution operation; This represents the features after dilated convolution. This represents the dilation convolution operation; This indicates that the fused feature is obtained by adding the features from standard convolution and dilated convolution; Represents input features; This represents the attention weights generated by the BAM submodule; This represents the sigmoid activation function; This represents pointwise convolution; Pointwise convolution that represents vertical compression; Pointwise convolution represents horizontal compression; Indicates element weighting; This indicates the output characteristics of HCPM.
[0048] This step significantly enhances the model's ability to identify fine structures such as alveolar ridge crests and periodontal ligament spaces, making the output features more discriminative at fuzzy boundaries.
[0049] Step S3: Decode the encoded and enhanced features and perform cross-scale multi-feature fusion to restore the spatial resolution of the image and generate a segmentation mask to complete the model construction;
[0050] The encoded and enhanced features then enter the decoder stage. In this stage, the invention implements a key adaptive multi-scale fusion strategy to gradually restore the spatial resolution of the image and generate a segmentation mask.
[0051] like Figure 3 As shown, the decoding and upsampling stages of the deep learning model also include an AMFB module, which comprises two sequentially arranged parts: AFFM and CMFF. The AMFB module first receives feature inputs at different scales through an adaptive feature fusion (AFFM) sub-step, and then performs weighted fusion to process the high-level semantic features from the encoder. and low-level detail features from the upsampling path To address the issue of inconsistent contributions from the two components, the network automatically learns two scalar weight parameters. and The fusion ratio is dynamically adjusted based on the complexity of the image content. The fusion formula is as follows:
[0052]
[0053] In the formula, and These represent the adaptive weights learned by AFFM; This indicates element-wise weighting; and These represent high-level semantic features and low-level detail features, respectively.
[0054] Features after fusion The process then proceeds to the multi-scale feature fusion (CMFF) sub-step. Within the CMFF, the MSCB (Multi-Scale Convolution Block) processes features in parallel using multiple convolutional kernels, including both standard convolutional branches and dilated convolutional branches, to capture local features within different receptive fields.
[0055] After the outputs of the two convolutional branches are added together, the interaction of feature channels is enhanced through channel grouping and shuffle operations, thereby further improving the feature representation capability.
[0056] The specific operation of this process is shown in the following formula:
[0057]
[0058] In the formula, Represents input features; () represents the standard convolution operation; This represents the dilation convolution operation; This indicates the characteristics after the Shuffle operation; () indicates a shuffle operation, used to enhance interaction between channels.
[0059] After the MSCB output, the BAM branch performs spatial attention modeling on the features, with the following formula:
[0060]
[0061] In the formula, This represents the output characteristics after AFFM fusion; () indicates the adaptive feature fusion module; Indicates the first Features of the MSCB output; () indicates the first Multi-scale convolutional blocks; Indicates the stacking sequence number; This represents the spatial attention weights generated by BAM within the CMFF; This indicates the characteristics of the MSCB output; Indicates the first Features after attention weighting; This represents the output characteristics of AMFB.
[0062] BAM employs a two-branch pointwise convolution (PWConv). One branch compresses the features to an H×1 dimension, and the other branch compresses them to a 1×H dimension. The two branches are multiplied to obtain an H×H spatial correlation map, which is then mapped to an H×H×C channel attention vector using PWConv. Finally, sigmoid activation normalizes the weights, which are then multiplied element-wise with the fused multi-scale features to enhance locally important features. This process highlights the details of tooth edges, alveolar bone contours, and microstructures. This decoding and fusion process is repeated until the feature map is restored to the original resolution, ensuring that the final output contains both accurate semantic category information and clear geometric boundaries.
[0063] Step S4: Input the dataset into the model for supervised training;
[0064] After the model is built, DE-SAM is trained under supervision using a labeled dataset. To guide the model to simultaneously focus on pixel classification accuracy, region overlap rate, and boundary consistency, this invention designs and calculates a multi-task weighted loss function, mul_loss. This loss function combines binary cross-entropy loss BCELoss, IoU loss IoULLoss, Dice loss DiceLoss, and boundary loss BoundaryLoss, and its total loss formula is as follows:
[0065]
[0066] In the formula, This represents the weighted combination loss function mul_loss; The loss function is BCELoss; Represents the loss function IoULoss; DiceLoss represents the loss function; This represents the loss function, BoundaryLoss.
[0067] The loss function BCELoss is used to measure the binary classification error between the pixel probability output by the model and the true label, as shown in the following formula:
[0068]
[0069] In the formula, Indicates the total number of pixels; This represents the boundary gradient of the model's predicted labels; Represents the boundary gradient of the true label;
[0070] The loss function IoULoss controls the degree of overlap between the predicted and ground truth regions, penalizes shape deviations in the segmented regions, and encourages the network to match the overall segmentation shape with the ground truth label. Specifically, it is shown in the following equation:
[0071]
[0072] The loss function DiceLoss is used to reflect the overlap of regions and solve the problem of imbalance between positive and negative samples. The specific formula is as follows:
[0073]
[0074] In the formula, This indicates a smoothing term to prevent division by zero errors;
[0075] The boundary loss function is crucial in this step. It uses the Sobel operator to calculate the difference between the predicted and true label boundary gradients, forcing the predicted boundary to be sharper, as shown in the following formula:
[0076]
[0077] In the formula, This represents the Sobel gradient operator. The model parameters are continuously updated by minimizing the total loss using the backpropagation algorithm until the model converges.
[0078] Step S5: Use the trained model for segmentation of the dental image to be tested;
[0079] Example:
[0080] Once the model is trained, the CBCT image to be tested can be input, and the model will directly output pixel-level segmentation masks for teeth and alveolar bone. To verify the effectiveness of this embodiment, Figure 4 The diagram shows the segmentation results of the method of the present invention on actual clinical data.
[0081] Figure 4 The original image dataset for the results predicted by this model originated from West China Hospital of Stomatology, Sichuan University. A total of 213 cases of Medical Digital Imaging and Communication (DICOM) format data were collected. After reasonable screening, 165 patient samples were finally selected to participate in the experiment. The cohort included 86 males and 79 females, with an age range of 10 to 55 years. Data were acquired by cone-beam computed tomography (CBCT) scans using equipment manufactured by Morita Manufacturing Co., Ltd., Japan. Specific imaging parameters were as follows: slice thickness (interval) 1 mm, peak tube voltage 85 kV, and X-ray tube current 5 mA.
[0082] To verify the effectiveness and superiority of the proposed DE-SAM model in tooth and alveolar bone segmentation tasks, this invention selected several representative medical image segmentation models for comparative experiments, including the classic convolutional network UNet, the context-enhanced model CENet, the multi-scale feature fusion model CPFNet, the CNN-Transformer hybrid structure UCTransNet, the attention-enhanced network FAT-Net, the structural attention network DCSAU-Net, and UN-SAM based on large model transfer. All models were trained and tested under the same dataset partitioning, training strategy, and evaluation metric settings to ensure the fairness and comparability of the experimental results. Model performance was comprehensively evaluated from multiple dimensions, including region overlap (Dice, mIoU), overall pixel classification accuracy (Acc), and boundary accuracy (HD95, ASD).
[0083] Table 1. Experimental results comparing the performance of segmentation models
[0084]
[0085] The experimental results are shown in Table 1. Overall, the proposed method achieved optimal or competitive performance on most evaluation metrics. Traditional CNN methods (such as UNet and CENet) suffer from limited receptive fields and insufficient ability to model complex tooth boundaries and fine alveolar bone structures, with Dice values of 0.9123 and 0.9154, respectively, showing relatively limited overall performance. CPFNet and UCTransNet, which introduce multi-scale fusion and contextual modeling, improved segmentation accuracy, with UCTransNet achieving a Dice of 0.9376, indicating that the Transformer structure can effectively enhance global semantic modeling capabilities. Furthermore, the attention-enhanced models FAT-Net and DCSAU-Net significantly improved boundary metrics, with HD95 decreasing to 3.57 and 2.98, respectively, indicating that structural attention helps improve boundary consistency. The SAM-based transfer model UN-SAM further validated the potential of large-scale pre-trained models in medical image segmentation tasks, achieving a Dice of 0.9515, demonstrating that the SAM encoder can provide strong general representation capabilities. However, UN-SAM mainly relies on the original encoded features for decoding and lacks a feature enhancement mechanism for the structural characteristics of dental images. It still suffers from insufficient local detail representation in complex root morphology and alveolar bone boundary areas.
[0086] In comparison, the proposed DE-SAM achieves the best overall segmentation performance, with Dice and mIoU reaching 0.9662 and 0.9354 respectively, representing improvements of 1.47% and 0.42% compared to UN-SAM. This performance improvement primarily stems from three structural design aspects: First, the TSA module, by explicitly modeling spatial relationships and long-range dependencies, effectively compensates for the shortcomings of SAM's encoded features in modeling local geometric relationships, enabling the model to establish an overall structural association between the crown, root, and alveolar bone. Second, the HCPM module utilizes multi-scale convolution and bilinear attention mechanisms to enhance local texture and boundary responses, improving the ability to identify grayscale proximity regions and blurred edges. Furthermore, the AMFB multi-scale adaptive fusion strategy dynamically integrates semantic information from different levels during the decoding stage, achieving synergistic optimization of global semantics and fine-grained structure. Thanks to these designs, DE-SAM achieves the lowest ASD score of 0.071, indicating higher contour consistency in challenging boundary regions such as the root apex and alveolar ridge. Although Acc is similar to UN-SAM, the proposed method not only improves the overall segmentation accuracy but also significantly enhances the ability to recover details of complex anatomical structures and the robustness of the model by combining the region overlap and boundary distance indices.
[0087] The above description is merely a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the embodiments of the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A tooth image segmentation method combining the SAM2 algorithm, characterized in that, Includes the following steps: Step S1: Obtain the dental image sequence to be segmented and perform standardization preprocessing; Step S2: Input the preprocessed image into the deep learning model, and encode and enhance local features through the encoder; Step S3: Decode the encoded and enhanced features and perform cross-scale multi-feature fusion to restore the spatial resolution of the image and generate a segmentation mask to complete the model construction; Step S4: Input the dataset into the model for supervised training; Step S5: Use the trained model for segmentation of the dental image to be tested; In step S2, the core encoder of the deep learning model is built based on SAM2, and TSA and HCPM modules are set in parallel branches at the end of the encoder. The TSA module enhances the model's spatial awareness and long-range dependency modeling capabilities. By introducing positional encoding to explicitly embed the spatial coordinate information of each feature point, it enables the model to accurately understand the geometric distribution and relative positional relationships of teeth within the jawbone. Its core calculation formula is shown below: In the formula, Q , K , V These represent the query, key, and value matrices, respectively. The scaling factor is represented by `Attention()`; the attention mechanism function is represented by `Softmax()`; and the normalization function is represented by `Softmax()`. Represents the transpose of the key matrix; The HCPM module includes parallel deep convolution and standard convolution to extract features from different receptive fields. The deep convolution is used to capture local details of enamel texture and root morphology, while the standard convolution is used to integrate features of alveolar bone density distribution areas. The HCPM module also includes a BAM submodule to calculate the collaborative weights of channels and spatial dimensions of key anatomical structures in dental images. The core calculation formula for the HCPM module is shown below: In the formula, This represents the features after standard convolution processing; This represents the standard convolution operation; This represents the features after dilated convolution. This represents the dilation convolution operation; This indicates that the fused feature is obtained by adding the features from standard convolution and dilated convolution; Represents input features; This represents the attention weights generated by the BAM submodule; This represents the sigmoid activation function; This represents pointwise convolution; Pointwise convolution that represents vertical compression; Pointwise convolution represents horizontal compression; Indicates element weighting; This indicates the output characteristics of HCPM.
2. The tooth image segmentation method combining the SAM2 algorithm according to claim 1, characterized in that: The dental image is a tapered wire harness image.
3. The tooth image segmentation method combining the SAM2 algorithm according to claim 1, characterized in that: The decoding and upsampling stage of the deep learning model in step S2 also includes an AMFB module, which comprises two parts, AFFM and CMFF, set sequentially.
4. The tooth image segmentation method combining the SAM2 algorithm according to claim 3, characterized in that: The AFFM is used to receive feature inputs at different scales and perform weighted fusion to obtain the fused features. Its core calculation formula is shown below: In the formula, and These represent the adaptive weights learned by AFFM for high-level and low-level features, respectively. This indicates element-wise weighting; and These represent high-level semantic features and low-level detail features, respectively.
5. A tooth image segmentation method combining the SAM2 algorithm according to claim 4, characterized in that: The CMFF is set up in AMFB in a stacked manner three times, and is used to perform multi-scale convolution and attention enhancement on the fused features after AFFM processing. The core calculation formula of CMFF is shown in the following formula: In the formula, This represents the output characteristics after AFFM fusion; () indicates the adaptive feature fusion module; Indicates the first Features of the MSCB output; () indicates the first Multi-scale convolutional blocks; Indicates the stacking sequence number; This represents the spatial attention weights generated by BAM within the CMFF; This indicates the characteristics of the MSCB output; Indicates the first Features after attention weighting; This represents the output characteristics of AMFB.
6. A tooth image segmentation method combining the SAM2 algorithm according to claim 3, characterized in that: The feature input received by the AMFB module is processed sequentially by AFFM and CMFF and then summed. The expressive power of the features is further enhanced through channel grouping and shuffle operations. The operating principle of this process is shown in the following equation: In the formula, Represents input features; () represents the standard convolution operation; This represents the dilation convolution operation; This indicates the characteristics after the Shuffle operation; () indicates a shuffle operation, used to enhance interaction between channels.
7. The tooth image segmentation method combining the SAM2 algorithm according to claim 1, characterized in that: The loss function for supervised training in step S4 is a weighted combined loss function mul_loss, which consists of four loss functions: BCELoss, IoULLoss, DiceLoss, and BoundaryLoss, as shown in the following formula: In the formula, This represents the weighted combination loss function mul_loss; The loss function is BCELoss; Represents the loss function IoULoss; DiceLoss represents the loss function; This represents the loss function, BoundaryLoss. The loss function BCELoss is used to measure the binary classification error between the pixel probability output by the model and the true label, as shown in the following formula: In the formula, Indicates the total number of pixels; This represents the boundary gradient of the model's predicted labels; Represents the boundary gradient of the true label; The loss function IoULoss controls the degree of overlap between the predicted and ground truth regions, encouraging the network to match the overall segmentation shape with the ground truth labels, as shown in the following formula: The loss function DiceLoss is used to reflect the overlap of regions, as shown in the following formula: In the formula, This indicates a smoothing term to prevent division by zero errors; The loss function BoundaryLoss is used to calculate the difference between the predicted and true label boundary gradients, as shown in the following formula: In the formula, This represents the Sobel gradient operator.