An oil film state and safety risk automatic test method and system for oil mirror scanning

CN122836073APending Publication Date: 2026-09-29SHENZHEN SHENGQIANG TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611341169.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-01
Publication Date
2026-09-29

AI Technical Summary

Technical Problem

现有测试通常仅关注扫描最终的成像结果,既无法实时监测扫描过程中油膜扩散、气泡移位、油膜断裂等动态变化对成像稳定性的影响,也缺少扫描完成后针对物镜、玻片及载物台的油液残留污染风险检测环节,难以形成“状态预判-过程监控-事后评估”的完整测试闭环,不利于故障溯源与设备维护指导

Benefits of technology

1、本发明针对传统人工测试判定标准不一、异常类型难区分的问题,将油膜状态拆解为连续性、气泡风险、油量异常三个可量化维度,通过图像分区计算、梯度特征提取、焦点位置偏移比对等算法,输出客观的数值化评分。油膜连续性评分通过亮度均匀性、清晰度、暗斑占比的加权计算,可稳定识别断油、局部油膜不均等肉眼易忽略的异常;气泡风险评分结合暗斑灰度、边缘环形特征、圆形度约束精准筛选气泡,排除照明不均导致的伪缺陷;油量异常评分通过平均亮度、对比度、焦点峰值位置与标准样本的偏差,可定量区分少油、过油及油膜厚度不均问题;该设计将原本依赖人工经验的定性判断转化为可复现、可追溯的量化指标,大幅提升了不同测试人员、不同测试批次间的结果一致性,可直接支撑量产阶段的标准化出厂质检。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122836073A_ABST
    Figure CN122836073A_ABST
Patent Text Reader

Abstract

The application discloses an oil film state and safety risk automatic test method and system for oil mirror scanning, and the method comprises the following steps: a test scene set containing a plurality of preset oil film states is constructed, and a corresponding oil dripping mode and an expected risk type are matched; an oil film detection image is collected when the oil mirror moves to a test area, data such as position, speed, motor load and focusing evaluation value are synchronously collected during a Z-axis down focus process, and a focusing evaluation curve is fitted; the continuity of the oil film, bubble risk and oil quantity abnormality are analyzed and scored, and a safety risk score is calculated based on the Z-axis data; a scanning stability score is calculated in real time during the scanning process, and a pollution risk score is calculated after the scanning is completed; and a test conclusion is output by comprehensively considering the six scores. The application can accurately identify problems such as oil interruption, bubbles and oil quantity abnormalities by means of image partition, gradient feature extraction and focus offset comparison algorithms, and can exclude pseudo defects caused by uneven illumination.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of microscopic scanning technology, and in particular to an automated testing method and system for oil film state and safety risk in oil immersion scanning. Background Technology

[0002] Bright-field and fluorescence integrated scanning equipment is a core imaging device in fields such as pathological analysis and biological sample testing. It is typically equipped with multiple magnification objectives to adapt to different resolution imaging needs, among which the 60x high-magnification oil immersion objective is a key component for achieving high-resolution microscopic imaging. Oil immersion imaging relies on the oil-filled medium between the objective and the sample slide, which improves light transmission and imaging resolution by eliminating the refractive index difference between air and glass. Systematic testing of the imaging quality and operational safety of oil immersion scanning is required in various scenarios, including equipment development and verification, factory quality inspection, lifespan reliability testing, and after-sales fault reproduction.

[0003] Currently, most high-magnification oil immersion tests in the industry rely on manual operation: testers manually add oil to the slide, visually observe the oil film, and then start the scanning program. The final test result is determined by subjective visual judgment of image clarity and the presence of bubbles or dark spots. This type of testing method has many insurmountable drawbacks: First, the evaluation of oil film condition lacks quantitative standards, resulting in poor consistency of test results. Different testers have significant individual differences in their judgment criteria for oil quantity, oil film continuity, and the degree of bubble influence. Furthermore, various anomalies such as insufficient oil, excessive oil, oil film breakage, bubble interference, and surface contamination can all manifest as blurred images or localized dark spots. It is difficult to reliably distinguish the types of anomalies by visual observation alone, making it impossible to form quantifiable and traceable evaluation indicators, and thus failing to meet the needs of standardized testing in the mass production stage.

[0004] Secondly, there is a lack of proactive risk assessment mechanisms for the operation of oil immersion lenses. During the focusing process, abnormal slide height, Z-axis motion accuracy deviation, or abnormal oil film condition can easily lead to hardware damage accidents such as objective lens collisions or scraping. Existing testing solutions mostly rely on hard limit protection at the end of the equipment or manual emergency shutdown, failing to proactively identify and intervene before contact risks occur by using operating parameters such as Z-axis position, motor load, and focusing curve. As a result, the equipment safety during the testing process cannot be effectively guaranteed.

[0005] Third, the testing process lacks a closed-loop evaluation system covering the entire process. Existing tests typically only focus on the final imaging result of the scan, failing to monitor in real time the impact of dynamic changes such as oil film diffusion, bubble displacement, and oil film breakage on imaging stability during the scanning process. Furthermore, they lack a post-scan oil residue contamination risk detection step for the objective lens, slide, and stage, making it difficult to form a complete testing closed loop of "state prediction - process monitoring - post-evaluation," which is detrimental to fault tracing and equipment maintenance guidance.

[0006] Fourth, the ability to pinpoint the cause of failure is insufficient. High-magnification oil immersion scanning is a complex process involving the coupling of multiple factors such as the optical imaging system, the Z-axis motion system, the state of the oil immersion medium, and the objective lens safety distance. Relying solely on the binary judgment of "whether the imaging is qualified" cannot accurately distinguish whether the root cause of scanning abnormalities is an oil film condition problem, a Z-axis safety risk, an optical path system malfunction, or contamination interference. This greatly reduces the efficiency of problem-solving during the R&D phase and the accuracy of quality control during the mass production phase. Summary of the Invention

[0007] The purpose of this invention is to address the shortcomings of the prior art by providing an automated testing method and system for oil film status and safety risks in oil immersion scanning.

