Pupil segmentation method in vision diopter detection based on YOLOv11 improvement

By combining the improved YOLOv11 segmentation method with dual thresholding and Gaussian cognitive uncertainty function, the problems of robustness and fine-tuning in pupil image processing are solved, and high-precision pupil segmentation and refractive power detection are achieved.

CN121904088APending Publication Date: 2026-04-21SHANGHAI NORMAL UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHANGHAI NORMAL UNIVERSITY
Filing Date
2025-12-11
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Existing pupil image processing techniques lack robustness in segmentation under complex lighting and eye occlusion scenarios, have poor target focusing and adaptability, and lack fine-grained processing, which limits the accuracy and practicality of off-center photogrammetry diopter detection methods.

Method used

An improved segmentation method based on YOLOv11 is adopted, which combines dual-threshold segmentation and Gaussian cognitive uncertainty function. Through C2PSA attention mechanism and anchor-free localization mechanism, accurate pupil segmentation and boundary uncertainty assessment are achieved.

Benefits of technology

It improves the robustness and accuracy of pupil segmentation, reduces background noise interference, enhances the model's ability to capture subtle changes in pupil morphology, and improves the accuracy and reliability of refractive power detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121904088A_ABST
    Figure CN121904088A_ABST
Patent Text Reader

Abstract

The invention relates to a pupil segmentation method in vision diopter detection based on YOLOv11 improvement. The method comprises the following steps: firstly, acquiring an eye infrared image, processing the preprocessed image by using a segmentation model improved based on YOLOv11, and outputting an instance mask image with a pupil target frame; based on the mask image, a pupil area image with a fixed size is extracted, and then a binary mask image is generated through double-threshold segmentation. According to the method, a Gaussian cognitive uncertainty function is constructed, a pupil boundary uncertainty thermodynamic diagram is generated based on a binary mask diagram, finally, the binary mask diagram and the thermodynamic diagram are output at the same time, and high-precision pupil segmentation capable of evaluating boundary uncertainty is completed. End-to-end processing from infrared image to pupil segmentation and boundary reliability visualization is realized in the whole process. Compared with the prior art, the method has the advantages that the robustness under complex illumination is enhanced, the pupil segmentation precision is improved, and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of pupil image processing technology, and in particular to a pupil segmentation method for visual acuity refractive error detection based on YOLOv11. Background Technology

[0002] The prevalence of refractive errors is rising globally, and myopia among adolescents has become a key focus of public health. The need for low-cost, large-scale, and efficient vision screening in primary healthcare institutions and schools is becoming increasingly urgent.

[0003] Traditional refractive error measurement relies on specialized optometry equipment. While it can accurately measure refractive status, the equipment is expensive, bulky, and difficult to carry. It also requires specialized personnel to operate and is time-consuming per test, making it unsuitable for scenarios with limited primary healthcare resources and failing to meet the high-efficiency requirements of screening students in schools. Against this backdrop, eccentric radiographic refractive error measurement, with its advantages of non-contact operation, miniaturized equipment, and fast testing speed, has become a core alternative for low-cost vision screening. Its principle involves using an infrared light source to illuminate the eyeball, forming a light spot. After capturing an image of the eye, the relative offset between the pupil center and the light spot is analyzed to establish a correlation model between the offset and refractive error, enabling rapid estimation of refractive status.

[0004] However, the performance of eccentric photography methods is highly dependent on the accurate processing of pupil images, and current pupil image processing technology still has many key shortcomings: First, the segmentation algorithm lacks robustness. Traditional methods such as single threshold segmentation and simple edge detection cannot adapt to complex lighting conditions (such as pupil reflection under strong light and blurred boundaries under low light) and eye occlusion (eyelash coverage, partial eyelid occlusion). They are prone to misidentifying corneal reflections as pupil areas or eyelash shadows as pupil defects, resulting in incomplete pupil morphology and boundaries that deviate from the true physiological structure. Second, the model has poor focusing and adaptability to the target. Existing deep learning segmentation models lack targeted feature attention mechanisms, making it difficult to distinguish the pupil from background noise such as eyelid texture and eyelashes, and resulting in weak ability to capture spatial details of the pupil. Furthermore, traditional anchor-frame object detection mechanisms require preset fixed parameters, while the pupil is a non-rigid target (its size / shape fluctuates significantly under varying lighting and physiological conditions). The fixed size of the anchor frame cannot adapt to its dynamic changes, easily leading to positioning errors. Thirdly, there is a lack of refined processing and error control. Existing processes often use direct segmentation of the entire image without local focusing optimization of the pupil region. Irrelevant backgrounds such as the skin around the eye in infrared images easily interfere with the segmentation results, even misidentifying circular background textures as pupils. Moreover, traditional binary hard segmentation ignores the gradual light transition characteristics of the pupil-iris transition zone, rigidly classifying edge pixels, causing pixel-level errors.

