A calibration method, device, medium and product for line-spectral confocal systems
By combining cubic spline fitting with boundary and smoothing conditions, the problem of low calibration accuracy of line spectrum confocal systems is solved, achieving higher accuracy and stable calibration results, adapting to complex data distributions, and avoiding global fitting distortion and endpoint errors.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING ZHONGKE HUIYI TECHNOLOGY CO LTD
- Filing Date
- 2025-12-08
- Publication Date
- 2026-06-23
Smart Images

Figure CN122265411A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of line spectrum confocal calibration technology, and in particular to a calibration method, device, medium and product for line spectrum confocal systems. Background Technology
[0002] Linear spectral confocal systems are high-precision three-dimensional measurement systems based on the principle of spectral confocalization. They acquire surface height information of objects through spectral scanning and optical imaging, and are widely used in surface topography measurement, three-dimensional contour reconstruction, and thin film thickness detection. This system utilizes polychromatic light emitted from a broadband light source, focusing different wavelengths of light at different axial positions through a dispersive objective lens, forming focal points distributed along the optical axis. When the surface of the object being measured is located at a specific axial position, the light of the corresponding wavelength is strongly reflected and demodulated by the spectrometer, thereby achieving accurate measurement of the object's surface height. Due to its advantages such as non-contact operation, high resolution, and strong anti-interference capability, linear spectral confocal technology plays a crucial role in online inspection and quality control in precision manufacturing, microelectronics, and biomedicine.
[0003] Currently, the measurement accuracy of line spectral confocal systems is highly dependent on accurate calibration. In practical applications, factors such as manufacturing errors of optical components, assembly deviations, environmental temperature variations, and spectrometer response nonlinearity can lead to discrepancies between the actual response and the theoretical model, thus affecting the accuracy of the measurement results. Therefore, precise calibration of the spectral confocal system is essential to establish an accurate mapping relationship between spectral wavelengths (or pixel positions) and actual physical heights. For the calibration of line spectral confocal systems, the industry currently commonly uses polynomial fitting calibration methods. However, the calibration accuracy using polynomial fitting methods is relatively low. Summary of the Invention
[0004] The purpose of this application is to provide a calibration method, device, medium, and product for a line spectrum confocal system, which can improve the calibration accuracy of the line spectrum confocal system.
[0005] To achieve the above objectives, this application provides the following solution: In a first aspect, this application provides a calibration method for a line spectral confocal system, comprising: The target line spectrum confocal system is used to obtain the spectral images formed by plane mirrors at different heights at each calibration point, thus obtaining the target spectral image at each calibration point. For each calibration point, the target spectral image is extracted at the column level to obtain the peak position-height correspondence data for each column of spectral data at each calibration point; A dataset is constructed based on the peak position-height correspondence data of the same column of spectral data from all calibration points; Based on each constructed dataset, and in conjunction with the set constraints, cubic spline fitting is performed to obtain a cubic spline fitting model for each column of spectral data of the target line spectral confocal system; wherein, the constraints include boundary conditions and smoothing conditions.
[0006] Optionally, based on each constructed dataset and combined with the set constraints, cubic spline fitting is performed to obtain a cubic spline fitting model for each column of spectral data of the target line spectral confocal system, specifically including: Each dataset is divided into a training set and a test set; Cross-validation is performed on the corresponding cubic spline models based on the training set of each dataset to select the optimal hyperparameters for each cubic spline model; Based on the optimal hyperparameters of each cubic spline model, the cubic spline model with the corresponding optimal hyperparameter configuration is retrained using each training set; The cubic spline fitting model trained on the corresponding training set is tested on each test set to evaluate the fitting error of the retrained cubic spline fitting model.
[0007] Optionally, the step of cross-validating the corresponding cubic spline models based on the training set of each dataset to select the optimal hyperparameters for each cubic spline model specifically includes: Each training set is used as the target training set, and each candidate hyperparameter combination in the target training set is used as the target hyperparameter combination. Perform a verification operation for each target hyperparameter combination: Based on the target hyperparameter combination, cubic spline fitting is performed using K-1 data points in the target training set to obtain K-1 fitting indices; where K is the total number of data points in the target training set. The remaining 1 data point in the target training set is used as a test sample to test the cubic polynomial of the fit, and the Kth fit index is obtained. After performing the verification operation, for each combination of target hyperparameters, the average value of the K test indicators is calculated; The optimal hyperparameters for the cubic spline fitting model corresponding to the target training set are selected by choosing the combination of K minimum average fitting indices.
[0008] Optionally, the step of performing cubic spline fitting using K-1 data points in the target training set based on the target hyperparameter combination specifically includes: The K-1 data points of the target training set are divided into multiple data intervals, and cubic spline fitting is performed on each data interval.
[0009] Optionally, the cubic spline fitting employs at least one of penalized spline fitting and Akima spline fitting.
[0010] Optionally, dividing the K-1 data points of the target training set into multiple data intervals specifically includes: The K-1 data points in the target training set are considered as a data interval between adjacent data points.
[0011] Optionally, the step of extracting the peaks at the sub-pixel level from the target spectral image of each calibration point column by column specifically includes: The brightest pixel is found in each column of spectral data of the target spectral image at each calibration point using the three-point comparison method. Starting from the brightest pixel, take n pixels above and below the starting point to obtain 2n+1 pixels. Perform Gaussian fitting on the 2n+1 pixels to obtain the peak position.
[0012] In a second aspect, this application provides a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the calibration method for a line spectral confocal system described in any one of the above descriptions.
[0013] Thirdly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the calibration method for a line spectral confocal system described above.
[0014] Fourthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the calibration method for a line spectral confocal system described above.
[0015] According to the specific embodiments provided in this application, the following technical effects are disclosed: This application provides a calibration method, device, medium, and product for a line spectrum confocal system. It acquires spectral images of the target line spectrum confocal system formed by measuring plane mirrors at different heights, obtaining the target spectral image at each height. After constructing datasets based on the peak position-height correspondence data of the same column of spectral data at all calibration points, cubic spline fitting is performed on each constructed dataset, combined with set constraints, to obtain a cubic spline fitting model for each column of spectral data of the target line spectrum confocal system. The fitted cubic spline model characterizes the mapping relationship between the peak position and corresponding height of each column of spectral data of the target line spectrum confocal system, thus achieving calibration of the target line spectrum confocal system through cubic spline fitting.
[0016] By performing low-order cubic spline fitting, the problem of a surge in endpoint errors caused by high-order overfitting in polynomial fitting calibration methods, which leads to a decrease in calibration accuracy, is avoided. Simultaneously, the smoothing condition ensures a smooth transition between each data segment, and the control of boundary conditions prevents the accumulation of endpoint errors that could cause a decrease in calibration accuracy. Furthermore, since the fitting of each data interval depends only on its local data and is not affected by data from other regions, the calibration method of this application can adapt to complex, large-volume, or non-uniformly distributed data, avoiding the bias of traditional global fitting methods when facing local anomalies. This achieves more accurate and flexible calibration, avoiding the decrease in calibration accuracy caused by global fitting distortion. In summary, this application improves calibration accuracy. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 A schematic flowchart illustrating a calibration method for a line spectrum confocal system provided in an embodiment of this application; Figure 2 A schematic diagram of the functional modules of a calibration device for a line spectrum confocal system provided in an embodiment of this application; Figure 3 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0019] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0020] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0021] Currently, the method of calibrating linear spectral confocal systems using polynomial fitting suffers from global fitting distortion when dealing with large amounts of data or uneven data distribution, leading to a decrease in calibration accuracy. Furthermore, if the polynomial order of the polynomial fitting model is too high, Runge's phenomenon occurs, causing a surge in endpoint errors and resulting in decreased calibration accuracy at the edges of the measurement range.
[0022] To address the aforementioned issues, in one exemplary embodiment, such as Figure 1 As shown, a calibration method for a line spectral confocal system is provided. This method is executed by a computer device and includes the following steps 101 to 104. Wherein: Step 101: Obtain the spectral images formed by the target line spectral confocal system measuring plane mirrors at different heights at each calibration point, and obtain the target spectral image at each calibration point.
[0023] In this embodiment of the application, the target line spectrum confocal system refers to the line spectrum confocal system to be calibrated.
[0024] Step 102: Extract the peaks at the sub-pixel level from the target spectral image of each calibration point column by column to obtain the peak position-height correspondence data for each column of spectral data of each calibration point.
[0025] In this embodiment of the application, the peak position-height correspondence data of each column of spectral data is a data pair consisting of the peak position of each column of spectral data and the corresponding height data of that column of spectral data.
[0026] Step 103: Construct a dataset based on the peak position-height correspondence data of the same column of spectral data for all calibration points.
[0027] In this embodiment, the number of datasets constructed is the total number of columns in each target spectral image, the total number of elements in each dataset is the total number of calibration points in the target spectral image, and each element in each dataset is the peak-height correspondence data of the same column of spectral data for all calibration points. When constructing the dataset, the peak-height correspondence data of the corresponding column of spectral data for each calibration point is used as a data point in the dataset.
[0028] For example, if there are 2000 calibration points and each target spectral image has 5120 columns, then the peak position-height correspondence data of the first column of spectral data from the 2000 calibration points constitutes the first dataset, the peak position-height correspondence data of the second column of spectral data from the 2000 calibration points constitutes the second dataset, and so on, the peak position-height correspondence data of the 5120th column of spectral data from the 2000 calibration points constitutes the 5120th dataset.
[0029] Step 104: Based on each constructed dataset and combined with the set constraints, perform cubic spline fitting to obtain a cubic spline fitting model for each column of spectral data of the target line spectral confocal system; wherein, the constraints include boundary conditions and smoothing conditions.
[0030] In this embodiment, the smoothing condition, or smoothness constraint, refers to the continuity condition of the spline curve, including continuous function values, continuous first derivative, and continuous second derivative.
[0031] The resulting cubic spline fitting model characterizes the mapping relationship between the peak position and the corresponding height of each column of spectral data in the target line spectral confocal system.
[0032] By implementing steps 101 to 103 above, spectral images formed by measuring plane mirrors at different heights of the target line spectral confocal system are obtained, resulting in target spectral images at each height. After constructing datasets based on the peak position-height correspondence data of the same column of spectral data at all calibration points, cubic spline fitting is performed on each constructed dataset in combination with the set constraints to obtain a cubic spline fitting model for each column of spectral data of the target line spectral confocal system. The fitted cubic spline fitting model represents the mapping relationship between the peak position and the corresponding height of each column of spectral data of the target line spectral confocal system, thus realizing the calibration of the target line spectral confocal system through cubic spline fitting.
[0033] By performing low-order cubic spline fitting, the problem of a surge in endpoint errors caused by high-order overfitting in polynomial fitting calibration methods, which leads to a decrease in calibration accuracy, is avoided. Simultaneously, the smoothing condition ensures a smooth transition between each data segment, and the control of boundary conditions prevents the accumulation of endpoint errors that could cause a decrease in calibration accuracy. Furthermore, since the fitting of each data interval depends only on its local data and is not affected by data from other regions, the calibration method of this application can adapt to complex, large-volume, or non-uniformly distributed data, avoiding the bias of traditional global fitting methods when facing local anomalies. This achieves more accurate and flexible calibration, avoiding the decrease in calibration accuracy caused by global fitting distortion. In summary, this application improves calibration accuracy.
[0034] The embodiments of this application use a cubic spline fitting model, which fully considers phenomena such as data errors and noise disturbances. Various constraints can be added during fitting to mitigate such effects. In addition, cubic spline fitting will not produce Runge phenomenon, thus avoiding excessive endpoint errors.
[0035] In another exemplary embodiment of this application, the calibration method for a line spectral confocal system described above further includes, before step 101: Step 201: Adjust the plane mirror to be within the range of the line spectrum confocal sensor of the line spectrum confocal system.
[0036] In this embodiment, the measured object can be adjusted to be within the range of the line spectrum confocal sensor by adjusting its position, or the measured object can be adjusted to be within the range of the line spectrum confocal sensor by adjusting its position. There is no specific limitation on this, and the choice can be made according to actual needs.
[0037] In another exemplary embodiment of this application, step 201 specifically includes: By controlling the movement of the micro-motion platform, the plane mirror is moved into the range of the line spectrum confocal system.
[0038] In this embodiment, the plane mirror is adjusted by moving the micro-motion platform up and down, so that the light stripe reflected by the plane mirror is within the visible area of the online spectral confocal sensor. The clear range above and below the center of the linear CMOS is selected as the reference, and the displacement of the micro-motion platform is recorded to ensure that it is within the designed depth of field range.
[0039] In another exemplary embodiment of this application, step 101 specifically includes: After the acquisition program is started, the micro-motion platform moves gradually from low to high or from high to low according to the preset acquisition step size based on the measured height of the plane mirror, so that the acquired data meets the monotonicity constraint (such as monotonically increasing or decreasing). The camera is started at each table vertex. The camera will automatically adjust the exposure time according to the brightness of the real-time acquired spectral image and continue to shoot until the spectral image reaches the preset target brightness. When the spectral image reaches the preset target brightness, a set number of spectral images are acquired, and the average of multiple acquisitions is used to eliminate occasional errors.
[0040] In another exemplary embodiment of this application, step 104 specifically includes steps 301 to 304, wherein: Step 301: Divide each dataset into a training set and a test set.
[0041] In this embodiment, each dataset is divided into a training set and a test set for cross-validation. This allows for the evaluation of the performance of the fitted spline model on unknown data, thereby verifying its generalization ability.
[0042] Step 302: Cross-validate the corresponding cubic spline model based on the training set of each dataset to select the optimal hyperparameters for each cubic spline model.
[0043] In this embodiment, the optimal hyperparameter configuration is selected through cross-validation as the hyperparameters of the cubic spline fitting model. The hyperparameters include at least the smoothing coefficient, the number of nodes, and the node positions.
[0044] The smoothing coefficient is used at the node positions of the spline fitting model for the two data segments to ensure smoothness at the nodes.
[0045] The number of nodes refers to the number of intervals used for piecewise fitting in spline fitting, i.e., the number of "nodes" connecting data points. Each node is a key position in the fitted curve that needs to be controlled, and the number of nodes directly determines the complexity of the fitting. The more nodes, the more complex the fitted polynomial, and the better it can adapt to local variations in the data. However, too many nodes may lead to overfitting, and the fitted curve may over-respond to noise or local outliers. Therefore, appropriately increasing the number of nodes allows for fitting at a finer scale, resulting in more accurate fitting results, especially when the data distribution is uneven or there are large local variations.
[0046] Node location refers to the specific position of each node in the dataset, determining the split points of the fitted curve and the location of local fitting intervals. The node location determines the segmentation method of the fit. A cubic polynomial is fitted between every two adjacent nodes. Therefore, the choice of node location directly affects the data partitioning, and thus the fitting effect. Specifically, the choice of node location reflects the characteristic changes of the data; appropriate node locations ensure local adaptability. For example, if certain parts of the data change significantly or fluctuate frequently, more nodes can be added to these regions to achieve a more accurate fit to these changes. At the same time, appropriate node location selection can avoid overfitting and underfitting because node location not only affects the data partitioning but also the smoothness and adaptability of the fit. Inappropriate node location settings may lead to local overfitting or global poor fitting.
[0047] Cross-validation controls spline complexity and prevents overfitting / underfitting. Splines have high degrees of freedom: the number of nodes, node positions, and smoothness all significantly affect endpoint error and total error. Cross-validation can select the configuration with the smallest error and that meets the constraints on unknown data.
[0048] Furthermore, cross-validation robustly addresses heteroscedasticity and local anomalies: the SNR / curvature of spectral peaks varies significantly across different height ranges. Cross-validation can screen for solutions that are stable across the entire range (e.g., appropriately increasing node density in high curvature regions, improving smoothness / using robust weights in low SNR regions), preventing the model from being "led" by local anomalies. Additionally, it provides objective data for engineering thresholds and deployment decisions: cross-validation outputs the mean ± variance of indicators such as endpoint RMSE and overall P95 error, allowing for the setting of release thresholds and reducing deployment risks.
[0049] The release threshold is a standard used in the validation process of spline fitting models to determine whether the model meets quality requirements and can be put into practical application or deployment. The release threshold is typically a set of standards or tolerance ranges set during testing. If the prediction error or other indicators of the spline fitting model exceed this range, it indicates that the model cannot achieve the expected accuracy or stability, and therefore cannot be applied or deployed.
[0050] Through cross-validation, the spline fitting model generates several error metrics, such as endpoint RMSE (root mean square error) and whole-segment P95 error (95th percentile error). These metrics reflect the performance and stability of the spline fitting model on different datasets, and reflect its accuracy and physical plausibility. The acceptance threshold is set based on the mean ± variance of these error metrics, serving as a standard for judging whether the spline fitting model is acceptable. When setting the acceptance threshold, the mean and variance of these metrics can be utilized in the following ways: Endpoint RMSE (Root Mean Square Error): Endpoint RMSE refers to the root mean square value of the error of the fitted model at the endpoints (usually the beginning and end of the data). The smaller this index, the more accurate the fitted curve is at both ends of the data. A large endpoint error may mean that the fitting is inaccurate or unstable in the boundary region, which may affect the overall calibration accuracy. Global P95 error: The P95 error refers to the 95th percentile error over the entire dataset, meaning that the error is less than this value at 95% of the data points, reflecting the overall accuracy of the spline fitting model; Methods for setting the release threshold: Based on the results of cross-validation, the mean and variance of the endpoint RMSE are calculated. If the error exceeds a certain preset tolerance range (e.g., mean + 2 times the variance), the spline fitting model cannot be approved. The mean ± variance of the P95 error across the entire range can be used to set a range. If the error exceeds the predetermined upper limit (e.g., mean + 1.5 times the variance), it indicates that the overall fit of the model is poor and needs to be readjusted.
[0051] If the error of the spline fitting model exceeds the set threshold, it indicates that the spline fitting model may produce excessive errors in practical applications, affecting measurement accuracy. By setting appropriate allowance thresholds, it can be ensured that the deployed spline fitting model has an acceptable error range in practical applications, avoiding overfitting or underfitting, thereby controlling the error range and ensuring accuracy. By setting allowance thresholds for endpoint RMSE and P95 errors, the fitting accuracy of the spline fitting model in the boundary and global regions can be evaluated. If these indicators exceed the thresholds, it indicates that the spline fitting model is unstable in these regions, which may lead to errors or inaccurate measurement results in practical applications. Therefore, setting reasonable allowance thresholds helps avoid the risks caused by inaccurate spline fitting models after deployment. Simultaneously, during testing, cross-validation can not only evaluate the performance of the spline fitting model on known data but also test its generalization ability to unseen data. By setting allowance thresholds and ensuring their stability, it can be ensured that the deployed spline fitting model can maintain high accuracy in different application scenarios and environments, reducing the risks caused by instability or unexpected performance.
[0052] During cross-validation, error assessment at the endpoints (i.e., the beginning and end of the training set), particularly the RMSE (Root Mean Square Error) at the endpoints, helps determine the reasonableness of the fitting results. Excessive endpoint error may indicate that the fitted model cannot accurately capture changes in physical quantities at either end of the data set, especially when monotonicity requirements exist; controlling endpoint error is crucial in such cases. Calculating the RMSE at the endpoints allows evaluation of the model's accuracy across the entire dataset. Controlling the fitting error at the boundaries effectively prevents error accumulation from negatively impacting overall calibration accuracy.
[0053] Step 303: Based on the optimal hyperparameters of each cubic spline model, retrain the cubic spline model with the corresponding optimal hyperparameter configuration using each training set.
[0054] For example, if there are 3 training sets: the optimal hyperparameters of the first cubic spline model are selected from the first training set and denoted as the first hyperparameters. Then, the first cubic spline model with the first hyperparameter configuration is retrained using the first training set; the optimal hyperparameters of the second cubic spline model are selected from the second training set and denoted as the second hyperparameters. Then, the second cubic spline model with the second hyperparameter configuration is retrained using the second training set; the optimal hyperparameters of the third cubic spline model are selected from the third training set and denoted as the third hyperparameters. Then, the third cubic spline model with the third hyperparameter configuration is retrained using the third training set.
[0055] Step 304: Test the cubic spline fitting model trained on the corresponding training set using each test set to evaluate the fitting error of the retrained cubic spline fitting model.
[0056] For example, if there are 3 sets of training data: the cubic spline model retrained using the training set of the first set of training data is denoted as the first cubic spline model, and the test set of the first set of training data is used to test the first cubic spline model; the cubic spline model retrained using the training set of the second set of training data is denoted as the second cubic spline model, and the test set of the second set of training data is used to test the second cubic spline model; the cubic spline model retrained using the training set of the third set of training data is denoted as the third cubic spline model, and the test set of the third set of training data is used to test the third cubic spline model.
[0057] In this embodiment, error evaluation is measured using the mean absolute error (MAE). For each original height data point, the height value is predicted using a fitted cubic spline model. First, the absolute error for each data point is calculated: ; in, This is the actual height value. The height value is predicted using a cubic spline fitting model.
[0058] Then, calculate the average of the absolute errors for all data points to obtain the mean absolute error (MAE): ; Here, n is the total number of data points in the test set, and MAE, as an error assessment metric, can intuitively measure the accuracy of the fitted model. A smaller error indicates a better fit, while a larger error indicates a bias in the fit.
[0059] In another exemplary embodiment of this application, in step 302 above, the cross-validation employs leave-one-up cross-validation or grouped cross-validation.
[0060] In another exemplary embodiment of this application, step 302 above includes steps 401 to 404. Wherein: Step 401: Each training set is used as the target training set, and each candidate hyperparameter combination of the target training set is used as the target hyperparameter combination.
[0061] Step 402: Perform verification operations for each target hyperparameter combination: Based on the target hyperparameter combination, cubic spline fitting is performed using K-1 data points in the target training set to obtain K-1 fitting indices; where K is the total number of data points in the target training set. The remaining one data point in the target training set is used as a test sample to test the fitted cubic polynomial, thus obtaining the Kth fit index.
[0062] In this embodiment, the fitting index is not specifically limited and can be set according to actual needs. For example, absolute error can be used.
[0063] Step 403: After performing the verification operation, for each combination of target hyperparameters, calculate the average value of the K fitting indices.
[0064] Step 404: Select the candidate hyperparameter combination with the smallest average value of the K fitting indices as the optimal hyperparameter of the cubic spline fitting model corresponding to the target training set.
[0065] In another exemplary embodiment of this application, step 401 above, which involves performing cubic spline fitting using K-1 data points in the target training set based on the target hyperparameter combination, specifically includes: The K-1 data points of the target training set are divided into multiple data intervals, and cubic spline fitting is performed on each data interval.
[0066] In this embodiment of the application, each data interval corresponds to a set of continuous peak-height data. During the fitting process, it is necessary to ensure that the data changes within adjacent data intervals are smooth and continuous, that is, to meet the smoothness condition, ensure a smooth transition between data points, and avoid errors and discontinuities caused by global fitting.
[0067] The cubic polynomial for each data interval is used to describe the trend of data variation within that interval. The cubic polynomial fitting result for each data interval is calculated independently, but the continuity between adjacent data intervals is taken into account.
[0068] Regarding the continuity problem: Continuity of function values: The cubic polynomial fitting result of each data interval will be equal to the cubic polynomial fitting result of the adjacent data interval at the intersection point, ensuring the continuity of function values; First derivative continuity: The first derivative values of cubic polynomials in adjacent data intervals are equal at the intersection point, ensuring a smooth transition; Second derivative continuity: The second derivative values of cubic polynomials in adjacent data intervals are equal at the intersection point, further ensuring smoothness and avoiding abrupt changes.
[0069] In another exemplary embodiment of this application, in step 104 above, the boundary conditions include natural boundary conditions and fixed derivative boundary conditions.
[0070] In this embodiment, natural boundary conditions refer to assuming the second derivative is zero at both ends of the training set, i.e., requiring the curve at the endpoints to be "straight". Natural boundary conditions can reduce overfitting and avoid overly "curved" spline curves. Fixed boundary conditions refer to fixing the slope or curvature of the curve by giving the derivative at the endpoints. In some application scenarios, since the slope or curvature at the endpoints is known, it can be directly used as a boundary condition for constraint.
[0071] Setting boundary conditions can prevent calibration accuracy degradation caused by the accumulation of endpoint errors. First, it avoids overfitting at the boundaries. Without controlling boundary conditions, spline curves may overfit at the ends of the data, causing excessive curvature at the endpoints and increasing errors at the boundaries. This overfitting causes the fitted model to deviate from the true data in other regions (especially near the endpoints), thus reducing the accuracy of the entire calibration process. Overfitting can be avoided by reasonably controlling boundary conditions, such as setting natural boundary conditions or fixing endpoint derivatives. Second, it reduces the accumulation of endpoint errors. In cubic spline fitting, if the influence of boundary conditions is not considered, the fitting result may not perfectly match the curve fitting result at the endpoints, potentially resulting in large errors. These errors affect the entire fitting process, especially in cases with multiple calibration points, where errors may gradually accumulate and propagate to other parts. By controlling boundary conditions, the magnitude of errors can be controlled during the fitting process at the endpoints, ensuring that errors do not severely impact the accuracy of the entire system. Third, it ensures smooth transitions and endpoint smoothness. In cubic spline fitting, controlling boundary conditions ensures smooth transitions at the endpoints, preventing abrupt or uneven transitions when the curve reaches the boundary. For example, if the boundary conditions require the second derivative to be zero, the spline function will be more stable near the boundary. This helps prevent the boundary data from having an excessive influence on the fitting, thereby improving the overall stability of the fit. Additionally, it suppresses local anomalies. In actual calibration processes, data often contain some local outliers, especially in certain regions of the spectral image, which may deviate from expectations due to noise or measurement errors. Controlling the boundary conditions can effectively limit the influence of these local outliers to a small range in some cases, preventing them from adversely affecting the global fitting results.
[0072] In another exemplary embodiment of this application, the boundary conditions in step 104 above include weighted boundary conditions.
[0073] In some special cases, it may be necessary to weight the endpoints of the training set in order to reduce the impact of endpoint errors on the global fitting results.
[0074] For example, weighted least squares can be used to assign smaller weights to endpoint data, thereby reducing the impact of endpoint errors.
[0075] In another exemplary embodiment of this application, the cubic spline fitting in step 402 above employs at least one of penalized spline fitting and Akima spline fitting.
[0076] In another exemplary embodiment of this application, in step 402 above, penalized spline fitting is first used. If the fitting result is not ideal (e.g., the fitting index is greater than a preset error threshold), Akima spline fitting is switched to be used.
[0077] Generally, penalized splines are used for data fitting. The penalty term in the penalized spline can dynamically adjust the smoothness of the fitted curve. Penalized splines have fewer data intervals, making them the most balanced fitting method. When the fitting result is unsatisfactory, Akima splines can be used for refitting. Akima splines have smaller segments, meaning more data intervals, which addresses the problem that penalized splines with larger segments cannot guarantee smooth curve changes well when there is a lot of noise, resulting in many spikes or outliers. They have strong robustness to local outliers, allowing the fitted curve to remain smooth in areas of large local fluctuations without being overly affected by outliers.
[0078] The cubic spline method not only supports basic piecewise fitting, but also allows for the selection of different types of spline fitting (such as Akima splines or penalized splines) according to actual needs. This feature enables the embodiments of this application to flexibly adapt to different application scenarios and select the most suitable spline type, thereby improving calibration accuracy and adaptability.
[0079] In another exemplary embodiment of this application, the K-1 data points of the target training set are divided into multiple data intervals, specifically including: The K-1 data points in the target training set are used as a data interval to further ensure a smooth transition between data points.
[0080] In another exemplary embodiment of this application, in order to improve the fitting speed while ensuring the fitting effect, step 402 above uses a combination of penalized spline fitting and Akima spline fitting for fitting.
[0081] In this embodiment, for data with high local noise in the training set, Akima splines with smaller segment sizes (i.e., smaller data intervals) can be used for fitting. Conversely, for data with low local noise in the training set, penalized splines with larger segment sizes can be used for fitting, thereby achieving a combination of penalized splines and Akima splines for fitting the training set.
[0082] In another exemplary embodiment of this application, step 102 above, which involves extracting the peak sub-pixel level of the target spectral image for each calibration point column by column, specifically includes steps 501 to 502. Wherein: Step 501: Use the three-point comparison method to find the brightest pixel in each column of spectral data of each target spectral image at each calibration point.
[0083] In this embodiment, the spectral data of each column is extracted individually at the sub-pixel level based on the peak position, ensuring that the fitting process of each column is appropriately constrained, and a suitable fitting method is selected based on the data characteristics. Column-by-column constrained fitting helps improve the local adaptability of the data, enabling the fitting of each column to accurately capture the local changes in that column and reduce global fitting distortion.
[0084] Step 502: Taking the brightest pixel in each column of spectral data of each target spectral image as the starting point, take n pixels above and below the starting point (n is an empirical value) to obtain 2n+1 pixels. Perform Gaussian fitting on the 2n+1 pixels to obtain the peak position of each column of spectral data of each target spectral image (pixel space, unit is pixels).
[0085] In this embodiment, the light generally conforms to the Gaussian distribution characteristics. Therefore, by inputting the obtained (2n+1) pixels into the Gaussian model for fitting, the fitted parameter μ is the sub-pixel level peak position.
[0086] By extracting peaks at the subpixel level, the data is made robust, ensuring that the peak positions can still be accurately extracted from the spectral data even in the presence of noise, thus reducing the impact of noise on the fitting.
[0087] In another exemplary embodiment of this application, if the number of spectral images acquired for each calibration point is greater than 1, then step 102 above further includes: Step 503: Based on the peak position of each column of spectral data of each target spectral image of each calibration point, calculate the average peak position of the corresponding column of spectral data of all target spectral images of each calibration point, and use the average peak position as the peak position of the corresponding column of spectral data of each calibration point.
[0088] For example, if there are 5 target spectral images for each calibration point, then the average peak position of the first column of spectral data for each calibration point is the average of the peak positions of the first column of spectral data for the 5 target spectral images.
[0089] In another exemplary embodiment of this application, the Gaussian model used for Gaussian fitting is: ; in, μ σ represents the mean (the center of the distribution, also the mode and median), σ>0, and σ represents the standard deviation (controlling the width of the distribution). The peak height is represented by σ; x represents the input pixel position; and f(x) represents the peak height. x The probability density at that location.
[0090] This application employs cubic spline methods instead of traditional multi-order polynomial fitting, achieving significant improvements in endpoint accuracy, enhanced noise resistance, improved local adaptability, and support for monotonicity constraints. Compared to traditional methods, cubic spline methods can better handle complex datasets, adapt to different data distributions and noise levels, and provide higher accuracy calibration results. Through this innovative combination of technical features, this application not only overcomes the shortcomings of existing methods but also significantly improves the calibration accuracy of spectral images, demonstrating significant practical application value.
[0091] In this embodiment, cubic splines are used instead of traditional multi-order polynomial fitting, aiming to improve the accuracy and enhance the noise robustness of spectral image calibration through a series of technical means. Specifically, a spline calibration system is formed by combining techniques such as data robustness, mapping direction consistency, column-by-column constrained fitting, high-density grid, quality gate, and deployable encapsulation, which is end-point stable, globally overshoot-free, monotonically reversible, and easily deployable.
[0092] 1. Data Robustness: Makes the calibration process insensitive to noise and outliers, improving the accuracy and reliability of the calibration results.
[0093] The data is robustened by subpixel-level peak extraction to ensure that the peak positions can still be accurately extracted from the spectral data even in the presence of noise, thereby reducing the impact of noise on the fitting.
[0094] During the fitting process, Akima splines are used to enhance the robustness of local outliers, so that the fitted curve can remain smooth in data regions with large local fluctuations without being overly affected by outliers.
[0095] 2. Mapping Direction Consistency: Ensure that data transformations remain consistent at each stage (such as mapping from spectral data to altitude data), without any reversal or inconsistent mapping behavior.
[0096] 3. Column-Restricted Fitting: During the fitting process, each column of spectral data is processed or constrained independently to ensure that the fitting result of each column of data can better reflect the local features.
[0097] Specifically, the spectral data for each column is extracted individually at the sub-pixel level based on the peak position, ensuring that the fitting process for each column is appropriately constrained, and a suitable fitting method is selected based on the data characteristics.
[0098] Constrained fitting column by column helps improve the local adaptability of the data, enabling the fitting of each column to accurately capture the local changes in that column and reduce global fitting distortion.
[0099] 4. High-Density Grid: Increases the accuracy of the fitted data by using a higher sampling density, thereby improving the accuracy and detail of the final calibration results.
[0100] The micro-motion platform collects data from each calibration point through high-density sampling, making the dataset used in the fitting process more detailed and accurate.
[0101] High-density gratings provide more calibration points, thereby enhancing the accuracy of the fit and avoiding fitting errors caused by data sparsity.
[0102] 5. Quality Gate: This refers to controlling the quality of calibration results through preset standards or thresholds, ensuring that only calibration results that meet the standards can be accepted and used.
[0103] Cross-validation is used to test the accuracy of the final model, and release thresholds are set by calculating indicators such as endpoint RMSE and full-segment P95 error to ensure the quality of calibration results.
[0104] The quality gate ensures the reliability and accuracy of the calibration results, preventing the adoption of results with excessive calibration errors or those that do not meet physical requirements.
[0105] 6. Deployable Packaging: This refers to packaging calibration methods and models in a repeatable and easily deployable form to facilitate use and maintenance in practical applications.
[0106] By encapsulating calibration methods and models into easily deployable computer programs or devices, the method can be widely applied to practical spectral calibration tasks, thereby improving the operability and scalability of the calibration method. This enables the technology to be used not only in the laboratory but also in actual production and measurement.
[0107] In traditional polynomial fitting, the presence of higher-order terms can lead to overshoot, where the fitted curve exceeds the range of the actual data in certain regions, especially at data boundaries. Cubic spline fitting, through piecewise fitting (performing local fitting within each interval) and satisfying constraints, ensures that the fitted curve remains smooth in each interval, thus avoiding global overshoot.
[0108] Based on the same inventive concept, this application also provides a calibration apparatus for a line-spectrum confocal system for implementing the calibration method for a line-spectrum confocal system described above. The solution provided by this apparatus is similar to the implementation described in the above method. Therefore, the specific limitations of one or more embodiments of the calibration apparatus for a line-spectrum confocal system provided below can be found in the limitations of the calibration method for a line-spectrum confocal system described above, and will not be repeated here.
[0109] In one exemplary embodiment, such as Figure 2 As shown, a calibration device 70 for a line spectrum confocal system is provided, comprising: The image acquisition module 701 is used to acquire the spectral images formed by the plane mirrors at different heights measured at each calibration point by the target line spectral confocal system, and to obtain the target spectral image at each calibration point; Image processing module 702, used for: For each calibration point, the target spectral image is extracted at the column level to obtain the peak position-height correspondence data for each column of spectral data at each calibration point; A dataset is constructed based on the peak position-height correspondence data of the same column of spectral data from all calibration points; The calibration module 703 is used to perform cubic spline fitting on each constructed dataset and in combination with the set constraints to obtain a cubic spline fitting model for each column of spectral data of the target line spectral confocal system; wherein the constraints include boundary conditions and smoothing conditions.
[0110] For details of each step in this embodiment, please refer to the description of the above method embodiments, which will not be repeated here.
[0111] In another exemplary embodiment of this application, the calibration device 70 for a line spectrum confocal system described above further includes: The motion control module 704 is used to adjust the plane mirror to the range of the line spectrum confocal sensor of the line spectrum confocal system.
[0112] For details of each step in this embodiment, please refer to the description of the above method embodiments, which will not be repeated here.
[0113] In another exemplary embodiment of this application, the motion control module 704 is further configured to move the plane mirror into the range of the line spectrum confocal system by controlling the movement of the micro-motion platform.
[0114] In another exemplary embodiment of this application, the image acquisition module 701 is further configured to: After the acquisition program is started, the micro-motion platform moves gradually from low to high or from high to low according to the preset acquisition step size based on the measured height of the plane mirror, so that the acquired data meets the monotonicity constraint (such as monotonically increasing or decreasing). The camera is started at each table vertex. The camera will automatically adjust the exposure time according to the brightness of the real-time acquired spectral image and continue to shoot until the spectral image reaches the preset target brightness. When the spectral image reaches the preset target brightness, a set number of spectral images are acquired, and the average of multiple acquisitions is used to eliminate occasional errors.
[0115] In another exemplary embodiment of this application, the calibration module 703 is further configured to: Each dataset is divided into a training set and a test set; Cross-validation is performed on the corresponding cubic spline models based on the training set of each dataset to select the optimal hyperparameters for each cubic spline model; Based on the optimal hyperparameters of each cubic spline model, the cubic spline model with the corresponding optimal hyperparameter configuration is retrained using each training set; The cubic spline fitting model trained on the corresponding training set is tested on each test set to evaluate the fitting error of the retrained cubic spline fitting model.
[0116] For details regarding error assessment in this application embodiment, please refer to the description in the above method embodiment, which will not be repeated here.
[0117] In another exemplary embodiment of this application, the calibration module 703 is further configured to: Cross-validation is used to output the mean ± variance of indicators such as endpoint RMSE and overall P95 error. Based on this, the release threshold is set to reduce the risk of going live.
[0118] For details regarding the release threshold in this application embodiment, please refer to the description in the above method embodiment, which will not be repeated here.
[0119] In another exemplary embodiment of this application, the calibration module 703 is further configured to: Each training set is used as the target training set, and each candidate hyperparameter combination in the target training set is used as the target hyperparameter combination. Perform a verification operation for each target hyperparameter combination: Based on the target hyperparameter combination, cubic spline fitting is performed using K-1 data points in the target training set to obtain K-1 fitting indices; where K is the total number of data points in the target training set. The remaining 1 data point in the target training set is used as a test sample to test the cubic polynomial of the fit, and the Kth fit index is obtained. After performing the verification operation, for each combination of target hyperparameters, the average value of the K fitted indices is calculated; The candidate hyperparameter combination with the smallest average of the K fitting indices is selected as the optimal hyperparameter for the cubic spline fitting model corresponding to the target training set.
[0120] In another exemplary embodiment of this application, the calibration module 703 is further configured to: The K-1 data points of the target training set are divided into multiple data intervals, and cubic spline fitting is performed on each data interval. For details, please refer to the description of the above method implementation, which will not be repeated here.
[0121] In another exemplary embodiment of this application, the boundary conditions include natural boundary conditions and fixed derivative boundary conditions.
[0122] In another exemplary embodiment of this application, the boundary conditions include weighted boundary conditions.
[0123] In another exemplary embodiment of this application, the cubic spline fitting described above employs at least one of penalized spline fitting and Akima spline fitting.
[0124] In another exemplary embodiment of this application, the calibration module 703 is further configured to: When performing cubic spline fitting for each data interval, first use penalized spline fitting. If the fitting result is not ideal, switch to Akima spline fitting.
[0125] In another exemplary embodiment of this application, the calibration module 703 is further configured to: When performing cubic spline fitting for each data interval, a combination of penalized spline fitting and Akima spline fitting is used for fitting.
[0126] In another exemplary embodiment of this application, the calibration module 703 is further configured to: The K-1 data points in the target training set are used as a data interval to further ensure a smooth transition between data points.
[0127] In another exemplary embodiment of this application, the image processing module 702 is further configured to: The brightest pixel is found in each column of spectral data of each target spectral image at each calibration point using the three-point comparison method. Starting from the brightest pixel in each column of spectral data of each target spectral image, n pixels are taken above and below the starting point (n is an empirical value) to obtain 2n+1 pixels. Gaussian fitting is then performed on the 2n+1 pixels to obtain the peak position (pixel space, unit is pixels) of each column of spectral data of each target spectral image.
[0128] In another exemplary embodiment of this application, the image processing module 702 is further configured to: Based on the peak position of each column of spectral data of each target spectral image at each calibration point, the average peak position of the corresponding column of spectral data of all target spectral images at each calibration point is calculated, and this average peak position is used as the peak position of the corresponding column of spectral data for each calibration point.
[0129] In another exemplary embodiment of this application, the Gaussian model used for Gaussian fitting is: ; in, μ σ represents the mean (the center of the distribution, also the mode and median), σ>0, and σ represents the standard deviation (controlling the width of the distribution). The peak height is represented by σ; x represents the input pixel position; and f(x) represents the peak height. x The probability density at that location.
[0130] In one exemplary embodiment, a computer device is provided, which may be a server or a terminal, and its internal structure diagram may be as follows. Figure 3 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores calibration data for line-spectral confocal systems. The I / O interfaces allow the processor to exchange information with external devices. The communication interface allows communication with external terminals via a network connection. When executed by the processor, the computer program implements a calibration method for line-spectral confocal systems.
[0131] Those skilled in the art will understand that Figure 3The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0132] In one exemplary embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0133] In one exemplary embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0134] In one exemplary embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0135] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0136] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).
[0137] The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0138] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0139] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A calibration method for a line spectrum confocal system, characterized in that, The calibration method for the line spectrum confocal system includes: The target line spectrum confocal system is used to obtain the spectral images formed by plane mirrors at different heights at each calibration point, thus obtaining the target spectral image at each calibration point. For each calibration point, the target spectral image is extracted at the column level to obtain the peak position-height correspondence data for each column of spectral data at each calibration point; A dataset is constructed based on the peak position-height correspondence data of the same column of spectral data from all calibration points; Based on each constructed dataset, and in conjunction with the set constraints, cubic spline fitting is performed to obtain a cubic spline fitting model for each column of spectral data of the target line spectral confocal system; wherein, the constraints include boundary conditions and smoothing conditions.
2. The calibration method for a line spectrum confocal system according to claim 1, characterized in that, Based on each constructed dataset and combined with the set constraints, cubic spline fitting is performed to obtain a cubic spline fitting model for each column of spectral data of the target line spectral confocal system, specifically including: Each dataset is divided into a training set and a test set; Cross-validation is performed on the corresponding cubic spline models based on the training set of each dataset to select the optimal hyperparameters for each cubic spline model; Based on the optimal hyperparameters of each cubic spline model, the cubic spline model with the corresponding optimal hyperparameter configuration is retrained using each training set; The cubic spline fitting model trained on the corresponding training set is tested on each test set to evaluate the fitting error of the retrained cubic spline fitting model.
3. The calibration method for a line spectrum confocal system according to claim 2, characterized in that, The method of cross-validating the corresponding cubic spline models based on the training set of each dataset to select the optimal hyperparameters for each cubic spline model specifically includes: Each training set is used as the target training set, and each candidate hyperparameter combination in the target training set is used as the target hyperparameter combination. Perform a verification operation for each target hyperparameter combination: Based on the target hyperparameter combination, cubic spline fitting is performed using K-1 data points in the target training set to obtain K-1 fitting indices; where K is the total number of data points in the target training set. The remaining 1 data point in the target training set is used as a test sample to test the cubic polynomial of the fit, and the Kth fit index is obtained. After performing the verification operation, for each combination of target hyperparameters, the average value of the K test indicators is calculated; The optimal hyperparameters for the cubic spline fitting model corresponding to the target training set are selected by choosing the combination of K minimum average fitting indices.
4. The calibration method for a line spectrum confocal system according to claim 3, characterized in that, The method of performing cubic spline fitting using K-1 data points in the target training set based on the target hyperparameter combination specifically includes: The K-1 data points of the target training set are divided into multiple data intervals, and cubic spline fitting is performed on each data interval.
5. The calibration method for a line spectrum confocal system according to claim 4, characterized in that, The cubic spline fitting employs at least one of penalized spline fitting and Akima spline fitting.
6. The calibration method for a line spectrum confocal system according to claim 4, characterized in that, The process of dividing the K-1 data points of the target training set into multiple data intervals specifically includes: The K-1 data points in the target training set are considered as a data interval between adjacent data points.
7. The calibration method for a line spectrum confocal system according to claim 1, characterized in that, The process of extracting the peaks at the sub-pixel level from the target spectral image of each calibration point column by column specifically includes: The brightest pixel is found in each column of spectral data of the target spectral image at each calibration point using the three-point comparison method. Starting from the brightest pixel, take n pixels above and below the starting point to obtain 2n+1 pixels. Perform Gaussian fitting on the 2n+1 pixels to obtain the peak position.
8. A computer device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the steps of the calibration method for a line-spectral confocal system according to any one of claims 1-7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the steps of the calibration method for a line spectrum confocal system as described in any one of claims 1-7.
10. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the steps of the calibration method for a line spectrum confocal system as described in any one of claims 1-7.