[0008] The objective of this invention is achieved through the following technical solution: an automated testing method for oil film state and safety risks using oil immersion scanning, comprising the following specific steps: S1: Construct a set of oil film test scenarios. The set of test scenarios includes a variety of preset oil film states. Each oil film state corresponds to a dripping method and expected risk type. S2: Control the oil mirror to move towards the test area, and acquire an oil film detection image when it approaches the test area. At the same time, acquire Z-axis response data during Z-axis downward movement and autofocus. The Z-axis response data includes Z-axis position, Z-axis speed, motor load, and focus evaluation value at the corresponding position. Fit a focus evaluation curve based on the focus evaluation value. S3: Analyze the oil film detection image and calculate the oil film continuity score, bubble risk score, and oil volume anomaly score respectively; calculate the Z-axis safety risk score based on the Z-axis response data; if the Z-axis safety risk score exceeds the preset safety threshold, stop the Z-axis from continuing to descend and output a safety risk warning; if the Z-axis safety risk score does not exceed the preset safety threshold, proceed to the next step. S4: Start the oil immersion scan and calculate the scan stability score in real time during the scan; after the oil immersion scan is completed, switch to the preset blank inspection area to acquire the contamination detection image, and calculate the contamination risk score based on the contamination detection image and the clean reference image; S5: Calculate the comprehensive oil mirror test score based on oil film continuity score, bubble risk score, oil volume anomaly score, Z-axis safety risk score, scanning stability score, and contamination risk score. Output the test conclusion based on the comprehensive test score and locate the anomaly type.

[0009] As a preferred embodiment, the focus evaluation value F_i is calculated from the focus evaluation image corresponding to the i-th Z-axis sampling position, and the specific calculation method is as follows: First, select an effective evaluation region in the focus evaluation image. Then, remove saturated pixels, invalid edge regions, and obvious dark areas from the effective evaluation region. Next, calculate the horizontal and vertical gradient responses. Based on the horizontal and vertical gradient responses, the proportion of saturated pixels, and the proportion of low-brightness pixels, calculate the initial focus evaluation value. Finally, perform temporal smoothing on the initial focus evaluation value to obtain the final focus evaluation value.

[0010] Images and corresponding focus evaluation values ​​are acquired within a preset Z-axis range at fixed step intervals. After smoothing and filtering, the focus evaluation values ​​are fitted with a quadratic curve to obtain the focus evaluation curve.

[0011] Preferably, the calculation method for the oil film continuity score is as follows: The oil film detection image is divided into n sub-regions. For each sub-region, the brightness uniformity, sharpness, and abnormal dark spot area ratio are calculated. The brightness uniformity, sharpness, and abnormal dark spot area ratio of each sub-region are weighted and summed to obtain the sub-region continuity evaluation result. The average of the evaluation results of all sub-regions is then taken to obtain the oil film continuity score. Among them, the brightness uniformity is calculated based on the average brightness and brightness standard deviation of the sub-region, the sharpness is calculated based on the Laplacian response of the sub-region, and the abnormal dark spots are identified by local background subtraction combined with edge gradient constraints.

[0012] As a preferred method, the bubble risk score is calculated as follows: the oil film detection image is filtered and the background is estimated, and a bubble candidate mask is generated by using the dark spot grayscale threshold and the annular edge response; the bubble candidate mask is analyzed by connected components, and suspected bubble regions that meet the preset area judgment conditions and roundness judgment conditions are selected; the number of suspected bubbles, the total area of ​​suspected bubbles, the bubble edge intensity value and the bubble roundness value are extracted, and the bubble risk score is calculated based on the number of suspected bubbles, the total area of ​​suspected bubbles, the bubble edge intensity value and the bubble roundness value.

[0013] Preferably, the calculation method for the oil quantity anomaly score is as follows: calculate the average brightness and contrast of the effective area of ​​the oil film, and simultaneously calculate the focal peak position based on the focus evaluation curve; calculate the deviations of the average brightness, contrast, and focal peak position from the reference brightness, reference contrast, and reference focal position corresponding to the standard oil film to obtain the average brightness deviation, contrast deviation, and focal peak position deviation; and perform a weighted summation of the average brightness deviation, contrast deviation, and focal peak position deviation to obtain the oil quantity anomaly score; if the oil quantity anomaly score exceeds a preset oil quantity anomaly threshold, determine the oil quantity anomaly type based on the offset direction of the average brightness, contrast, and focal peak position, and provide adjustment suggestions based on the oil quantity anomaly type; the oil quantity anomaly types include insufficient oil, excessive oil, or uneven oil film thickness.

[0014] As a preferred option, the formula for the focus evaluation curve is: F(z)=αz²+βz+γ, z∈N_k; In the formula, α, β, and γ are all polynomial coefficients; The formula for calculating the focal peak position Z_peak is as follows: Z_peak = -β / (2α); In the formula, N_k is the neighborhood formed by several Z-axis sampling points before and after the peak sampling point; When the fitting accuracy does not meet the preset fitting accuracy requirements, the peak position of the backup focus is calculated using the peak neighborhood weighted centroid method.

[0015] Preferably, the method for calculating the scan stability score is as follows: The scanning process divides each frame of the image into multiple sub-regions, and obtains the sharpness, brightness, and abnormal region ratio of each sub-region. The average sharpness, sharpness variance, brightness variance, and abnormal region ratio of all images are calculated. The average sharpness, sharpness variance, brightness variance, and abnormal region ratio are weighted and summed to obtain the scanning stability score. When the scanning stability score is lower than the preset stability threshold, it is determined that there is a risk of oil film diffusion, bubble movement, oil breakage, or increased contamination during the oil immersion scanning process.

[0016] Preferably, the pollution risk score is calculated as follows: The contamination detection image is flattened and corrected. The flattened and corrected contamination detection image is then compared with the clean reference image to extract suspected oil contamination areas. The total area ratio of suspected oil contamination areas, the number of suspected oil contamination areas, the edge gradient of suspected oil contamination areas, and the background brightness anomaly values ​​of suspected oil contamination areas are calculated. The total area ratio of suspected oil contamination areas, the number of suspected oil contamination areas, the edge gradient of suspected oil contamination areas, and the background brightness anomaly values ​​of suspected oil contamination areas are then weighted and summed to obtain the contamination risk score. When the contamination risk score exceeds the preset contamination threshold, a cleaning prompt is output and the contamination location is recorded.

[0017] Preferably, the Z-axis safety risk score is calculated based on the difference between the current working distance and the minimum safe distance, the change in motor load, the Z-axis speed, and the offset of the focus evaluation curve; wherein, the offset of the focus evaluation curve is the offset between the current measured focus evaluation curve and the preset standard focus evaluation curve; when the Z-axis safety risk score exceeds the preset Z-axis safety risk threshold, it is determined that there is a risk of collision, scraping, or abnormal contact, and the Z-axis is stopped from continuing to descend.