[0005] In summary, current pupil image processing technology suffers from problems such as insufficient segmentation robustness, poor target focusing and adaptability, lack of refined processing, and lack of uncertainty assessment, which restrict the accuracy and practicality of off-center photogrammetry diopter detection methods. Summary of the Invention

[0006] The purpose of this invention is to overcome the shortcomings of the existing technology and provide a pupil segmentation method for visual acuity refractive power detection based on YOLOv11.

[0007] The objective of this invention can be achieved through the following technical solutions: According to one aspect of the present invention, a pupil segmentation method for visual acuity refractive power detection based on YOLOv11 is provided, the method comprising the following steps: S1. Obtain an infrared image of the eye with a pupil image; S2. Build a segmentation model based on YOLOv11, and input the preprocessed infrared image of the eye into the segmentation model to output an instance mask image with the pupil target box. S3. Based on the instance mask image, extract the image of the fixed-size region containing the pupil; S4. Perform double threshold segmentation on the image of a fixed-size region to generate a binary mask image; S5. Construct a Gaussian cognitive uncertainty function, and use this function to generate a corresponding pupil boundary uncertainty heatmap based on a binary mask image. S6. Output a binary mask image and a heatmap of pupil boundary uncertainty to complete pupil segmentation.

[0008] As a preferred technical solution, the infrared image of the eye with pupil image in S1 is derived from the infrared image during the refractive error detection process, and the resolution is uniformly 720x380.

[0009] By uniformly limiting the input image resolution to 720x380, sufficient pixel detail in the pupil region of the infrared image is ensured, avoiding feature loss due to excessively low resolution, while also preventing unnecessary computational burden caused by excessively high resolution. This specific resolution setting achieves an optimal balance between detection accuracy and computational efficiency, facilitating smooth operation on embedded or mobile vision testing devices.

[0010] As a preferred technical solution, the preprocessing in S2 includes size trimming and center alignment operations, wherein the size trimming strategy is to round down to an integer multiple of 32.

[0011] By employing a size cropping strategy that rounds down to multiples of 32, the model perfectly matches the downsampling characteristics of YOLO series network models (typically with a maximum stride of 32). This process avoids the extra padding or forced scaling required during the forward propagation of the convolutional neural network due to size mismatch, thereby eliminating the risk of image edge distortion or the introduction of invalid information, ensuring the purity of feature extraction and the inference speed of the model.

[0012] As a preferred technical solution, the segmentation model based on YOLOv11 improvement built in S2 includes: YOLOv11 integrates the C2PSA attention mechanism with mask prototype generation, and the segmentation head adopts an improved Mask structure; The improved segmentation model consists of a backbone feature extraction network, a feature fusion structure, and a multi-task output head, wherein the multi-task output head includes a segmentation branch and a detection box branch. The C2PSA attention mechanism is integrated by introducing it into the backbone feature extraction network, specifically by integrating the channel attention module and the spatial attention module to enhance the representation ability of pupil features. The fusion method for mask prototype generation is as follows: the segmentation branch is built with the prototype network and the mask generation module as the core to achieve the following process: first, a set of mask prototype feature maps are extracted through the prototype network, and then the prototype feature maps are weighted and fused with the detection box weights output by the model to finally generate an instance mask map corresponding to each pupil target; the instance mask map is a grayscale image, and its pixel value is used to represent the predicted probability that the corresponding pixel belongs to the pupil region.

[0013] As a preferred technical solution, the detection box branch is used to predict the spatial location information of the pupil target, the spatial location information including the target center point coordinates, width, height and the target presence confidence; This branch employs an anchor-free localization mechanism, which achieves precise localization of the pupil target by regressing the offset of each predicted point relative to its location in the feature map.

[0014] As a preferred technical solution, the specific process of extracting the image containing a fixed-size region of the pupil in S3 includes: Based on the pupil target bounding box in the instance mask image, obtain the center coordinates of the pupil target; On the original infrared image, using the center coordinates as a reference, an image of a fixed-size region is cropped.

[0015] As a preferred technical solution, the fixed size in S3 is specifically 60×60 pixels.

