A medical measuring scale-based wound size measurement method, system, device and storage medium
By using a wound size measurement method based on a medical measuring ruler, a trained model is used to segment the wound and the scale area and identify the scale ratio. This solves the problems of high equipment cost and poor patient compliance in existing technologies, and achieves high-precision, low-cost wound size measurement, which is suitable for multiple application scenarios.
Patent Information
- Application Number
- CN202611045229.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-14
- Publication Date
- 2026-08-25
AI Technical Summary
Existing wound measurement technologies suffer from high equipment costs, high operational barriers, poor patient compliance, and measurement accuracy that is easily affected by shooting angle and ruler surface deformation, making them difficult to widely apply in primary hospitals and general wards.
A wound size measurement method based on medical measuring rulers is adopted. The wound and scale area are segmented by a trained segmentation model, the scale ratio is identified, and morphological processing and Gaussian kernel density estimation are combined to realize the measurement of the actual physical length, width and area of the wound, reducing equipment dependence.
It enables high-precision, automated wound size measurement without the need for specialized hardware, improving patient compliance, reducing operational difficulty and implementation costs, and is suitable for bedside clinical care and home monitoring.
Smart Images

Figure CN122636709A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer vision and medical wound detection, specifically to a wound size measurement method, system, device, and storage medium based on a medical measuring ruler. Background Technology
[0002] Wound measurement is a core aspect of clinical wound management, widely used in the diagnosis and treatment of pressure ulcers, diabetic foot ulcers, postoperative incisions, chronic ulcers, and burn wounds. By accurately obtaining the length, width, area, and healing trend of the wound, healthcare professionals can objectively assess wound healing effectiveness, develop personalized treatment plans, and predict prognosis, providing significant guidance for clinical diagnosis and treatment.
[0003] Currently, wound measurement techniques can be classified according to dimensions into one-dimensional measurement methods, two-dimensional image methods, and three-dimensional imaging methods.
[0004] One-dimensional measurement methods, such as the ruler method and the probe method, use measuring instruments like medical wound measuring rulers and probes to measure the length, width, and depth of a wound, and then use formulas to estimate the wound area or volume. However, one-dimensional measurement methods rely solely on the physician's experience and visual observation, and are only suitable for relatively regular wounds, resulting in low measurement accuracy. While the probe method can address wounds with sinus tracts and improves measurement accuracy, it requires the probe to penetrate deep into the sinus tract, which may cause discomfort and lead to low patient compliance.
[0005] Two-dimensional imaging is a technique for measuring the two-dimensional dimensions of a wound by recording its two-dimensional contour. Common methods include transparent membrane tracing and digital image measurement. Transparent membrane tracing uses a transparent membrane to trace the wound contour to estimate the wound area. Digital image measurement offers higher measurement accuracy, is suitable for regular or irregular superficial wounds, and has higher patient compliance. It involves acquiring wound images with reference objects, having relevant programs identify the wound edges, and then using appropriate algorithms to measure the wound size. However, like probe methods, transparent membrane tracing requires contact with the wound and tracing the wound contour with a marker, which can cause patient discomfort. The reference objects used in digital image measurement are generally special color blocks or specially designed scales, not dedicated medical devices, and cannot meet clinical compliance requirements for medical devices in medical settings. Furthermore, they are prone to cross-infection due to reference object contamination and are difficult to adapt to standardized wound treatment procedures.
[0006] Three-dimensional imaging methods, such as laser scanning technology and structured light technology, can accurately restore the three-dimensional morphology of wounds, enabling non-invasive measurement and good patient compliance. However, three-dimensional imaging methods rely on dedicated laser scanning equipment and structured light imaging equipment, which have high equipment purchase costs and high subsequent maintenance and calibration costs, making it difficult to popularize and apply them in routine clinical scenarios such as primary hospitals and general wards, thus limiting their large-scale clinical promotion.
[0007] Therefore, in view of the shortcomings of existing technologies, there is an urgent need for a wound size measurement method, system, device and storage medium based on medical measuring rulers to make up for the deficiencies of existing technologies. Summary of the Invention
[0008] The first objective of this invention is to overcome at least one of the shortcomings of existing technologies and provide a wound size measurement method based on a medical measuring ruler. This wound size measurement method based on a medical measuring ruler effectively overcomes the core defects of existing wound measurement technologies, such as high equipment costs, high operational barriers, poor patient compliance, and measurement accuracy being easily affected by the shooting angle and ruler surface deformation, thereby reducing the operational difficulty of clinical wound measurement.
[0009] The above-mentioned objectives of the present invention are achieved through the following technical measures: A method for measuring wound size based on a medical measuring ruler is provided, comprising the following steps; S1. Obtain a two-dimensional wound image with a medical measuring ruler; S2. The medical measurement ruler scale region and wound region in the two-dimensional wound image of step S1 are segmented by the trained segmentation model to obtain the scale mask and wound mask respectively; then the scale mask is aligned and morphologically processed to obtain a binary scale image. S3. Identify the scale lines in the binary scale image from step S2, remove extraneous lines, and obtain the scale ratio of the medical measuring ruler. S4. Map the scale ratio from step S3 to the nominal scale physical length of the medical measuring ruler to obtain the mapping scale of the medical measuring ruler. S5. Based on the mapping scale in step S4 and the wound area mask in step S2, the actual physical length, width and area of the wound are obtained, and the wound measurement results are finally obtained.
[0010] Preferably, step S2 specifically includes the following sub-steps: S2.1. The scale region of the medical measuring ruler in the two-dimensional wound image of step S1 is segmented by the trained measuring ruler segmentation model to obtain the scale mask; the wound region in the two-dimensional wound image of step S1 is segmented by the trained wound segmentation model to obtain the wound mask. S2.2 Calculate the minimum bounding rectangle of the scale mask in step S2.1, and then perform tilt angle detection and affine correction on the two-dimensional wound image of S1 and the minimum bounding rectangle to obtain a positive measurement ruler mask with the rectangular area aligned vertically and rotated horizontally; at the same time, calculate the minimum bounding rectangle of the wound mask in step S2.1 to obtain the length and width coordinates of the wound mask. S2.3. Perform morphological processing on the positive measurement scale mask from step S2.2 to obtain a binary scale image.
[0011] Preferably, S5 specifically involves: obtaining the actual physical length, width, and area of the wound based on the mapping scale in step S4, the wound area mask in step S2, and the length and width coordinates of the wound mask, and finally obtaining the wound measurement result.
[0012] Preferably, step S3 specifically includes the following sub-steps: S3.1 Detect the scale line segments in the binary scale image of step S2, and then filter and process the scale line segments to obtain the processed scale line segments; S3.2. Perform vertical projection on each processed scale line segment in step S3.1 to obtain a vertical projection curve; then lock the core region of interest (ROI) where the scale lines are distributed in the vertical projection curve; select three uniform sampling rows in four equal divisions within the core ROI, perform fast grayscale transition detection on each sampling row, count the number of valid transition pairs in each sampling row, and delete sampling rows where the number of valid transition pairs count is less than the threshold to obtain valid sampling rows; S3.3 Extract the scale edges for each valid sampling line obtained in step S3.2, and then force pairing of the scale lines; then generate the spacing sequence of the forced pairing scales for each valid sampling line, filter outliers from the spacing sequence, and obtain the filtered group spacing sequence for each valid sampling line. S3.4. Calculate the mainstream spacing of the filtered group spacing sequence for each valid sample line in step S3.2 using the Random Sampling Consensus Algorithm (RANSAC); simultaneously obtain the optimal global scale spacing (global_peak) for all valid sample lines in step S3.2 using Gaussian KDE estimation (Gaussian KDE); then use the range of ±1 pixel of the optimal global scale spacing, i.e., [global_peak_int-1, global_peak_int+1], as the global scale spacing error range of the medical measuring ruler.
[0013] Preferably, step S3.1 above includes the following sub-steps: S3.1.1. Taking the upper left corner of the binary scale image as the origin, the horizontal direction of the scale bar of the medical measuring ruler is defined as the X-axis, and the direction of the scale line is defined as the Y-axis. S3.1.2 Detect the scale line segments in the binary scale image of step S2 using the LSD line segment detector, and then retain only the line segments that simultaneously meet the angle condition, length condition, and horizontal offset condition; then for the sub-pixel line segments, calculate the normalized center x coordinate x_norm=round((x1+x2) / 2), upper boundary y_start=round(min(y1,y2)), and lower boundary y_end=round(max(y1,y2)), and convert the line segments into vertical integer coordinate line segments; S3.1.3 Merge line segments that meet the merging conditions, then take the average of the X coordinates within the cluster and the union of the Y range to obtain the processed scale line segments.
[0014] Preferably, step S3.2 above includes the following sub-steps: S3.2.1. Initialize the zero array proj of height h for each processed tick line segment in step S3.1. Then, traverse each processed tick line segment and perform vertical projection (proj[row]+=1) on each row from y_start to y_end to obtain the vertical projection curve. S3.2.2 Calculate the effective length L=y_end-y_start+1 of all processed scale segments, and estimate the probability density of the effective length using Gaussian KDE to find the optimal scale length L(L_scale) of the segment corresponding to the main peak. S3.2.3 Find the peak position y_peak of the vertical projection curve obtained in step S3.2.1, and then expand δ*L above and below the peak position, with 0.5 < δ < 1, to obtain the core region of interest (ROI). S3.2.4. Select three uniform sampling rows in four equal divisions within the core region of interest (ROI); S3.2.5. Traverse the row pixels in each sampling row and record the transition point L_x from black to white; continue traversing and find the subsequent transition point R_x from white to black; then calculate the scale width w (width=R_x-L_x), and only those 3≤w≤30 are considered valid scales; S3.2.6 Count the number of valid tick marks in each sampling row to obtain the number of valid transition pairs in each sampling row; S3.2.7 Delete the sampled rows where the number of valid transition pairs count is less than or equal to the transition pair threshold to obtain valid sampled rows.
[0015] Preferably, step S3.3 above includes the following sub-steps: S3.3.1. Extract the scale edge for each valid sampling row obtained in step S3.2. Traverse the row pixels of each valid sampling row, define all pixel grayscale jump points from 0 to 255 as the left edge, and define all pixel grayscale jump points from 255 to 0 as the right edge. S3.3.2. Sort all transition points in ascending order of x-coordinate. For each left edge transition point, find the first right edge transition point. If the distance between the two is within the range of 3 to 30 pixels, pair them as a scale and record the left edge coordinate L_i and the right edge coordinate R_i. Sort by L_i coordinate to obtain the corresponding effective scale left edge group L_edges and effective scale right edge group R_edges of the effective sampling row. S3.3.3 Calculate the x-spacing between adjacent scales in the effective left edge group L_edges and effective right edge group R_edges of each effective sampling line to obtain the left edge group spacing [L_2-L_1,L_3-L_2,……,L_n-L_{n-1}] and the right edge group spacing [R_2-R_1,R_3-R_2,……,R_n-R_{n-1}]. Each effective sampling line has a set of left edge group spacing and right edge group spacing, and the left edge group spacing and right edge group spacing of the same effective sampling line are defined as the group spacing sequence. S3.3.4. Use the interquartile range method to remove outliers from the intergroup interval sequence corresponding to each valid sampling row in step S3.3.3, and obtain the filtered intergroup interval sequence.
[0016] Preferably, S3.4 above is performed by the following steps: S3.4.1 Calculate the main distance of the filtered group distance sequence for each valid sampled row in step S3.2 using the Random Sampling Consensus Algorithm (RANSAC); simultaneously merge the filtered group distance sequences of each valid sampled row in step S3.2 into a large array (all_distances), and then use Gaussian KDE to perform global probability density analysis on the large array (all_distance) to obtain the optimal global scale distance (global_peak) corresponding to the main peak. S3.4.2. The range of the optimal global scale spacing plus or minus 1 pixel, i.e., [global_peak_int-1, global_peak_int+1], is used as the global scale spacing error range of the medical measuring ruler. At the same time, valid sampling rows whose mainstream spacing is not within the global scale spacing error range are deleted, and only valid sampling rows whose mainstream spacing is within the global scale spacing error range are retained.
[0017] Preferably, the above-mentioned measuring ruler segmentation model is selected from any one of YOLOv11s-seg, Mask R-CNN, and SOLOv2; the measuring ruler segmentation model is trained using a measuring ruler dataset.
[0018] Preferably, the wound segmentation model is selected from any one of YOLOv11s-seg, Mask R-CNN, and SOLOv2; the wound segmentation model is trained using a wound dataset.
[0019] Preferably, the morphological processing described above includes at least one of grayscale conversion, CLAHE enhancement, Gaussian blur, black hat operation, closing operation, OTSU thresholding, and median filtering.
[0020] Preferably, the threshold for the above transition pair is 5.
[0021] Preferably, the angle condition is 85°~95°.
[0022] Preferably, the length condition is greater than or equal to 5 pixels.
[0023] Preferably, the horizontal offset condition is that the difference in horizontal coordinates is less than or equal to 1 pixel.
[0024] Preferably, the above merging conditions are that the difference in the X coordinate is less than 1 pixel, and there is overlap in the Y-axis range with an overlap of less than 1 pixel.
[0025] Preferably, the above wound measurement results also include wound soft tissue recognition results, which are identified by a trained YOLOv11 wound soft tissue recognition model.
[0026] Preferably, the wound soft tissue recognition model is selected from any one of YOLOv11s-seg, Mask R-CNN, and SOLOv2; the wound soft tissue recognition model is trained using a wound soft tissue dataset.
[0027] During the acquisition of the two-dimensional wound image, the medical measuring ruler is at the same horizontal plane as the wound.
[0028] The second objective of this invention is to overcome at least one of the shortcomings of existing technologies and provide a wound size measurement system. This wound size measurement system effectively overcomes the core defects of existing wound measurement technologies, such as high equipment cost, high operation threshold, poor patient compliance, and measurement accuracy being easily affected by shooting angle and ruler surface deformation. It can achieve stable, efficient, and automated measurement of wound size without dedicated hardware equipment, significantly reducing the operational difficulty and implementation cost of clinical wound measurement, and can be adapted to the application needs of different scenarios such as bedside clinical care and home wound monitoring.
[0029] The above-mentioned objectives of the present invention are achieved through the following technical measures: A wound size measurement system is provided, comprising: The measuring ruler extraction module receives a two-dimensional wound image with a medical measuring ruler and performs step S2 in the wound size measurement method described above. The scale extraction module is communicatively connected to the measuring ruler extraction module and performs step S3 in the above wound size measurement method; The ratio acquisition module is communicatively connected to the scale extraction module and executes step S4 in the above wound size measurement method; The wound size quantification module is communicatively connected to the measuring ruler extraction module and the proportion acquisition module, and executes step S5 in the wound size measurement method described above.
[0030] A third objective of this invention is to overcome at least one of the shortcomings of existing technologies and provide a wound size measuring device. This wound size measuring device effectively overcomes the core defects of existing wound measurement technologies, such as high equipment cost, high operation threshold, poor patient compliance, and measurement accuracy being easily affected by shooting angle and ruler surface deformation. It can achieve stable, efficient, and automated measurement of wound size without dedicated hardware equipment, significantly reducing the operational difficulty and implementation cost of clinical wound measurement, and can be adapted to the application needs of different scenarios such as bedside clinical care and home wound monitoring.
[0031] The above-mentioned objectives of the present invention are achieved through the following technical measures: A wound size measuring device is provided, comprising: The front-end interaction unit is used to acquire a two-dimensional wound image with a medical measuring ruler, convert it into a base64 encoded format, and send it to the back-end processing unit. At the same time, it receives and displays the measurement results returned by the back-end processing unit.
[0032] The backend processing unit integrates the wound size measurement system described above; receives the base64 format image sent by the frontend interaction unit and decodes it to restore it as a two-dimensional wound image; executes steps S2-S5 in the wound size measurement method described above; encapsulates the data into structured JSON format data and sends it back to the frontend interaction unit; The data storage unit is communicatively connected to the front-end interaction unit and the back-end processing unit, respectively, and is used to store the original two-dimensional wound image, measurement process parameters, and wound measurement results.
[0033] A fourth objective of this invention is to overcome at least one of the shortcomings of existing technologies by providing a computer-readable storage medium. This computer-readable storage medium effectively overcomes the core defects of existing wound measurement technologies, such as high equipment costs, high operational barriers, poor patient compliance, and measurement accuracy being easily affected by shooting angle and ruler surface deformation. It enables stable, efficient, and automated wound size measurement without the need for dedicated hardware, significantly reducing the operational difficulty and implementation cost of clinical wound measurement, and is adaptable to the application needs of different scenarios such as bedside clinical care and home wound monitoring.
[0034] The above-mentioned objectives of the present invention are achieved through the following technical measures: A computer-readable storage medium is provided having a computer program stored thereon, which, when executed on a computer, causes the computer to perform the aforementioned wound size measurement method.
[0035] The beneficial effects of this invention are: 1. The hospital's standard medical measuring ruler is used directly as the physical calibration benchmark. There is no need to touch the wound or trace the wound outline. This avoids the patient discomfort and cross-infection risk caused by traditional transparent film tracing and probe measurement, thus improving patient compliance and clinical safety. 2. The scale ROI area is vertically divided into four equal parts for sampling to obtain three sets of sampling rows: upper, middle and lower. The effective rows are then filtered by the number threshold through jump. Uniform sampling at multiple locations can avoid the defects of single row sampling being affected by local stains, bends, and occlusions, and increase the number of effective scale samples, especially improving the stability and reliability of the scale calculation for small wounds. 3. A line segment detector is used to extract fine scale lines and obtain floating-point high-precision line segment coordinates. Furthermore, by normalizing the center coordinates and correcting the upper and lower boundaries, the slightly tilted and deformed original line segments are uniformly converted into standard vertical integer pixel line segments, eliminating the scale positioning deviation caused by shooting tilt and micro deformation of the ruler. Compared with traditional simple pixel-level detection, the scale positioning accuracy is significantly improved. 4. Due to shooting errors such as lighting issues, it is impossible for each scale line to perfectly fit the rectangle. This invention generates two independent spacing sequences for the left and right edge groups of the scale, respectively, which effectively expands the number of effective samples, reduces the statistical bias caused by insufficient samples in small-size measurement scenarios, and makes the scale spacing fitting results more stable. 5. This invention does not require high-cost 3D equipment such as laser scanning and structured light. It can complete high-precision automated measurement using only conventional medical measuring rulers and ordinary imaging equipment. The equipment cost and operation and maintenance cost are extremely low. It can be widely adapted to all scenarios such as hospital wards at all levels, community clinics, and home wound monitoring, and has strong promotion potential. Attached Figure Description
[0036] The invention will be further described with reference to the accompanying drawings, but the contents of the drawings do not constitute any limitation on the invention.
[0037] Figure 1 This is a flowchart of a wound size measurement method based on a medical measuring ruler.
[0038] Figure 2 This is the scale mask for the medical measuring ruler in Example 2.
[0039] Figure 3 This is the image of the scale mask in Example 2 after grayscale conversion.
[0040] Figure 4 This is the image of the scale mask in Example 2 after CLAHE enhancement.
[0041] Figure 5 This is the image of the scale mask in Example 2 after Gaussian blurring.
[0042] Figure 6 This is the image of the scale mask in Example 2 after black hat computation.
[0043] Figure 7 The image is the result of closing the scale mask in Example 2.
[0044] Figure 8 The image is the result of OTSU thresholding and median filtering of the scale mask in Example 2.
[0045] Figure 9 The image shown is the binary image after line segment detection and filtering in Example 2.
[0046] Figure 10 The image shown is the deduplication and merging result of the binary image in Example 2.
[0047] Figure 11 This is the vertical projection curve for Example 2.
[0048] Figure 12 This is the core region of interest (ROI) in Example 2.
[0049] Figure 13 This is the sampling row in Example 2.
[0050] Figure 14 This is a two-dimensional wound image from Example 3.
[0051] Figure 15 This is the wound mask for Example 3.
[0052] Figure 16 The wound mask of Example 3 is used to segment the wound in a two-dimensional wound image.
[0053] Figure 17This refers to the wound mask and wound in Example 3.
[0054] Figure 18 This is a visualization output diagram of the front-end interactive unit of the wound size measuring device for pressure ulcers in Example 3.
[0055] Figure 19 This is a visualization output of the connection between the scale points of the medical measuring ruler in Example 5. Detailed Implementation
[0056] The technical solution of the present invention will be further described in conjunction with the following embodiments.
[0057] Example 1
[0058] A method for measuring wound size based on a medical measuring ruler, such as Figure 1 As shown, it includes the following steps; S1. Obtain a two-dimensional wound image with a medical measuring ruler; S2. The medical measurement ruler scale region and wound region in the two-dimensional wound image of step S1 are segmented by the trained segmentation model to obtain the scale mask and wound mask respectively; then the scale mask is aligned and morphologically processed to obtain a binary scale image. S3. Identify the scale lines in the binary scale image from step S2, remove extraneous lines, and obtain the scale ratio of the medical measuring ruler. S4. Map the scale ratio from step S3 to the nominal scale physical length of the medical measuring ruler to obtain the mapping scale of the medical measuring ruler. S5. Based on the mapping scale in step S4 and the wound area mask in step S2, the actual physical length, width and area of the wound are obtained, and the wound measurement results are finally obtained.
[0059] It should be noted that the stray lines in this invention specifically refer to light and dark lines, scratches, and other stray lines generated during imaging. In this invention, the medical measuring ruler is positioned on the same horizontal plane as the wound during the acquisition of the two-dimensional wound image to improve measurement accuracy.
[0060] The wound measurement results of this invention also include wound soft tissue recognition results, which are obtained through a trained wound soft tissue recognition model. The wound soft tissue recognition model is selected from any one of YOLOv11s-seg, Mask R-CNN, and SOLOv2. This implementation uses the YOLOv11s-seg model as an example. In practice, a CBAM optimization model is added to the P3 layer of the YOLOv11s-seg model. The YOLOv11 wound soft tissue recognition model is trained using a wound soft tissue dataset. The loss function of the YOLOv11 wound soft tissue recognition model is optimized as Dice + CE + Boundary: 0.4 * dice_loss + 0.3 * ce_loss + 0.3 * boundary_loss, where the loss weights are adjusted to dice = 0.4, ce = 0.3, and boundary = 0.3. The YOLOv11 wound soft tissue recognition model provides accurate clinical information such as location, type stage, confidence level, pixel area, and contour.
[0061] Step S2 specifically includes the following sub-steps: S2.1. The scale region of the medical measuring ruler in the two-dimensional wound image of step S1 is segmented by the trained measuring ruler segmentation model to obtain the scale mask; the wound region in the two-dimensional wound image of step S1 is segmented by the trained wound segmentation model to obtain the wound mask. S2.2 Calculate the minimum bounding rectangle of the scale mask in step S2.1, and then perform tilt angle detection and affine correction on the two-dimensional wound image and the minimum bounding rectangle in S1 to obtain the upright measuring ruler mask with the rectangular area aligned in the vertical direction and rotated in the horizontal direction; at the same time, calculate the minimum bounding rectangle of the wound mask in step S2.1 to obtain the length and width coordinates of the wound mask. S2.3. Perform morphological processing on the positive measurement ruler mask from step S2.2 to obtain a binary scale image; the morphological processing includes at least one of grayscale conversion, CLAHE enhancement, Gaussian blur, black hat operation, closing operation, OTSU thresholding, and median filtering.
[0062] It should be noted that the measurement ruler segmentation model of this invention is selected from any one of YOLOv11s-seg, Mask R-CNN, and SOLOv2; the measurement ruler segmentation model is trained using a measurement ruler dataset. This embodiment uses the YOLOv11s-seg model as an example for illustration. When the YOLOv11s-seg model is used as the measurement ruler segmentation model, its loss function is the default loss function of the YOLOv11s-seg model, specifically the ratio BCE+Dice: 0.5*bce_loss + 0.5*dice_loss.
[0063] The wound segmentation model is selected from any one of YOLOv11s-seg, Mask R-CNN, and SOLOv2; the wound segmentation model is trained using a wound dataset. This implementation uses the YOLOv11s-seg model as an example, with CBAM optimization added to the P3 layer of the YOLOv11s-seg model. The loss function of the YOLOv11 wound segmentation model is optimized as Dice + CE + Boundary: 0.4 * dice_loss + 0.3 * ce_loss + 0.3 * boundary_loss, where the loss weights are adjusted to dice = 0.4, ce = 0.3, and boundary = 0.3. To alleviate the problem of mask fitting straight edges, the YOLOv11 wound segmentation model is modified so that when upsample = True, F.interpolate is used to upsample to high resolution, followed by crop_mask cropping. The YOLOv11 wound segmentation model provides accurate clinical information such as location, type and stage, confidence level, pixel area, and contour.
[0064] Specifically, S5 involves obtaining the actual physical length, width, and area of the wound based on the mapping scale from step S4, the wound area mask from step S2, and the length and width coordinates of the wound mask, ultimately yielding the wound measurement result.
[0065] Step S3 specifically includes the following sub-steps: S3.1 Detect the scale line segments in the binary scale image of step S2, and then filter and process the scale line segments to obtain the processed scale line segments; S3.2. Perform vertical projection on each processed scale line segment in step S3.1 to obtain a vertical projection curve; then lock the core region of interest (ROI) where the scale lines are distributed in the vertical projection curve; select three uniform sampling rows in four equal divisions within the core ROI, perform fast grayscale transition detection on each sampling row, count the number of valid transition pairs in each sampling row, and delete sampling rows where the number of valid transition pairs count is less than the threshold to obtain valid sampling rows; S3.3 Extract the scale edges for each valid sampling line obtained in step S3.2, and then force pairing of the scale lines; then generate the spacing sequence of the forced pairing scales for each valid sampling line, filter outliers from the spacing sequence, and obtain the filtered group spacing sequence for each valid sampling line. S3.4. The mainstream spacing of the group spacing sequence after filtering each valid sample line in step S3.2 is calculated using the Random Sampling Consensus Algorithm (RANSACRegressor). At the same time, the optimal global scale spacing gp(global_peak) of all valid sample lines in step S3.2 is obtained by Gaussian kernel density estimation (KDE), and the optimal global scale spacing gp(global_peak) is the scale ratio. Then, the range of ±1 pixel of the optimal global scale spacing, i.e., the range [global_peak_int-1, global_peak_int+1], is used as the global scale spacing error range of the medical measuring ruler.
[0066] Step S3.1 includes the following sub-steps: S3.1.1. Taking the upper left corner of the binary scale image as the origin, the horizontal direction of the scale bar of the medical measuring ruler is defined as the X-axis, and the direction of the scale line is defined as the Y-axis. S3.1.2. Detect the scale lines in the binary scale image from step S2 using an LSD line segment detector, and then retain only the line segments that simultaneously meet the angle condition, length condition, and horizontal offset condition. For sub-pixel line segments, calculate the normalized center x-coordinate x_norm=round((x1+x2) / 2), upper boundary y_start=round(min(y1,y2)), and lower boundary y_end=round(max(y1,y2)), converting the line segments into vertical integer coordinate line segments. The angle condition, length condition, and horizontal offset condition of this invention can be different. This embodiment uses an angle condition of 85°~95°, a length condition of greater than or equal to 5 pixels, and a horizontal offset condition of a horizontal coordinate difference of less than or equal to 1 pixel as an example for explanation. S3.1.3 Merge the line segments that meet the merging conditions, then take the average of the X coordinates within the cluster and the union of the Y range to obtain the processed scale line segments. The merging conditions of the present invention can be different ranges. This embodiment takes the merging condition of X coordinate difference being less than 1 pixel and Y axis range having overlap with an overlap of less than 1 pixel as an example for explanation.
[0067] Step S3.2 includes the following sub-steps: S3.2.1. Initialize the zero array proj of height h for each processed tick line segment in step S3.1. Then, traverse each processed tick line segment and perform vertical projection on each row from y_start to y_end, i.e., proj[row]+=1, to obtain the vertical projection curve. S3.2.2 Calculate the effective length L = y_end - y_start + 1 of all processed scale segments. Estimate the probability density of the effective length using Gaussian kernel density estimation (KDE) and find the optimal scale length L (L_scale) of the segment corresponding to the main peak. S3.2.3 Find the peak position y_peak of the vertical projection curve obtained in step S3.2.1, and then expand δ*L_scale above and below the peak position y_peak, with 0.5 < δ < 1, to obtain the core region of interest (ROI). S3.2.4. Select three uniform sampling rows in four equal divisions within the core region of interest (ROI); S3.2.5. Traverse the row pixels in each sampling row and record the transition point L_x from black to white; continue traversing and find the subsequent transition point R_x from white to black; then calculate the scale width w, i.e., width = R_x - L_x, and only when 3 ≤ width ≤ 30 is it considered a valid scale. S3.2.6 Count the number of valid tick marks in each sampling row to obtain the number of valid transition pairs in each sampling row; S3.2.7 Delete the sampling rows where the number of valid transition pairs count is less than or equal to the transition pair threshold to obtain valid sampling rows. In this embodiment, the transition pair threshold is 5 as an example. Of course, the transition pair threshold of the present invention can also be other values.
[0068] Step S3.3 includes the following sub-steps: S3.3.1. Extract the scale edge for each valid sampling row obtained in step S3.2. Traverse the row pixels of each valid sampling row, define all pixel grayscale jump points from 0 to 255 as the left edge, and define all pixel grayscale jump points from 255 to 0 as the right edge. S3.3.2. Sort all transition points in ascending order of x-coordinate. For each left edge transition point, find the first right edge transition point. If the distance between the two is within the range of 3 to 30 pixels, pair them as a scale and record the left edge coordinate L_i and the right edge coordinate R_i. Sort by L_i coordinate to obtain the corresponding effective scale left edge group L_edges and effective scale right edge group R_edges of the effective sampling row. S3.3.3 Calculate the x-spacing between adjacent scales in the effective left edge group L_edges and effective right edge group R_edges of each effective sampling line to obtain the left edge group spacing [L_2-L_1,L_3-L_2,……,L_n-L_{n-1}] and the right edge group spacing [R_2-R_1,R_3-R_2,……,R_n-R_{n-1}]. Each effective sampling line has a set of left edge group spacing and right edge group spacing, and the left edge group spacing and right edge group spacing of the same effective sampling line are defined as the group spacing sequence. S3.3.4. Use the interquartile range method to remove outliers from the intergroup interval sequence corresponding to each valid sampling row in step S3.3.3, and obtain the filtered intergroup interval sequence.
[0069] S3.4 is performed by the following steps: S3.4.1 Calculate the main distance of the filtered group distance sequence for each valid sampled row in step S3.2 using the Random Sampling Consensus Algorithm (RANSAC). Simultaneously, merge the filtered group distance sequences of each valid sampled row in step S3.2 into a large array all_distances. Then, use Gaussian KDE to perform global probability density analysis on the large array all_distance to obtain the optimal global scale distance gp (global_peak) corresponding to the main peak. S3.4.2. The optimal global scale spacing gp (global_peak) within the range of [global_peak_int-1, global_peak_int+1] is used as the global scale spacing error range of the medical measuring ruler. At the same time, valid sampling rows whose mainstream spacing is not within the global scale spacing error range are deleted, and only valid sampling rows whose mainstream spacing is within the global scale spacing error range are retained.
[0070] The beneficial effects of this wound size measurement method based on a medical measuring ruler are as follows: 1. It directly uses a hospital-standard medical measuring ruler as the physical calibration benchmark, eliminating the need for contact with the wound or tracing its outline. This avoids patient discomfort and the risk of cross-infection associated with traditional transparent film tracing and probe measurements, improving patient compliance and clinical safety. 2. The scale ROI area is longitudinally divided into four equal parts for sampling, obtaining three sets of sampling rows (upper, middle, and lower). Effective rows are then selected using a jump threshold. Uniform sampling at multiple locations avoids the limitations of single-row sampling due to localized dirt, bending, or obstruction, increasing the number of effective scale samples, especially improving the stability and reliability of scale calculations for small wounds. 3. A line segment detector is used to extract fine scale lines, obtaining high-precision floating-point line segment coordinates. Further, by normalizing the center coordinates and correcting the upper and lower boundaries, slight tilts and irregularities are corrected. 1. The original line segments are uniformly converted into standard vertical integer pixel line segments, eliminating the scale positioning deviation caused by shooting tilt and slight deformation of the ruler. Compared with traditional simple pixel-level detection, the scale positioning accuracy is significantly improved. 2. Due to shooting errors such as lighting issues, it is impossible for each scale line to perfectly fit a rectangle. This invention generates two independent spacing sequences for the left and right edge groups of the scale, effectively expanding the number of effective samples and reducing the statistical deviation caused by insufficient samples in small-size measurement scenarios, making the scale spacing fitting results more stable. 3. This invention does not require high-cost 3D equipment such as laser scanning and structured light. It can complete high-precision automated measurement using only conventional medical measuring rulers and ordinary shooting equipment. The equipment cost and maintenance cost are extremely low. It can be widely adapted to all scenarios such as hospital wards, community clinics, and home wound monitoring, and has strong promotion potential.
[0071] Example 2
[0072] A wound size measurement method based on a medical measuring ruler, which is otherwise the same as that in Example 1, except that: Stage 0: Two-dimensional wound image with medical measuring ruler - Preliminary stage: Objective: To receive Base64 encoded images uploaded by users via the FastAPI interface, process them, and prepare them for subsequent analysis.
[0073] Execution logic: Receive Request: Receives request parameters containing fileId (unique identifier) and img (Base64 encoded image).
[0074] Base64 decoding: Remove the Base64 header identifier and decode the image data into binary format.
[0075] Temporary saving: Save the decoded image data as a temporary JPG file in the / tmp directory. The filename includes a timestamp to avoid conflicts.
[0076] Read the original image: Use the imread function of the OpenCV library to read the temporary file and obtain a NumPy array of the original color image, which will be used for subsequent cropping and drawing operations.
[0077] Initialize result data: Prepare data structures such as final_status (final status code), final_result (final result description string), final_msg (error message list), wound_data (wound segmentation result dictionary), exp1_results (Exp1 tissue subdivision result list), and ruler_data (measurement ruler recognition result dictionary).
[0078] Output: Image source data (temporary file path, original image array), and a sign indicating that preprocessing is complete.
[0079] Phase 1: Wound Division Objective: To segment and identify all wound regions from images using a trained YOLOv11 wound segmentation model (with CBAM added in P3, and loss weights adjusted to dice=0.4, ce=0.3, boundary=0.3) and the YOLOv11s-seg model, providing accurate location, type and stage, confidence score, pixel area, contour, and other key clinical information. The YOLOv11 wound segmentation model was trained using a dataset of 2082 wound images publicly available on the Roboflow website, under a CC BY 4.0 license.
[0080] Execution logic: Model loading: Use the trained YOLOv11 wound segmentation model, ensuring the model is loaded only once. If the model file does not exist, return a loading failure error.
[0081] Device selection: Check if the CUDA computing device is available. If it is available, use the GPU to accelerate inference; otherwise, use the CPU. Log the device information.
[0082] YOLO Inference: Input a 2D wound image with a medical measuring ruler into the trained YOLOv11 wound segmentation model to perform object detection. Set the confidence threshold to 0.3, the IOU threshold to 0.5, the input image size to 640×640, and disable window display and save functions.
[0083] Result analysis: Traverse the boxes in the inference output results[0] and extract the class_id, class_name (backend classification), conf (confidence), box (minimum bounding rectangle), and mask (mask vertex list) for each detected target.
[0084] Mask binarization: Create an all-zero matrix (uint8 type) of the same size as the 2D wound image, traverse the vertex list of each mask, and fill the polygon region with 255 according to the vertex order to obtain the original mask image.
[0085] Maximum Connected Component Extraction: Using morphological connected component analysis (connected components with stats), all connected regions are counted, sorted by area, and the connected region with the largest area is selected as the main flesh and blood region. Fragment noise is removed to obtain the denoised main_body_mask (mask of the main wound region).
[0086] Pixel area calculation: Count the number of pixels with a value of 255 in main_body_mask to obtain the actual pixel area (square pixels) of the wound in the original image, which will be used for subsequent quantization of the wound size.
[0087] Minimum bounding rectangle calculation: Extract the contour of main_body_mask (findContours), use cv2.minAreaRect to calculate the minimum area rotating rectangle, obtain the center coordinates (center_x, center_y), width, height and angle of the rectangle, and then call cv2.boxPoints to get the coordinates of the four vertices, flatten and store them as a list.
[0088] Contour simplification: Perform morphological opening operation (3×3 rectangular kernel) on main_body_mask to remove burrs and extract simplified contours. Use cv2.approxPolyDP to approximate the contours with a polygon area error rate of 0.001, reducing the number of data points and facilitating subsequent processing.
[0089] Result assembly: Sort by wound ID, create a dictionary for each wound containing class_id, class_name, conf, bbox (center point, width, height, angle, and four vertices), mask_contour (simplified outline), and mask_pixel_count (pixel area), and add it to the wounds list.
[0090] Status Update: Determine whether the wound segmentation was successful. If successful, set final_status to 1 (only the wound was successful); if unsuccessful, set final_status to 0 (the wound failed) and update the final_result description.
[0091] Output: A dictionary of wound segmentation results, named wound_data, containing a success identifier, wound_count (number of wounds), and a list of wounds (details for each wound).
[0092] Phase 2: Soft tissue identification in the wound area Objective: To perform local cropping on each detected wound region, and then use a trained wound soft tissue recognition model to detect tissue type and classify the soft tissue within the wound. The wound soft tissue recognition model was trained using 1100 labeled images from 2082 publicly available wound images on the Roboflow website as the dataset.
[0093] Execution logic: Loop processing: Iterate through each wound in the wound_data["wounds"] list and generate a unique wound_id for each wound.
[0094] Cropping region extraction: Based on the bounding box of the wound, minAreaRect (center_x, center_y, width, height), calculate the coordinates of the top left corner of the cropping region: x1 = max(0, center_xwidth / 220) and y2 = min(image_height, center_y + height / 2 + 20). The logic for y1 is the same as x1, and the logic for x2 is the same as y2. Padding = 20 pixels increases the cropping field of view. Call the [y1:y2,x1:x2] slicing operation of the original image to obtain the cropped image cropped_img, and record the cropping offsets off_x = x1 and off_y = y1.
[0095] Exp1 Model Inference: Load the trained YOLOv11 wound soft tissue recognition model, input the cropped_img into the model, set the confidence threshold to 0.3, the IOU threshold to 0.5, and the input size to 640×640, and perform tissue type detection.
[0096] Mask binarization: Create an all-zero matrix of the same size as cropped_img, fill the mask polygon region of each detected target with 255, and obtain the original tissue mask.
[0097] Maximum connected component extraction: Perform connected component analysis on the tissue mask, select the connected component with the largest area, remove external fragment noise, and obtain the main_body_mask.
[0098] Pixel area calculation: Count the number of 255 pixels in main_body_mask to obtain the pixel area of the organization in the cropping image.
[0099] Minimum bounding rectangle and contour simplification: Calculate the bounding box and simplified contour using the same process as wound segmentation to obtain the bbox and contour.
[0100] Detailed result assembly: For each detected organization, construct a dictionary containing class_id, class_name, conf, mask_contour, and mask_pixel_count, and add it to the details list.
[0101] Coordinate restoration: Add the cropping offset (x+offset_x, y+offset_y) to the coordinates of all contour points in the details list, and convert the cropped image coordinates back to the original image coordinate system.
[0102] Results storage: Add the Exp1 subdivision results to the exp1_results list and associate them with the corresponding wound ID.
[0103] Error handling: If cropping fails (e.g., coordinates exceed the image range), log the error message to final_msg.
[0104] Output: Exp1_results, a list of tissue subdivision results for each wound, including a success flag, wound_id, and a list of details (tissue classification information).
[0105] Phase 3: Medical Measurement Ruler Scale Region Segmentation and Preprocessing Objective: To segment the measuring ruler region in an image using a trained YOLOv11 measuring ruler segmentation model, perform rotation correction on the measuring ruler region to eliminate shooting angle deviation, and then perform cropping extraction to provide a measuring ruler mask image with the scale perpendicular to the measuring ruler and the scale pointing horizontally for scale recognition. The YOLOv11 measuring ruler segmentation model was trained using 1402 labeled medical measuring ruler images as a dataset.
[0106] Execution logic: Loading the measuring ruler model: Using the trained YOLOv11 measuring ruler segmentation model.
[0107] Measurement ruler detection inference: Input the two-dimensional wound image into the model, set the confidence threshold to 0.4 and the IOU threshold to 0.7, and perform measurement ruler region detection.
[0108] Mask generation: Create an all-zero matrix of the original image size, traverse the mask vertex list of the inference result, fill the polygon region with 255, and obtain the original measuring ruler mask raw_ruler_mask. If no measuring ruler is detected or the mask is empty, return failure.
[0109] Rotation parameter extraction: The rotation angle of the measuring ruler is extracted according to a preset strategy. The default method is minAreaRect, which calculates the minimum bounding rectangle for the mask contour, determines the orientation of the measuring ruler based on the aspect ratio of the rectangle, and calculates the rotation angle. The alternative method, LSD, is based on line segment detection to statistically determine the main direction angle. The rotation center angle (cx, cy) and rotation angle (rotate_angle) are extracted.
[0110] Rotation Transformation: Based on the rotation center and angle, the rotation matrix is calculated using cv2.get Rotation Matrix 2D. The position of the rotation center is adjusted so that the center of the image after the rotation matrix transformation is located at the center of the new size. The new dimensions new_w and new_h of the rotated image are calculated. The original image and the mask are subjected to an affine transformation using cv2.warp Affine to obtain the rotated image rotated_img and the mask rotated_mask.
[0111] Cropping the measuring ruler area: Extract the contour of rotated_mask, calculate the coordinates and width and height (x,y,w_crop,h_crop) of its minimum bounding rectangle, crop the image from the corresponding area of rotated_img to obtain cropped_img, and crop the mask from the corresponding area of rotated_mask to obtain cropped_mask.
[0112] Masking: The cropped image is combined with the cropped binary mask using cv2.bitwise_and, retaining only the measuring scale area, resulting in final_masked_img (i.e., a color image where the non-measuring scale area is transparent), as shown below. Figure 2 The resolution is 827×163.
[0113] Transformation parameter recording: Record the coordinates of the top left corner of the cropped area crop_xy=(x,y), the rotation matrix rot_matrix, the rotation center rot_center=(cx,cy), the rotation angle rot_angle, the size of the rotated image rot_size=(new_w,new_h), and the original image size original_size=(width,height), and encapsulate them into a trans_params dictionary, which is used to inversely transform the coordinates of the measurement ruler image back to the original image coordinates.
[0114] Status update: If the measurement ruler segmentation and preprocessing are successful, mark seg_success as True; otherwise, mark it as False.
[0115] Output: The preprocessed measurement ruler results include final_masked_img (i.e., the measurement ruler area image after rotation transformation and cropping), trans_params (i.e., the coordinate transformation parameter dictionary), success (i.e., the success indicator), and message (i.e., the prompt message).
[0116] Phase 4: Scale Recognition Objective: For a positive-position measuring ruler mask, use an algorithm to detect and calculate the scale length and interval pixel value of the measuring ruler, and output the coordinates of all reliable scale points.
[0117] Execution logic: The preprocessing steps for the positive positioning measuring scale mask, from front to back, are as follows: Perform a series of image preprocessing operations on final_masked_img to generate a clean binary scale image suitable for scale detection.
[0118] Grayscale conversion: Use cv2.cvtColor to convert a color image to a grayscale image, such as... Figure 3 The resolution is 827×163.
[0119] CLAHE Enhancement: Create a CLAHE object (i.e., contrast limit clipLimit=2.0, grid size gridSize=(4,4)) to locally enhance the contrast of the grayscale image, highlighting the details of the tick marks, such as... Figure 4 The resolution is 827×163.
[0120] Gaussian blur: Gaussian blur denoising is performed on the enhanced image using a 3×3 kernel (sigmaX=0, sigmaY=0), smoothing image noise, such as... Figure 5 The resolution is 827×163.
[0121] Black hat operation: Create a structuring element (7,3) (i.e., a horizontal bar), perform a vertically oriented black hat operation (MORPH_BLACKHAT) on the blurred image, and enhance the details of dark lines (i.e., tick marks), such as... Figure 6 The resolution is 827×163.
[0122] Closing operation: Create a struct (3,1) (i.e., a vertical bar), perform a vertical closing operation (MORPH_CLOSE) on the black hat result, connect the broken tick marks to ensure the continuity of the tick marks, such as... Figure 7 The resolution is 827×163.
[0123] OTSU thresholding: Using adaptive OTSU thresholding, the optimal segmentation threshold is automatically calculated based on the histogram, converting the image into a black and white binary image (i.e., black for the background is 0, and white for the scale is 255), such as... Figure 8 The resolution is 827×163.
[0124] Median filtering: Use a 3×3 vertical median filter (i.e., kernel size 3) to remove isolated salt-and-pepper noise from the binary image, such as... Figure 8 .
[0125] Phase 5: Scale line recognition and spacing calculation 5.1 Line Segment Detection and Screening LSD line segment detection: The created LSD line segment detector (LSD_REFINE_ADV) performs detection on the preprocessed binary image to obtain lines, _, _, _ (lines is a list of line segment tuples, each tuple contains four coordinates x1, y1, x2, y2 and angle information).
[0126] Line segment filtering and conversion: Traverse the `lines` list, extract the start and end coordinates of each line segment, calculate the angle with the horizontal line, and filter line segments that meet the following conditions: Angle range: |angle| is between 85° and 95° (i.e., close to perpendicular). Length condition: Line segment length ≥ 5 pixels. Horizontal offset limit: Horizontal coordinate difference |dx| ≤ 1 pixel (i.e., close to strictly perpendicular).
[0127] For the sub-pixel line segments that pass the screening, calculate the center X coordinate x_norm=round((x1+x2) / 2), the upper boundary y_start=round(min(y1,y2)), and the lower boundary y_end=round(max(y1,y2)), converting the line segments into strictly perpendicular integer coordinate line segments, such as... Figure 9 The resolution is 827×163.
[0128] 5.2 Deduplication and Merging of Line Segments Merging: For scale segments with similar x_norm (tolerance of 1 pixel) and overlapping Y-axis ranges (tolerance of 1 pixel), merge them into a new segment. The x-coordinate is taken as the average within the cluster, and the Y-range is taken as the union, resulting in a clean list of vertical long line segments called merged_segments, such as... Figure 10 The resolution is 827×163.
[0129] Post-merge check: Count the number of merged_segments. If it is less than 5, return failure (i.e., the number of time scale lines is insufficient).
[0130] 5.3 Vertical Projection and Scale Length Estimation Vertical projection: Initialize a zero array `proj` of height `h`, iterate through each line segment, and for each row from `y_start` to `y_end`, execute `proj[row] += 1` to obtain the vertical projection curve (the horizontal axis is the Y coordinate, and the vertical axis is the line segment coverage count at that position), such as... Figure 11 .
[0131] Gaussian kernel density estimation (KDE): Calculate the effective length of all line segments L = y_end - y_start + 1, and use the Gaussian kernel density estimation (KDE) to estimate the probability density of the length. Set the bandwidth to 0.5, sample 1000 points to find the optimal scale length L_scale corresponding to the main peak (rounded to an integer).
[0132] Core Region of Interest (ROI) Locating: Locate the peak position y_peak on the projection curve. Using y_peak as the center, extend the region above and below it by δ*L_scale. In this embodiment, δ is preferably 0.6 (extending by a total of 1.2 times the length of L_scale). Round to the nearest integer to ensure the y-coordinate range does not exceed the image boundaries, thus obtaining the final y-coordinate range of the ROI [final_y_min, final_y_max]. Figure 12 .
[0133] 5.4 Uniform Sampling and Validity Pre-verification Quadruple sampling: Within the core Region of Interest (ROI), three sampling rows are selected evenly. The upsampling row y_top = round(final_y_min + y_range * 0.25); The mid-sampling row y_mid = round(final_y_min + y_range * 0.50); The downsampling row is calculated as y_bot = round(final_y_min + y_range * 0.75). Where y_range = final - y_max - final_y_min, rounds all y coordinates and removes duplicates.
[0134] Sampling row pre-validation: Perform fast grayscale transition detection on each sampling row and count the number of valid "black→white→black" transition pairs (from left edge to right edge) in that row: Traverse the row pixels and record the transition point L_x (left edge coordinates) from black to white. Continue traversing and find the immediately following white→black transition point R_x (right edge coordinates). Calculate the scale width width = R_x - L_x, and only consider it a valid scale if 3 ≤ width ≤ 30. Count the number of valid transition pairs count. Keep the sampling rows with a transition pair count ≥ 5 to obtain the valid sampling rows. Taking a sampling row within a valid sampling row as an example, such as... Figure 14If all sampled rows fail pre-validation, return a failure message and indicate "No valid scale detected".
[0135] 5.5 Scale Edge Detection and Pairing For all valid sampled rows that pass pre-validation, perform precise tick edge extraction and pairing: Traverse the row pixels, detecting all 0→255 transition points as left edges and 255→0 transition points as right edges. Sort all transition points in ascending order of x-coordinate. For each left edge transition point, find the first right edge transition point. If the distance between the two is within the range of 3~30 pixels, the pairing is successful, and the left edge coordinate L_i and right edge coordinate R_i are recorded. Sort by the L_i coordinate to obtain the valid left tick edge group L_edges and valid right tick edge group R_edges for that valid sampled row.
[0136] Specifically, when sampling rows are included in the valid sampling action, the x-coordinates identified by the left and right edges are as follows: Valid scale left edge group A (black→white): [19, 54, 78, 91, 103, 115, 127, 139, 151, 163, 176, 188, 200,212, 224, 236, 248, 260, 272, 284, 296, 308, 320, 332, 344, 356, 368, 380,391, 404, 427, 439, 451, 463, 475, 487, 499, 511, 535, 560, 572, 584, 596,608, 620, 633, 645, 669, 682, 694, 706, 718, 730, 743, 766). Effective scale right edge group B (white→black): [4, 10, 35, 46, 59, 83, 95, 107, 119, 131, 143, 156, 168, 180, 192, 204, 216, 228, 240, 253, 264, 288, 301, 312, 324, 336, 348, 360, 372, 396, 408, 420, 443, 456, 467, 479, 491, 504, 515, 540, 552, 564, 576, 588, 600, 613, 625, 637, 674, 686, 710, 722, 746, 770, 793).
[0137] Result status classification: Count the number of rows with a valid transition pair count < 8 among all valid sampled rows, denoted as low_count_rows: If low_count_rows == 2: Mark the status as ERR_CAPTURE (shooting error), the process terminates and returns failure. If low_count_rows == 1: Mark the status as WARN_SKEW (tilt error exists), and continue execution. If low_count_rows == 3: Mark the status as WARN_LOW_SAMPLE (insufficient scale sample size), and continue execution. If low_count_rows == 0: Mark the status as NORMAL (normal), and continue execution.
[0138] The result grading applies to situations where the measuring scale is bent. When `low_count_rows` is 0, a sufficient number of left and right edge groups can be obtained from the effective sampling rows for subsequent steps. When `low_count_rows` is 1, one effective sampling row may have fewer graduations. This could be due to two scenarios: first, the row only captures centimeter graduations, which has little impact; second, the bending may be the cause, but two effective sampling rows still provide enough samples for subsequent steps. When `low_count_rows` is 2, two effective sampling rows may have fewer graduations, possibly due to excessive bending or obstruction during shooting, requiring reshooting. When `low_count_rows` is 3, all three effective sampling rows may have fewer graduations, indicating only a small wound (e.g., 0.8cm) was captured, and the process continues.
[0139] 5.6 Spacing Sequence Generation Spacing sequence generation: For the left and right edge groups of each valid sampling line, calculate the x-spacing between adjacent ticks to obtain a spacing sequence: Left edge group spacing: [L_2-L_1,L_3-L_2,...,L_n-L_{n-1}] Right edge group spacing: [R_2-R_1,R_3-R_2,...,R_n-R_{n-1}] Merge the left and right edge group spacings of all sampling rows to generate a maximum of 6 spacing sequences.
[0140] When sampling rows in the effective sampling action, the adjacent difference of the left edge group spacing A is: [35, 24, 13, 12, 12, 12, 12, 12, 12, 12, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 13, 23, 12, 12, 12, 12, 12, 12, 12, 24, 25, 12, 12, 12, 12, 13, 12, 24, 13, 12, 12, 12, 12, 13, 23]. Right edge group spacing B adjacent difference: [6, 25, 11, 13,24, 12, 12, 12, 12, 12, 13, 12, 12, 12, 12, 12, 12, 12, 13, 11, 24, 13, 11, 12, 12, 12, 12, 12, 12, 24, 12, 12, 23, 13, 11, 12, 12, 13, 11, 25, 12, 12, 12, 12, 12, 13, 12, 12, 37, 12, 24, 12, 24, 24, 23].
[0141] 5.7 Two-level outlier filtering Outlier filtering: For each spacing sequence, outliers are removed using the interquartile range (IQR) method: Calculate the Q1 (25%) and Q3 (75%) quantiles, calculate IQR = Q3Q1, and set the outlier threshold = Q3 + 1.5 * IQR. Only large spacings within the threshold are retained, filtering out abnormal spacings caused by occlusion or malfunctions.
[0142] 5.8. RANSAC robust fitting yields the scale ratio. For each filtered distance sequence, the mainstream distance is fitted using the Random Sample Consensus (RANSAC) algorithm: A cumulative X-coordinate sequence y_cum = np.cumsum(distances) is constructed, with independent variables 1, 2, 3, ... (tick numbers). The slope s is fitted using a RANSAC Regressor (with a residual threshold of 1.0), and this slope is the mainstream tick distance d_ransac (floating-point value) for that distance sequence. The RANSAC algorithm is robust to a small number of outliers and can accurately identify the mainstream distance.
[0143] Global KDE Validation: All filtered distance sequences are merged into a large array all_distances. Gaussian kernel density estimation (KDE) is used to perform global probability density analysis on all distances with a bandwidth of 0.5. 1000 points are sampled to find the optimal global scale distance global_peak (floating-point value) corresponding to the main peak, and global_peak is the scale ratio. In this embodiment, global_peak=12.05, that is, 12.05 pixels within 1mm, which means 1 pixel corresponds to 0.08mm.
[0144] Filtering continuous valid scale points: Filter continuous scale points from target_edges, requiring that the distance between each adjacent scale point is within the range of (optimal global scale distance + 1, optimal global scale distance - 1) [global_peak_int - 1, global_peak_int + 1] (allowing a 1-pixel error), denoted as valid_vis_edges. The length of valid_vis_edges must be ≥ 8 (at least 8 consecutive valid scale points). Simultaneously, the optimal global scale distance global_peak for all valid sampling rows in step S3.2 is obtained through Gaussian kernel density estimation (KDE). Then, the range [global_peak_int - 1, global_peak_int + 1] is used as the global scale distance error range for the medical measuring ruler. Specifically, substituting global_peak of 12.05 into the above range and rounding it down yields [11, 13], which is the global scale distance error range for the medical measuring ruler.
[0145] Example 3
[0146] An application of a wound size measurement method based on a medical measuring ruler, specifically taking pressure ulcers as an example, such as... Figures 14 to 18 The data format of the JSON file sent from the backend processing unit to the frontend interaction unit: { "fileId": "jkdslajalc71415", # File ID, passed in when calling the API. "result": "All recognitions were successful", #status description "status": 2, #Execution status 0 indicates recognition failure, 1 indicates only wound recognition and segmentation were successful, 2 indicates both measuring ruler and wound recognition were successful. "msg": [ "One wound target successfully detected" "Segmentation and preprocessing of measuring scale successful" "Recognition successful" ], # Log for each stage "wounds": [ # contains information about all wounds] { "vertex":[x1,y1,x2,y2,x3,y3,x4,y4], #The four vertices of the circumscribed rectangle "size": [w,h],#Length and width of the bounding rectangle "concls": [ #Recognition results] { "name": "exp_name", #Model Name "details": [ #Model Results] { "clzid": 1, #Classification number "clz": "classify", #Category Name "conf": 0.908797562122345, #confidence level "pixels": 56853, #wound pixel area "contour": [x1,y1,x2,y2,] #Contour coordinates } #The model results are now complete. There may be multiple wound results for one model. }, #End of wound model { "name": "tissue", # Model Name "details": [#Model Results] { "clzid": 2, #Classification number "clz": "dermis", #Category Name "conf": 0.7916428565979004, #confidence level "pixels": 26523, #wound pixel area "contour": [x1,y1,x2,y2,]#contour coordinates } #The model results have ended; there may be multiple tissue results from one model. } #End of Organizational Model } #End of wound module "ruler": { Measuring ruler scale module "lap": 13,# mm graduation mark "scale": 8.006006006, #mm pixels "start": [x,y], #Start coordinates of the tick mark "points": [x1,y1,x2,y2,…] #Tick coordinates } The measuring ruler markings have ended.
[0147] Example 4
[0148] A wound size measurement system includes a measuring ruler extraction module that receives a two-dimensional wound image with a medical measuring ruler and performs step S2 in the wound size measurement method of Embodiment 1. The scale extraction module is communicatively connected to the measuring ruler extraction module and performs step S3 in the wound size measurement method as described in Example 1. The proportion acquisition module is communicatively connected to the scale extraction module and executes step S4 in the wound size measurement method as described in Example 1. The wound size quantification module is communicatively connected to the measuring ruler extraction module and the proportion acquisition module, and executes step S5 in the wound size measurement method of Example 1.
[0149] This wound size measurement system consists of four main functional modules, each with a clearly defined function, low coupling, and simple communication logic. It incorporates core algorithms such as segmentation modeling, line segment detection, and robust fitting to automate the entire wound measurement process. This system offers the advantages of interference resistance and high accuracy in wound size measurement methods. It does not rely on expensive dedicated equipment and can be flexibly deployed in various environments such as servers and industrial control computers. This not only facilitates future functional iterations and maintenance but also significantly lowers the threshold for clinical deployment, making it suitable for various wound measurement scenarios in hospitals, communities, and homes.
[0150] Example 5
[0151] A wound size measuring device, comprising: The front-end interaction unit is used to acquire two-dimensional wound images with medical measuring rulers, convert them into base64 encoded format, and send them to the back-end processing unit. Simultaneously, it receives and displays the measurement results returned by the back-end processing unit, such as... Figure 18 ; The backend processing unit integrates the wound size measurement system of Embodiment 4; receives the base64 format image sent by the frontend interaction unit and decodes it to restore it into a two-dimensional wound image; executes steps S2-S5 in the wound size measurement method of Embodiment 1; encapsulates the data into structured JSON format data and sends it back to the frontend interaction unit. The data storage unit is connected to the front-end interaction unit and the back-end processing unit respectively, and is used to store the original two-dimensional wound image, measurement process parameters and wound measurement results.
[0152] In the front-end interaction unit, strict visual validation is performed for display purposes. Filter candidate rows: From the sampled rows that have passed the pre-validation, extract those rows that satisfy d_ransac_int==global_peak_int (equal integer spacing) as candidate rows.
[0153] Selecting the target row: If candidate rows exist, select the row with the largest number of valid transition pairs from the candidate rows, denoted as target_row (target sampling row), and its left edge group is denoted as target_edges.
[0154] Visualization: If the length of `valid_vis_edges` meets the condition, draw lines connecting these tick points on the final returned image: the tick line height is 80% of the image height. The color is green. The line thickness is 2 pixels. Record `binary_img` (the preprocessed binary image) for visualization, such as... Figure 19 .
[0155] Failure determination: If the length of valid_vis_edges is less than 8, or there are no candidate rows, an error message "processing error or shooting problem" will be appended to the returned result.
[0156] Result Assembly: Construct a scale recognition result dictionary `result_data` based on the verification results, containing: success (success indicator): True if successful, False if unsuccessful.
[0157] message (list of prompt messages): contains "successful recognition" or error messages.
[0158] scale_length (scale length): The estimated scale length L_scale.
[0159] scale_spacing (scale spacing): global scale spacing global_peak (floating-point value).
[0160] scale_points (list of scale point coordinates): a list of [(x1, target_row), (x2, target_row), ...].
[0161] The output of the backend processing unit is a scale recognition result dictionary, result_data, which includes a success identifier, a list of messages, scale_length, scale_spacing, scale_points, and a binary image, binary_img.
[0162] In the front-end interactive unit, inverse coordinate transformation is also required. The goal of inverse coordinate transformation is to convert the coordinates of the scale points obtained by scale recognition from the processed measuring ruler image (after rotation and cropping) back to the absolute coordinates in the original image so that they can be displayed in the same coordinate system as the wound segmentation results.
[0163] Execution logic: Receive parameters: Receive the list of scale point coordinates (scale_points, from the target_row row of the cropped measuring ruler image) and the transformation parameter trans_params.
[0164] Point transformation process: Perform the following inverse transformation steps for each tick point (x, y): Step 1: Transform from the cropped image coordinates to the rotated image coordinates. Add the top-left corner offset of the cropped area to the cropped image coordinates to obtain the coordinates (x+crop_x, y+crop_y) in the rotated image.
[0165] Step 2: Transform from the coordinates of the rotated image to the coordinates of the original image. Construct the homogeneous form (3×3) of the rotation matrix, calculate the inverse matrix M_inv of the rotation matrix, and use the homogeneous coordinate transformation formula (x'=M_inv×[x,y,1]^T) to obtain the homogeneous coordinates of the transformed point in the original image.
[0166] Step 3: Take the first two columns (x and y) of the homogeneous coordinates after the inverse transformation and convert them into integer coordinates.
[0167] Error handling: If an exception occurs during the inverse transformation (such as matrix singularity), the error message is recorded in final_msg.
[0168] Output: A list of converted tick point coordinates (in the original coordinate system), and a list of final_msg errors.
[0169] The data storage unit assembly and output operation aims to assemble the results of all modules, such as wound segmentation, Exp1 tissue subdivision, and measuring ruler measurement, into a unified JSON format, including the classification mapping, numerical results, and visualization information required by the front end, and generate a visualization image to save the results.
[0170] Execution logic: Final JSON structure construction: Create a complete JSON structure containing fileId (input identifier), result (result description string), status (status code), msg (message list), wounds (wound list), and ruler (measuring ruler data).
[0171] Coordinate mapping transformation: Define the WOUND_CLASS_MAP dictionary to map the class_id (0-5) output by the backend model to the classification information (clzid and clz) required by the frontend. Class_id=0 corresponds to {clzid:4,clz:"deep tissue injury"}, 1 corresponds to {clzid:5,clz:"unstageable"}, 2 corresponds to {clzid:0,clz:"stage 1"}, 3 corresponds to {clzid:1,clz:"stage 2"}, 4 corresponds to {clzid:2,clz:"stage 3"}, and 5 corresponds to {clzid:3,clz:"stage 4"}.
[0172] Assembly of the wounds list: Iterating through each wound in the wound segmentation results: Extract the four vertices (box_pts) and dimensions (width, height) of the minimum bounding rectangle directly from the bbox.
[0173] For each wound, construct the Exp0 classification information exp0_detail: including class_id, class_name (backend), clz (frontend segmentation), clzid (frontend classification ID), conf (confidence), mask_pixel_count (pixel area), and contour (simplified contour, flattened into one dimension).
[0174] If the wound has an Exp1 result, iterate through its details list and construct the Exp1 classification information exp1_details_list: each entry contains class_id, class_name, conf, mask_pixel_count, and contour (flattened).
[0175] Construct a list of concls expert categories, containing two experts: class (Exp0) and tissue (Exp1).
[0176] Combine exp0_detail and exp1_details_list into concls.details.
[0177] Assemble the complete data for this injury: vertex (vertex flattening), size (dimensions), concls (expert classification list).
[0178] The ruler part is assembled as follows: Extract scale_length, scale_spacing, and scale_points data from ruler_data. Call the flatten_contour function on the scale_points list to flatten the two-dimensional coordinates [(x1,y1),(x2,y2),...] into one-dimensional [x1,y1,x2,y2,...]. Set start to the first two points in the list. Put the flattened list of points into the points field of ruler_json to build the complete ruler data structure.
[0179] Top-level JSON assembly: Assemble the fileId, result (status description string), status (0 wound failure, 1 wound success only, 2 both recognized successfully), msg (message list), wounds list, and rule data into a top-level JSON object.
[0180] NumPy type conversion: The `convert_numpy_types` function is called to recursively traverse the entire JSON object, converting all NumPy integers to Python int, all NumPy floating-point numbers to Python float, and all NumPy arrays to Python list or tuple, ensuring JSON serialization compatibility.
[0181] JSON saving: Check if save_json is True in the configuration. If it is True, create a JSON file named fileId in the configured json_save_dir directory, write the converted top-level JSON to the file, and record the save path log.
[0182] Image visualization rendering: Check if `save_img` is True in the configuration. If True, create an image save directory named after `fileId` and re-read the original image `img`. Draw the wound contour using green (0,255,0) with a line width of 3 pixels. Draw the minimum bounding rectangle vertices (8 points) of the wound using purple (255,0,255), with a dot radius of 5 pixels and filled with solid color. For each wound, loop through the Exp1 results, using `color_exp1_palette` to draw the corresponding contour (blue 255,0,0, cyan 0,255,255, orange 255,165,0), and fill the semi-transparent (weight 0.2) colored area using `cv2.fillPoly`, then overlay it onto the original image.
[0183] Draw the scale points of the measuring ruler on the original image using red (0,0,255), with a dot radius of 5 pixels and a solid fill.
[0184] Use cv2.imwrite to save annotated_result.jpg to the image directory.
[0185] If binary_ruler_img (a preprocessed binary image for scale recognition) is provided, save binary_ruler.jpg to the image directory.
[0186] Result returned: The final top-level JSON object is returned to the front end via an HTTP response with status code 200 (OK); before returning, temporary files are deleted (if they exist).
[0187] Exception handling: For received HTTPException (404, 400) and general exception, catch the exception and log it, delete the temporary file, and throw the corresponding exception; for general exception (500), record the stack information, delete the temporary file, and return the internal error information.
[0188] Output: Final JSON result file and visualization image file. The front end obtains the results via HTTP response.
[0189] This wound size measurement device includes a front-end interaction unit, a back-end processing unit, and a data storage unit, integrating image acquisition, algorithm calculation, result display, and data archiving functions. Based on a standardized data format, the device achieves stable transmission and visual output, providing intuitive and clear measurement results. It also possesses complete medical data retention capabilities, supporting wound healing tracking and medical record tracing. The entire measurement process utilizes a non-contact method to avoid the risk of cross-infection, and it features low hardware cost and flexible deployment.
[0190] Example 6
[0191] A computer-readable storage medium having a computer program stored thereon, which, when executed on a computer, causes the computer to perform a wound size measurement method as described in Example 1.
[0192] The computer-readable storage medium contains the wound size measurement program, which can be directly loaded and run on various compatible computers and embedded devices. It has offline running capability and program portability, which facilitates batch distribution of programs, device migration and field deployment. As the program carrier of the whole technical solution, its form is universal and easy to use. It not only ensures the integrity and consistency of the algorithm program, but also provides basic support for the application of the measurement method and system on different terminals.
[0193] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the scope of protection of the present invention. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the essence and scope of the technical solutions of the present invention.
Claims
1. A method for measuring wound dimensions based on a medical measuring ruler, characterized in that: Includes the following steps; S1. Obtain a two-dimensional wound image with a medical measuring ruler; S2. The medical measurement ruler scale region and wound region in the two-dimensional wound image of step S1 are segmented by the trained segmentation model to obtain the scale mask and wound mask respectively; then the scale mask is aligned and morphologically processed to obtain a binary scale image. S3. Identify the scale lines in the binary scale image from step S2, remove extraneous lines, and obtain the scale ratio of the medical measuring ruler. S4. Map the scale ratio from step S3 to the nominal scale physical length of the medical measuring ruler to obtain the mapping scale of the medical measuring ruler. S5. Based on the mapping scale in step S4 and the wound area mask in step S2, the actual physical length, width and area of the wound are obtained, and the wound measurement results are finally obtained.
2. The wound size measurement method based on a medical measuring ruler according to claim 1, characterized in that, Step S2 specifically includes the following sub-steps: S2.
1. The scale region of the medical measuring ruler in the two-dimensional wound image of step S1 is segmented by the trained measuring ruler segmentation model to obtain the scale mask; the wound region in the two-dimensional wound image of step S1 is segmented by the trained wound segmentation model to obtain the wound mask. S2.2 Calculate the minimum bounding rectangle of the scale mask in step S2.1, and then perform tilt angle detection and affine correction on the two-dimensional wound image of S1 and the minimum bounding rectangle to obtain a positive measurement ruler mask with the rectangular area aligned vertically and rotated horizontally; at the same time, calculate the minimum bounding rectangle of the wound mask in step S2.1 to obtain the length and width coordinates of the wound mask. S2.
3. Perform morphological processing on the positive positioning measurement scale mask from step S2.2 to obtain a binary scale image; Step S3 specifically includes the following sub-steps: S3.1 Detect the scale line segments in the binary scale image of step S2, and then filter and process the scale line segments to obtain the processed scale line segments; S3.
2. Perform vertical projection on each processed scale line segment in step S3.1 to obtain a vertical projection curve; then lock the core region of interest (ROI) where the scale lines are distributed in the vertical projection curve; select three uniform sampling rows in four equal divisions within the core ROI, perform fast grayscale transition detection on each sampling row, count the number of valid transition pairs in each sampling row, and delete sampling rows with fewer than the threshold number of valid transition pairs to obtain valid sampling rows; S3.3 Extract the scale edges for each valid sampling line obtained in step S3.2, and then force pairing of the scale lines; then generate the spacing sequence of the forced pairing scales for each valid sampling line, filter outliers from the spacing sequence, and obtain the filtered group spacing sequence for each valid sampling line. S3.4 Calculate the mainstream spacing of the group spacing sequence after filtering each effective sampling line in step S3.2 using the random sampling consensus algorithm; at the same time, obtain the optimal global scale spacing of all effective sampling lines in step S3.2 by Gaussian kernel density estimation, and the optimal global scale spacing is the scale ratio; then take the range of 1 pixel above and below the optimal global scale spacing as the global scale spacing error range of the medical measuring ruler. Step S5 specifically includes: obtaining the actual physical length, width and area of the wound based on the mapping scale in step S4, the wound area mask in step S2 and the length and width coordinates of the wound mask, and finally obtaining the wound measurement result.
3. The wound size measurement method based on a medical measuring ruler according to claim 2, characterized in that, Step S3.1 includes the following sub-steps: S3.1.
1. Taking the upper left corner of the binary scale image as the origin, the horizontal direction of the scale bar of the medical measuring ruler is defined as the X-axis, and the direction of the scale line is defined as the Y-axis. S3.1.2 Detect the scale line segments in the binary scale image of step S2 using the LSD line segment detector, and then retain only the line segments that simultaneously meet the angle condition, length condition, and horizontal offset condition; then calculate the normalized center x coordinate, upper boundary, and lower boundary for the sub-pixel line segments, and convert the line segments into vertical integer coordinate line segments. S3.1.3 Merge line segments that meet the merging conditions, then take the average of the X coordinates within the cluster and the union of the Y range to obtain the processed scale line segments.
4. The wound size measurement method based on a medical measuring ruler according to claim 3, characterized in that, Step S3.2 includes the following sub-steps: S3.2.
1. Initialize the zero array of height h for each processed scale line segment in step S3.1, then traverse each processed scale line segment, and perform vertical projection on each row to obtain the vertical projection curve. S3.2.2 Statistically calculate the effective length of all processed scale segments, estimate the probability density of the effective length using Gaussian kernel density estimation, and find the optimal scale length L of the segment corresponding to the main peak. S3.2.3 Find the peak position of the vertical projection curve obtained in step S3.2.1, and then expand δ*L above and below the peak position, with 0.5 < δ < 1, to obtain the core region of interest (ROI). S3.2.
4. Select three uniform sampling rows in four equal divisions within the core region of interest (ROI); S3.2.
5. Traverse the row pixels in each sampling row and record the transition point L_x from black to white; continue traversing to find the subsequent transition point R_x from white to black; then calculate the scale width w, and only those 3≤w≤30 are considered valid scales; S3.2.6 Count the number of valid tick marks in each sampling row to obtain the number of valid transition pairs in each sampling row; S3.2.7 Delete the sampling rows where the number of valid transition pairs is less than or equal to the transition pair threshold to obtain valid sampling rows.
5. The wound size measurement method based on a medical measuring ruler according to claim 4, characterized in that, Step S3.3 includes the following sub-steps: S3.3.
1. Extract the scale edge for each valid sampling row obtained in step S3.
2. Traverse the row pixels of each valid sampling row, define all pixel grayscale jump points from 0 to 255 as the left edge, and define all pixel grayscale jump points from 255 to 0 as the right edge. S3.3.
2. Sort all transition points in ascending order of x-coordinate. For each left edge transition point, find the first right edge transition point. If the distance between the two is within the range of 3 to 30 pixels, pair them as a scale and record the left edge coordinate L_i and the right edge coordinate R_i. Sort by L_i coordinate to obtain the effective scale left edge group and effective scale right edge group of the corresponding effective sampling row. S3.3.3 Calculate the x-spacing between adjacent scales in the left and right edge groups of each valid sampling line to obtain the left edge group spacing and the right edge group spacing. Each valid sampling line has a set of left edge group spacing and right edge group spacing, and define the left edge group spacing and right edge group spacing of the same valid sampling line as the group spacing sequence. S3.3.
4. Use the interquartile range method to remove outliers from the intergroup interval sequence corresponding to each valid sampling row in step S3.3.3 to obtain the filtered intergroup interval sequence.
6. The wound size measurement method based on a medical measuring ruler according to claim 5, characterized in that, S3.4 is performed by the following steps: S3.4.1 Calculate the main spacing of the filtered group spacing sequence of each valid sampling line in step S3.2 using the random sampling consensus algorithm; at the same time, merge the filtered group spacing sequences of each valid sampling line in step S3.2 into a large array, and then use Gaussian kernel density estimation to perform global probability density analysis on the large array to obtain the optimal global scale spacing corresponding to the main peak. S3.4.
2. The range of ±1 pixel of the optimal global scale spacing is taken as the global scale spacing error range of the medical measuring ruler; at the same time, the effective sampling rows whose mainstream spacing is not within the global scale spacing error range are deleted, and only the effective sampling rows whose mainstream spacing is within the global scale spacing error range are retained.
7. The wound size measurement method based on a medical measuring ruler according to claim 6, characterized in that: The measurement ruler segmentation model is selected from any one of YOLOv11s-seg, Mask R-CNN, and SOLOv2; the measurement ruler segmentation model is trained using a measurement ruler dataset; The wound segmentation model is selected from any one of YOLOv11s-seg, Mask R-CNN, and SOLOv2; the wound segmentation model is trained using a wound dataset. The morphological processing includes at least one of grayscale conversion, CLAHE enhancement, Gaussian blurring, black hat operation, closing operation, OTSU thresholding, and median filtering. The threshold for the transition pair is 5; The angle condition is 85°~95°; The length condition is greater than or equal to 5 pixels; The horizontal offset condition is that the difference in the horizontal coordinates is less than or equal to 1 pixel; The merging condition is that the difference in the X coordinate is less than 1 pixel, and there is overlap in the Y-axis range with an overlap of less than 1 pixel. The wound measurement results also include wound soft tissue identification results, which are identified by a trained wound soft tissue identification model. The wound soft tissue recognition model is selected from any one of YOLOv11s-seg, Mask R-CNN, and SOLOv2; the wound soft tissue recognition model is trained using a wound soft tissue dataset; During the acquisition of the two-dimensional wound image, the medical measuring ruler is at the same horizontal plane as the wound.
8. A wound size measurement system, characterized in that, include: The measuring ruler extraction module receives a two-dimensional wound image with a medical measuring ruler and performs step S2 in the wound size measurement method as described in any one of claims 1-7; The scale extraction module is communicatively connected to the measuring ruler extraction module and performs step S3 in the wound size measurement method as described in any one of claims 1-7; The proportion acquisition module is communicatively connected to the scale extraction module and executes step S4 in the wound size measurement method as described in any one of claims 1-7; The wound size quantification module is communicatively connected to the measuring ruler extraction module and the proportion acquisition module, and executes step S5 in the wound size measurement method as described in any one of claims 1-7.
9. A wound size measuring device, characterized in that, include: The front-end interaction unit is used to acquire two-dimensional wound images with medical measuring rulers, convert them into base64 encoded format and send them to the back-end processing unit, and at the same time receive and display the measurement results returned by the back-end processing unit. The backend processing unit integrates the wound size measurement system of claim 8; receives the base64 format image sent by the frontend interaction unit and decodes it to restore it into a two-dimensional wound image; executes steps S2-S5 in the wound size measurement method of any one of claims 1-7; encapsulates the data into structured JSON format data and sends it back to the frontend interaction unit; The data storage unit is communicatively connected to the front-end interaction unit and the back-end processing unit, respectively, and is used to store the original two-dimensional wound image, measurement process parameters, and wound measurement results.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed on a computer, it causes the computer to perform the wound size measurement method as described in any one of claims 1-7.