[0018] An automated testing system for oil film condition and safety risk assessment using oil immersion scanning, comprising: The oil immersion test scenario construction module is used to build a set of oil immersion test scenarios containing multiple preset test states, and to configure the oil dripping method and expected risk type corresponding to each test state; The oil film image acquisition module is used to acquire oil film detection images when the oil immersion lens approaches the test area, and to acquire contamination detection images in the blank inspection area after the oil immersion lens scan is completed. The Z-axis response acquisition module is used to simultaneously acquire Z-axis position, Z-axis speed, motor load, and corresponding focus evaluation values ​​during Z-axis descent and autofocus. The oil film status evaluation module is used to calculate the oil film continuity score, bubble risk score, and oil volume anomaly score based on the oil film detection image. The Z-axis safety evaluation module is used to calculate the Z-axis safety risk score based on the Z-axis response data. When the Z-axis safety risk score exceeds the preset Z-axis safety risk threshold, a Z-axis stop-descending command is triggered. The scanning stability evaluation module is used to calculate the image scanning stability score in real time during the oil immersion scanning process; The pollution risk assessment module is used to calculate the pollution risk score after scanning based on the pollution detection image and the clean reference image. The comprehensive judgment and report output module is used to calculate the comprehensive oil immersion test score and output the test results.

[0019] The beneficial effects of this invention are: 1. This invention addresses the problems of inconsistent judgment standards and difficulty in distinguishing anomaly types in traditional manual testing. It decomposes the oil film status into three quantifiable dimensions: continuity, bubble risk, and oil quantity anomaly. Through algorithms such as image partitioning calculation, gradient feature extraction, and focus position offset comparison, it outputs objective numerical scores. The oil film continuity score, through weighted calculation of brightness uniformity, clarity, and dark spot ratio, can reliably identify anomalies that are easily overlooked by the naked eye, such as oil gaps and local oil film unevenness. The bubble risk score, combined with dark spot grayscale, edge ring features, and roundness constraints, accurately filters bubbles and eliminates false defects caused by uneven lighting. The oil quantity anomaly score, through deviations of average brightness, contrast, and focus peak position from standard samples, can quantitatively distinguish between insufficient oil, excessive oil, and uneven oil film thickness. This design transforms qualitative judgments that originally relied on human experience into reproducible and traceable quantitative indicators, significantly improving the consistency of results between different testers and different test batches, and can directly support standardized factory quality inspection in the mass production stage.

[0020] 2. This invention addresses the lag inherent in traditional testing methods that rely on hard limits and manual shutdown. It establishes a Z-axis safety risk assessment model based on multi-parameter fusion. By calculating in real-time Z-axis working distance, motor load changes, movement speed, and abnormal focusing curve values, the model can identify risks of slide collisions and scraping before physical contact occurs between the objective lens and the slide. When the safety risk score exceeds a threshold, the system proactively stops Z-axis downward movement and outputs an alarm. This effectively addresses various risk scenarios such as abnormal slide height, Z-axis movement accuracy deviation, and abnormal oil film condition, preventing hardware damage to the objective lens and slide. Simultaneously, it supports safe operation in long-term unattended testing scenarios such as life testing, significantly improving equipment safety and reliability during the testing process.

[0021] 3. This invention breaks through the limitations of traditional testing that only focuses on the final imaging result, and constructs a closed-loop evaluation capability covering the entire process of oil immersion immersion scanning: before scanning starts, the oil film status is screened and safety risks are checked, and the scanning process is not started if the status is unqualified, thus avoiding invalid scanning and hardware risks from the source; during scanning, the image clarity fluctuation, brightness stability, and abnormal area ratio are monitored in real time, and the imaging attenuation caused by dynamic changes such as oil film diffusion, bubble displacement, and oil film breakage can be captured, distinguishing between instantaneous fluctuations and stability failures; after scanning, the risk of residual oil contamination on the objective lens, slide, stage, and dry lens path is automatically detected, and the contamination location, risk level, and cleaning and maintenance suggestions are output; this complete closed-loop testing system of the invention achieves full life cycle risk coverage of oil immersion immersion scanning, which not only ensures imaging quality, but also provides data support for daily equipment maintenance. Attached Figure Description

[0022] Figure 1 This is a flowchart of the method of the present invention. Detailed Implementation

[0023] 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 embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention are within the scope of protection of the present invention.

[0024] Those skilled in the art should understand that, in the disclosure of this invention, the terms "longitudinal," "lateral," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, the above terms should not be construed as limiting this invention.

[0025] It is understood that the term "a" should be understood as "at least one" or "one or more", that is, in one embodiment, the number of an element can be one, while in another embodiment, the number of the element can be multiple, and the term "a" should not be understood as a limitation on the number.

[0026] like Figure 1 As shown, an automated testing method for oil film condition and safety risk using oil immersion scanning includes the following specific steps: S1: Construct a set of oil film test scenarios. The set of test scenarios includes a variety of preset oil film states. Each oil film state corresponds to a dripping method and expected risk type.

[0027] In this step, the oil immersion test scenario set includes normal oil film, low oil condition, excessive oil condition, bubble condition, oil-free condition, contaminated condition, and abnormal slide height condition. Each condition corresponds to a test number, oil dripping method, expected risk type, and judgment threshold.

[0028] The set of oil immersion test scenarios, G, is denoted as: G={g_normal,g_low,g_high,g_bubble,g_break,g_pollute,g_height}; Among them, g_normal represents a normal oil film, g_low represents a low oil state, g_high represents an over-oil state, g_bubble represents a bubble state, g_break represents an oil-free state, g_pollute represents a contaminated state, and g_height represents an abnormal slide height state.

[0029] The oil immersion depth used in this application is 60x.

[0030] S2: Control the oil mirror to move towards the test area, and acquire an oil film detection image when it approaches the test area. At the same time, acquire Z-axis response data during Z-axis downward movement and autofocus. The Z-axis response data includes Z-axis position, Z-axis speed, motor load, and focus evaluation value at the corresponding position. Fit a focus evaluation curve based on the focus evaluation value.

[0031] In this step, oil film detection images are acquired before and after the oil mirror approaches the test area, and the Z-axis position z_i, Z-axis speed v_i, motor load L_i, and focus evaluation value F_i are recorded during Z-axis downward movement and autofocus.

[0032] The focal evaluation value F_i is calculated from the focal evaluation image corresponding to the i-th Z-axis sampling position, and its specific calculation method is as follows: First, select an effective evaluation region Ω_i in the focus evaluation image. Remove saturated pixels, invalid edge regions, and obvious dark field regions from the effective evaluation region. Then, calculate the horizontal and vertical gradient responses. Calculate the initial focus evaluation value based on the horizontal and vertical gradient responses, the proportion of saturated pixels, and the proportion of low-brightness pixels. Perform time-series smoothing on the initial focus evaluation value to obtain the final focus evaluation value.