[0016] As a preferred technical solution, the dual threshold segmentation process in S4 specifically includes: A first threshold and a second threshold are set. The first threshold is used to suppress bright noise caused by corneal reflection, and the second threshold is used to eliminate dark noise caused by eyelid edge shadows. Both the first and second thresholds are preset grayscale values. Image operations on a fixed-size region based on the first and second thresholds include: Regions with grayscale values ​​greater than or equal to the first threshold are identified as reflective bright regions and are removed. Regions with gray values ​​less than or equal to the second threshold are identified as background or shadow regions and are removed. Regions with gray values ​​less than the first threshold and greater than the second threshold are identified as valid pupil regions and are preserved.

[0017] As a preferred technical solution, the Gaussian cognitive uncertainty function in S5 uses the distance from each pixel in the binarized mask image to the pupil boundary as a variable. The closer the region is to the boundary, the higher the uncertainty score is assigned, thus forming a spatial distribution uncertainty heatmap; the specific expression of the Gaussian cognitive uncertainty function is: ; in, Score the uncertainty; For pixels ( x , y The distance from the pupillary margin to the pupillary border; x , y ) represents the pixel coordinate, and σ is the width of the preset control uncertainty area; This is the preset distance reference value.

[0018] As a preferred technical solution, the uncertainty heatmap in S5 is encoded using a pseudo-color method. The brighter the color, the higher the uncertainty of the model's boundary prediction, which is used to assist in subsequent pupil boundary assessment and refractive error diagnosis.

[0019] According to another aspect of the present invention, a pupil segmentation system for visual acuity refractive power detection based on YOLOv11 is provided, the system comprising: Specifically, it includes: The image acquisition module is used to acquire or import infrared images of the eye that include pupil images.

[0020] The image acquisition module includes: The hardware interface unit supports communication with peripherals such as infrared fundus cameras and eye imaging devices, and receives real-time acquired infrared images of the eye. The image storage unit is used to standardize the format of the acquired infrared images (such as unifying them to JPG / PNG format and performing initial resolution calibration) and temporarily store them on local or cloud storage media for later retrieval.

[0021] The YOLOv11 improved segmentation model module is used to complete image preprocessing and instance mask output.

[0022] The YOLOv11 improved segmentation model module includes: The image preprocessing unit performs operations such as normalization, size scaling, noise reduction, and color gamut calibration on the input eye infrared image to adapt to the input requirements of the YOLOv11 model. Improved YOLOv11 segmentation model unit: Based on the native YOLOv11 detection-segmentation architecture, it is optimized for the characteristics of small pupil targets (such as enhancing the neck feature fusion module, adjusting the anchor box size, and introducing an attention mechanism). After loading the pre-trained weights, it performs inference on the pre-processed image and outputs the initial segmentation result containing the pupil target box coordinates and the instance mask image. The result storage unit is used to cache instance mask images and target bounding box information for subsequent modules to call.

[0023] The pupil region extraction module is used to extract a fixed-size pupil region image from the instance mask image.

[0024] The pupil region extraction module includes: The target bounding box localization unit is used to parse the coordinates of the pupil target bounding box in the instance mask image and determine the center position of the pupil. The fixed-size cropping unit uses the center of the pupil as a reference and crops the image to a region containing only the pupil according to a preset size (such as 64×64 or 128×128 pixels), ensuring that the region size is uniform and eliminating the impact of the overall image size difference on subsequent processing. The cropping result output unit transmits the fixed-size pupil region image to the next level module.

[0025] The dual threshold segmentation module is used to perform binarization processing on images of fixed-size pupil regions.

[0026] The dual threshold segmentation processing module includes: The threshold calculation unit adaptively calculates the dual thresholds based on the gray-scale distribution characteristics of the pupil region image. The binarization processing unit classifies image pixels according to two thresholds, sets the pupil region pixels as the foreground and the background region pixels as the background, and generates a binarized mask image.

[0027] The uncertainty heatmap generation module is used to construct and apply a Gaussian cognitive uncertainty function to generate a pupil boundary uncertainty heatmap.

[0028] The uncertainty heatmap generation module includes: Function building unit, used to define Gaussian cognitive uncertainty function and determine function parameters; The heatmap calculation unit calculates the uncertainty value of each pixel by substituting the pupil boundary pixel coordinates of the binary mask image into a Gaussian cognitive uncertainty function. The heatmap visualization unit maps uncertainty values ​​to heatmap colors, generating a heatmap of pupil boundary uncertainty.

[0029] The results output module is used to integrate and output the final segmentation results.

[0030] Compared with the prior art, the present invention has the following beneficial effects: 1. This invention achieves a leap from coarse localization to fine segmentation by combining an improved YOLOv11 deep learning model with dual-threshold segmentation and uncertainty analysis. Compared to traditional single algorithms, this method is more robust under complex lighting conditions; compared to single deep learning segmentation, this method, combined with post-processing steps, improves pixel-level accuracy of pupil edges. Simultaneously, the introduction of a Gaussian cognitive uncertainty function quantifies the degree of blurring at the pupil boundary, providing a reliable reference for subsequent refractive error detection, thereby significantly improving the detection accuracy and reliability of the vision screening system.

