Linear spectrum contour inflection point detection method using dynamic programming and Logistic fitting
Through the combination of dynamic programming and Logistic fitting function, the problem of data segmentation difficulty in linear spectral confocal technology is solved, and the effective segmentation of object areas of different heights is achieved, which improves data analysis efficiency.
Patent Information
- Application Number
- CN202510256339.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-05
- Publication Date
- 2025-06-13
AI Technical Summary
When the existing linear spectral confocal technology measures the height difference of objects and the alternating light and dark objects, data segmentation is difficult, resulting in the problem of effectively segmenting the areas of objects of different heights.
Dynamic programming method is used to find the best mutation point, and the maximum curvature is selected as the inflection point through the Logistic fitting function to realize the inflection point detection of the line spectral profile.
It effectively solves the data segmentation problem of line spectroscopy or similar line contour sensors in measuring object height difference and alternate objects with light and dark, and improves the data analysis efficiency of contour sensors in scenes.
Smart Images

Figure CN120144922A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of precision measurement and sensing technology, and particularly to a method for detecting inflection points of a line spectrum profile using dynamic programming and Logistic fitting. Background Art
[0002] Spectral confocal technology has obvious advantages such as high speed, high resolution, high adaptability, and non-contact, and is a promising three-dimensional surface topography measurement method. Nowadays, spectral confocal technology has developed into various forms of sensors. Spectral confocal technology can easily perform axial scanning operations in many online applications, and can also perform high-precision three-dimensional surface topography measurement for positions with large angles such as the edge surface of a mobile phone. Based on a point-type spectral confocal measurement system, only the depth information of a single measurement point is obtained in a single measurement. To obtain the three-dimensional topography characteristics of the object to be measured, two-dimensional scanning is required, which not only places high requirements on the stability of the movement of mechanical parts but also reduces the scanning efficiency. Therefore, the technology of line spectrum scanning has emerged. In the application of line spectrum scanning, inflection point detection is particularly important. Therefore, a method for detecting inflection points of a line spectrum profile using dynamic programming and Logistic fitting in the present invention is proposed. Summary of the Invention
[0003] The purpose of the present invention is to overcome the problems existing in the prior art, and provide a method for detecting inflection points of a line spectrum profile using dynamic programming and Logistic fitting, which uses the dynamic programming method to find the best mutation point, and at the same time, by fitting the logistic function, selects the point with the maximum curvature as the inflection point.
[0004] To achieve the above technical purpose and reach the above technical effect, the present invention is realized through the following technical solutions:
[0005] A method for detecting inflection points of a line spectrum profile using dynamic programming and Logistic fitting, comprising:
[0006] A line spectrum confocal displacement sensor for data acquisition;
[0007] A data cleaning module for cleaning the collected data;
[0008] A midpoint detection module for detecting mutation points in the cleaned data and using the dynamic programming method to find the best mutation point;
[0009] A data segmentation module for intercepting data in a certain window selected before and after the mutation point of the mutation data;
[0010] A step fitting module for fitting data using the Logistic function;
[0011] The inflection point screening module selects inflection points through the derivative of the Logistic function.
[0012] Further, in the data cleaning module, the collected data is first subjected to outlier removal. By calculating the distance between each point and the adjacent ten points, and filtering out the points with distances in the value range, and then convolving the data using the Gaussian kernel function to remove the influence of local noise. The cleaned data is used for inflection point detection data.
[0013] Further, in the midpoint detection module, the specific processing method includes the following steps:
[0014] Step S101: First, perform dataset segmentation, dividing the dataset into n equal parts according to the minimum step width;
[0015] Step S102: Define a single-segment loss function C, defining a loss function C for each segment of data;
[0016] Step S103: Define the overall loss function F, based on the single-segment loss function C, defining the loss function F for the entire dataset;
[0017] Step S104: Define the penalty term beta, setting a penalty term beta to balance different parts in the loss function;
[0018] Step S105: Initialize the possible mutation point set R, initializing a set R that only contains the starting point 0 of the dataset;
[0019] Step S106: Define the mutation point mapping table CP, creating a mapping table CP to record the information of mutation points;
[0020] Step S107: Define the mutation tolerance constant K, setting a constant K to determine the tolerance of mutation points;
[0021] Step S108: Start the loop, setting the loop variable to 0;
[0022] Step S109: Check the loop condition, checking whether i is less than n. If so, continue the loop;
[0023] Step S110: Define the equal division point, defining the i-th equal division point as s;
[0024] Step S111: Find the minimum loss point, finding all set points t in the set R such that F(s) = F(t) + C(t:s) + beta is the minimum t;
[0025] Step S112: Update the mapping table CP, adding [t, s] to the mapping table CP;
[0026] Step S113: Update set R, update all set points in R, and only retain those t for which F(s) >= F(t) + C(t:s) + K;
[0027] Step S114: Increment the loop variable, increment i by 1, and return to Step S109 to continue the loop;
[0028] Step S115: Define the equal division point at the end of the data set as sn. After the loop ends, define the equal division point at the end of the data set as sn;
[0029] Step S116: Find the corresponding mutation point. In the mapping table CP, find the mutation point tn corresponding to sn;
[0030] Step S117: Check if tn is greater than 0. If tn is greater than 0, assign tn to sn and execute Step S116 again;
[0031] Step S118: If tn is not greater than 0, end the process.
[0032] Furthermore, within the data segmentation module, the specific processing method includes the following steps:
[0033] Step S201: First, determine the segmentation starting point. Select the midpoints of adjacent steps. Select the midpoints of three adjacent steps, denoted as , , ;
[0034] Step S202: Obtain the maximum step width, calculate and obtain the maximum step width ;
[0035] Step S203: Obtain the segmentation starting point. Calculate the segmentation starting point and the ending point , and the formula is and ;
[0036] Step S204: Check the distance between the starting point and the midpoint, and determine if is greater than . If so, update , and then determine the segmentation ending point. If not, proceed to Step S205;
[0037] Step S205: Determine if is greater than . If so, update ; If not, proceed to Step S206;
[0038] Step S206: Calculate and obtain the minimum step width ;
[0039] Step S207: Determine whether it is less than . If so, add this segmentation point to the step segmentation queue; if not, discard it.
[0040] Furthermore, within the step fitting module, the specific processing method includes the following steps:
[0041] Step S301: Data differencing. First, perform differencing processing on the data to remove the trend or noise of the data, so as to better identify the step characteristics in the data;
[0042] Step S302: Weight initialization. Initialize the weight parameters of the model;
[0043] Step S303: Determine the initial conditions for iteration. Set the initial conditions of the iterative algorithm;
[0044] Step S304: Gradient descent. Use the gradient descent algorithm to optimize the model parameters to minimize the loss parameter;
[0045] Step S305: Update the loss function. After each gradient descent, update the value of the loss function to evaluate the fitting effect of the model;
[0046] Step S306: Determine whether the convergence condition is satisfied. Check whether the model satisfies the convergence condition. If not, determine whether the maximum number of iterations has been reached. If not, continue with the gradient descent process. If the maximum number of iterations has been reached, stop the iteration. If the convergence condition has been satisfied, perform the fitting curve calculation;
[0047] Step S307: Fitting curve calculation. Use the logistic function to perform the fitting curve calculation;
[0048] Step S308: Calculate the curvature of the fitting curve. Calculate the curvature of the fitting curve;
[0049] Step S309: Curvature threshold segmentation. Compare the calculated curvature with a preset threshold to determine the segmentation points of the curve;
[0050] Step S310: Return the inflection point position. Determine and return the inflection point position of the curve.
[0051] Furthermore, when detecting a single inflection point, first find the midpoint of the step jump. Assume that the step jump is a step jump after smoothing. At the midpoint of the step, the curve change rate is the largest, and the change rates on both sides gradually decrease. When it is less than the detection threshold, the point less than the detection threshold is considered as the inflection point. Among them, when performing the fitting curve calculation, the logistic function is used: , where a is the lower limit of the function as xx approaches negative infinity; b is the upper limit of the function as xx approaches positive infinity; c is the steepness of the curve, which determines the growth rate of the curve; d is the center point of the curve, that is, the x value such that y equals .
[0052] Further, within the inflection point screening module, the minimum step width extends from the midpoint of the step height to both sides to find the data for calculating the inflection point. When the width of the data is less than the minimum width, it is considered incomplete. When the incomplete data is at the end of the data, it is left for the next calculation.
[0053] The beneficial effects of the present invention are:
[0054] The present invention can effectively solve the data segmentation problem of line spectrum or similar line profile sensors in measuring the height difference of objects and measuring objects with alternating light and darkness, enabling effective segmentation of different height object regions and improving the data analysis efficiency in the scenario of the profile sensor. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 is a schematic flow chart of the midpoint detection module of the present invention;
[0056] Figure 2 is a schematic flow chart of the data segmentation module of the present invention;
[0057] Figure 3 is a schematic flow chart of the step fitting module of the present invention;
[0058] Figure 4 is a schematic diagram of the detection process of a single inflection point of the present invention;
[0059] Figure 5 is a schematic diagram of the inflection point screening module of the present invention;
[0060] Figure 6 is a schematic diagram of the data cleaning module of the present invention;
[0061] Figure 7 is a schematic diagram of the weight and fitting of the present invention;
[0062] Figure 8 is a block diagram of the module of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0063] The present invention will be described in detail below with reference to the drawings and in conjunction with embodiments.
[0064] A method for detecting inflection points of a line spectrum profile using dynamic programming and Logistic fitting, as Figure 8 shown, includes:
[0065] A line spectrum confocal displacement sensor for data acquisition;
[0066] A data cleaning module for cleaning the collected data;
[0067] A midpoint detection module for detecting mutation points in the cleaned data and finding the optimal mutation point using the dynamic programming method;
[0068] A data segmentation module for intercepting data in a certain window selected before and after the mutation point of the mutation data;
[0069] A step fitting module for fitting data using the Logistic function;
[0070] An inflection point screening module for selecting inflection points through the derivative of the Logistic function.
[0071] Inside the data cleaning module, as Figure 6 shown, for a specific inflection point, it is extracted through the following steps. First, outliers are removed from the collected data. By calculating the distance between each point and the adjacent ten points, and filtering out the values of the distance at , then the data is convolved using the Gaussian kernel function to remove the influence of local noise. The cleaned data is used for inflection point detection data. As Figure 7 shown, for the cleaned data, a larger weight is assigned to the data region with a larger change rate, so that it has a greater impact on the fitting result, making the fitting curve closer to the step change.
[0072] Inside the midpoint detection module, as Figure 1 shown, the specific processing method includes the following steps:
[0073] Step S101: First, perform dataset segmentation, dividing the dataset into n equal parts according to the minimum step width;
[0074] Step S102: Define a single-segment loss function C, defining a loss function C for each segment of data;
[0075] Step S103: Define an overall loss function F, defining the loss function F of the entire dataset based on the single-segment loss function C;
[0076] Step S104: Define a penalty term beta, setting a penalty term beta for balancing different parts in the loss function;
[0077] Step S105: Initialize the possible mutation point set R, initializing a set R that only contains the starting point 0 of the dataset;
[0078] Step S106: Define a mutation point mapping table CP, creating a mapping table CP for recording the information of mutation points;
[0079] Step S107: Define the mutation tolerance constant K, and set a constant K to determine the tolerance of mutation points;
[0080] Step S108: Start the loop, and set the loop variable to 0;
[0081] Step S109: Check the loop condition, check if i is less than n, if so, continue the loop;
[0082] Step S110: Define the equal division points, and define the i-th equal division point as s;
[0083] Step S111: Find the minimum loss point, find all set points t in the set R such that t is the one that makes F(s) = F(t) + C(t:s) + beta the smallest;
[0084] Step S112: Update the mapping table CP, and add [t, s] to the mapping table CP;
[0085] Step S113: Update the set R, update all set points in R, and only keep the t where F(s) >= F(t) + C(t:s) + K;
[0086] Step S114: Increment the loop variable, i is incremented by 1, and return to Step S109 to continue the loop;
[0087] Step S115: Define the equal division point at the end of the data set as sn, and after the loop ends, define the equal division point at the end of the data set as sn;
[0088] Step S116: Find the corresponding mutation point, and find the mutation point tn corresponding to sn in the mapping table CP;
[0089] Step S117: Check if tn is greater than 0, if tn is greater than 0, assign tn to sn and execute Step S116 again;
[0090] Step S118: If tn is not greater than 0, the process ends.
[0091] Within the data segmentation module, as Figure 2 shown, the specific processing method includes the following steps:
[0092] Step S201: First determine the segmentation starting point, select the midpoint of adjacent steps, select the midpoints of three adjacent steps, denoted as , , ;
[0093] Step S202: Obtain the maximum step width, calculate and obtain the maximum step width ;
[0094] Step S203: Obtain the starting point of segmentation, and calculate the starting point of segmentation based on the midpoint and the ending point , and the formula is and ;
[0095] Step S204: Check the distance between the starting point and the midpoint, and judge whether it is greater than . If so, update , and then determine the ending point of segmentation. If not, proceed to Step S205;
[0096] Step S205: Judge whether it is greater than . If so, update ; if not, proceed to Step S206;
[0097] Step S206: Calculate and obtain the minimum step width ;
[0098] Step S207: Judge whether it is less than . If so, add this segmentation point to the step segmentation queue. If not, discard it.
[0099] Inside the step fitting module, as Figure 3 shown, the specific processing method includes the following steps:
[0100] Step S301: Data differencing. First, perform differencing processing on the data to remove the trend or noise of the data, so as to better identify the step features in the data;
[0101] Step S302: Weight initialization. Initialize the weight parameters of the model;
[0102] Step S303: Determine the initial conditions for iteration. Set the initial conditions of the iterative algorithm;
[0103] Step S304: Gradient descent. Use the gradient descent algorithm to optimize the model parameters to minimize the loss parameter;
[0104] Step S305: Update the loss function. After each gradient descent, update the value of the loss function to evaluate the fitting effect of the model;
[0105] Step S306: Judge whether the convergence condition is satisfied. Check whether the model satisfies the convergence condition. If not, judge whether the maximum number of iterations is reached. If not, continue with the gradient descent process. If the maximum number of iterations has been reached, stop the iteration. If the convergence condition has been satisfied, perform the fitting curve calculation;
[0106] Step S307: Fitting curve calculation, using the logistic function for fitting curve calculation;
[0107] Step S308: Fitting curve curvature calculation, calculating the curvature of the fitting curve;
[0108] Step S309: Curvature threshold segmentation, comparing the calculated curvature with a preset threshold to determine the segmentation point of the curve;
[0109] Step S310: Return the inflection point position, determining and returning the inflection point position of the curve.
[0110] When detecting a single inflection point, first find the midpoint of the step jump. Assume that the step jump is the step jump after smoothing. At the midpoint of the step, the curve change rate is the largest, and the change rates on both sides gradually decrease. When it is less than the detection threshold, the point less than the detection threshold is considered as the inflection point. Among them, when calculating the fitting curve, the logistic function is used: , where a is the lower limit of the function when xx approaches negative infinity; b is the upper limit of the function when xx approaches positive infinity; c is the steepness of the curve, which determines the growth rate of the curve; d is the center point of the curve, that is, the x value makes y equal to .
[0111] Within the inflection point screening module, the minimum step width, that is Figure 5 In No. 1 of the serial number, centered on the midpoint of the step height, expand to both sides to find the data for calculating the inflection point. When the width of the data is less than the minimum width, that is Figure 5 as shown in No. 2 of the serial number, it is considered incomplete. When the incomplete data is at the end of the data, it is left for the next calculation.
[0112] The above are only the preferred embodiments of the present invention and are not used to limit the present invention. For those skilled in the art, the present invention can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A line spectrum profile inflection point detection method using dynamic programming and Logistic fitting, characterized in that: include: Line spectrum confocal displacement sensor, used for data collection; A data cleaning module is used to clean the collected data; The midpoint detection module is used to detect mutation points in the cleaned data and find the optimal mutation point using the dynamic programming method; The data segmentation module is used to intercept the data of a certain window selected before and after the mutation point; Step fitting module, using Logistic function to fit data; Inflection point screening module, selects inflection points through the derivative of the Logistic function.
2. The line spectrum profile inflection point detection method using dynamic programming and logistic fitting according to claim 1, characterized in that: In the data cleaning module, the collected data is firstly subjected to outlier removal, by calculating the distance between each point and its ten adjacent points and summing the distances between them. The values are filtered out, and then the Gaussian kernel function is used to convolve the data to remove the influence of local noise. The cleaned data is used for inflection point detection data.
3. The line spectrum profile inflection point detection method using dynamic programming and logistic fitting according to claim 2, characterized in that: In the midpoint detection module, the specific processing method includes the following steps: Step S101: firstly, the data set is segmented, and the data set is divided into n equal parts according to the minimum step width; Step S102: define a single-segment loss function C, and define a loss function C for each segment of data; Step S103: defining an overall loss function F, based on the single-segment loss function C, defining the loss function F of the entire data set; Step S104: define a penalty term beta, and set a penalty term beta to balance different parts in the loss function; Step S105: Initialize a possible mutation point set R, and initialize a set R, which only contains the starting point 0 of the data set; Step S106: define a mutation point mapping table CP, and create a mapping table CP for recording mutation point information; Step S107: define a mutation tolerance constant K, and set a constant K to determine the tolerance of the mutation point; Step S108: The loop starts and the loop variable is set to 0; Step S109: loop condition check, check whether i is less than n, if yes, continue looping; Step S110: define equal division points, define the i-th equal division point as s; Step S111: Find the minimum loss point, find all set points t in the set R, and make F(s)=F(t)+C(t:s)+beta the smallest t; Step S112: update the mapping table CP and add [t, s] to the mapping table CP; Step S113: Update the set R, update all the set points in R, and only keep t with F(s)>=F(t)+C(t:s)+K; Step S114: the loop variable is incremented, i is increased by 1, and the loop returns to step S109 to continue; Step S115: define the equal division point at the end of the data set as sn. After the loop is completed, define the equal division point at the end of the data set as sn; Step S116: searching for the corresponding mutation point, searching for the mutation point tn corresponding to sn in the mapping table CP; Step S117: Check whether tn is greater than 0. If tn is greater than 0, assign tn to sn and execute step S116 again; Step S118: If tn is not greater than 0, the process ends.
4. The line spectrum profile inflection point detection method using dynamic programming and logistic fitting according to claim 3, characterized in that: In the data segmentation module, the specific processing method includes the following steps: Step S201: First determine the segmentation starting point, select the midpoints of adjacent steps, and select the midpoints of three adjacent steps, recorded as , , ; Step S202: Obtain the maximum step width, calculate and obtain the maximum step width ; Step S203: Get the segmentation starting point and calculate the segmentation starting point based on the midpoint and end point , the formula is and ; Step S204: Check the distance between the starting point and the midpoint and determine Is it greater than If yes, update , and then determine the segmentation end point, if not, proceed to step S205; Step S205: Determination Is it greater than If yes, update ; If not, proceed to step S206; Step S206: Calculate and obtain the minimum step width ; Step S207: Determination Is it less than , if so, add this segmentation point to the step segmentation queue, if not, discard it.
5. The line spectrum profile inflection point detection method using dynamic programming and logistic fitting according to claim 4, characterized in that: In the step fitting module, the specific processing method includes the following steps: Step S301: data differentiation, firstly performing differentiation processing on the data to remove the trend or noise of the data so as to better identify the step features in the data; Step S302: weight initialization, initializing the weight parameters of the model; Step S303: Determine the initial conditions for iteration and set the initial conditions for the iteration algorithm; Step S304: Gradient descent, using a gradient descent algorithm to optimize model parameters to minimize loss parameters; Step S305: updating the loss function. After each gradient descent, the value of the loss function is updated to evaluate the fitting effect of the model. Step S306: Determine whether the convergence condition is met, check whether the model meets the convergence condition, if not, determine whether the maximum number of iterations has been reached, if not, continue the gradient descent process, if the maximum number has been reached, stop the iteration, if the convergence condition has been met, perform the fitting curve calculation; Step S307: fitting curve calculation, using logistic function to perform fitting curve calculation; Step S308: Calculating the curvature of the fitting curve, calculating the curvature of the fitting curve; Step S309: Curvature threshold segmentation, comparing the calculated curvature with a preset threshold to determine the segmentation point of the curve; Step S310: Return the inflection point position, determine and return the inflection point position of the curve.
6. The line spectrum profile inflection point detection method using dynamic programming and logistic fitting according to claim 5, characterized in that: When detecting a single inflection point, first find the midpoint of the step jump. Assuming that the step jump is a smoothed step jump, at the midpoint of the step, the curve change rate is the largest, and the change rate on both sides gradually decreases. When it is less than the detection threshold, the point less than the detection threshold is considered to be an inflection point. When calculating the fitting curve, the logistic function is used: , where a is the lower limit of the function when x approaches negative infinity; b is the upper limit of the function when x approaches positive infinity; c is the steepness of the curve, which determines the growth rate of the curve; d is the center point of the curve, that is, the x value that makes y equal .
7. The line spectrum profile inflection point detection method using dynamic programming and logistic fitting according to claim 6, characterized in that: In the inflection point screening module, the minimum step width is centered at the midpoint of the step height and expands to both sides to find data used to calculate the inflection point. When the width of the data is less than the minimum width, it is considered incomplete. When the incomplete data is at the end of the data, it is left for the next calculation.