[0033] The formula for calculating the gradient intensity G_i(x,y) of a single pixel is as follows: G_i(x,y)=[S_x I_i(x,y)]²+[S_y I_i(x,y)]²; In the formula, I_i(x,y) is the gray value of the i-th frame focus evaluation image at pixel coordinates (x,y); S_x and S_y are the gradient operators in the horizontal and vertical directions, respectively.

[0034] The formula for calculating the initial focus evaluation value F_i is as follows: F_i=average_{(x,y)∈Ω_i}G_i(x,y)×(1-P_sat,i)×(1-P_dark,i); In the formula, the average _{(x,y)∈Ω_i}G_i(x,y) represents the arithmetic mean of the gradient values ​​of all pixels in the effective evaluation region Ω_i, which is used to obtain the original sharpness score of the whole image; P_sat,i is the proportion of saturated pixels (the proportion of pixels whose grayscale reaches the maximum value or are overexposed due to oil film reflection) in the i-th frame of the focus evaluation image, and P_dark,i is the proportion of low-brightness pixels (the proportion of pixels in the dark spot area formed by bubbles and oil breakage).

[0035] The initial focus evaluation value is subjected to time-series smoothing to obtain the final focus evaluation value F_i′: F_i′=ρF_i+(1-ρ)F_(i-1)′; F_(i-1)′ is the focus evaluation value after smoothing in the (i-1)th frame, and ρ is the smoothing coefficient, which ranges from 0 to 1.

[0036] This calculation method combines clear texture, overexposure penalty, and dark field penalty to avoid false focus peaks caused by bubble spots or oil film reflections.

[0037] Images and corresponding focus evaluation values ​​are acquired within a preset Z-axis range at fixed step intervals. After smoothing and filtering, the focus evaluation values ​​are fitted with a quadratic curve to obtain the focus evaluation curve.

[0038] The data Z_i of the i-th Z-axis sampling point is defined as: Z_i={z_i,v_i,L_i,F_i,t_i}; wherein, t_i represents the sampling time. The data can be used to determine whether load mutation, abnormal focus curve or insufficient safety distance occurs when the oil immersion objective approaches the slide.

[0039] S3: analyzing the oil film detection image, and calculating an oil film continuity score, a bubble risk score and an abnormal oil amount score respectively; calculating a Z-axis safety risk score according to the Z-axis response data; if the Z-axis safety risk score exceeds a preset safety threshold, stopping the Z-axis from continuing to move downward and outputting a safety risk prompt; if the Z-axis safety risk score does not exceed the preset safety threshold, performing the next step.

[0040] In this step, the calculation method of the oil film continuity score is: dividing the oil film detection image into n sub-regions, and calculating brightness uniformity, definition and abnormal dark spot area ratio for each sub-region respectively; performing weighted summation on the brightness uniformity, definition and abnormal dark spot area ratio of each sub-region to obtain a continuity evaluation result value of the sub-region, then averaging the evaluation results of all sub-regions to obtain the oil film continuity score; wherein the brightness uniformity is calculated based on the average brightness and brightness standard deviation of the sub-region, the definition is calculated based on the Laplacian response of the sub-region, and abnormal dark spots are identified by local background subtraction combined with edge gradient constraints.

[0041] wherein, for the j-th sub-region Ω_j, the brightness uniformity is denoted as U_j, the definition is denoted as K_j, and the abnormal dark spot area ratio is denoted as A_j.

[0042] U_j=clamping[1-σ_j / (μ_j+ε),0,1] K_j=average_{(x,y)∈Ω_j}| ²I(x,y)| / (K_ref+ε) wherein, clamping[·,0,1] means limiting the calculation result between 0 and 1, ²I(x,y) is the Laplacian response of the image, and K_ref is the definition reference value of a standard oil film sample at the same magnification and under the same exposure. ε is a very small positive number used to prevent the denominator from being zero in numerical calculation.

[0043] the abnormal dark spot area ratio A_j is obtained by local background subtraction, and the local background B_j(x,y) is obtained by median filtering: the gray value D_j(x,y) of pixels in the j-th sub-region Ω_j of the oil film detection image is: when I(x,y)<B_j(x,y)-τ_d and | ∇I(x,y)|>τ_g, D_j(x,y)=1; otherwise, D_j(x,y)=0; In the formula, τ_d is the gray-level difference threshold of the dark spot (a preset constant), and I(x,y) is the original image gray-level value at coordinates (x,y); I(x,y)| represents the grayscale gradient magnitude of the pixel; τ_g is the edge gradient threshold (a preset constant).

[0044] When D_j(x,y) is 1, the pixel is identified as an abnormal dark spot pixel, belonging to the oil film defect area; When the value is 0: the pixel is judged as a normal pixel and is not an abnormal dark spot.

[0045] A_j=Σ_{(x,y)∈Ω_j}D_j(x,y) / |Ω_j|; Σ_{(x,y)∈Ω_j} represents the summation of the grayscale values ​​D_j(x,y) of all pixels within the sub-region Ω_j. Since D_j(x,y) only takes two values, 0 and 1, the summation essentially counts the total number of pixels within the sub-region that are identified as abnormal dark spots, which is equivalent to the pixel area of ​​the dark spots. |Ω_j| represents the total number of pixels within the sub-region Ω_j.

[0046] The formula for calculating the oil film continuity score C_oil is as follows: C_oil=(1 / n)×Σ_j(a_1×U_j+a_2×K_j+a_3×A_j); In the formula, a_1, a_2, and a_3 are all weighting coefficients, with a_3 taking a negative value.

[0047] A higher C_oil indicates a more continuous oil film and greater suitability for oil immersion scanning. If C_oil is below a preset continuity threshold, the oil film may be found to be interrupted, low in oil, or contaminated.

[0048] The calculation method for the bubble risk score is as follows: Filtering and background estimation are performed on the oil film detection image, and a bubble candidate mask is generated by using the dark spot grayscale threshold and the annular edge response; Connectivity analysis is performed on the bubble candidate mask to screen out suspected bubble regions that meet the preset area and roundness judgment conditions; The number of suspected bubbles, the total area of ​​suspected bubbles, the bubble edge intensity value, and the bubble roundness value are extracted, and the bubble risk score is calculated based on the number of suspected bubbles, the total area of ​​suspected bubbles, the bubble edge intensity value, and the bubble roundness value.