[0031] 2. In this invention, by integrating the C2PSA (Channel and Spatial Attention) mechanism into the backbone network, the model can adaptively focus on the key feature region of the pupil, effectively improving the model's selective attention to spatial details and suppressing interference from background noise such as eyelashes and eyelid textures. Simultaneously, the use of a mask prototype generation branch allows the model to not only output rectangular boxes but also reconstruct high-quality instance masks based on prototype coefficients. This improvement significantly enhances the model's ability to capture subtle morphological changes in the pupil, making the segmentation results more closely resemble the true physiological shape of the pupil. The detection box branch employs an anchor-free localization mechanism, eliminating the cumbersome process of pre-setting a large number of anchors required in traditional object detection. This not only reduces the number of model parameters and computational complexity, accelerating inference speed, but also, for non-rigid targets like the pupil whose size varies significantly under different lighting conditions, the anchor-free mechanism, by directly regressing the center point offset, has stronger generalization ability and localization flexibility.

[0032] 3. In this invention, a strategy shift from full-image search to local refinement is achieved by performing secondary cropping on the center coordinates determined based on the instance mask. This step effectively removes most of the background areas unrelated to the pupil in the original infrared image, greatly narrowing the search range for subsequent image processing. This not only improves the algorithm's running speed but also prevents circular textures in the background from misleading pupil segmentation.

[0033] 4. In this invention, a dual-threshold segmentation strategy is employed to specifically address two major interference issues in ocular infrared images. The first threshold effectively removes high-brightness noise caused by corneal reflection points, while the second threshold eliminates dark area noise caused by eyelid shadows and eyelashes. Compared to a single threshold method, this interval filtering mechanism can more accurately extract the true effective pupil area, ensuring the purity of the basic data for refractive power calculation.

[0034] 5. In this invention, a distance-based Gaussian cognitive uncertainty function is constructed to solve the problem of blurred boundary definition in the transition region between the pupil and iris. Unlike traditional binary hard segmentation, this function assigns continuous probability scores to edge pixels, consistent with the physical characteristics of light gradually changing at the edge of the eyeball. By quantizing the confidence of the segmented edges, the quantization error caused by hard cutting is reduced, thereby improving the sub-pixel accuracy of refractive power calculation. Attached Figure Description

[0035] Figure 1 This is a schematic diagram of the pupil segmentation method in visual acuity refractive power detection based on YOLOv11 in this invention. Figure 2 This is a schematic diagram of the improved YOLOv11 network framework in the embodiment; Figure 3 This is a schematic diagram of the dual threshold segmentation process in the embodiment. Detailed Implementation

[0036] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0037] Currently, the mainstream method for visual acuity and refractive error testing is automatic or manual refraction using an optometry instrument. As the most widely used device in clinical practice, the optometry instrument can accurately measure the refractive state of the human eye, including myopia, hyperopia, and astigmatism, and its test results have high reliability and stability. However, traditional optometry instruments have a series of limitations, including high cost, large size, inconvenience in transportation, complex operation procedures, low testing efficiency, and the requirement for operation by professional optometrists. Therefore, they are difficult to promote in primary healthcare institutions or to achieve large-scale group vision screening.

[0038] To address the aforementioned issues, the eccentric photography method was proposed and has gradually become a rapid and convenient method for initial vision screening. This method indirectly estimates the refractive state of the eye by capturing infrared images and analyzing the positional offset of the pupil center relative to the light spot, thus achieving non-contact refractive power estimation. However, because the eccentric photography method is highly dependent on image quality and pupil localization, current practical applications still suffer from problems such as large errors in refractive power calculation and insufficient robustness in image processing.

[0039] Further research revealed that the key to improving the detection accuracy of this method lies in acquiring pupil images with clear boundaries, complete shapes, and minimal occlusion interference, and using these images as input for subsequent refractive error modeling and calculation. Therefore, high-precision pupil image segmentation technology has become a core supporting element for realizing a low-cost and high-efficiency vision screening system.

