Ankle joint normal position X-ray image key point detection and angle measurement method
By constructing a key point detection model for ankle joint anteroposterior X-ray images, the errors and low efficiency caused by manual calibration are solved, efficient and accurate key point detection and angle measurement are achieved, and the accuracy and efficiency of ankle joint diagnosis are improved.
Patent Information
- Application Number
- CN202510876986.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-27
- Publication Date
- 2025-09-26
AI Technical Summary
In the existing technology, the angle measurement of ankle joint anteroposterior X-ray images relies on manual calibration, which has problems such as large human errors, cumbersome measurement, long time consumption and low accuracy, and lacks efficient and accurate key point detection and angle measurement algorithms.
A key point detection model for ankle joint anteroposterior X-ray images was constructed, including data preprocessing, key point labeling, data enhancement, network model construction and loss function optimization. A deep separable convolution structure and multi-layer feature fusion strategy were used to automatically calculate joint angles through the key point detection network.
It improves the accuracy and efficiency of key point detection in ankle X-ray images, provides doctors with a faster and more accurate angle measurement tool, and improves the diagnosis process and patient treatment outcomes.
Smart Images

Figure CN120707886A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a method for detecting key points and measuring angles of an ankle joint anteroposterior X-ray image. Background Art
[0002] Ankle injuries are common orthopedic conditions, particularly among athletes and the elderly, and are becoming more common among younger individuals. Traditional ankle assessment methods rely heavily on manual measurement and diagnosis by clinicians, using commonly used examination methods such as X-rays, CT scans, and MRIs. Although X-rays are widely used in the diagnosis of fractures and joint deformities, existing imaging assessment methods still have limitations in terms of angle measurement and joint health assessment.
[0003] Prior art methods for measuring angles in anteroposterior ankle X-ray images typically rely on manual calibration and measurement. This traditional method is not only susceptible to human error, but also cumbersome and time-consuming, with low accuracy and efficiency. Furthermore, manual measurement requires high-level professional expertise from the physician, and each assessment requires manual drawing of angles and marking of key points, increasing diagnostic time and workload.
[0004] Although some computer-assisted image analysis methods have been used to assist in orthopedic imaging diagnosis, most of these methods lack efficient and accurate algorithms for key point detection and angle measurement. In particular, the precise measurement of joint surface angles in ankle joint images has not been effectively addressed. Therefore, a new automated method is urgently needed that can efficiently and accurately detect key points in ankle X-ray images and accurately calculate the relevant angles based on these key points, thereby providing clinicians with a more reliable diagnostic basis. Summary of the Invention
[0005] In view of the shortcomings of the existing technology, the purpose of the present invention is to provide a method for detecting key points and measuring angles of ankle joint anteroposterior X-ray images.
[0006] To achieve the above object, the present invention provides the following technical solutions:
[0007] A method for detecting key points and measuring angles of an ankle joint anteroposterior X-ray image, comprising the following steps:
[0008] S1. Collecting X-ray images of human ankle joints and performing data preprocessing;
[0009] First, export the ankle joint anteroposterior X-ray image from the hospital. The ankle joint anteroposterior X-ray image used is the ankle joint X-ray plain scan image with an original resolution of 1024×1024 and the image format is JPG.
[0010] Then, data preprocessing is performed, including image normalization and standardization; normalization scales the image pixel values from [0, 255] to the range of [0, 1], and standardization standardizes the mean and standard deviation of the image pixel values so that the mean of the pixels in the entire image is 0 and the variance is 1.
[0011] S2. Label the key point detection labels of the ankle joint anteroposterior X-ray image, and perform data enhancement and data set division;
[0012] First, key points are manually labeled on each X-ray image based on the needs of angle measurement. There are 12 key points labeled D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, and D12. This labeling is performed by personnel with a medical background in conjunction with an AI labeling platform to ensure accuracy and consistency.
[0013] Secondly, connect the lines according to the predetermined connection rules;
[0014] Predetermined connection rules: connect 6 lines; connect key point D1 and key point D2 into a line L1; connect key point D3 and key point D4 into a line L2; connect key point D5 and key point D6 into a line L3; connect key point D7 and key point D8 into a line L4; connect key point D9 and key point D10 into a line L5; connect key point D11 and key point D12 into a line L6;
[0015] The angles that need to be measured include: tibial lateral malleolus angle (J1, the angle between L1 and L4), tibial medial malleolus angle (J2, the angle between L1 and L3), tibial articular surface angle (J3, the angle between L1 and L5), tibial fossa angle (J4, the angle between L1 and L2), tibiotalar angle (J5, the angle between L3 and L6), fibular malleolus angle (J6, the angle between L4 and L6), talar inclination angle (J7, the angle between L5 and L6), lateral malleolus angle (J8, the angle between L3 and L4), and tibiotalar angle (J9, the angle between L2 and L5).
[0016] Then, a variety of data enhancement methods are adopted to expand the number of samples in the ankle joint anteroposterior X-ray image key point detection dataset;
[0017] The data enhancement method includes: mirror flipping along the vertical axis of the image, that is, flipping the image along the vertical axis, which helps the model learn the performance of objects in different directions; random rotation of -15° to +15°, which enhances the model's adaptability to object rotation changes, so that it can better handle the performance of objects at different angles; random 0.8 to 1.2 scale scaling, randomly selecting a scale ratio between 0.8 and 1.2, so that the model can handle objects at different scales; scale transformation of the image, stagger transformation, that is, stretching a part of the image along the horizontal or vertical direction to form a parallelogram, which can simulate the deformation of the object when the perspective changes; Gaussian noise, adding random noise that follows a Gaussian distribution to the pixel values of the image. By introducing noise, the model can more easily learn the characteristics of real-world data and improve generalization ability; Gaussian blur, Gaussian blurring the image, the blurring degree is controlled by a standard deviation parameter, which can reduce the details and noise in the image, and help the model focus on the overall shape and structure of the object;
[0018] Finally, the training set and test set are randomly divided into two groups with a ratio of 7:3.
[0019] S3. Construct a network model for detecting key points in ankle X-ray images;
[0020] First, the input and output parts of the network model are constructed; the input is the preprocessed and data-enhanced ankle X-ray image, and the output is the position coordinate information of 12 key points for subsequent angle measurement;
[0021] Next, the backbone of the network model is constructed. The backbone uses a depthwise separable convolutional structure to extract multi-scale features layer by layer. Specifically, the layers include a cross-stage partial connection layer (C2f module), which forms feature maps that gradually reduce resolution while enhancing semantic expression. The Spatial Pyramid Pooling Fast Module (SPPF module) fuses feature information from different receptive fields, improving the model's ability to detect keypoints of varying sizes.
[0022] Next, the detection head of the network model is constructed. The detection head adopts a multi-layer feature fusion strategy to fuse feature maps from different scales (P3 / P4 / P5 convolutional layers) to enhance the accuracy of key point positioning. The fused features are further refined through the convolutional layers and the C2f module to improve the precision of key point positioning. The dynamic upsampling module based on attention scale sequence fusion (ASF-Dysample module) is introduced to optimize the weighted combination of features at different scales, improving the model's ability to recognize complex skeletal structures.
[0023] Finally, the two-dimensional coordinate information of the key points is output, and corresponding regression output channels are designed for the 12 key points.
[0024] S4. Construct the loss function, determine the optimizer and hyperparameters, input the training set, and train the network parameters;
[0025] First, for the key point detection task, the present invention constructs a composite loss function, which consists of the following two parts:
[0026] Keypoint position regression loss (L reg ): The mean square error (MSE) is used as the regression error of the two-dimensional coordinates of the key points to measure the distance difference between the key points predicted by the model and the actual marked key points. The specific formula is as follows:
[0027]
[0028] In formula (1), N=12 is the number of key points, is the predicted coordinate of the i-th key point, p i The actual coordinates.
[0029] Keypoint confidence loss (L conf ): In order to improve the model's ability to discriminate the existence of key points, the key point confidence loss is introduced, and the binary cross entropy loss function is used to calculate the difference between the predicted confidence and the true label. The specific formula is as follows:
[0030]
[0031] In formula (2), N=12 is the number of key points, is the model’s confidence in predicting the presence of each key point, c i is the actual label of the position; when c i =1, the loss function is That is, the model has low confidence in the location of the key point ( close to 0), the loss will be greater; when c i = 0, the loss function is That is, the model incorrectly predicts that this location is a key point ( If it is close to 1), the loss will be greater;
[0032] The comprehensive loss function is:
[0033] L=αL reg +βL conf (3)
[0034] In formula (3), α and β are loss weight hyperparameters, which are used to balance the contribution of the two parts of loss. The specific values are determined through experimental tuning.
[0035] Then, the adaptive moment estimation optimization algorithm Adam (Adaptive Moment Estimation) is used, and the optimizer parameter update strategy is defined by formula (4) as:
[0036]
[0037] In formula (4), θ t is the parameter at the tth iteration, and are the first-order and second-order momentum of the gradient, η is the learning rate, set to 0.001, ε is a very small constant, set to 1e-8, and λ is the weight decay coefficient, set to 0.01.
[0038] Next, set the hyperparameters. The main hyperparameters include:
[0039] Batch Size: set to 32;
[0040] Epochs: 300 epochs, combined with early stopping to prevent overfitting.
[0041] Finally, the network parameters are trained. First, the preprocessed and enhanced training set is input into the model for forward propagation to calculate the predicted key point coordinates and confidence. Then, the error is calculated based on the loss function, and the model parameters are updated through backpropagation. Then, during the training process, the validation set is used to monitor the model performance, and the learning rate and other hyperparameters are dynamically adjusted to ensure the stability of the training process. Finally, after the training is completed, the optimal model parameters are saved for subsequent key point detection and angle measurement.
[0042] S5. Load the optimal model parameters obtained from the above training into the constructed key point detection model, input the test set data into the model, and obtain the key point results;
[0043] First, load the trained model weight parameters and input the test set data into the model; then, post-process the output information; finally, obtain the key point detection results;
[0044] S6. Calculate the angle using the key point detection results;
[0045] First, load the image containing keypoint annotations and its corresponding label data, and extract the locations of the keypoints from the image; the label file for each image contains annotation information of multiple shapes, including rectangular boxes and points. The points represent the locations of the keypoints, and the rectangular boxes are used to mark the areas of interest.
[0046] Secondly, after obtaining the coordinates of all key points, they are connected according to the predetermined connection rules to make the connection lines more obvious in the image;
[0047] Then, for each pair of connected points, calculate the angle between the two vectors. First, calculate the vectors of the two line segments, calculate their dot product and modulus, and then find the cosine of the angle. The calculation formula is shown in formula (5). Then, use the inverse cosine function to obtain the angle and convert it to degrees. The calculation formula is shown in formula (6). Finally, return the angle to two decimal places.
[0048]
[0049] θ=arccos(cos(θ)) (6)
[0050] In formula (5), v1 and v2 are vectors of two points, and the dot product v1·v2=v 1x ·v 2x +v 1y ·v 2y , the modulus of the vector
[0051]
[0052] In general, the above technical solutions conceived by the present invention can achieve the following beneficial effects:
[0053] (1) This paper provides a unique dataset specifically designed for key point detection in ankle joint anteroposterior X-ray images, which solves the problem of insufficient existing data and provides the necessary resources and foundation for future related research and applications.
[0054] (2) The present invention provides a key point detection model for ankle joint anteroposterior X-ray images, which significantly improves the accuracy and efficiency of key point detection tasks in ankle joint anteroposterior X-ray images.
[0055] (3) The present invention provides a method for measuring joint angles in ankle X-ray images, providing doctors with a faster and more accurate angle measurement tool. This technological innovation helps improve the diagnostic process and enhance patient treatment outcomes and health management. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 is a flow chart of the present invention;
[0057] Figure 2 This is a schematic diagram of labeling key points of an ankle joint anteroposterior X-ray image according to the present invention;
[0058] Figure 3 This is a schematic diagram of the ankle joint anteroposterior X-ray measurement angle of the present invention;
[0059] Figure 4 Schematic diagram of the network model framework for detecting key points in ankle joint anteroposterior X-ray images of the present invention;
[0060] Figure 5 Schematic diagram of the C2f module in the network model for detecting key points in ankle joint anteroposterior X-ray images of the present invention;
[0061] Figure 6 Schematic diagram of the SPPF module in the network model for detecting key points in ankle joint anteroposterior X-ray images of the present invention;
[0062] Figure 7 Schematic diagram of the ASF-Dysample module in the network model for detecting key points in ankle joint anteroposterior X-ray images of the present invention;
[0063] Figure 8 The test results of key point detection using the ankle joint anteroposterior X-ray image key point detection network model in the embodiment of the present invention, wherein (a) is the input ankle joint anteroposterior X-ray test image, (b) is the corresponding image key point label, and (c) is the result predicted by the corresponding network model. DETAILED DESCRIPTION
[0064] Reference Figures 1 to 8 The following examples are used to illustrate the present invention but are not intended to limit the scope of the present invention.
[0065] A method for detecting key points and measuring angles in ankle joint anteroposterior X-ray images, such as Figure 1 As shown, the following steps are included:
[0066] Step S1: collecting an X-ray image of a person's ankle joint and performing data preprocessing;
[0067] Specifically, the following steps are performed: the ankle joint anteroposterior X-ray image is exported from the hospital. The ankle joint anteroposterior X-ray image used is an ankle joint X-ray plain scan image with an original resolution of 1024×1024 and the image format is JPG;
[0068] Perform data preprocessing, including image normalization and standardization; normalization scales the image pixel values from [0, 255] to the range of [0, 1], and standardization normalizes the mean and standard deviation of the image pixel values so that the mean of each pixel is 0 and the variance is 1;
[0069] Step S2: Label the key point detection labels of the ankle joint anteroposterior X-ray images, and expand the number of images by data augmentation to construct a key point detection dataset of the ankle joint anteroposterior X-ray images; the ankle joint anteroposterior X-ray image key point detection dataset consists of ankle joint anteroposterior X-ray images and corresponding key point labels;
[0070] The details are as follows:
[0071] like Figure 2 As shown in the figure, according to the needs of angle measurement, manual key point annotation is performed on each X-ray image; there are a total of 12 key point labels, namely D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, and D12. The annotation work is completed by personnel with a medical background in conjunction with the artificial intelligence annotation platform to ensure the accuracy and consistency of the annotation; the lines are connected according to the predetermined connection rules;
[0072] like Figure 3 As shown, the predetermined connection rule is: connect 6 lines; connect key point D1 and key point D2 into a line L1; connect key point D3 and key point D4 into a line L2; connect key point D5 and key point D6 into a line L3; connect key point D7 and key point D8 into a line L4; connect key point D9 and key point D10 into a line L5; connect key point D11 and key point D12 into a line L6;
[0073] The angles that need to be measured include: tibial lateral malleolus angle (J1, the angle between L1 and L4), tibial medial malleolus angle (J2, the angle between L1 and L3), tibial articular surface angle (J3, the angle between L1 and L5), tibial fossa angle (J4, the angle between L1 and L2), tibiotalar angle (J5, the angle between L3 and L6), fibular malleolus angle (J6, the angle between L4 and L6), talar inclination angle (J7, the angle between L5 and L6), lateral malleolus angle (J8, the angle between L3 and L4), and tibiotalar angle (J9, the angle between L2 and L5).
[0074] Data augmentation was used to expand the number of samples in the ankle joint anteroposterior X-ray image key point detection dataset. The data augmentation methods included mirror flipping along the vertical axis of the image, random rotation of -15° to +15°, random scaling of 0.8 to 1.2 times, shear transformation, Gaussian noise, and Gaussian blur.
[0075] The training set and test set are randomly divided into two groups with a ratio of 7:3.
[0076] Step S3: Construct a network model for detecting key points in ankle X-ray images and use labeled data to train the model. The network model framework is as follows: Figure 4 As shown, specifically:
[0077] Construct the input and output parts of the network model; the input is the preprocessed and data-enhanced ankle joint X-ray image, and the output is the position coordinate information of 12 key points for subsequent angle measurement;
[0078] The backbone of the network model is constructed using a depthwise separable convolutional architecture to extract multi-scale features layer by layer. Specifically, the layers include a cross-stage partial connection layer (C2f module), which forms feature maps that gradually reduce resolution while enhancing semantic expression. The Spatial Pyramid Pooling (SPPF) module is used to fuse feature information from different receptive fields, improving the model's ability to detect keypoints of varying sizes.
[0079] The core of the network model backbone network in this embodiment is the C2f module, which has the following structure: Figure 5 As shown. First, the input feature map is subjected to preliminary feature extraction and downsampling through the convolution layer; then, it enters the core processing flow of the C2f module - the feature map is divided into two parts according to the channel dimension, one part is directly connected to the output end across the layer, and the other part is sequentially transformed through multiple parallel bottleneck layers, where n is set to 1-4. Models of different sizes use different configurations. Small models use 1 or 2 bottleneck layers, medium-sized models use 2 or 3 bottleneck layers, and large models use 3 or 4 bottleneck layers. The network model in this embodiment uses 2 bottleneck layers; then, a residual structure is used to enhance feature expression within each bottleneck layer, and the output feature maps of each bottleneck layer are all spliced together, and then a 1×1 convolution is used to integrate the channel dimension; finally, the integrated residual branch features are spliced again with the features of the initial cross-layer connection to form the final output feature map, which not only retains shallow detail information but also integrates deep semantic features;
[0080] The core of the network model backbone network in this embodiment is the SPPF module, which has the following structure: Figure 6 As shown. First, after the input feature map enters the module, it first passes through a 1×1 convolution layer, which is used to adjust the number of channels and perform preliminary integration of features. Then, the feature map processed by 1×1 convolution enters four branches in parallel, one of which is directly connected, and the other three branches are connected to the maximum pooling layer of 5×5, 9×9, and 13×13 sizes respectively. Through pooling operations of different scales, multi-scale feature information is extracted. Then, the feature maps output by the four branches are spliced in the channel dimension to achieve multi-scale feature fusion and obtain richer feature expression. Finally, the spliced feature map passes through another 1×1 convolution layer to further integrate and adjust the channels of the fused features, and finally generates the output feature map, providing high-quality feature input for subsequent detection tasks.
[0081] The detection head of the network model is constructed. The detection head adopts a multi-layer feature fusion strategy to fuse feature maps from different scales (P3 / P4 / P5 convolutional layers) to enhance the accuracy of key point positioning. The fused features are further refined through the convolutional layers and C2f modules to improve the precision of key point positioning. Dynamic upsampling based on attention scale sequence fusion (ASF-Dysample module) is introduced to optimize the weighted combination of features at different scales, improving the model's ability to recognize complex skeletal structures.
[0082] The core of the network model backbone network in this embodiment is the ASF-Dysample module, which has the following structure: Figure 7 As shown. First, after the input feature map enters the module, it passes through parallel convolution layers with different receptive fields (such as 3×3, 5×5, and 7×7) to quickly capture multi-scale features from details to semantics and build a basic feature pyramid; then, the multi-scale features are sent to the attention-guided scale sequence fusion component, which uses the attention mechanism to calculate the weights of the features at each scale, dynamically adjusts the importance of features at different levels, and gradually fuses them in sequence to enhance sensitivity to targets of different sizes; then, the fused features enter the dynamic sampling upsampling unit, which learns the optimal sampling points and weights and adaptively generates a sampling grid based on the feature content to achieve refined upsampling operations and effectively retain edge and detail information; finally, the upsampled features are channel-integrated and feature-enhanced through a 1×1 convolution layer, outputting feature maps with high resolution and strong semantic information, providing high-quality input data for subsequent detection heads;
[0083] The Pose module outputs the two-dimensional coordinate information of key points, and the corresponding regression output channels are designed for the 12 key points.
[0084] Step S4: Construct the loss function, determine the optimizer and hyperparameters, input the training set, and train the network parameters;
[0085] The details are as follows:
[0086] For the key point detection task, the present invention constructs a composite loss function consisting of the following two parts:
[0087] Keypoint position regression loss (L reg ): The mean square error (MSE) is used as the two-dimensional coordinate regression error of the key point to measure the distance difference between the key point predicted by the model and the actual labeled key point position. The specific formula is as follows:
[0088]
[0089] In formula (1), N=12 is the number of key points, is the predicted coordinate of the i-th key point, p iMark the real coordinates;
[0090] Keypoint confidence loss (L conf ): In order to improve the model's ability to discriminate the existence of key points, the key point confidence loss is introduced, and the binary cross entropy loss function is used to calculate the difference between the predicted confidence and the true label. The specific formula is as follows:
[0091]
[0092] In formula (2), N=12 is the number of key points, is the model’s confidence in predicting the presence of each key point, c i is the actual label of the position; when c i =1, the loss function is That is, the model has low confidence in the location of the key point ( close to 0), the loss will be greater; when c i = 0, the loss function is That is, the model incorrectly predicts that this location is a key point ( If it is close to 1), the loss will be greater;
[0093] The comprehensive loss function is:
[0094] L=αL reg +βL conf (3)
[0095] In formula (3), α and β are loss weight hyperparameters, which are used to balance the contribution of the two parts of loss. The specific values are determined by experimental tuning.
[0096] Adaptive moment estimation optimization algorithm Adam (Adaptive Moment Estimation) is used, and the optimizer parameter update strategy is defined by formula (4) as:
[0097]
[0098] In formula (4), θ t is the parameter at the tth iteration, and are the first-order and second-order momentum of the gradient, η is the learning rate, set to 0.001, ε is a very small constant, set to 1e-8, and λ is the weight decay coefficient, set to 0.01.
[0099] Next, set the hyperparameters. The main hyperparameters include:
[0100] Batch Size: set to 32;
[0101] Epochs: 300 epochs, combined with early stopping to prevent overfitting.
[0102] The entire training process for training network parameters is as follows: first, the preprocessed and enhanced training set is input into the model, and forward propagation is performed to calculate the predicted key point coordinates and confidence levels. Then, the error is calculated based on the loss function, and the model parameters are updated through backpropagation. Next, during training, the validation set is used to monitor model performance, and the learning rate and other hyperparameters are dynamically adjusted to ensure a stable training process. Finally, after training is complete, the optimal model parameters are saved for subsequent key point detection and angle measurement.
[0103] Step S5: The constructed key point detection model loads the optimal model parameters obtained from the above training, inputs the test set data into the model, and obtains the key point results;
[0104] Specifically: load the trained model weight parameters, input the test set data into the model; post-process the output information; obtain the key point results, such as Figure 8 As shown in the figure, (a) is the input ankle joint X-ray test image, (b) is the corresponding image key point label, and (c) is the corresponding network model prediction result;
[0105] Step S6: Calculate the angle using the key point detection results;
[0106] The details are as follows:
[0107] Load the image containing the keypoint annotations and their corresponding label data, and extract the keypoint locations from the image. The label file for each image contains annotation information of multiple shapes, which usually include rectangular boxes and points. The points represent the locations of the keypoints, and the rectangular boxes may be used to mark the areas of interest.
[0108] After obtaining the coordinates of all key points, the lines connecting the corresponding points in the image are calculated according to the predetermined connection rules. Each pair of key points is connected by a vector, which serves as the basis for subsequent angle calculations. To improve the visualization effect, the key points in the image are further expanded to make the connecting lines more obvious in the image;
[0109] For each pair of connected points, calculate the angle between the two vectors. First, calculate the vectors of the two line segments, calculate their dot product and modulus, and then find the cosine of the angle, as shown in formula (5). Then, use the inverse cosine function to obtain the angle and convert it to degrees, as shown in formula (6). Finally, return the angle to two decimal places;
[0110]
[0111] θ=arccos(cos(θ)) (6)
[0112] In formula (5), v1 and v2 are vectors of two points, and the dot product v1·v2=v 1x ·v 2x +v 1y ·v 2y , the modulus of the vector
[0113] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the embodiments of the present disclosure is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but should also cover other technical solutions formed by any combination of the above-mentioned technical features or their equivalent features without departing from the above-mentioned inventive concept. For example, the above-mentioned features and the technical features with similar functions disclosed in the embodiments of the present disclosure (but not limited to) are replaced with each other to form a technical solution.
Claims
1. A method for detecting key points and measuring angles in an ankle joint anteroposterior X-ray image, characterized by: The following steps are involved: S1. Collecting X-ray images of human ankle joints and performing data preprocessing; S2. Label the key point detection labels of the ankle joint anteroposterior X-ray image, and perform data enhancement and data set division; S3. Construct a network model for detecting key points in ankle X-ray images; S4. Construct the loss function, determine the optimizer and hyperparameters, input the training set, and train the network parameters; S5. Load the optimal model parameters obtained from the above training into the constructed key point detection model, input the test set data into the model, and obtain the key point results; S6. Calculate the angle using the key point detection results.
2. The method for detecting key points and measuring angles of ankle joint anteroposterior X-ray images according to claim 1, characterized in that: Step S1 includes the following: Data preprocessing: including image normalization and standardization; normalization scales the image pixel values from [0, 255] to the range of [0, 1], and standardization normalizes the mean and standard deviation of the image pixel values so that the mean of the pixels in the entire image is 0 and the variance is 1.
3. The method for detecting key points and measuring angles of an ankle joint anteroposterior X-ray image according to claim 2, wherein: Wherein step S2 comprises the following: First, key points are manually labeled on each X-ray image based on the needs of angle measurement. There are 12 key points labeled D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, and D12. This labeling is performed by personnel with a medical background in conjunction with an AI labeling platform to ensure accuracy and consistency. Secondly, connect the lines according to the predetermined connection rules; Predetermined connection rules: connect 6 lines; Connect key point D1 and key point D2 into a line L1; connect key point D3 and key point D4 into a line L2; connect key point D5 and key point D6 into a line L3; connect key point D7 and key point D8 into a line L4; connect key point D9 and key point D10 into a line L5; Connect key point D11 and key point D12 into a line L6; The angles that need to be measured include: tibial lateral malleolus angle (J1, the angle between L1 and L4), tibial medial malleolus angle (J2, the angle between L1 and L3), tibial articular surface angle (J3, the angle between L1 and L5), tibial fossa angle (J4, the angle between L1 and L2), tibiotalar angle (J5, the angle between L3 and L6), fibular malleolus angle (J6, the angle between L4 and L6), talar inclination angle (J7, the angle between L5 and L6), lateral malleolus angle (J8, the angle between L3 and L4), and tibiotalar angle (J9, the angle between L2 and L5). Then, data augmentation was used to expand the number of samples in the ankle joint anteroposterior X-ray image key point detection dataset. The data augmentation methods included mirror flipping along the vertical axis of the image, random rotation of -15° to +15°, random scaling of 0.8 to 1.2 times, shear transformation, Gaussian noise, and Gaussian blur. Finally, the training set and test set are randomly divided into two groups with a ratio of 7:
3.
4. The method for detecting key points and measuring angles of an ankle joint anteroposterior X-ray image according to claim 3, wherein: Wherein step S3 comprises the following: First, the input and output parts of the network model are constructed; the input is the preprocessed and data-enhanced ankle X-ray image, and the output is the position coordinate information of 12 key points for subsequent angle measurement; Then, the backbone network of the network model is constructed. The network backbone adopts a depthwise separable convolutional structure to extract multi-scale features layer by layer. The specific layers include a cross-stage partial connection layer (C2f module), which forms a feature map with gradually reduced resolution while enhancing semantic expression. The spatial pyramid pooling fast module (SPPF module) is used to fuse feature information from different receptive fields. Next, the detection head of the network model is constructed. The detection head adopts a multi-layer feature fusion strategy to fuse feature maps from different scales (P3 / P4 / P5 convolutional layers). The fused features are further refined through convolutional layers and the C2f module. The dynamic upsampling module based on attention scale sequence fusion (ASF-Dysample module) is introduced to optimize the weighted combination of features at different scales, improving the model's ability to recognize complex skeletal structures. Finally, the two-dimensional coordinate information of the key points is output, and corresponding regression output channels are designed for the 12 key points.
5. The method for detecting key points and measuring angles of an ankle joint anteroposterior X-ray image according to claim 4, characterized in that: Wherein step S4 comprises the following: First, for the key point detection task, the present invention constructs a composite loss function, which consists of the following two parts: Keypoint position regression loss (L reg ): The mean square error (MSE) is used as the two-dimensional coordinate regression error of the key point to measure the distance difference between the key point predicted by the model and the actual labeled key point position. The specific formula is as follows: In formula (1), N=12 is the number of key points, is the predicted coordinate of the i-th key point, p i The actual coordinates. Keypoint confidence loss (L conf ): In order to improve the model's ability to discriminate the existence of key points, the key point confidence loss is introduced, and the binary cross entropy loss function is used to calculate the difference between the predicted confidence and the true label. The specific formula is as follows: In formula (2), N=12 is the number of key points, is the model’s confidence in predicting the presence of each key point, c i is the actual label of the position; when c i =1, the loss function is That is, the model has low confidence in the location of the key point ( close to 0), the loss will be greater; when c i = 0, the loss function is That is, the model incorrectly predicts that this location is a key point ( If it is close to 1), the loss will be greater; The comprehensive loss function is: L=αL reg +βL conf (3) In formula (3), α and β are loss weight hyperparameters, which are used to balance the contribution of the two parts of loss. The specific values are determined by experimental tuning. Then, the adaptive moment estimation optimization algorithm Adam (Adaptive Moment Estimation) is used, and the optimizer parameter update strategy is defined by formula (4) as: In formula (4), θ t is the parameter at the tth iteration, and are the first-order and second-order momentum of the gradient, η is the learning rate, set to 0.001, ε is the minimum constant, set to 1e-8, and λ is the weight decay coefficient, set to 0.01; Next, set the hyperparameters. The main hyperparameters include: Batch Size: set to 32; Epochs: 300 epochs, combined with early stopping to prevent overfitting. Finally, the network parameters are trained. First, the preprocessed and enhanced training set is input into the model for forward propagation to calculate the predicted key point coordinates and confidence. Then, the error is calculated based on the loss function, and the model parameters are updated through backpropagation. Then, during the training process, the validation set is used to monitor the model performance, and the learning rate and other hyperparameters are dynamically adjusted to ensure the stability of the training process. Finally, after the training is completed, the optimal model parameters are saved for subsequent key point detection and angle measurement.
Citation Information
Cited By
Real-time image splicing method and device suitable for robot embedded platform
CN121392449A