[0049] In oil film images, bubbles typically appear as localized circular dark spots, bright rings at the edges, abrupt changes in sharpness, or focal anomalies. A bubble risk score is calculated by extracting the number of suspected bubbles (B_n), the total area of ​​suspected bubbles (B_a), the bubble edge intensity (B_e), and the bubble roundness value (B_c).

[0050] The extraction method for the above parameters is as follows: Performing bilateral filtering or Gaussian filtering on the oil film detection image I(x,y) to suppress random noise; obtaining a background image B(x,y) by large-window median filtering or morphological opening operation; then generating a bubble candidate mask M_b(x,y) based on dark spot responses and edge annular responses: When I(x,y)<B(x,y)-τ_b or R_edge(x,y)>τ_e, M_b(x,y)=1; Otherwise, M_b(x,y)=0; Wherein, R_edge(x,y) is the annular edge response formed by the brightness difference between the inner and outer rings, τ_b and τ_e are a dark spot threshold and an edge threshold respectively. Connected component analysis is performed on M_b(x,y) to obtain the area A_q, perimeter L_q, average boundary gradient E_q and circularity C_q of the q-th candidate region: C_q=4πA_q / (L_q²+ε); When A_min≤A_q≤A_max and C_q≥C_min, the candidate region is retained as a suspected bubble region, and the circularity C_q at this time is the bubble circularity value B_c. Wherein, A_min is a minimum area threshold, A_max is a maximum area threshold, and C_min is a minimum circularity threshold.

[0051] Extracting the number of suspected bubbles B_n, the total area of suspected bubbles B_a, the bubble edge intensity B_e and the bubble circularity value B_c, and normalizing the above parameters.

[0052] The final calculation formula for the bubble risk score R_bubble is: R_bubble=b_1×B_n+b_2×B_a+b_3×B_e+b_4×B_c Wherein, b_1, b_2, b_3, and b_4 are all weighting coefficients. If R_bubble exceeds the bubble risk threshold, it is determined that the current oil film has bubble risk, and the region where the bubbles are located is recorded.

[0053] The calculation method of the oil amount abnormality score is: calculating the average brightness and contrast of the effective region of the oil film, and calculating the peak position of the focus based on a focus evaluation curve; deviating the average brightness, contrast and focus peak position from the reference brightness, reference contrast and reference focus position corresponding to the standard oil film respectively to obtain an average brightness deviation, a contrast deviation and a focus peak position deviation, and performing weighted summation on the average brightness deviation, contrast deviation and focus peak position deviation to obtain the oil amount abnormality score.

[0054] Wherein, the formula of the focus evaluation curve is: F(z)=αz²+βz+γ, z∈N_k; In the formula, α, β, and γ are all polynomial coefficients; The formula for calculating the focal peak position Z_peak is as follows: Z_peak = -β / (2α); In the formula, N_k is the neighborhood formed by several Z-axis sampling points before and after the peak sampling point; When the fitting accuracy does not meet the preset fitting accuracy requirement, the peak position of the backup focus is calculated using the peak neighborhood weighted centroid method. The specific calculation formula is as follows: Z_peak=Σ_{i∈N_k}z_i·F_i′ / Σ_{i∈N_k}F_i′; In the formula, z_i is the physical coordinate of the Z-axis corresponding to the i-th sampling point in the neighborhood N_k, that is, the height of the objective lens at that sampling point; the numerator Σ_{i∈N_k}z_i·F_i′ in the formula represents the weighted summation of the Z-axis positions with the focus evaluation value as the weight; the denominator Σ_{i∈N_k}F_i′ represents the sum of all focus evaluation values ​​in the neighborhood N_k.

[0055] Average brightness I_oil and contrast ratio K_oil are calculated based on the effective oil film area Ω_oil, respectively: I_oil=average_{(x,y)∈Ω_oil}I(x,y); K_oil = average_{(x,y)∈Ω_oil}| ²I(x,y)|; The final calculation formula for the oil quantity anomaly score R_oil is: R_oil=c_1×|I_oil-I_ref|+c_2×|K_oil-K_ref|+c_3×|Z_peak-Z_ref|; Where I_ref is the reference luminance corresponding to the standard oil film, K_ref is the reference contrast corresponding to the standard oil film, and Z_ref is the reference focal position corresponding to the standard oil film. I_oil represents the average luminance, and K_oil represents the contrast.

[0056] If the oil level abnormality score exceeds the preset oil level abnormality threshold, the type of oil level abnormality is determined based on the average brightness, contrast and the offset direction of the focal peak position, and adjustment suggestions are given based on the type of oil level abnormality. The types of oil level abnormality include low oil, excessive oil or uneven oil film thickness.

[0057] The Z-axis safety risk score R_z is calculated based on the difference between the current working distance and the minimum safe distance, the change in motor load, the Z-axis speed, and the offset of the focus evaluation curve. The offset of the focus evaluation curve is the offset between the current measured focus evaluation curve and the preset standard focus evaluation curve. When the Z-axis safety risk score exceeds the preset Z-axis safety risk threshold, it is determined that there is a risk of collision, scraping, or abnormal contact, and the Z-axis will stop descending.

[0058] The formula for calculating the Z-axis safety risk score R_z is as follows: R_z=d_1 / (D_z-D_safe+ε)+d_2×ΔL+d_3×v_z+d_4×|ΔF_z|; In the formula, ε is the minimum value to prevent the denominator from being zero, and d_1 to d_4 are all weighting coefficients. D_z is the current working distance, which refers to the current distance between the oil mirror and the slide, D_safe is the minimum safe distance, ΔL is the change in motor load, v_z is the Z-axis speed, and ΔF_z is the offset of the focus evaluation curve.

[0059] S4: Start the oil immersion scan and calculate the scan stability score in real time during the scan; after the oil immersion scan is completed, switch to the preset blank inspection area to acquire the contamination detection image, and calculate the contamination risk score based on the contamination detection image and the clean reference image.

[0060] The method for calculating the scan stability score is as follows: The scanning process divides each frame of the image into multiple sub-regions, and obtains the sharpness, brightness, and abnormal region ratio of each sub-region. The average sharpness, sharpness variance, brightness variance, and abnormal region ratio of all images are calculated. The average sharpness, sharpness variance, brightness variance, and abnormal region ratio are weighted and summed to obtain the scanning stability score S_img. When the scanning stability score is lower than the preset stability threshold, it is determined that there is a risk of oil film diffusion, bubble movement, oil breakage, or increased contamination during the oil immersion scanning process.