[0040] Example 1 In this embodiment, a pupil segmentation method based on YOLOv11 for refractive power detection is adopted, and the method steps are as follows: Figure 1 As shown, it specifically includes: S1. Obtain an infrared image of the eye with a pupil image; S2. Build a segmentation model based on YOLOv11, and input the preprocessed infrared image of the eye into the segmentation model to output an instance mask image with the pupil target box. S3. Based on the instance mask image, extract the image of the fixed-size region containing the pupil; S4. Perform double threshold segmentation on the image of a fixed-size region to generate a binary mask image; S5. Construct a Gaussian cognitive uncertainty function, and use this function to generate a corresponding pupil boundary uncertainty heatmap based on a binary mask image. S6. Output a binary mask image and a heatmap of pupil boundary uncertainty to complete pupil segmentation.

[0041] The eye infrared image is preprocessed and input into a segmentation model based on an improved YOLOv11. The model includes lightweight improvements and multi-scale enhancements to the YOLOv11 network structure to achieve high-precision segmentation of small pupil targets, used to extract the mask prototype features of the pupil target region. Based on the center coordinates of the target detection box output by the model, a fixed-size 60x60 pixel region containing the pupil is extracted. The extracted region is then subjected to double-threshold segmentation to generate a binary mask image, used to obtain the pupil closure contour. A Gaussian cognitive uncertainty function is then constructed based on the binary mask image to generate the corresponding pupil boundary uncertainty heatmap. Finally, the pupil segmentation image and uncertainty heatmap are output. The eye infrared image with pupil image is derived from the pupil infrared image during the refractive error detection process, with a uniform resolution of 720x380.

[0042] Image preprocessing methods include size normalization and spatial alignment operations, where the cropping strategy is to round down to multiples of 32.

[0043] In the model, the segmentation branch is used to generate grayscale mask images of the pupils. Specifically, this involves the prototype network extracting a set of prototype mask feature maps, and then weighting and fusing these prototype maps with the detection box weights output by the model to generate an instance mask image corresponding to each pupil target. The instance mask grayscale image represents the predicted probability value of each pixel belonging to the pupil region. The C2PSA attention mechanism is embedded in the backbone network of the YOLOv11 (You Only Look Once version 11) model to enhance the model's ability to extract pupil boundary features. This includes channel attention modules and spatial attention modules, which combine local and global features to improve the representation accuracy of edge regions.

[0044] The steps to extract the 60x60 pixel region containing the pupil include: Based on the pupil bounding box output by the segmentation model, obtain its center coordinates; A fixed-size image region of 60x60 pixels is cropped from the original infrared image, using this center as a reference. This image region is then used as input for subsequent double-threshold segmentation.

[0045] Dual-threshold style processing includes setting an upper threshold. and lower threshold The pixels in the 60x60 pixel region are divided into three categories based on their grayscale values: Gray value greater than the upper threshold The areas identified as reflective, high-brightness areas were removed. Gray value less than the lower threshold The regions identified as background or shadow areas are removed. Grayscale values ​​are located in ~ The region identified is retained as the effective pupil region.

[0046] A dual-threshold strategy is used to suppress reflective interference in the corneal region and image noise caused by eyelash occlusion under complex lighting conditions, thereby enhancing the continuity and closure of the pupil boundary contour.

[0047] The Gaussian uncertainty function uses the distance from each pixel in the pupil mask image to its boundary as a variable, assigning a higher uncertainty score to the region near the boundary, thus forming a spatially distributed uncertainty heatmap. The mathematical expression of the Gaussian uncertainty function is: Where (x, y) represents pixel coordinates, and σ controls the width of the uncertain region (set to σ=0.05).

[0048] The uncertainty heatmap uses a pseudo-color method for visualization. The brighter the color, the higher the uncertainty of the model's boundary prediction, which is used to assist in subsequent pupil boundary assessment and refractive error diagnosis.

[0049] This method uses an improved YOLOv11 segmentation algorithm and employs a C2PSA attention mechanism to model attention across different sub-regions of the feature map. This structure effectively improves the model's selective attention to spatial details. The model is built upon the Segment branch module in YOLOv11, and its segmentation head uses an improved Mask and Proto structure. This effectively extracts high-dimensional mask prototypes for each category of target region and dynamically combines them through mask coefficients, thereby generating pixel-level segmentation maps of the target region in a compact and efficient manner.

[0050] In this scheme, uncertainty estimation is introduced, which can effectively enhance YOLO's ability to express regions with ambiguous boundaries without modifying the main structure of YOLO.

[0051] The specific implementation process of this method is as follows: S1. Obtain an infrared image of the eye with a pupil image; Infrared images were acquired using a near-infrared camera with a light source wavelength set in the 850nm range to avoid visible light interference. The image resolution was 720×380 pixels in single-channel grayscale format. The acquired images exhibit strong pupil contrast, which is beneficial for subsequent recognition and segmentation processing.

