A head shadow landmark location method based on double-layer CSwin and CNN
By combining the double-layer CSwin Transformer and CNN, using depth-separable convolution and cross-shaped window self-attention mechanism, it solves the problem of insufficient positioning accuracy and robustness of traditional models in medical image processing, and achieves a more efficient head. Shadow mark point positioning and image segmentation effects.
Patent Information
- Application Number
- CN202410277189.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-12
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-03-12
AI Technical Summary
Traditional CNN models and deep neural networks have problems with insufficient positioning accuracy and robustness in processing complex and highly variable data in medical images.
The head shadow landmark positioning method uses double-layer CSwin and CNN, uses Densenet-121 as the backbone network, combined with double-layer CSwin Transformer, uses depth-separable convolution and cross-shaped window self-attention mechanism to extract multi-scale features and perform feature extraction Fusion to improve the representation ability and adaptability of the model.
It improves the accuracy and robustness of head shadow landmark positioning, can better adapt to different types and complexity of medical image data, and enhances the model's understanding and adaptability to complex structures and changes.
Smart Images

Figure CN118014981B
Abstract
Description
Technical Field
[0001] The invention belongs to the field of computer vision and medical image processing, and in particular relates to a head shadow landmark point positioning method based on double-layer CSwin and CNN. Background Art
[0002] In the field of computer vision and medical image processing, the automatic localization of cephalometric landmarks is an important task in the analysis of lateral head image data. Traditional methods often rely on manually designed feature extraction and rule formulation, which may be limited by complex image changes and diversity and difficult to adapt to changes in different data sets and scenes.
[0003] In recent years, with the development of deep learning technology, especially the successful application of convolutional neural network (CNN) in image processing, automatic landmark localization has made significant progress. CNN can learn high-level feature representation from images, which helps to improve the understanding and representation of complex image structures.
[0004] For example, Chinese patent document with publication number CN109146845A discloses a method for detecting landmark points in skull images based on a convolutional neural network. The positioning accuracy of the landmark points is improved through the design of the network structure and the selection of the loss function.
[0005] A Chinese patent document with publication number CN116012689A discloses a semi-supervised medical image landmark location method based on topological structure constraints, which uses a deep neural network to locate the landmarks of medical images.
[0006] However, for complex and highly variable data such as medical images, traditional CNN models and deep neural networks may still have certain limitations, and there is still room for improvement in positioning accuracy and robustness. Summary of the invention
[0007] The present invention provides a head shadow landmark point positioning method based on double-layer CSwin and CNN, which can obtain more accurate head shadow landmark point positioning results.
[0008] A head shadow landmark location method based on double-layer CSwin and CNN, comprising the following steps:
[0009] (1) Collect a dataset of lateral head images, annotate the head landmarks and divide it into a training set and a validation set;
[0010] (2) Preprocessing the lateral head images in the training set and the validation set; and converting the positions of the head shadow landmarks in the lateral head images into two-dimensional Gaussian heat maps;
[0011] (3) constructing a landmark positioning model, wherein the landmark positioning model includes a CNN encoder, a double-layer CSwin encoder and a decoder;
[0012] Among them, the CNN encoder uses Densenet-121 as the backbone network. In the corresponding four CNN blocks, the standard convolution is replaced by the depth-separable convolution. The multi-scale features of the head lateral image are extracted by the CNN encoder. 1 , C 2 , C 3 , C 4};
[0013] In the two-layer CSwin encoder, each layer of CSwin has four stages. The CSwin Block of each stage extracts the corresponding feature representation, and then inputs the features of the same stage into the CF module to obtain the fusion features of each stage of the head lateral image {S 1 , S 2 , S 3 , S 4};
[0014] Finally, the multi-scale features {C 1 , C 2 , C 3 , C 4} and the fusion features of each stage output by the double-layer CSwin encoder {S 1 , S 2 , S 3 , S 4 The decoder first fuses the features of the same scale from the two encoders, and then fuses the features of different scales from the previous stage through upsampling. Finally, the final features are regressed through two layers of convolution to obtain the predicted heat map.
[0015] (4) Use the training set to train the landmark positioning model, and verify the trained model using the verification set;
[0016] (5) Preprocessing the lateral head image to be located is input into the trained model to predict the heat map of the head shadow landmark points; converting the heat map into landmark points to obtain the coordinates of the head shadow landmark points.
[0017] Furthermore, in step (2), the positions of the head shadow landmarks in the lateral head image are converted into a two-dimensional Gaussian heat map. The specific process is as follows:
[0018] First, set the heat map of each landmark point to all 0s and set the landmark point coordinates to (x 0 ,y 0), according to radius, a two-dimensional grid is generated to obtain two one-dimensional arrays xx and yy, which cover a two-dimensional range with values from -radius to radius. Then, a two-dimensional Gaussian distribution is generated by applying the Gaussian distribution formula, which is as follows:
[0019]
[0020] Among them, σ represents the range of the control distribution, which is set to 8 here, and radius is set to 20;
[0021] Then, the values on the two-dimensional Gaussian distribution that are less than the threshold are set to zero to increase the sparsity of the Gaussian distribution; then, the effective range of the assignment operation on the heat map is determined, and the generated Gaussian distribution is locally placed in the central area of the heat map;
[0022] Finally, we need to avoid the situation where multiple key points appear on the same heat map. The formula for determining the range is as follows;
[0023] gaussian[gaussian<finfo(gaussian.dtype).eps*gaussian.max()]=0
[0024] left,right=min(x 0 , radius), min(width-x 0 , radius+1)
[0025] top,bottom=min(y 0 , radius), min(height-y 0 , radius+1)
[0026] Where width and height represent the width and height of the heat map. In step (3), the depthwise separable convolution splits the standard convolution into two steps: depthwise convolution and pointwise convolution. The specific formula is as follows: Depthwise SeparableConvolution(x)=Pointwise Convolution(Depthwise Convolution(x))
[0027] Among them, Depthwise Separable Convolution refers to depth-separable convolution, PointwiseConvolution is point-by-point convolution with a 1x1 convolution kernel; Depthwise Convolution is a depth-wise convolution, and for an input with C input channels, C convolution kernels are used.
[0028] In step (3), the multi-scale features {C 1 , C 2 , C 3 , C 4} and the fusion features of each stage output by the double-layer CSwin encoder {S 1 , S 2 , S 3 , S 4}, and their resolutions are 1 / 4, 1 / 8, 1 / 16, and 1 / 32 respectively relative to the input lateral head image.
[0029] In step (3), in the two-layer CSwin encoder, the CF module is a fusion module of the two layers of CSwin, which includes a global attention module and a local attention module. Both of these attention mechanisms are composed of spatial attention SA and channel attention CA.
[0030] The CF module first concatenates the features of the same stage of the two-layer CSwin to obtain the input feature X. In the local attention module, it is divided into four feature vectors of equal size along the H and W directions. j , and then input them into the CA module to get the channel vector F cj , then the eigenvector f j With the channel vector F cj Multiply to get the updated channel vector F cj ; Then update the channel vector F cj Use the SA module to obtain the corresponding space vector F Sj , and then the updated channel vector F cj The corresponding space vector F Sj Multiply to get the updated space vector F Sj , and finally reorganize to obtain the output feature P of the local attention module 1 ;
[0031] In the global attention module, the input feature X is not divided, and the other steps are the same. It is input into the CA module and the SA module in turn to obtain the final output feature P 2 ; Finally, P 1 With P 2 Multiply to get the final output of the fusion feature S of each stage i .
[0032] The SA module uses the spatial information between regions to find some features related to the task. It performs adaptive maximum pooling and adaptive average pooling on the input features, connects the results of adaptive maximum pooling and adaptive average pooling to obtain a feature map with a dimension twice the number of channels, performs convolution operations on the connected feature map, and finally normalizes it: The formula is as follows:
[0033] F S =σ(ξ(Concat(P avg (X), P max (X))))
[0034] Among them, X represents the input feature, P avg and P Max Represents adaptive maximum pooling and adaptive average pooling in the channel dimension, ζ represents 7×7 convolution, and σ represents the sigmoid activation function;
[0035] The CA module assigns different weights to channels to measure the importance of features. First, the input features are globally averaged pooled, and then the result of the global average pooling is passed through the first fully connected layer, through a nonlinear activation function, and then the output of the first fully connected layer is passed through the second fully connected layer to obtain the final channel attention coefficient, which is then normalized. The formula is as follows:
[0036] F C =σ(FC 2 (ReLu(FC 1 (GAP(X)))))
[0037] Among them, FC represents the fully connected layer, GAP represents the global average pooling, and σ represents the sigmoid function.
[0038] In step (3), in the two-layer CSwin encoder, the CSwin Block of each stage adopts a cross-window self-attention mechanism to calculate self-attention in parallel in the horizontal and vertical directions; by dividing the input features into strips of equal width, each strip forms a window, achieving better results while limiting the computational cost. The formula is as follows
[0039] y l =CSWin-Attention(LN(x l-1 ))+x l-1
[0040] x l =MLP(LN(CSWin-Attention(LN(x l-1 ))+x l-1 ))+CSWin-Attention(LN(x l-1 ))+x l -1
[0041] Among them, x l Represents the output of the lth CSwin Block.
[0042] In step (3), the feature fusion module is used to fuse features of different scales. The specific process is as follows:
[0043] First, both features are input into the ECA module. The ECA module generates channel attention weights through a combination of adaptive average pooling, 1D convolution and sigmoid activation function, and applies them to the input features to obtain the output Z 1 , Z 2 ; The formula is as follows:
[0044] Y = σ(conv(GAP(X)))
[0045]
[0046] Among them, GAP represents global average pooling, σ represents the sigmoid activation function, and output represents the final output (two features are input to ECA respectively, so there are two outputs Z 1 , Z 2 ), X represents two input features, and Y represents the generated weight;
[0047] Then, Z 1 , Z 2 The features are extracted through 3×3Conv+Relu, and then the output of the previous layer (named X i+1 ) upsampled by a factor of two, and Z 1 , Z 2 Splicing to form the existing feature B i , initialize a normal distribution of attractor parameters, with B i Perform cross attention to form a new attractor, and then follow B i Perform cross attention to form the final feature X i The attractor parameter is a learning parameter that can help guide the model to focus on specific features or regions and enhance the ability of feature representation.
[0048] Compared with the prior art, the present invention has the following beneficial effects:
[0049] 1. The present invention uses two encoders, a deep convolutional neural network (Densenet-121) and a CSwin Transformer, to extract multi-scale features, which helps to capture the information in the head image more comprehensively, including structural features of different scales and levels.
[0050] 2. The present invention introduces CSwin Transformer, which uses a self-attention mechanism of a cross-shaped window to reduce computational complexity. Compared with the traditional Transformer model, CSwin Transformer is more adaptable in medical image processing and can effectively process the complex structure and changes of head shadow images.
[0051] 3. The present invention adopts a double-layer Swin Transformer with more Transformer modules, thus being able to achieve more levels of feature interaction and information fusion. This helps to improve the model's understanding and correlation between features at different scales and in different contexts, thereby improving the accuracy and robustness of medical image segmentation.
[0052] The two-layer Swin Transformer improves the model's representation ability by increasing the number of parameters and model capacity, which means that the model can better adapt to medical image data of different types and complexity and better solve various medical image segmentation tasks.
[0053] 4. CNN performs well in image processing and can learn rich local and global feature representations from the original image. CSwin introduces the self-attention mechanism in Transformer, which helps to capture the long-distance dependencies between different positions in the image. By fusing these two different types of feature representations, the present invention can comprehensively consider local and global information, thereby more comprehensively understanding the structure and characteristics of the head image.
[0054] Medical images are usually complex and highly variable. Traditional CNN models may have limitations in processing complex and highly variable data such as medical images, while CSwin's self-attention mechanism can improve the model's adaptability to complex structures and changes. By combining with CNN, the model can more comprehensively understand local and global features and improve its adaptability to different situations. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 This is a flow chart of a head shadow landmark location method based on double-layer CSwin and CNN of the present invention;
[0056] Figure 2 This is a framework diagram of the landmark positioning model in the present invention;
[0057] Figure 3 It is the structural diagram of CSwin Block in the present invention;
[0058] Figure 4 is a structural diagram of a decoder in the present invention;
[0059] Figure 5 It is a structural diagram of the CF module in the present invention. DETAILED DESCRIPTION
[0060] The present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be pointed out that the embodiments described below are intended to facilitate the understanding of the present invention and do not have any limiting effect on the present invention.
[0061] The embodiment of the present invention provides a head shadow landmark location method based on double-layer CSwin and CNN, and the method can also be extended to other target detection scenarios.
[0062] This method first processes images and landmarks through data preprocessing, including random horizontal flipping, random affine transformation and other methods; then, the landmark positions are transformed with the help of algorithms to obtain a two-dimensional Gaussian heat map; the processed images and landmark heat maps are input into a dual-channel model of a double-layer CSwin and CNN (named the landmark location model) for training to obtain the optimal model; finally, when locating the key points of the test set, the heat map is converted into landmark points to obtain the predicted key point coordinates.
[0063] like Figure 1 As shown, a head shadow landmark location method based on double-layer CSwin and CNN includes the following steps:
[0064] Step 1: Get two datasets, one with 19 points and the other with 38 points. Use the two datasets for training respectively. The training process for each dataset is the same as Figure 1 As shown in the figure, the training set, validation set, and test set of 19 points are 150, 150, and 100 images respectively; the training set, validation set, and test set of 38 points are 300, 50, and 50 images respectively.
[0065] Step 2: Since the number of training sets is small, data augmentation technology is used to transform the training sets to enhance the robustness of the model. Considering the limitations of the graphics card, the image is first scaled to 512*512, and then the image is randomly flipped horizontally with a probability of 0.5, and then a random affine transformation is performed with a probability of 0.5, a scaling ratio of [0.8, 1.2], a rotation angle of [-15°, 15°], and a translation distance of [-10, 10].
[0066] Step 3: First, set the heat map of each landmark point to all 0s and set the landmark point coordinates to (x 0 ,y 0 ), according to radius, generate a two-dimensional grid, generate two one-dimensional arrays xx and yy, which cover a two-dimensional range with values from -radius to radius, and then generate a two-dimensional Gaussian distribution by applying the Gaussian distribution formula, the formula is as follows:
[0067]
[0068] Where σ represents the range of the control distribution, which is set to 8 here, and radius is set to 20.
[0069] Then, the values on the Gaussian that are less than the threshold are set to zero to increase the sparsity of the Gaussian distribution; then the effective range of the assignment operation on the heat map is determined, and the generated Gaussian distribution is locally placed in the central area of the heat map. Finally, it is necessary to avoid the situation where multiple key points appear on the same heat map. The formula for determining the range is as follows.
[0070] gaussian[gaussian<finfo(gaussian.dtype), eps*gaussian.max()]=0
[0071] left,right=min(x0,radius),min(width-x0,radius+1)
[0072] top, bottom=min(y0, radius), min(height-y0, radius+1)
[0073] Among them, width and height represent the width and height of the heat map.
[0074] Step 4: Input the processed training set images and heat maps into the landmark positioning model, set the Bach Size to 2, the initial learning rate to 0.0001, the loss function to Focal Loss, the epoch to 100, and the early stopping mechanism to test the validation set for each epoch model. Save the model with the best performance on the validation set as the best model and use it to test the test set.
[0075] The framework of the landmark location model is as follows Figure 2 As shown, it includes two encoders and a decoder. One of the encoders selects the densenet-121 in CNN as the backbone network. The main feature of DenseNet is that it introduces the concept of dense connection in the network connection mode. The present invention improves the Block of DenseNet and replaces the standard convolution with the depthwise separable convolution. The depthwise separable convolution splits the standard convolution into two steps: depthwise convolution and pointwise convolution, which can effectively reduce the number of parameters and computational complexity of the model while maintaining the expressiveness of the model.
[0076] Depthwise Separable Convolution(x)==Pointwise Convolution(DepthwiseConvolution(x))
[0077] Among them, Depthwise Separable Convolution refers to depth-separable convolution, Pointwise Convolution is point-by-point convolution, 1x1 convolution kernel, Depthwise Convolution is depth convolution, and for input with C input channels, C convolution kernels are used.
[0078] Each CNN Block in the figure consists of a Dense Block and a Transition Layer. The Dense Block uses BN+RELU+Depthwise Separable Convolution+BN+RELU+Depthwise Separable Convolution. The four CNN Blocks contain 6, 12, 24, and 16 Dense Blocks respectively. The Transition Layer is used to control the complexity of the network and reduce the size of the feature map, including a convolution layer and an average pooling layer. The feature maps extracted from these four CNNBlocks are represented as {C 1 , C 2 , C 3 , C 4}, their resolutions are 1 / 4, 1 / 8, 1 / 16, and 1 / 32 relative to the input medical images.
[0079] Another encoder is a two-layer CSwin Transformer, such as Figure 2 As shown, it is a stack of two CSwins, both CSwins have four stages, and each stage has an output, which is represented here as {S 01 , S 02 , S 03 , S 04} and {S 11 , S 12 , S 13 , S 14}; Then input the same stage to the CF module to get the final double-layer CSwin output S of each stage i .
[0080] like Figure 5As shown in the figure, the CF module is a fusion module of two CSwin Transformers, which includes a global attention module and a local attention module. While acquiring the global features in the image, it helps to improve the network's perception of local details. The two attention mechanisms consist of spatial attention (SA) and channel attention (CA).
[0081] Because not all areas in the image are effective for landmark detection, the present invention uses the spatial information between areas through the SA module to find some features related to the task. It performs adaptive maximum pooling and adaptive average pooling on the input features, connects the results of adaptive maximum pooling and adaptive average pooling to obtain a feature map with a dimension twice the number of channels, performs a convolution operation on the connected feature map, and finally normalizes it. The formula shown is as follows:
[0082] F S =σ(ξ(Concat(P avg (X), P max (X))))
[0083] Where X represents the input features, P avg and P max represents adaptive maximum pooling and adaptive average pooling in the channel dimension, ζ represents 7×7 convolution, and σ represents the sigmoid activation function.
[0084] At the same time, the present invention also uses a CA module to assign different weights to channels to measure the importance of features. First, the input features are globally averaged and pooled, and then the result of the global average pooling is passed through the first fully connected layer, through a nonlinear activation function, and then the output of the first fully connected layer is passed through the second fully connected layer to obtain the final channel attention coefficient, and finally normalized. The formula is as follows:
[0085] F C =σ(FC 2 (ReLu(FC 1 (GAP(X)))))
[0086] Among them, FC represents the fully connected layer, GAP represents the global average pooling, and σ represents the sigmoid function.
[0087] CF module is to first S 0i With S 1i The input feature X is concatenated and divided into four feature vectors f of equal size along the H and W directions in the local attention module. j , and then input them into CA to get the channel vector F cj , then the eigenvector f j With F cjMultiply to get the final F cj , through the SA block to obtain the corresponding F Sj , then F cj With F Sj Multiply to get the final F Sj , and finally reorganize to get the output P of the local attention module 1 In the global attention module, there is no division, and the other steps are the same. It is input into the CA and SA modules in turn to obtain the final output P 2 Finally, P 1 With P 2 Multiply to get the final output S i . The formula shown is as follows.
[0088] X=Concat(S 0i , S 1i )
[0089] Local:
[0090] X=[f 1 , f 2 , f 3 , f 4 ]
[0091] F Cj =CA(f j )
[0092]
[0093] F Sj =SA(F Cj )
[0094]
[0095] Global:
[0096] F C =CA(X)
[0097]
[0098] F S =SA(F C )
[0099]
[0100] CSwin Transformer consists of four CSwin Blocks. Figure 3As shown in Figure 1, it is based on transformer and adopts a self-attention mechanism of cross-shaped windows, which can calculate self-attention in parallel in the horizontal and vertical directions. By dividing the input features into strips of equal width, each strip forms a window, better results can be achieved while limiting the computational cost. The features extracted at each stage are represented as {S 1 , S 2 , S 3 , S 4}, the same as CNN, the resolution is 1 / 4, 1 / 8, 1 / 16, 1 / 32 relative to the input medical image. The output formula of each layer is as follows.
[0101]
[0102] where x l Represents the output of the l-th layer CSwin Block.
[0103] Decoder such as Figure 4 As shown in the figure, the outputs of the two encoders are first passed through the ECA module. ECA is a channel attention mechanism that enables the model to focus more on important channels, improves the model's sensitivity to input features, and helps improve the quality of feature representation. It generates channel attention weights through a combination of adaptive average pooling, 1D convolution, and sigmoid activation function, and applies them to the input features to obtain the output Z 1 , Z 2 . The formula shown is as follows.
[0104] Among them, GAP represents global average pooling, σ represents the sigmoid activation function, and output represents the final output (two features are input to ECA respectively, so there are two outputs Z 1 , Z 2 ), X represents two input features, and Y represents the generated weights.
[0105] Then, Z 1 , Z 2 The features are extracted through 3×3Conv+Relu, and then the output of the previous layer (named X i+1 ) upsampled by a factor of two, and Z 1 , Z 2 Splicing to form the existing feature B i , initialize a normal distribution of attractor parameters, with B i Perform cross attention to form a new attractor, and then follow B i Perform cross attention to form the final feature X iThe first layer (C4, S4) is directly concatenated without the output of the previous layer. The rest is similar to the above. Finally, the output is obtained from the decoder. Since the output feature resolution of the decoder is 1 / 4 of the input image, it is upsampled by 4 times and a fused features (3×3Conv, 1×1Conv) is used to regress the heat map. The decoder formula is as follows.
[0106] CS i =ReLU(Conv(concat(S i , C i )))
[0107] B i =Concat(Interpolate(X(i+1)),CS i )
[0108] new_attracor=(CrossAttFeatTran(B i , attractor))
[0109] X(i)=CrossAttFeatTrans(new_attractor, B i )
[0110] CrossAttFeatTrans: Assuming the input query feature is query_feat and the key feature is key_feat, the formula is as follows:
[0111] mixed_query_layer=Linear(query_feat)
[0112] mixed_key_layer=Linear(key_feat)
[0113] attention_scores=matmul(mixed_query_layer, mixed_key_layer T )
[0114]
[0115] attention_probs=softmax(attention_scores)
[0116] attention_probs=Dropout(attention_probs)
[0117] out_feat=outTrans(mixed_key_layer, attention_probs)
[0118] mode_dim is 48, Dropout is the drop operation, the drop probability is 0.2, ourTrans and matmul represent matrix multiplication.
[0119] Focal loss is selected as the loss function, and the sample weights are adjusted based on the prediction accuracy, so that the model pays more attention to samples that are misclassified and difficult to classify.
[0120] Suppose the predicted value is predict, the target value is target, and the loss function is loss. The calculation of the loss function is divided into two parts: positive samples and negative samples:
[0121] 1) For positive samples (target>0.9), calculate the Focal Loss of positive samples:
[0122] pos_loss=-log 2 (pos_pred)(1-pos_pred) 2
[0123] 2) For negative samples (target≤0.9), calculate the Focal Loss of negative samples and multiply it by the weight neg_weights:
[0124] neg_loss=-log 2 (1-neg_pred)neg_pred 2 neg_weights
[0125] 3) Calculate the total loss by adding the positive sample loss and the negative sample loss and dividing by the number of positive samples;
[0126] If there is no positive sample (num_pos=0), the total loss is the negative sample loss:
[0127]
[0128] At the same time, the learning rate is continuously adjusted during the training process and decays in the following way.
[0129]
[0130] Among them, lr init is the initial learning rate, gamma is the decay coefficient, which indicates the decay factor of the learning rate, epoch is the number of rounds of current training, and step_size is the step size for adjusting the learning rate, which is set to 10.
[0131] Step 5: Use the trained model to test the data set, and take the coordinates of the position with the largest value in the heat map as the key point position. If the maximum value appears in multiple positions, an average position is obtained by averaging them.
[0132] The key point coordinates are restored from the scaled image coordinates to the original image coordinates, and the final landmark point coordinates are obtained by multiplying the scaling ratio.
[0133]
[0134]
[0135] Where h and w are the height and width of the original image, and new_h and new_w are the height and width of the scaled image.
[0136] The embodiments described above provide a detailed description of the technical solutions and beneficial effects of the present invention. It should be understood that the above are only specific embodiments of the present invention and are not intended to limit the present invention. Any modifications, supplements and equivalent substitutions made within the scope of the principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A head shadow landmark location method based on double-layer CSwin and CNN, characterized in that: The following steps are involved: (1) Collect a dataset of lateral head images, annotate the head landmarks and divide it into a training set and a validation set; (2) Preprocessing the lateral head images in the training set and the validation set; and converting the positions of the head shadow landmarks in the lateral head images into two-dimensional Gaussian heat maps; (3) constructing a landmark positioning model, wherein the landmark positioning model includes a CNN encoder, a double-layer CSwin encoder and a decoder; Among them, the CNN encoder uses Densenet-121 as the backbone network. In the corresponding four CNN blocks, the standard convolution is replaced by the depthwise separable convolution. The multi-scale features {C1, C2, C3, C4} of the head lateral image are extracted through the CNN encoder. In the two-layer CSwin encoder, each layer of CSwin has four stages. The CSwin Block of each stage extracts the corresponding feature representation, and then inputs the features of the same stage into the CF module to obtain the fusion features of each stage of the head lateral image {S1, S2, S 3, S4}; Finally, the multi-scale features {C1, C2, C 3, C4} and the fusion features {S1, S2, S 3, S4} is input to the decoder, which first fuses the features of the same scale of the two encoders, and fuses the features of different scales in the previous stage through upsampling; finally, the final features are regressed through two layers of convolution to obtain the predicted heat map; (4) Use the training set to train the landmark positioning model, and verify the trained model using the verification set; (5) Preprocessing the lateral head image to be located is input into the trained model to predict the heat map of the head shadow landmark points; converting the heat map into landmark points to obtain the coordinates of the head shadow landmark points.
2. The head shadow landmark location method based on double-layer CSwin and CNN according to claim 1, characterized in that: In step (2), the positions of the head shadow landmarks in the lateral head image are converted into a two-dimensional Gaussian heat map. The specific process is as follows: First, set the heat map of each landmark point to all 0, set the landmark point coordinates to (x0, y0), generate a two-dimensional grid according to radius, and obtain two one-dimensional arrays xx and yy. These two arrays cover a two-dimensional range with values from -radius to radius. Then, generate a two-dimensional Gaussian distribution by applying the Gaussian distribution formula. The formula is as follows: Among them, σ represents the range of the control distribution, which is set to 8 here, and radius is set to 20; Then, the values on the two-dimensional Gaussian distribution that are less than the threshold are set to zero to increase the sparsity of the Gaussian distribution; then, the effective range of the assignment operation on the heat map is determined, and the generated Gaussian distribution is locally placed in the central area of the heat map; Finally, we need to avoid the situation where multiple key points appear on the same heat map. The formula for determining the range is as follows; gaussian[gaussian <finfo(gaussian.dtype).eps*gaussian.max()]=0 left,right=min(x0,radius),min(width-x0,radius+1) top,bottom=min(y0,radius),min(height-y0,radius+1) Among them, width and height represent the width and height of the heat map.
3. The head shadow landmark location method based on double-layer CSwin and CNN according to claim 1, characterized in that: In step (3), the depthwise separable convolution splits the standard convolution into two steps: depthwise convolution and pointwise convolution. The specific formula is as follows: DepthwiseSeparableConvolution(x)=PointwiseConvolution(DepthwiseConvolution(x)) Among them, Depthwise Separable Convolution refers to depth-separable convolution, PointwiseConvolution is point-by-point convolution with a 1x1 convolution kernel; Depthwise Convolution is a depth-wise convolution, and for an input with C input channels, C convolution kernels are used.
4. The head shadow landmark location method based on double-layer CSwin and CNN according to claim 1, characterized in that: In step (3), the multi-scale features {C1, C2, C 3, C4} and the fusion features {S1, S2, S 3, S4}, their resolutions are 1 / 4, 1 / 8, 1 / 16, and 1 / 32 respectively relative to the input lateral head image.
5. The head shadow landmark location method based on double-layer CSwin and CNN according to claim 1, characterized in that: In step (3), in the two-layer CSwin encoder, the CF module is a fusion module of the two layers of CSwin, which includes a global attention module and a local attention module. Both of these attention mechanisms are composed of spatial attention SA and channel attention CA. The CF module first concatenates the features of the same stage of the two-layer CSwin to obtain the input feature X. In the local attention module, it is divided into four feature vectors of equal size along the H and W directions. j , and then input them into the CA module to get the channel vector F cj , then the eigenvector f j With the channel vector F cj Multiply to get the updated channel vector F cj ; Then update the channel vector F cj Use the SA module to obtain the corresponding space vector F Sj , and then the updated channel vector F cj The corresponding space vector F Sj Multiply to get the updated space vector F sj , and finally reorganize to obtain the output feature P1 of the local attention module; In the global attention module, the input feature X is not divided, and the other steps are the same. It is input into the CA module and the SA module in turn to obtain the final output feature P2; finally, P1 and P2 are multiplied to obtain the final output of the fusion feature S of each stage i .
6. The head shadow landmark location method based on double-layer CSwin and CNN according to claim 5, characterized in that: The SA module uses the spatial information between regions to find some features related to the task. It performs adaptive maximum pooling and adaptive average pooling on the input features, connects the results of adaptive maximum pooling and adaptive average pooling to obtain a feature map with a dimension twice the number of channels, performs convolution operations on the connected feature map, and finally normalizes it: The formula is as follows: F S =σ(ξ(Concat(P avg (X),P max (X)))) Among them, X represents the input feature, P avg and P max Represents adaptive maximum pooling and adaptive average pooling in the channel dimension, ζ represents 7×7 convolution, and σ represents the sigmoid activation function; The CA module assigns different weights to channels to measure the importance of features. First, the input features are globally averaged pooled, and then the result of the global average pooling is passed through the first fully connected layer, through a nonlinear activation function, and then the output of the first fully connected layer is passed through the second fully connected layer to obtain the final channel attention coefficient, which is then normalized. The formula is as follows: F C =σ(FC2(ReLu(FC1(GAP(X))))) Among them, FC represents the fully connected layer, GAP represents the global average pooling, and σ represents the sigmoid function.
7. The head shadow landmark location method based on double-layer CSwin and CNN according to claim 1, characterized in that: In step (3), in the two-layer CSwin encoder, the CSwin Block of each stage adopts a cross-window self-attention mechanism to calculate self-attention in parallel in the horizontal and vertical directions; by dividing the input features into strips of equal width, each strip forms a window, achieving better results while limiting the computational cost. The formula is as follows: x l =MLP(LN(CSWin-Attention(LN(x l-1 ))+x l-1 ))+CSWin-Attention(LN(x l-1 ))+x l-1 Among them, x l Represents the output of the lth CSwin Block.
8. The head shadow landmark location method based on double-layer CSwin and CNN according to claim 1, characterized in that: In step (3), the feature fusion module is used to fuse features of different scales. The specific process is as follows: First, both features are input into the ECA module. The ECA module generates channel attention weights through a combination of adaptive average pooling, 1D convolution and sigmoid activation function, and applies them to the input features to obtain outputs Z1 and Z2; the formula is as follows: Y = σ(conv(GAP(X))) Among them, GAP represents global average pooling, σ represents the sigmoid activation function, output represents the final output, and the two features are input to ECA respectively, so there are two outputs Z1 and Z2; X represents the two input features, and Y represents the weight; Then, Z1 and Z2 extract features through 3×3Conv+Relu, and then convert the output X of the previous layer into i+1 Upsample twice and concatenate with Z1 and Z2 to form the existing feature B i , initialize a normal distribution of attractor parameters, with B i Perform cross attention to form a new attractor, and then follow B i Perform cross attention to form the final feature X i .
Citation Information
Patent Citations
Convolution neural network based marker detection method for skull image
CN109146845A
Semi-supervised medical image mark point positioning method based on topological structure constraint
CN116012689A
X-ray head shadow survey mark point automatic positioning method based on deep learning
CN116704036A
Medical image segmentation method and device fusing multi-scale features, and storage medium
CN117315244A
Swin-transformer image denoising method and system based on channel attention
WO2023092813A1