[0061] The criteria for determining the abnormal region A_i are as follows: In the i-th pollution detection image, if any sub-region simultaneously or individually exhibits at least one of the following: local clarity below the threshold, local brightness deviating from the background of the entire image, abnormal dark or bright spots, oil film trailing near the splicing seam, or bubble movement traces, then the sub-region is counted as an abnormal region.

[0062] Specifically, the i-th pollution detection image is divided into r sub-regions Ω_i,r, and the sharpness K_i,r, average brightness I_i,r, and dark spot area ratio A_dark,i,r of each sub-region are calculated.

[0063] When K_i,r<τ_K or |I_i,r-average(I_i)|>τ_I or A_dark,i,r>τ_A, H_i,r=1; Otherwise, H_i,r=0; The abnormal region A_i is: A_i=Σ_rH_i,r·|Ω_i,r| / Σ_r|Ω_i,r|; Where H_i,r is the anomaly marker of the r-th sub-region of the i-th image, and τ_K, τ_I, and τ_A are the thresholds for sharpness, brightness deviation, and dark spot area ratio, respectively. The numerator Σ_rH_i,r·|Ω_i,r| is the total area of ​​all anomalous sub-regions, and the denominator Σ_r|Ω_i,r| represents the total area of ​​effective detection in the image.

[0064] The formula for calculating the scan stability score S_img is: S_img = e_1 × mean (K_i) - e_2 × variance (K_i) - e_3 × variance (I_i) - e_4 × mean (A_i); Among them, e_1 to e_4 are all weighting coefficients.

[0065] The method for calculating the pollution risk score is as follows: The contamination detection image is flattened and corrected. The flattened and corrected contamination detection image is then compared with the clean reference image to extract suspected oil contamination areas. The total area ratio of suspected oil contamination areas P_a, the number of suspected oil contamination areas P_n, the edge gradient of suspected oil contamination areas P_g, and the background brightness anomaly value of suspected oil contamination areas P_i are calculated. The total area ratio of suspected oil contamination areas, the number of suspected oil contamination areas, the edge gradient of suspected oil contamination areas, and the background brightness anomaly value of suspected oil contamination areas are weighted and summed to obtain the contamination risk score. When the contamination risk score exceeds the preset contamination threshold, a cleaning prompt is output and the contamination location is recorded.

[0066] The area percentage of suspected oil contamination P_a, the number of suspected oil contamination areas P_n, the oil contamination edge gradient P_g, and the background brightness anomaly value P_i are extracted using the following algorithm: First, the contamination detection image I_p(x,y) is flat-field corrected to obtain the flat-field corrected I_c(x,y): I_c(x,y)=I_p(x,y) / (I_flat(x,y)+ε); Where I_flat(x,y) is a blank field of view or a uniformly illuminated calibration image, and ε is a minimum value to prevent the denominator from being zero; then, I_c(x,y) is subtracted from the clean reference image I_clean(x,y) to obtain the image difference result D_p(x,y): D_p(x,y)=|I_c(x,y)-I_clean(x,y)|.

[0067] When D_p(x,y)>τ_p and | When I_c(x,y)|>τ_pg, M_p(x,y)=1; Otherwise, M_p(x,y)=0; Where M_p(x,y) is a binary mask for contamination detection, used to mark whether the pixel at coordinates (x,y) is a suspected oil stain; I_c(x,y)| represents the gradient magnitude of the corrected image, characterizing the sharpness of the gray-level boundary at the pixel; τ_p is the pollution differential brightness threshold, and τ_pg is the oil stain edge gradient threshold. Only when the edge sharpness exceeds this threshold does it conform to the edge characteristics of oil stains.

[0068] P_a=ΣM_p(x,y) / A_check; P_n = N_p / N_check; P_g = average_{(x,y)∈boundary(M_p)}| I_c(x,y)|; P_i=|average_{M_p=1}I_c(x,y)-average_{M_p=0}I_c(x,y)| / (average_{M_p=0}I_c(x,y)+ε); Where A_check is the area of ​​the blank check region, N_p is the number of connected components, N_check is the quantity normalization factor set according to the area of ​​the check region, and the boundary (M_p) is the set of boundary pixels of the suspected oil contamination area. Isolated noise points with too small an area and insufficient edge gradient are filtered out by the minimum area threshold A_min and morphological opening and closing operations.

[0069] The formula for calculating the pollution risk score R_pollute is as follows: R_pollute=f_1×P_a+f_2×P_n+f_3×P_g+f_4×P_i; In the formula, f_1, f_2, f_3, and f_4 are all weighting coefficients.

[0070] S5: Calculate the comprehensive oil mirror test score based on oil film continuity score, bubble risk score, oil volume anomaly score, Z-axis safety risk score, scanning stability score, and contamination risk score. Output the test conclusion based on the comprehensive test score and locate the anomaly type.

[0071] The specific formula for calculating the comprehensive test score S is as follows: S=w_1×C_oil+w_2×S_img-w_3×R_bubble-w_4×R_oil-w_5×R_z-w_6×R_pollute; In the formula, w_1 to w_6 are all weight coefficients.

[0072] If the comprehensive test score S is greater than or equal to the pass threshold of the comprehensive test score S_pass, the oil microscope test is determined to be passed; If S_warn≤S_60<S_pass, it is determined as a warning and a recheck is required; If the comprehensive test score S is greater than or equal to the warning threshold of the comprehensive test score S_warn and less than the pass threshold of the comprehensive test score S_pass, it is determined as a warning and a recheck is required; If the comprehensive test score S is less than the warning threshold of the comprehensive test score S_warn, the test is determined to be failed.

[0073] The process of locating the risk type is specifically as follows: performing normalized ratio calculation on bubble risk, abnormal oil amount, Z-axis safety risk, contamination risk and oil film discontinuity respectively with corresponding judgment thresholds to generate an abnormal item set exceeding the thresholds; selecting the item with the largest normalized ratio as the main abnormal type, and taking the remaining items exceeding the thresholds as secondary abnormalities, and outputting an abnormal list from high to low according to the risk degree; when the Z-axis safety risk reaches the failure level, preferentially outputting a slide collision risk prompt and terminating the test; when the contamination risk is triggered simultaneously with oil film discontinuity and bubble risk, outputting an oil film-contamination coupling anomaly identifier.