[0052] S2. Build a segmentation model based on YOLOv11, and input the preprocessed infrared image of the eye into the segmentation model to output an instance mask image with the pupil target box. The infrared image of the eye is preprocessed and input into a segmentation model based on YOLOv11. The model includes a segment branch and a C2PSA attention mechanism to extract the mask prototype features of the pupil target region. The preprocessing method involves cropping and center-aligning the image using a normalization preprocessing module to ensure that the pupil region is approximately centered in the image. The resizing principle is to round down by 32 pixels, so that the input image can be adapted to the multi-scale feature extraction structure of YOLOv11.

[0053] like Figure 2 As shown, the preprocessed image is input into the improved YOLOv11 model. This model consists of a backbone network, a feature fusion structure (Neck), and a multi-task output head (Head). Specifically: Backbone is used for image feature extraction. It adopts the improved module C3K2 based on YOLOv8. Its structure is composed of small-sized convolutional kernels (3×3) and the Bottleneck module, which significantly reduces the number of model parameters while maintaining the feature representation ability. The Neck section adopts a feature pyramid structure to support multi-scale feature fusion; The Head section includes three branches: the Segment branch, the Box detection branch, and an optional Classification branch.

[0054] Furthermore, the Backbone introduces a C2PSA (Cross-Partial Spatial Attention) mechanism. This module integrates two Partial Spatial Attention mechanisms, which can apply differentiated spatial attention weights to different sub-regions of the feature map, thereby enhancing the model's ability to recognize edge details and blurred regions.

[0055] The segmentation head is built around an improved prototypical network (ProtoNet) and a mask generation module. The prototypical network generates a set of highly discriminative base masks, capable of extracting stable mask features without significantly increasing the parameter size. The mask module fuses the generated prototypical features with the bounding box location information to obtain a pixel-level mask for each target region. This mask is not directly used as the final region; a dual-threshold strategy is still required.

[0056] Furthermore, the segmentation branch is trained using a joint loss function, where the segmentation loss function (seg_loss) uses the binary cross entropy (BCE) mathematical expression as follows: ; in, This represents the number of positive samples, i.e., the number of matched targets. This represents the ROI region corresponding to the k-th positive sample. This represents the total number of pixels in the ROI region. This represents the probability that the model predicts the p-th pixel to be a foreground object. This represents the true label corresponding to the p-th pixel, where 1 represents the foreground and 0 represents the background.

[0057] Furthermore, the bounding box head is used to predict the spatial location information of the pupil target, including the target center point (x, y), width w, height h, and objectness score. The bounding box output by this branch is used for subsequent pupil region cropping and mask image localization.

[0058] This branch employs an anchor-free localization mechanism, regressing the offset of each predicted point relative to its feature map position. To improve localization accuracy and address the challenge of predicting pupils in small targets, the detection box branch uses Distributed Focal Loss (DFL) and Box Loss during training. The mathematical expression for the Distributed Focal Loss (DFL) is as follows: ; in, Predict the probability for the target class. This is the scaling factor. These are the balance factor and the focusing parameter.

[0059] The bounding box loss measures the positional deviation between the predicted and ground truth bounding boxes. Based on the WIoU v3 dynamic weighting mechanism, it improves the model's ability to fit high-quality targets by introducing a penalty term and a focusing factor, thereby enhancing the model's ability to fit ordinary-quality samples. YOLOv11 uses dynamically weighted WIoU v3 as its core loss function, and its mathematical expression is as follows: ; ; in, These are the weighting coefficient terms; To compare the losses between the two; The x-coordinate of the center of the true bounding box; The ordinate is the center coordinate of the true bounding box. and The width of the minimum bounding rectangle that simultaneously contains both the predicted and ground truth bounding boxes. and height , which is the size of the smallest rectangle that can completely accommodate the two boxes, and * indicates gradient separation; Intermediate loss term; final loss The mathematical expression is: ; ; ; For focusing coefficient, for Exponential moving average, To adjust the parameters.

[0060] S3. Based on the center coordinates of the target detection box output by the model, extract a fixed-size region of 60x60 pixels containing the pupil. In this embodiment, the object detection branch (Bounding Box Head) in the YOLOv11 model outputs the center coordinates of each detected object. Width w and height h. To standardize the processing flow and accommodate the localization requirements of subsequent segmentation and uncertainty modeling, the system crops a fixed window region of 60×60 pixels from the original image based on these center coordinates. This region is designed to compactly contain all the structural features of a typical pupil boundary, preserving spatial context while reducing background interference.

