How to identify pupils
By extracting and processing the contour point data of the subject's pupil, removing invalid data from the occlusion area, and fitting the circle using the least squares method, the problem of pupil recognition difficulty in the existing technology is solved, and accurate pupil recognition for special groups such as the elderly is achieved.
Patent Information
- Application Number
- CN202411436980.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-15
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2044-10-15
AI Technical Summary
The existing pupil positioning method is difficult to achieve accurate pupil recognition under light morphology changes and shadows of the subject's eyelids under light. Especially for the elderly, pupil occlusion is further increased by the difficulty of recognition.
By extracting the contour points set of the subject's pupil, the invalid data of the occluded area is eliminated, and the circle is fitted using the least squares method to obtain the coordinates and diameter of the pupil's center position.
Accurate recognition of unobstructed and obstructed pupils is achieved, and the success rate of pupil recognition methods in fully automatic ophthalmic medical devices is improved.
Smart Images

Figure CN119014805B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of ophthalmological examination image processing, and in particular to a pupil recognition method. Background Art
[0002] Currently, with the rapid development of image processing technology, image processing technology has begun to be widely used in medical devices. Among them, fully automatic ophthalmic examination equipment needs to accurately identify the subject's pupil when examining the subject's eyes. Currently, most existing pupil positioning methods use traditional image processing methods such as Hough transform, ellipse fitting, and gradient vector method. Because the morphology of the subject's eyes varies, different shadows are formed under lighting, making it difficult to accurately locate the pupil. The subject's pupil can only be identified in the entire captured image. The implementation of such pupil recognition methods is based on the fact that the captured subject's pupil part is in sharp contrast with other captured parts. In order to achieve pupil recognition using the above-mentioned traditional image processing methods, the success rate of pupil recognition is greatly reduced.
[0003] Furthermore, eye exams involve a special group, such as the elderly. As age increases, the risk of eye disease increases. Drooping eyelids often obscure the pupils. Even when instructed to keep their eyes wide open and fixed during an eye exam, this can be difficult for the elderly. This also complicates pupil identification. Summary of the Invention
[0004] To address the above issues, the present invention proposes a pupil recognition method. This method extracts a set of pupil contour points, removes invalid data from occluded pupil contours, and uses the least squares method to fit a circle to obtain the center coordinates and diameter of the pupil. This method can identify both normal, unobstructed pupils and occluded pupils.
[0005] The technical solution adopted by the present invention is as follows:
[0006] A pupil recognition method, characterized by comprising the following steps:
[0007] S1 (acquisition step), collecting images of the subject's eyes and grayscale processing the images;
[0008] S2 (precise positioning step), using the horizontal grayscale projection curve and the vertical projection curve of the subject's eye image to determine the horizontal position and the vertical position of the subject's pupil, respectively, to achieve precise positioning of the subject's pupil;
[0009] S3 (interception step), capturing an image of the effective area around the subject's pupil, which is a first effective area image that completely includes the subject's pupil;
[0010] S4 (segmentation step), determining a segmentation threshold, performing threshold segmentation on the intercepted first valid area to obtain a second valid area;
[0011] S5 (recognition step), identifying the contour of the obtained second effective area and screening out the contour of the subject's pupil;
[0012] S6 (fitting step), performing least squares circle fitting on the subject's pupil contour to obtain the center coordinates and radius of the pupil; the unobstructed subject's pupil contour point data are all valid data; the obstructed subject's pupil contour point data contain invalid data, and the invalid data are eliminated.
[0013] This recognition method extracts the pupil's contour points, removes invalid data from occluded areas, and uses the least squares method to fit a circle to obtain the pupil's center coordinates and diameter. This method can identify both normal, unobstructed pupils and occluded ones, significantly improving the success rate of pupil recognition in fully automated ophthalmic medical devices.
[0014] Optionally, step S2 includes the following steps:
[0015] S21, the image of the subject's eye area is a matrix with an m×n resolution. According to the formula Calculate the horizontal grayscale projection curve of the image, where the horizontal coordinate is the column number of the matrix and the vertical coordinate is the sum of the elements in each column of the matrix, where i, j are the rows and columns of the matrix, 0<i≤m, 0<j≤n, and M(i,j) represents the grayscale value of the pixel in the i-th column and j-th row;
[0016] S22, according to the formula Calculate the vertical grayscale projection curve of the image, where the horizontal coordinate is the row number of the matrix and the vertical coordinate is the sum of the elements in each row of the matrix, where i, j are the rows and columns of the matrix, 0<i≤m, 0<j≤n, and M(i,j) represents the grayscale value of the pixel in the i-th column and j-th row;
[0017] S23, determining the pupil position information of the subject, and analyzing the pupil position information from the horizontal grayscale projection curve and the vertical grayscale projection curve of the subject's eye area image.
[0018] Optionally, the S23 includes the following steps:
[0019] S231, perform first-order difference on the horizontal grayscale projection curve of the subject's eye image obtained in S21 to find the position of the trough in the horizontal grayscale projection curve of the subject's eye image, use array locs_h[] to record the position i of the trough, and use array pks_h[] to record the grayscale projection value y(i) corresponding to the trough position; filter out the grayscale projection value y(i) in the grayscale projection value array pks_h[] that is greater than half of the maximum horizontal grayscale projection value and is the minimum horizontal grayscale projection value, and at the same time determine the trough position i corresponding to the minimum grayscale projection value y(i) in the array locs_h[], and determine the horizontal coordinate of the subject's pupil position.
[0020] S232, perform first-order difference on the vertical grayscale projection curve of the subject's eye image in S22 to find the position of the trough in the vertical grayscale projection curve of the subject's eye image, use array locs_v[] to record the position j of the trough, and use array pks_v[] to record the grayscale projection value x(j) corresponding to the trough position j; filter out the grayscale projection value x(j) in the grayscale projection value array pks_v[] that is greater than half of the maximum vertical grayscale projection value and is the minimum vertical grayscale projection value, and at the same time determine the trough position j corresponding to the minimum vertical grayscale projection value x(j) in the array locs_v[], and determine the vertical coordinate of the subject's pupil position.
[0021] Optionally, the S3 step includes the following steps:
[0022] According to the position information of the subject's pupil (i, j),
[0023] Calculate the difference a between the horizontal coordinate i and the minimum value min_H of the non-zero area in the horizontal grayscale projection curve of the image of the subject's eye area;
[0024] Calculate the difference b between the maximum value max_H of the non-zero area in the horizontal grayscale projection curve of the subject's eye image and the horizontal coordinate i;
[0025] Calculate the difference c between the vertical coordinate j and the minimum value min_V of the non-zero area in the vertical grayscale projection curve of the subject's eye image;
[0026] Calculate the difference d between the maximum value max_V of the non-zero area in the horizontal grayscale projection curve of the subject's eye image and the vertical coordinate j;
[0027] Calculate the minimum value of a and b min(a,b), the minimum value of c and d min(c,d) respectively,
[0028] The normal pupil size in a dark room can reach 5-7mm. Assuming that the maximum pupil diameter in the image is D, if min(a,b)≥D and min(c,d)≥D, then the first effective area of the subject's pupil is intercepted as:
[0029] [i - D, j - D, 2D, 2D];
[0030] If min(a, b) ≥ D and min(c, d) < D, then the first effective region of the subject's pupil is intercepted as:
[0031] [i - D, min(c, d), 2D, 2 * min(c, d)];
[0032] If min(a, b) < D and min(c, d) ≥ D, then the first effective region of the subject's pupil is intercepted as:
[0033] [min(a, b), j - D, 2 * min(a, b), 2D];
[0034] If min(a, b) < D and min(c, d) < D, then the first effective region of the subject's pupil is intercepted as:
[0035] [min(a, b), min(c, d), 2 * min(a, b), 2 * min(c, d)];
[0036] Optionally, step S4 includes the following steps
[0037] S41, calculate the average value of the grayscale values of all pixels in the first effective region according to the average value calculation formula;
[0038] S42, calculate the standard deviation of the grayscale values of the pixels in the first effective region according to the standard deviation formula;
[0039] S43, use the difference between the average value of the grayscale values of the pixels in the first effective region and the standard deviation of the grayscale values of the pixels in the first effective region as the grayscale threshold for threshold segmentation of the first effective region, and perform threshold segmentation on the first effective region to obtain the second effective region.
[0040] Optionally, step S5 includes the following steps: detect the contours in the second effective region image obtained by using the findContours function in opencv.
[0041] Optionally, step S6 includes the following steps
[0042] S61, determine the state of the subject's pupil by judging the relationship between the width W in the horizontal direction and the height H in the vertical direction of the subject's pupil contour. If W ≠ H, then the state of the subject's pupil is an occluded state; otherwise, the state of the subject's pupil is unoccluded. All the pupil contour point data of the unoccluded subject are valid data, and there are invalid data in the pupil contour point data of the occluded subject.剔除无效数据;
[0043] It should be noted that the part "剔除无效数据" in the original text seems to be an incomplete expression in Chinese. I have translated it as "剔除 invalid data" as accurately as possible based on the context. If there is a more accurate expression, it can be adjusted accordingly.S62, calculating the best fitting circle center coordinates and radius for the valid pupil contour point data of the subject obtained in step S61;
[0044] S63, determining the center position coordinates of the subject's pupil based on the circle center coordinates obtained in S62 and the starting point coordinates of the first effective area intercepted in the intercepting step.
[0045] The present invention has the beneficial effect of extracting a set of pupil contour points, eliminating invalid data from occluded pupil contours, and fitting a circle using the least squares method to obtain the central coordinates and diameter of the pupil. This method can identify both normal, unobstructed pupils and occluded pupils, significantly improving the success rate of pupil recognition methods in fully automated ophthalmic medical devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments described in the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0047] Figure 1a It is an image of the eye of a normal subject;
[0048] Figure 1b It is an image of the subject's eyes being blocked;
[0049] Figure 2a It is the horizontal grayscale projection curve of the image of the eye area of a normal subject;
[0050] Figure 2b It is the horizontal grayscale projection curve of the image of the part covering the subject's eyes;
[0051] Figure 3a It is the vertical grayscale projection curve of the image of the eye area of a normal subject;
[0052] Figure 3b It is the vertical grayscale projection curve of the image of the part of the subject's eyes that is blocked;
[0053] Figure 4 This is a schematic diagram of the effective pupil area of a normal subject;
[0054] Figure 5 This is a schematic diagram of intercepting the effective area of the pupil of the subject;
[0055] Figure 6 is a diagram of the standard deviation range;
[0056] Figure 7aThis is a schematic diagram of the first effective area segmentation of a normal subject;
[0057] Figure 7b It is a schematic diagram of the segmentation of the first effective area of the occluded subject;
[0058] Figure 8a This is a schematic diagram of the second effective area contour recognition and screening results of normal subjects;
[0059] Figure 8b This is a schematic diagram of the contour recognition and screening results of the second effective area of the occluded subject;
[0060] Figure 9a This is a schematic diagram of the horizontal and vertical dimensions of the pupil outline of a normal subject;
[0061] Figure 9b It is a schematic diagram of the horizontal and vertical dimensions of the pupil contour of the blocked subject. DETAILED DESCRIPTION
[0062] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0063] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0064] S1, collect the image of the subject's eyes and convert the image into grayscale;
[0065] like Figure 1a As shown in , the image of the subject's eyes is collected without any obstruction; Figure 1b As shown in , the image of the subject's eye occlusion state is captured.
[0066] S2: Accurately locate the subject's pupil. Because the grayscale around the subject's pupil varies significantly in the captured eye image, the horizontal and vertical grayscale projection curves of the eye image can be used to determine the horizontal and vertical positions of the subject's pupil, respectively, thereby accurately locating the subject's pupil.
[0067] The specific implementation is as follows:
[0068] S21, the image of the subject's eye area is a matrix with an m×n resolution. The horizontal grayscale projection curve of the image is calculated according to formula (1), where the horizontal coordinate is the column number of the matrix and the vertical coordinate is the sum of the elements in each column of the matrix (that is, the sum of the pixel values in each column of the image).
[0069]
[0070] Where i and j are the rows and columns of the matrix, 0<i<m, 0<j<n, and M(i, j) represents the grayscale value of the pixel in the i-th column and j-th row.
[0071] The horizontal grayscale projection curve of the image in the eye area of a normal subject is as follows: Figure 2a As shown; the horizontal grayscale projection curve of the image in the image where the subject's eyes are blocked is as follows Figure 2b shown.
[0072] S22, according to formula (2), the grayscale projection curve in the vertical direction of the image is obtained, where the horizontal coordinate is the row number of the matrix, and the vertical coordinate is the sum of the elements in each row of the matrix (that is, the sum of the pixel values in each row of the image).
[0073]
[0074] Where i, j are the rows and columns of the matrix, 0<i≤m, 0<j≤n, and M(i, j) represents the grayscale value of the pixel in the i-th column and j-th row.
[0075] The vertical grayscale projection curve of the image in the eye area of a normal subject is as follows: Figure 3a As shown; the horizontal grayscale projection curve of the image in the image where the subject's eyes are blocked is as follows Figure 3b shown.
[0076] S23, determining the pupil position information of the subject.
[0077] From the horizontal grayscale projection curve and vertical grayscale projection curve of the subject's eye image, the pupil is located at the trough of the curve. The first-order difference at the trough of the curve is d y [i]<0,d y [i+1]>0 phenomenon. Find all d in the first-order difference of the curve y [i]<0,d y For points [i+1]>0, use the array locs[] to record the position i of the trough, and use the array pks[] to record the grayscale projection value corresponding to the trough position i. Use the bubble sort method to find the grayscale projection value in the array pks[] that is greater than half of the maximum grayscale projection value and the minimum grayscale projection value, as well as the corresponding position i.
[0078] S231, performing a first-order difference on the horizontal grayscale projection curve of the subject's eye image in step S21, and obtaining:
[0079] d y =y'(i)(0<i≤m)
[0080] With dy [i]<0,d y [i+1]>0(0<i<m) condition is used to find the position of the trough in the horizontal grayscale projection curve of the subject's eye image, use the array locs_h[] to record the position i of the trough, and use the array pks_h[] to record the grayscale projection value y(i) corresponding to the trough position i.
[0081] The grayscale projection values in the pks_h[] array are checked to see if they are greater than half the maximum horizontal grayscale projection of the subject's eye image. Bubble sorting is performed simultaneously to select those whose grayscale projection values are greater than half the maximum horizontal grayscale projection value and are the minimum grayscale projection value y(i). The valley position i corresponding to the minimum grayscale projection value y(i) in the locs_h[] array is determined, thereby determining the horizontal coordinate of the subject's pupil.
[0082] S232, performing a first-order difference on the vertical grayscale projection curve of the subject's eye image in step S21, and obtaining:
[0083] d x =x'(j) (0<j≤n)
[0084] With d x [j]<0,d x [j+1]>0(0<j<n) condition is used to find the position of the trough in the vertical grayscale projection curve of the subject's eye image, use the array locs_v[] to record the position i of the trough, and use the array pks_v[] to record the grayscale projection value x(j) corresponding to the trough position j.
[0085] The grayscale projection values in the pks_v[] array are checked to see if they are greater than half the maximum horizontal grayscale projection value of the subject's eye image. Bubble sorting is performed simultaneously to select those whose grayscale projection values are greater than half the maximum horizontal grayscale projection value and are the minimum grayscale projection value x(j). The trough position j corresponding to the minimum grayscale projection value x(j) in the locs_v[] array is determined, which is the vertical coordinate of the subject's pupil position.
[0086] S3, capturing the image of the effective area around the subject's pupil, which is the first effective area image, completely including the subject's pupil.
[0087] According to the position information of the subject's pupil (i, j),
[0088] Calculate the difference a=i-min_H between the horizontal coordinate i and the minimum value min_H of the non-zero area in the horizontal grayscale projection curve of the image of the subject's eye area;
[0089] Calculate the difference b = max_H - i between the maximum value max_H of the non-zero region in the horizontal gray-scale projection curve of the eye part image of the subject and the abscissa i;
[0090] Calculate the difference c = j - min_V between the ordinate j and the minimum value min_V of the non-zero region in the vertical gray-scale projection curve of the eye part image of the subject;
[0091] Calculate the difference d = max_V - j between the maximum value max_V of the non-zero region in the horizontal gray-scale projection curve of the eye part image of the subject and the ordinate i;
[0092] Respectively calculate the minimum values min(a, b) of a and b, and the minimum values min(c, d) of c and d.
[0093] In the case of a dark room, the pupil of a normal person can reach 5 - 7 mm. Assume that the pixel diameter of the maximum pupil in the picture is D. If min(a, b) ≥ D and min(c, d) ≥ D, then the first effective region of the subject's pupil is intercepted as:
[0094] [i - D, j - D, 2D, 2D];
[0095] If min(a, b) ≥ D and min(c, d) < D, then the first effective region of the subject's pupil is intercepted as:
[0096] [i - D, min(c, d), 2D, 2 * min(c, d)];
[0097] If min(a, b) < D and min(c, d) ≥ D, then the first effective region of the subject's pupil is intercepted as:
[0098] [min(a, b), j - D, 2 * min(a, b), 2D];
[0099] If min(a, b) < D and min(c, d) < D, then the first effective region of the subject's pupil is intercepted as:
[0100] [min(a, b), min(c, d), 2 * min(a, b), 2 * min(c, d)];
[0101] S4 Determine an appropriate segmentation threshold, and perform threshold segmentation on the first effective region intercepted in step S3.
[0102] In mathematics, the standard deviation is a measure of the dispersion degree of a set of data. It represents the degree of deviation of each data point from the average value. The larger the standard deviation, the greater the degree of deviation of the data points from the average value, and the greater the dispersion degree of the data distribution.
[0103] Average value calculation formula:
[0104]
[0105] Standard deviation calculation formula:
[0106]
[0107] The mean-variance method, the mean plus or minus the standard deviation is a mathematical statistical method used to explain the distribution of data. It can help us quickly understand the specific location of a certain point of data, including the maximum value, minimum value, specific location data, etc. The significance of the mean plus or minus the standard deviation is to describe the distribution range of the data. In general, the mean plus or minus one standard deviation can include about 68% of the data points. If you add or subtract two standard deviations, it can include about 95% of the data points. This range is called the "standard deviation range." Combined with the attached Figure 6 According to the standard deviation range diagram in and the data in Table 1 below, steps S41 to S43 are performed.
[0108] Table 1
[0109] Standard coefficient Pixel value ratio 1 68% 2 95% 3 99%
[0110] S41, calculate the average grayscale values of all pixels in the first effective area according to the average value calculation formula:
[0111]
[0112] Wherein, N represents the number of pixels in the first effective area, represents the sum of the grayscale values of all pixels in the first effective area, X i Represents the grayscale value of the i-th pixel in the first valid area.
[0113] S42, calculating the standard deviation of the grayscale values of pixels in the first effective area according to the standard deviation formula:
[0114]
[0115] Where N represents the number of pixels in the first effective area, X i represents the grayscale value of the i-th pixel in the first valid area, represents the average grayscale value of pixels in the first valid area, Represents the sum of the squares of the differences between the grayscale value of each pixel in the first valid area and the average grayscale value of the pixels.
[0116] S43: Using the difference between the average grayscale value of the pixels in the first effective area and the standard deviation of the grayscale value of the pixels in the first effective area as the grayscale threshold for the first effective area threshold segmentation.
[0117] Right now:
[0118]
[0119] Perform threshold segmentation on the first valid area to obtain the second valid area:
[0120] This process can be seen in Figure 7a as well as Figure 7b As shown in Figure 7a The diagram shows a process of performing threshold segmentation on the first effective area of a normal subject to obtain the second effective area. Figure 7b ] is a schematic diagram of a process of performing threshold segmentation on a first effective area of a normal subject to obtain a second effective area.
[0121] S5, identifying the contour of the second effective area obtained in step S4, and screening out the contour of the subject's pupil.
[0122] S51, using the findContours() function in OpenCV to detect the contours in the second valid area image obtained in step S4.
[0123] S52, the right image is the result of contour detection in the left image. Multiple contours will be detected, but there will be differences in size, area and other features between the contours. There is also a small contour included in the contour of the subject's pupil. The contour of the subject's pupil is screened out. The pupil contour of the unobstructed subject is close to a circle; while the lower half of the pupil contour of the subject obstructed by the upper eyelid is still close to a circle. For this process, please refer to the attached Figure 8a And attached Figure 8b As shown in the process, Figure 8a What is shown in the figure is the contour recognition and screening process of normal subjects. Figure 8b The contour recognition and screening process of the occluded subjects shown in .
[0124] S6, performing least squares circle fitting on the pupil contour of the subject obtained in step S5 to obtain the center coordinates (x, y) and radius r of the pupil.
[0125] When the subject's pupil is not blocked, the contour curve of the subject's pupil is close to a circular curve; after the subject's pupil is partially blocked by the upper eyelid, the contour curve of the lower half that is not blocked is still close to a circular curve.
[0126] Fitting a circle is one of the common tasks in image processing and computer vision. Its purpose is to find an optimal circle to describe the distribution characteristics of a given set of data points.
[0127] The least squares method for fitting a circle is a common mathematical optimization method that determines the best fitting circle by minimizing the sum of the squared distances between data points and the fitted circle. Specifically, for a given set of data points, the parameters of the optimal fitting circle can be obtained by solving an optimization problem that minimizes the objective function.
[0128] S61, pre-processing the pupil contour of the subject screened out in step S5
[0129] The state of the subject's pupil is determined by determining the relationship between the horizontal width W and the vertical height H of the subject's pupil outline. If W ≠ H, the subject's pupil is occluded; otherwise, the subject's pupil is unoccluded.
[0130] The unobstructed pupil contour point data of the subjects are all valid data. This state is as shown in the attached Figure 9a As shown in;
[0131] There are invalid data in the pupil contour point data of the obscured subject, and the invalid data needs to be eliminated. This state is as shown in the attached Figure 9b As shown in . Find the minimum X coordinate value of the pupil contour in the horizontal direction of the subject, the contour point coordinates when the Y coordinate value is the minimum (Xmin, Ymin1), and the contour point coordinates when the X coordinate value is the maximum and the Y coordinate value is the minimum (Xmax, Ymin2). Between Xmin and Xmax, the contour point data with a Y coordinate greater than Ymin1 or greater than Ymin2 is valid data. S62, for the valid data of the pupil contour point of the subject obtained in step S61 (x i ,y i )i=1,2,...,n, calculate the best fitting circle center coordinates (x0,y0) and radius r.
[0132] The equation of a circle can be expressed as:
[0133] (x-x0) 2 +(y-y0) 2 =r 2 (1)
[0134] For the circle fitting of the least squares method, the optimization objective function of the square error is:
[0135]
[0136] Where: (x i ,y i )i=1,2,...,n are the coordinates of the feature points on the arc; n is the number of feature points involved in fitting.
[0137] On the premise of maintaining the characteristics of this optimization objective function, we need to use a slightly different improved method to define the square of the error, which avoids the square root and obtains a direct solution to the minimization problem, defined as follows:
[0138]
[0139] Then formula (2) can be rewritten as:
[0140]
[0141] Let,B=-2y0,
[0142] That is, formula (3) can be expressed as:
[0143]
[0144] According to the principle of least squares, the parameters A, B, and C should make E obtain the minimum value. According to the method of finding the minimum value, A, B, and C should satisfy
[0145]
[0146] To solve the system of equations, first eliminate the parameter C, then
[0147] Mode have to
[0148]
[0149] Mode have to
[0150]
[0151] make
[0152]
[0153] Write equations (7) and (8) in matrix form
[0154]
[0155] According to formula (14) and formula (6), we can get:
[0156]
[0157] Thus, the best fitting center coordinates (x0, y0) and the fitting value of radius r are obtained:
[0158]
[0159] S63, the center coordinates of the fitted circle obtained in step S62 Determine the central position coordinates of the subject's pupil based on the starting point coordinates of the first valid region intercepted in step S3:
[0160] Assume that the pixel diameter of the maximum pupil in the picture is D. If min(a, b) ≥ D and min(c, d) ≥ D, then the coordinates of the center position of the subject's pupil
[0161]
[0162] If min(a, b) ≥ D and min(c, d) < D, then the coordinates of the center position of the subject's pupil
[0163]
[0164] If min(a, b) < D and min(c, d) ≥ D, then the coordinates of the center position of the subject's pupil
[0165]
[0166] If min(a, b) < D and min(c, d) < D, then the coordinates of the center position of the subject's pupil
[0167]
[0168] The diameter of the subject's pupil
[0169] The above-described embodiments only represent some embodiments of the present invention. The description is relatively specific and detailed, but it should not be construed as a limitation on the scope of the present invention patent. It should be noted that for those skilled in the art, they can still modify the technical solutions recorded in the foregoing embodiments or perform equivalent replacements for some of the technical features. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.
Claims
1. A method for identifying pupils, characterized in that: The following steps are included: The acquisition step is to acquire the image of the subject's eye area and grayscale the image; The precise positioning step is to determine the horizontal and vertical positions of the subject's pupils through the horizontal grayscale projection curve and the vertical projection curve of the subject's eye image, respectively, so as to achieve precise positioning of the subject's pupils; The interception step is to capture the image of the effective area around the pupil of the subject, which is the first effective area image and completely includes the pupil of the subject; A segmentation step, determining a segmentation threshold, performing threshold segmentation on the intercepted first effective area to obtain a second effective area; an identification step of identifying the contour of the obtained second effective area and screening out the contour of the subject's pupil; In the fitting step, the least squares circle fitting is performed on the pupil contour of the subject to obtain the center coordinates and radius of the pupil; the unobstructed pupil contour point data of the subject are all valid data; the obstructed pupil contour point data of the subject contain invalid data, and the invalid data is eliminated; The segmentation step includes the following steps, S41, calculating the average grayscale values of all pixels in the first effective area according to an average value calculation formula; S42, calculating the standard deviation of the grayscale values of pixels in the first effective area according to a standard deviation formula; S43, taking the difference between the average grayscale value of the pixels in the first effective area and the standard deviation of the grayscale value of the pixels in the first effective area as the grayscale threshold for threshold segmentation of the first effective area, performing threshold segmentation on the first effective area to obtain a second effective area; The fitting step comprises the following steps, S61, determining the state of the subject's pupil by determining the relationship between the horizontal width W and the vertical height H of the subject's pupil contour; If W≠H, the subject’s pupil state is occluded; On the contrary, if the pupil state of the subject is not blocked, the pupil contour point data of the subject that is not blocked are all valid data, and the pupil contour point data of the subject that is blocked contains invalid data, which is discarded; S62, calculating the best fitting circle center coordinates and radius for the valid data of the subject's pupil contour points obtained in step S61; S63, determining the center position coordinates of the subject's pupil according to the center coordinates obtained in S62 and the starting point coordinates of the first effective area intercepted in the intercepting step.
2. A pupil recognition method according to claim 1, characterized in that: The precise positioning steps include the following steps: S21, the image of the subject's eye area is a matrix of m×n resolution. According to the formula Find the horizontal grayscale projection curve of the image, where the horizontal coordinate is the column number of the matrix and the vertical coordinate is the sum of the elements in each column of the matrix, where i and j are the rows and columns of the matrix. , M(i,j) represents the gray value of the pixel in the i-th column and j-th row; S22, according to the formula Find the grayscale projection curve in the vertical direction of the image. Its horizontal coordinate is the row number of the matrix, and the vertical coordinate is the sum of the elements in each row of the matrix, where i and j are the rows and columns of the matrix. , M(i,j) represents the gray value of the pixel in the i-th column and j-th row; S23, determining the pupil position information of the subject, and analyzing the pupil position information from the horizontal grayscale projection curve and the vertical grayscale projection curve of the subject's eye area image.
3. A pupil recognition method according to claim 1, characterized in that: The identification step includes the following steps: using the findContours function in opencv to detect contours in the obtained second effective area image.
Citation Information
Patent Citations
Pupil positioning method and related device
CN116797661A
Pre-processing method for iris image
CN1885314A