[0074] The present invention also discloses an automatic test system for oil film state and safety risk used for oil microscope scanning, comprising: an oil microscope test scene construction module, configured to construct an oil microscope test scene set containing a plurality of preset test states, and configure the oil dripping mode and expected risk type corresponding to each test state; an oil film image acquisition module, configured to acquire an oil film detection image when the oil microscope approaches the test area, and acquire a contamination detection image in a blank inspection area after the oil microscope scanning is completed; a Z-axis response acquisition module, configured to synchronously acquire the Z-axis position, Z-axis speed, motor load and the focus evaluation value at the corresponding position during the Z-axis downward probing and automatic focusing process; an oil film state evaluation module, configured to calculate an oil film continuity score, a bubble risk score and an abnormal oil amount score respectively based on the oil film detection image; a Z-axis safety evaluation module, configured to calculate a Z-axis safety risk score based on Z-axis response data, and trigger a Z-axis stop downward probing instruction when the Z-axis safety risk score exceeds a preset Z-axis safety risk threshold; a scanning stability evaluation module, configured to calculate an image scanning stability score in real time during the oil microscope scanning process; a contamination risk evaluation module, configured to calculate a contamination risk score after scanning according to the contamination detection image and a clean reference image; The comprehensive judgment and report output module is used to calculate the comprehensive oil immersion test score and output the test results.

[0075] Compared with existing technologies, the present invention has the following advantages: 1. This invention addresses the problems of inconsistent judgment standards and difficulty in distinguishing anomaly types in traditional manual testing. It decomposes the oil film status into three quantifiable dimensions: continuity, bubble risk, and oil quantity anomaly. Through algorithms such as image partitioning calculation, gradient feature extraction, and focus position offset comparison, it outputs objective numerical scores. The oil film continuity score, through weighted calculation of brightness uniformity, clarity, and dark spot ratio, can reliably identify anomalies that are easily overlooked by the naked eye, such as oil gaps and local oil film unevenness. The bubble risk score, combined with dark spot grayscale, edge ring features, and roundness constraints, accurately filters bubbles and eliminates false defects caused by uneven lighting. The oil quantity anomaly score, through deviations of average brightness, contrast, and focus peak position from standard samples, can quantitatively distinguish between insufficient oil, excessive oil, and uneven oil film thickness. This design transforms qualitative judgments that originally relied on human experience into reproducible and traceable quantitative indicators, significantly improving the consistency of results between different testers and different test batches, and can directly support standardized factory quality inspection in the mass production stage.

[0076] 2. This invention addresses the lag inherent in traditional testing methods that rely on hard limits and manual shutdown. It establishes a Z-axis safety risk assessment model based on multi-parameter fusion. By calculating in real-time Z-axis working distance, motor load changes, movement speed, and abnormal focusing curve values, the model can identify risks of slide collisions and scraping before physical contact occurs between the objective lens and the slide. When the safety risk score exceeds a threshold, the system proactively stops Z-axis downward movement and outputs an alarm. This effectively addresses various risk scenarios such as abnormal slide height, Z-axis movement accuracy deviation, and abnormal oil film condition, preventing hardware damage to the objective lens and slide. Simultaneously, it supports safe operation in long-term unattended testing scenarios such as life testing, significantly improving equipment safety and reliability during the testing process.

[0077] 3. This invention breaks through the limitations of traditional testing that only focuses on the final imaging result, and constructs a closed-loop evaluation capability covering the entire process of oil immersion immersion scanning: before scanning starts, the oil film status is screened and safety risks are checked, and the scanning process is not started if the status is unqualified, thus avoiding invalid scanning and hardware risks from the source; during scanning, the image clarity fluctuation, brightness stability, and abnormal area ratio are monitored in real time, and the imaging attenuation caused by dynamic changes such as oil film diffusion, bubble displacement, and oil film breakage can be captured, distinguishing between instantaneous fluctuations and stability failures; after scanning, the risk of residual oil contamination on the objective lens, slide, stage, and dry lens path is automatically detected, and the contamination location, risk level, and cleaning and maintenance suggestions are output; this complete closed-loop testing system of the invention achieves full life cycle risk coverage of oil immersion immersion scanning, which not only ensures imaging quality, but also provides data support for daily equipment maintenance.

[0078] This invention is not limited to the preferred embodiments described above. Anyone can derive other products in various forms under the guidance of this invention. However, regardless of any changes in shape or structure, any technical solution that is the same as or similar to this application falls within the protection scope of this invention.

Claims

1. An automated testing method for oil film state and safety risk in oil immersion scanning, characterized in that, The specific steps include the following: S1: Construct a set of oil film test scenarios. The set of test scenarios includes a variety of preset oil film states. Each oil film state corresponds to a dripping method and expected risk type. S2: Control the oil mirror to move towards the test area, and acquire an oil film detection image when it approaches the test area. At the same time, acquire Z-axis response data during Z-axis downward movement and autofocus. The Z-axis response data includes Z-axis position, Z-axis speed, motor load, and focus evaluation value at the corresponding position. Fit a focus evaluation curve based on the focus evaluation value. S3: Analyze the oil film detection images and calculate the oil film continuity score, bubble risk score, and oil quantity anomaly score respectively; And calculate the Z-axis safety risk score based on the Z-axis response data; If the Z-axis safety risk score exceeds the preset safety threshold, the Z-axis will stop descending and a safety risk warning will be output. If the Z-axis safety risk score does not exceed the preset safety threshold, proceed to the next step; S4: Start the oil immersion scan and calculate the scan stability score in real time during the scan; After the oil immersion scan is completed, switch to the preset blank inspection area to acquire a contamination detection image, and calculate the contamination risk score based on the contamination detection image and the clean reference image; S5: Calculate the comprehensive oil mirror test score based on oil film continuity score, bubble risk score, oil volume anomaly score, Z-axis safety risk score, scanning stability score, and contamination risk score. Output the test conclusion based on the comprehensive test score and locate the anomaly type.

2. The automated testing method for oil film state and safety risk in oil immersion scanning according to claim 1, characterized in that, The focus evaluation value F_i is calculated from the focus evaluation image corresponding to the i-th Z-axis sampling position. The specific calculation method is as follows: First, select an effective evaluation region in the focus evaluation image. Then, remove saturated pixels, invalid edge regions, and obvious dark areas from the effective evaluation region. Next, calculate the horizontal and vertical gradient responses. Based on the horizontal and vertical gradient responses, the proportion of saturated pixels, and the proportion of low-brightness pixels, calculate the initial focus evaluation value. Finally, perform temporal smoothing on the initial focus evaluation value to obtain the final focus evaluation value. Images and corresponding focus evaluation values ​​are acquired within a preset Z-axis range at fixed step intervals. After smoothing and filtering, the focus evaluation values ​​are fitted with a quadratic curve to obtain the focus evaluation curve.