[0061] S4. Perform double threshold segmentation on the target detection box region to generate a binary mask image, which is used to obtain the pupil closure contour. In this embodiment, based on the fixed-size bounding box of 60x60 pixels generated for each detection result, the pupil region is located and extracted by extracting the pixel matrix of the corresponding region. To eliminate the influence of illumination differences and to address the unique low reflectivity of the pupil region, a dual-threshold segmentation function is designed, with the mathematical expression as follows: ; The lower threshold is used to exclude dark area noise caused by eyelid edge shadows, while the upper threshold is used to suppress bright noise generated by corneal reflection. This local processing strategy effectively improves single-frame processing time while ensuring the segmentation mask effectively fills the tiny holes inside the pupil and smooths the edges. The pupil closure contour is obtained after the dual-threshold segmentation method. Figure 3 As shown in the figure, the blue box is the selected box of the target analysis area, namely the pupil. The color of the uncertainty estimation result map represents the reliability of the result: the blue area indicates that the segmentation result of the area has low uncertainty, the analysis result is more reliable and the error is small; The uncertainty of the segmentation results gradually increases from yellow to red, and the corresponding target region boundaries may be blurred and the recognition error may be large.

[0062] S5. Construct a Gaussian cognitive uncertainty function from the original mask image to generate the corresponding pupil boundary uncertainty heatmap; In this embodiment, a Gaussian cognitive uncertainty function is further constructed to model the spatial distribution of the pupil boundary and generate a corresponding uncertainty heatmap. Specifically, YOLOv11 sets the probability distinction threshold between the pupil foreground and background to approximately 0.2 in this task, and based on this, a Gaussian center is set. And the following function is introduced to model the uncertainty: ; in, Represents pixel coordinates, Control the width of the uncertain region (set to) The function responds highly near the prediction boundary, indicating that the model lacks clear judgment in this region; while it responds less in high-confidence regions of the foreground or background, representing that the model has strong predictive confidence.

[0063] S6. Output the pupil segmentation image and uncertainty heatmap. In this embodiment, an improved YOLOv11 network framework is employed, with the core module being the C3K2 module. This module is a further improvement upon the C2f module of YOLOv8, primarily combining a set of small-sized convolutional kernels (3×3) with a Bottleneck structure to achieve parameter compression while maintaining feature representation capabilities. Furthermore, the C2PSA (Cross-Partial Spatial Attention) module introduced in YOLOv11 integrates two PSA (Partial Spatial Attention) mechanisms for attention modeling of different sub-regions of the feature map. This structure effectively enhances the model's selective attention to spatial details, making it particularly suitable for medical image segmentation tasks requiring the capture of fine boundary regions.

[0064] In the improved YOLOv11 network framework, the core module is the C3K2 module, which is a further improvement on the C2f module of YOLOv8. It mainly combines a set of small-sized convolutional kernels (3×3) with a Bottleneck structure, achieving parameter compression while maintaining feature representation capabilities. Furthermore, the C2PSA (Cross-Partial Spatial Attention) module introduced in YOLOv11 integrates two PSA (Partial Spatial Attention) mechanisms for attention modeling of different sub-regions of the feature map. This structure effectively enhances the model's selective attention to spatial details, making it particularly suitable for medical image segmentation tasks that require capturing fine boundary regions.

[0065] To verify the effectiveness of this method, based on the above embodiments, the proposed solution was tested on a collected dataset containing 600 samples, with the training set, validation set, and test set divided in a ratio of 7:2:1. The experimental results are shown in Table 1. Table 1 Experimental Results When using the YOLOv11-based framework to detect pupils in eye images, the detection accuracy reached a near-perfect 99.82% (precision = 0.99822), with a recall rate of 100% (recall = 1.00000). In terms of core evaluation metrics, the mAP at the 50% IoU threshold was as high as 99.5% (mAP50 = 0.99500), and the more challenging 50-95% IoU composite metric also performed strongly (mAP50-95 = 0.85162). Notably, the pupil segmentation loss was significantly optimized to 0.54425 (seg_loss), coupled with a classification loss of 0.41127 (cls_loss), indicating that the model accurately identifies the pupil region while achieving fine edge segmentation. The bounding box regression loss stabilized at 0.66159 (box_loss), validating the accurate localization capability of the detection boxes. These results collectively demonstrate that the model meets the accuracy requirements for practical application, indicating that the model can achieve a high level of accuracy in pupil recognition.

[0066] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A pupil segmentation method for visual acuity refractive error detection based on YOLOv11, characterized in that, The method steps include: S1. Obtain an infrared image of the eye with a pupil image; S2. Build a segmentation model based on YOLOv11, and input the preprocessed infrared image of the eye into the segmentation model to output an instance mask image with the pupil target box. S3. Based on the instance mask image, extract the image of the fixed-size region containing the pupil; S4. Perform double threshold segmentation on the image of a fixed-size region to generate a binary mask image; S5. Construct a Gaussian cognitive uncertainty function, and use this function to generate a corresponding pupil boundary uncertainty heatmap based on a binary mask image. S6. Output a binary mask image and a heatmap of pupil boundary uncertainty to complete pupil segmentation.

2. The pupil segmentation method in visual acuity refractive error detection based on YOLOv11 as described in claim 1, characterized in that, The infrared image of the eye with pupil image in S1 is derived from the infrared image during the refractive error detection process, and the resolution is uniformly 720x380.

3. The pupil segmentation method in visual acuity refractive error detection based on YOLOv11 as described in claim 1, characterized in that, The preprocessing in S2 includes size trimming and center alignment operations, wherein the size trimming strategy is to round down to an integer multiple of 32.

4. The pupil segmentation method in visual acuity refractive error detection based on YOLOv11 as described in claim 1, characterized in that, The segmentation model built based on the improved YOLOv11 in S2 includes: YOLOv11 integrates the C2PSA attention mechanism with mask prototype generation, and the segmentation head adopts an improved Mask structure; The improved segmentation model consists of a backbone feature extraction network, a feature fusion structure, and a multi-task output head, wherein the multi-task output head includes a segmentation branch and a detection box branch. The C2PSA attention mechanism is integrated by introducing it into the backbone feature extraction network, specifically by integrating the channel attention module and the spatial attention module to enhance the representation ability of pupil features. The fusion method for mask prototype generation is as follows: the segmentation branch is built with the prototype network and the mask generation module as the core to achieve the following process: first, a set of mask prototype feature maps are extracted through the prototype network, and then the prototype feature maps are weighted and fused with the detection box weights output by the model to finally generate an instance mask map corresponding to each pupil target; the instance mask map is a grayscale image, and its pixel value is used to represent the predicted probability that the corresponding pixel belongs to the pupil region.

5. The pupil segmentation method in visual acuity refractive error detection based on YOLOv11 as described in claim 4, characterized in that, The detection box branch is used to predict the spatial location information of the pupil target, which includes the target center point coordinates, width, height, and the target's presence confidence. This branch employs an anchor-free localization mechanism, which achieves precise localization of the pupil target by regressing the offset of each predicted point relative to its location in the feature map.

6. The pupil segmentation method in visual acuity refractive error detection based on YOLOv11 as described in claim 1, characterized in that, The specific process of extracting the image containing the fixed-size region of the pupil in S3 includes: Based on the pupil target bounding box in the instance mask image, obtain the center coordinates of the pupil target; On the original infrared image, using the center coordinates as a reference, an image of a fixed-size region is cropped.

7. The pupil segmentation method in visual acuity refractive error detection based on YOLOv11 as described in claim 6, characterized in that, The fixed size in S3 is specifically 60×60 pixels.

8. The pupil segmentation method in visual acuity refractive power detection based on YOLOv11 as described in claim 1, characterized in that, The dual-threshold segmentation process in S4 specifically includes: A first threshold and a second threshold are set. The first threshold is used to suppress bright noise caused by corneal reflection, and the second threshold is used to eliminate dark noise caused by eyelid edge shadows. Both the first and second thresholds are preset grayscale values. Image operations on a fixed-size region based on the first and second thresholds include: Regions with grayscale values ​​greater than or equal to the first threshold are identified as reflective bright regions and are removed. Regions with gray values ​​less than or equal to the second threshold are identified as background or shadow regions and are removed. Regions with gray values ​​less than the first threshold and greater than the second threshold are identified as valid pupil regions and are preserved.

9. The pupil segmentation method in visual acuity refractive power detection based on YOLOv11 as described in claim 1, characterized in that, The Gaussian cognitive uncertainty function in S5 uses the distance from each pixel in the binarized mask image to the pupil boundary as a variable. Regions closer to the boundary receive a higher uncertainty score, thus forming a spatial distribution uncertainty heatmap. The specific expression of the Gaussian cognitive uncertainty function is as follows: ; in, Score the uncertainty; For pixels ( x , y The distance from the pupillary margin to the pupillary border; x , y ) represents the pixel coordinate, and σ is the width of the preset control uncertainty area; This is the preset distance reference value.

10. The pupil segmentation method in visual acuity refractive error detection based on YOLOv11 as described in claim 9, characterized in that, The uncertainty heatmap in S5 is encoded using a pseudo-color method. The brighter the color, the higher the uncertainty of the model's boundary prediction, which is used to assist in subsequent pupil boundary assessment and refractive error diagnosis.