3. The automated testing method for oil film state and safety risk in oil immersion scanning according to claim 1, characterized in that, The calculation method for the oil film continuity score is as follows: The oil film detection image is divided into n sub-regions. For each sub-region, the brightness uniformity, sharpness, and abnormal dark spot area ratio are calculated. The brightness uniformity, sharpness, and abnormal dark spot area ratio of each sub-region are weighted and summed to obtain the sub-region continuity evaluation result. The average of the evaluation results of all sub-regions is then taken to obtain the oil film continuity score. Among them, the brightness uniformity is calculated based on the average brightness and brightness standard deviation of the sub-region, the sharpness is calculated based on the Laplacian response of the sub-region, and the abnormal dark spots are identified by local background subtraction combined with edge gradient constraints.

4. The automated testing method for oil film state and safety risk in oil immersion scanning according to claim 1, characterized in that, The calculation method for bubble risk score is as follows: filter and background estimation are performed on the oil film detection image, and bubble candidate masks are generated by dark spot grayscale threshold and annular edge response; connected component analysis is performed on the bubble candidate masks to screen out suspected bubble regions that meet the preset area judgment condition and roundness judgment condition; The number of suspected bubbles, the total area of ​​suspected bubbles, the bubble edge intensity value, and the bubble roundness value are extracted. Based on the number of suspected bubbles, the total area of ​​suspected bubbles, the bubble edge intensity value, and the bubble roundness value, a bubble risk score is calculated.

5. The automated testing method for oil film state and safety risk in oil immersion scanning according to claim 1, characterized in that, The calculation method for the oil volume anomaly score is as follows: calculate the average brightness and contrast of the effective area of ​​the oil film, and at the same time calculate the focus peak position based on the focus evaluation curve. The average brightness, contrast, and focal peak position are deviated from the reference brightness, reference contrast, and reference focal position corresponding to the standard oil film, respectively, to obtain the average brightness deviation, contrast deviation, and focal peak position deviation. The average brightness deviation, contrast deviation, and focal peak position deviation are weighted and summed to obtain the oil volume anomaly score. If the oil level abnormality score exceeds the preset oil level abnormality threshold, the type of oil level abnormality is determined based on the average brightness, contrast and the offset direction of the focal peak position, and adjustment suggestions are given based on the type of oil level abnormality. The types of oil level abnormality include low oil, excessive oil or uneven oil film thickness.

6. The automated testing method for oil film state and safety risk in oil immersion scanning according to claim 5, characterized in that, The formula for the focus evaluation curve is: F(z)=αz²+βz+γ, z∈N_k; In the formula, α, β, and γ are all polynomial coefficients; The formula for calculating the focal peak position Z_peak is as follows: Z_peak = -β / (2α); In the formula, N_k is the neighborhood formed by several Z-axis sampling points before and after the peak sampling point; When the fitting accuracy does not meet the preset fitting accuracy requirements, the peak position of the backup focus is calculated using the peak neighborhood weighted centroid method.

7. The automated testing method for oil film state and safety risk in oil immersion scanning according to claim 1, characterized in that, The method for calculating the scan stability score is as follows: The frame-by-frame images during the scanning process are divided into multiple sub-regions, and the sharpness, brightness, and percentage of abnormal areas in each sub-region are obtained. The average sharpness, sharpness variance, brightness variance, and average percentage of abnormal areas of all images are calculated. The average sharpness, sharpness variance, brightness variance, and average percentage of abnormal areas are weighted and summed to obtain the scanning stability score. When the scanning stability score is lower than the preset stability threshold, it is determined that there is a risk of oil film diffusion, bubble movement, oil breakage, or increased contamination during the oil immersion scanning process.

8. The automated testing method for oil film state and safety risk in oil immersion scanning according to claim 1, characterized in that, The method for calculating the pollution risk score is as follows: The pollution detection image is flattened and corrected. The pollution detection image after flattening and correction is then compared with the clean reference image to extract suspected oil pollution areas. The total area ratio of suspected oil pollution areas, the number of suspected oil pollution areas, the edge gradient of suspected oil pollution areas, and the abnormal value of background brightness of suspected oil pollution areas are calculated. The pollution risk score is calculated by weighting and summing the total area ratio of suspected oil pollution areas, the number of suspected oil pollution areas, the edge gradient of suspected oil pollution areas, and the background brightness anomalies of suspected oil pollution areas. When the pollution risk score exceeds the preset pollution threshold, a cleaning prompt is output and the location of the pollution is recorded.

9. The automated testing method for oil film state and safety risk in oil immersion scanning according to claim 1, characterized in that, The Z-axis safety risk score is calculated based on the difference between the current working distance and the minimum safe distance, the change in motor load, the Z-axis speed, and the offset of the focus evaluation curve. The offset of the focus evaluation curve is the offset between the current measured focus evaluation curve and the preset standard focus evaluation curve. When the Z-axis safety risk score exceeds the preset Z-axis safety risk threshold, it is determined that there is a risk of collision, scraping, or abnormal contact, and the Z-axis is stopped from continuing to descend.

10. An automated testing system for oil film state and safety risk in oil immersion scanning, used to implement the automated testing method for oil film state and safety risk in oil immersion scanning as described in any one of claims 1-9, characterized in that, include: The oil immersion test scenario construction module is used to build a set of oil immersion test scenarios containing multiple preset test states, and to configure the oil dripping method and expected risk type corresponding to each test state; The oil film image acquisition module is used to acquire oil film detection images when the oil immersion lens approaches the test area, and to acquire contamination detection images in the blank inspection area after the oil immersion lens scan is completed. The Z-axis response acquisition module is used to simultaneously acquire Z-axis position, Z-axis speed, motor load, and corresponding focus evaluation values ​​during Z-axis descent and autofocus. The oil film status evaluation module is used to calculate the oil film continuity score, bubble risk score, and oil volume anomaly score based on the oil film detection image. The Z-axis safety evaluation module is used to calculate the Z-axis safety risk score based on the Z-axis response data. When the Z-axis safety risk score exceeds the preset Z-axis safety risk threshold, a Z-axis stop-descending command is triggered. The scanning stability evaluation module is used to calculate the image scanning stability score in real time during the oil immersion scanning process; The pollution risk assessment module is used to calculate the pollution risk score after scanning based on the pollution detection image and the clean reference image. The comprehensive judgment and report output module is used to calculate the comprehensive oil immersion test score and output the test results.