CN113554670A - Fitting method based on cubic spline and curve fitting device - Google Patents

Fitting method based on cubic spline and curve fitting device Download PDF

Info

Publication number
CN113554670A
CN113554670A CN202010340312.2A CN202010340312A CN113554670A CN 113554670 A CN113554670 A CN 113554670A CN 202010340312 A CN202010340312 A CN 202010340312A CN 113554670 A CN113554670 A CN 113554670A
Authority
CN
China
Prior art keywords
node
nodes
error
fitting
value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010340312.2A
Other languages
Chinese (zh)
Inventor
李玥
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing A&e Technologies Co ltd
Original Assignee
Beijing A&e Technologies Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing A&e Technologies Co ltd filed Critical Beijing A&e Technologies Co ltd
Priority to CN202010340312.2A priority Critical patent/CN113554670A/en
Publication of CN113554670A publication Critical patent/CN113554670A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/13Edge detection

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Generation (AREA)

Abstract

The fitting method based on the cubic spline comprises the steps of selecting a second number of nodes and first nodes from a node vector to form a second node when the error between a fitting value obtained by curve fitting by using a first number of first nodes and a data point is larger than a first error threshold; obtaining control points by using the second node, and judging whether the number of the control points is greater than the preset maximum number of the control points; and if the number of the control points is greater than the preset maximum number of the control points, performing segmentation processing on the contour formed by all the data points, and respectively fitting each section of contour, so that the error between the fitting value on the fitted spline curve and the data points is smaller than a first error threshold value. By means of the method, the calculation complexity can be reduced, and the fitting speed is improved.

Description

Fitting method based on cubic spline and curve fitting device
Technical Field
The application relates to the technical field of data processing, in particular to a fitting method and a curve fitting device based on cubic splines.
Background
In various industrial-grade actuating mechanisms, the cubic B spline is a common linear type, a cubic B spline curve has the advantages of local modification characteristics, convex hull, symmetry, third-order microminiaturization and the like, and the parameter expression form is simple, so that the cubic B spline curve is suitable for computer programming and is widely applied to computer-aided manufacturing. Taking the articulated industrial robot as an example, in common operations such as carrying, palletizing, spot welding and the like, basic task requirements can be realized by adopting the combination of straight lines and circular arcs. However, with the widening of the application fields of industrial robots, such as arc welding and drawing work; if the welding track is an irregular curve, the workload of adopting straight lines and circular arc tracks to approximate the welding track is large, and errors are easy to occur.
The inventor of the application finds in long-term research and development that when a series of track points are fitted by utilizing a cubic B spline, corresponding nodes and control points need to be calculated; taking the common least square approximation as an example, when there are many and dense trace points, it may take a long time to fit all trace points as the same spline.
Disclosure of Invention
The application mainly solves the problem of providing a fitting method and a curve fitting device based on cubic splines, which can reduce the calculation complexity and improve the fitting speed.
In order to solve the technical problem, the technical scheme adopted by the application is as follows: a fitting method based on cubic splines is provided, and comprises the following steps: when the error between a fitting value obtained by curve fitting by using a first number of first nodes and a data point is larger than a first error threshold value, selecting a second number of nodes and the first nodes from the node vector to form a second node; obtaining control points by using the second node, and judging whether the number of the control points is greater than the preset maximum number of the control points; and if the number of the control points is greater than the preset maximum number of the control points, performing segmentation processing on the contour formed by all the data points, and respectively fitting each section of contour, so that the error between the fitting value on the fitted spline curve and the data points is smaller than a first error threshold value.
In order to solve the above technical problem, another technical solution adopted by the present application is: providing a curve fitting device comprising: a memory and a processor connected to each other, wherein the memory is adapted to store a computer program which, when executed by the processor, is adapted to carry out the above-mentioned cubic spline based fitting method.
In order to solve the above technical problem, another technical solution adopted by the present application is: a storage medium is provided for storing a computer program for implementing the above-described cubic spline-based fitting method when executed by a processor.
Through the scheme, the beneficial effects of the application are that: when curve fitting is carried out, the number of the current control points is used as a basis for carrying out sectional processing on the contour formed by all data points, when the number of the current control points is large, sectional processing is carried out, each section of contour is respectively fitted, and the fitting and judging operations are repeated until the fitted spline curve meets the requirement of error precision; the calculation complexity is reduced through the segmentation processing, and the fitting speed can be improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts. Wherein:
FIG. 1 is a schematic flow chart diagram of an embodiment of a cubic spline-based fitting method provided herein;
FIG. 2 is a schematic flow chart diagram of another embodiment of a cubic spline-based fitting method provided herein;
FIG. 3 is a schematic diagram of a polygon fit in another embodiment of a cubic spline-based fitting method provided herein;
FIG. 4 is a schematic diagram of fitting results obtained by polygon fitting in another embodiment of the fitting method based on cubic splines provided in the present application;
FIG. 5 is a schematic angle diagram of a polygon fit in another embodiment of the cubic spline-based fitting method provided herein;
FIG. 6 is a graph showing the fitting results in the prior art;
FIG. 7 is a schematic diagram of the fitting results in another embodiment of the cubic spline-based fitting method provided herein;
FIG. 8 is another schematic diagram of the fitting results in another embodiment of the cubic spline-based fitting method provided herein;
FIG. 9 is a schematic diagram of an embodiment of a curve fitting apparatus provided herein;
fig. 10 is a schematic structural diagram of an embodiment of a storage medium provided in the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In order to solve the problem of complex track processing, the application provides a method for approximating an irregular curve by using spline curve fitting so as to plan the track.
Approximation is more difficult than interpolation, in the interpolation problem, the number of control points is automatically determined by the selected times and the given number of data (including constraints such as data points, guide vectors and the like), the setting of node vectors is direct, and error checking of curves and curved surfaces is not needed. In the approximation problem, the error margin E of the curved surface is input together with the data to be fitted, and it is generally not known in advance how many control points are needed to achieve the desired accuracy E, so that the approximation is generally implemented by iteration.
Referring to fig. 1, fig. 1 is a schematic flow chart of an embodiment of a fitting method based on cubic splines provided in the present application, where the method includes:
step 11: and when the error between a fitting value obtained by curve fitting by using the first number of first nodes and a data point is larger than a first error threshold value, selecting a second number of nodes from the node vector and the first nodes to form a second node.
Firstly, performing curve fitting by using a first number of first nodes to obtain a spline curve, obtaining fitting values according to the spline curve, calculating the error of each fitting value and a data point corresponding to each fitting value, and taking the sum of all errors as the error between each fitting value and the data point; when the error between the fitting value and the data point is judged to be larger than the first error threshold value, the number of the first nodes used currently is insufficient, and a second number of nodes can be selected from the node vector and added into the current node to form a second node.
Step 12: and obtaining control points by using the second node, and judging whether the number of the control points is greater than the preset maximum number of the control points.
After a new node is added into the current node, calculating a second node to obtain a control point corresponding to the second node; when the number of the control points is too large, the calculation speed is influenced, so that the number of the control points is limited, and whether the number of the current control points is larger than the preset maximum control point number or not is judged.
Step 13: and if the number of the control points is greater than the preset maximum number of the control points, performing segmentation processing on the contour formed by all the data points, and respectively fitting each section of contour, so that the error between the fitting value on the fitted spline curve and the data points is smaller than a first error threshold value.
If the number of the current control points is larger than the preset maximum control point number, the current control points are more in number, the calculated amount calculated by using the current control points is larger, therefore, the contour formed by all the data points is processed in a segmented mode, and each segment of contour is processed by using the method from the step 11 to the step 12 until a spline curve which meets the preset error precision is fitted; the spline curve can be composed of a plurality of spline curve segments, the number of the spline curve segments is matched with the grouping number of all data points, and each group of data points corresponds to one spline curve segment; nodes can be adaptively added and segmented according to the distribution characteristics of the data points so as to approximate the distribution of the data points.
The method is characterized in that when a spline curve obtained by curve fitting by using a first number of first nodes does not meet the requirement of error precision, new nodes are added into the current nodes to form second nodes, whether the number of the current control points is larger or not is judged according to the number of the second nodes, if the number of the current control points exceeds the preset maximum control point number, segmentation processing is carried out, each section of contour is fitted respectively, and the fitting and judging operations are repeated until the fitted spline curve meets the requirement of the error precision; by limiting the number of the current control points, the calculation complexity is reduced by utilizing segmentation processing, and the fitting speed can be improved.
Referring to fig. 2, fig. 2 is a schematic flow chart of another embodiment of the fitting method based on cubic splines provided in the present application, and the method includes:
step 201: and (4) parameterizing all the data points to obtain a parameter value corresponding to each data point.
The parameterization method comprises uniform parameterization, chord length parameterization and centripetal parameterization, wherein the parameterization is carried out on all data points by utilizing the chord length parameterization method, d is the total chord length, and the expression is as follows:
Figure BDA0002468143030000051
then
Figure BDA0002468143030000052
Where n +1 is the number of data points, { QkThe "data points are the data points,
Figure BDA0002468143030000053
for the parameter value, | Qk-Qk-1I is the data point QkAnd Qk+1The euclidean distance between.
Step 202: and processing the parameter values to obtain nodes corresponding to each parameter value, and forming a node vector.
And obtaining a node vector consisting of a plurality of nodes by using the mathematical operation relation between the parameter values and the nodes.
In a specific embodiment, where i is int (d) represents the largest integer less than or equal to d, a total of n + p +2 nodes are required, thus having n-p interior nodes and n-p +1 interior node intervals, such that
Figure BDA0002468143030000054
Wherein, m +1 is the quantity of node, and n +1 is the quantity of control point, and m is n + p +1, and p is the number of times of curve, and outer node is:
u0=…=up=0,um-p=…=um=1 (4)
the inner nodes are defined as follows:
Figure BDA0002468143030000061
the node vector is:
U={u0,u1,…,um} (6)
step 203: and selecting a first number of nodes from the node vector as first nodes, and obtaining first control points by using the first nodes.
And processing the first nodes by using a least square method to obtain first control points, wherein the number of the first control points is less than that of the first nodes.
In one embodiment, to avoid the non-linearity problem, the weight is set to 1, and the parameter value of the data point is pre-calculated
Figure BDA00024681430300000610
And a node vector U, and establishing and solving a linear least square problem to solve the unknown control point. Assume p ≧ 1, n ≧ p, and Q is given0,…,Qm(m>n), the p-th non-rational curve is:
Figure BDA0002468143030000062
the p-times irrational curve satisfies the following condition:
Q0=C(0),Qm=C(1) (8)
the remaining data points QkIs approximated in the least-squares sense, i.e.
Figure BDA0002468143030000063
With respect to n +1 variables PiThe minimum value is reached, and the minimum value,
Figure BDA0002468143030000064
are pre-calculated parameter values.
The generated curve generally passes through data point Q inaccuratelykAnd in general
Figure BDA0002468143030000065
Not on a curve with QkThe closest point, let
Figure BDA0002468143030000066
Then order
Figure BDA0002468143030000067
f is about n-1 variables P1,…,Pn-1The scalar function of (a) is implemented by applying a standard linear least squares technique to minimize an objective function f associated with n-1 unknown control points
Figure BDA0002468143030000068
All partial derivatives of (A) are equal to zero, the first of which
Figure BDA0002468143030000069
The partial derivatives are:
Figure BDA0002468143030000071
order to
Figure BDA0002468143030000072
Then there are:
Figure BDA0002468143030000073
the above formula is one to control the point P1,…,Pn-1Is a linear equation of the unknown quantity, a linear equation system containing n-1 unknown quantities and n-1 equations is obtained:
Figure BDA0002468143030000074
where N is a matrix of (m-1) × (N-1) consisting of scalars:
Figure BDA0002468143030000075
r is a column vector consisting of n-1 points:
Figure BDA0002468143030000076
Figure BDA0002468143030000077
according to the node vector U and the parameter value of each data point
Figure BDA0002468143030000078
The matrix N and the column vector R can be calculated, and the control point vector P can be calculated according to the relationship among the matrix N, the column vector R and the control point column vector P; on the first iteration, a small number of control points may be selected, for example, the number of first control points may be 6, p may be 3, and the number of first nodes may be 10.
Step 204: and obtaining a spline curve by using the first node and the first control point.
After the first control point is calculated by using the first node, a spline curve is calculated by using the node, the control point and the basis function, and the definition of the p-th-order B-spline curve is as follows:
Figure BDA0002468143030000081
{Piis a control point, { Ni,p(u) is a vector defined at an aperiodic (and non-uniform) node
Figure BDA0002468143030000082
The above basis functions.
Figure BDA0002468143030000083
The basis functions and matrixes N and R required to be calculated in the least square method can be solved according to the nodes, so that a control point column vector P is solved, and the calculation complexity of the control point column vector P is directly related to the number of control points.
Step 205: and judging whether the error value between the data point and the estimation value on the spline curve is larger than a first error threshold value.
After a spline curve is obtained by using the first node and the first control point, whether the fitting result meets the requirement or not is judged, namely, the error between each data point and the corresponding estimation value is calculated, the errors corresponding to all the data points are added to obtain the total error, and the size relation between the total error and the first error threshold is judged.
Step 206: and if the error value between the data point and the estimated value on the spline curve is less than or equal to the first error threshold value, stopping the operation and outputting the parameters of the spline curve.
If the error values corresponding to all the data points are less than or equal to the error values, the currently fitted spline curve is shown to be in accordance with the distribution rule of the data points, at the moment, the operation can be stopped, and parameters of the spline curve are directly output, wherein the parameters of the spline curve comprise: a node, a control point, or a parameter of a basis function, etc.
Step 207: and if the error value between the data point and the estimated value on the spline curve is greater than the first error threshold value, selecting a second number of nodes and the first nodes from the node vector to form a second node, storing the error value, and establishing a mapping table between the nodes and the error value.
If the error values corresponding to all the data points are larger than the first error threshold value, the fact that the error of the spline curve obtained by fitting the first node and the first control point is not within the allowable range is indicated, the number of the nodes needs to be increased, namely, the nodes are selected from the node vector and added into the current node to form a second node, and the corresponding relation between all the nodes and the error values is established and stored.
Step 208: and determining a second error threshold according to the first error threshold and the current iteration number.
The second error threshold is set according to the idea that the value of the second error threshold gradually decreases along with the increase of the iteration times, namely the change trend of the second error threshold is opposite to the change trend of the current iteration times; because the spline curve fitted will get closer and closer to the contour to be fitted as the number of iterations increases.
The upper limit of the iteration times, namely the preset maximum iteration times, can be set, and the upper limit of the iteration times is used for ensuring the timeliness of the program operation; whether the current iteration times are equal to the preset maximum iteration times or not can be judged; if the current iteration times are equal to the preset maximum iteration times, stopping the iteration; and if the current iteration times are less than the preset maximum iteration times, continuing the iteration.
In a specific embodiment, when the current iteration number is less than the first preset iteration number, the second error threshold E2 ═ max { E1, k ═ E ═ max [ ]M}; where E1 is the first error threshold, k is the adjustment factor, EMWhich is the maximum of all the error values saved in step 207.
When the current iteration number is greater than or equal to a first preset iteration number and is less than or equal to a second preset iteration number, a second error threshold value E2 ═ k × EM
When the current iteration number is greater than a second preset iteration number and is less than or equal to a preset maximum iteration number, a second error threshold E2 ═ min { E1 ═ (I) }M-IC)*(1-k),k*EM}; wherein, IMTo prepareSetting the maximum number of iterations, ICIs the current iteration number.
In a specific embodiment, the first predetermined number of iterations may be 3, the second predetermined number of iterations may be 5, the predetermined maximum number of iterations may be 10, and the adjustment coefficient k is 0.8.
It is understood that the preset maximum iteration number and the setting of the second error threshold may be changed to other constraints when meeting the time requirement and meeting the principle that the accuracy requirement is higher and higher as the iteration number increases.
Step 209: and selecting the node corresponding to the local maximum error value from the mapping table, and adding the node into the current node to form a second node.
Recording the node with the error value larger than the second error threshold value as a third node; and then comparing the third node with the error value corresponding to the node adjacent to the third node, and recording the node corresponding to the maximum error value as the second node.
In a specific embodiment, in the mapping table stored in step 207, a node having an error value greater than the second error threshold E2 and having a maximum value of 5 error values adjacent to the error value is selected, and the node corresponding to the error value is added to the current node; that is, assuming that the sequence number of the current error value is n, the nth error value is greater than the second error threshold E2 and its value is greater than the (n-1) th, the (n-2) th, the (n +1) th and the (n +2) th error values.
Step 210: and calculating the number of second control points corresponding to the second nodes according to the number of the second nodes.
Step 211: and judging whether the number of the second control points exceeds the preset maximum control point number.
Obtaining the number of control points by using the number corresponding relation between the nodes and the control points, and then judging whether the number of the control points exceeds the preset maximum control point number or not; and if the number of the second control points does not exceed the preset maximum number of the control points, processing the current node by using a least square method to obtain the current control point, and continuing to iterate.
Step 212: and if the number of the second control points exceeds the preset maximum control point number, executing a step of performing segmentation processing on the contour formed by all the data points.
If the number of the control points obtained by calculation according to the second node exceeds the preset maximum number of the control points, the number of the control points used at present is large, and when the column vector P of the control points is calculated by using a formula (13), the calculation amount of the inversion operation on the matrix N is large, so that the calculation speed is influenced; therefore, measures of segmented processing can be taken.
Further, the outline composed of all data points is approximated by a polygon approximation method to obtain an outline polygon, and the vertex coordinates of the polygon are recorded to form a polygon vertex coordinate sequence.
In a specific embodiment, the approximation is performed by using a Douglas-pocker (Douglas-Peucker) algorithm, as shown in fig. 3, a straight line segment AB is connected between the two points a and B at the head and the tail of the line S, and the straight line segment AB is a chord of the line; calculating a point C with the maximum distance from the straight line segment AB on the line S, and calculating a distance d between the point C and the straight line segment AB; comparing the distance d with a predetermined distance threshold value; if the distance d is smaller than the distance threshold, the straight line segment AB is used as the approximation of the line S, and the processing is finished; if the distance d is larger than the distance threshold, the line is divided into two segments of AC and BC by the point C, and the two segments of line are processed as above. When all lines are processed, the broken lines formed by all the segmentation points are connected in sequence, and the broken lines can be used as approximations to the lines. The distance threshold is the accuracy of the polygon approximation method, and the smaller the distance threshold, the more similar the result of the polygon approximation to the original contour, for example, as shown in fig. 4, the accuracy of the left image is 5 pixels, and the accuracy of the right image is 1 pixel, and the result of the right side can be seen to be closer to the original contour.
Then calculating cosine values of vertexes of the outline polygon; the cosine value is monotonically decreased within the range of 0-180 degrees and is easy to calculate, so that the cosine value of the top point is selected and calculated; for example, assuming that the coordinates of the current vertex are (x0, y0), the vertices adjacent to the current vertex are (x1, y1) and (x2, y2), and the distances between the current vertex and the adjacent vertices are d1 and d2, respectively, the cosine value of the current included angle is ((x1-x0) × (x2-x0) + (y1-y0) (y2-y0))/(d 1) × d 2).
Selecting a vertex corresponding to the maximum cosine value from the cosine values of all the vertexes as a separation point, wherein the vertex corresponding to the maximum cosine value is the position with the smallest included angle and the sharpest included angle; and (3) dividing the contour into two sub-contours at the division point, respectively fitting the data points corresponding to each sub-contour, returning to the step of parameterizing all the data points by using a chord length parameterization method to obtain the parameter value corresponding to each data point, and continuing iteration until the error between the estimation value on each spline curve and the data point is less than a first error threshold.
For example, as shown in fig. 5, the line S is approximated to straight line segments AD, DC, and CB, cosine values of the angles a and β are calculated as the cosine values of the vertices C and D, respectively, and since the cosine value of the angle β is smaller than the cosine value of the angle a, the line is divided into two segments at the vertex C, and each segment is processed by the above-described steps.
In a specific embodiment, the point coordinates of 11 contours are input and fitted separately by existing methods; setting the number of initial control points to be 6, and changing the number of the control points to be 2 times of the original number if the error value does not meet the requirement during iteration; under such conditions, the obtained fitting result is shown in fig. 6, wherein black points are control points, and star points are contour starting points; as can be seen from fig. 6, in addition to the simple four circular arcs, other more complex figures are represented by a very large number of control points, especially the outermost contour, which corresponds to an excessive number of control points, resulting in an excessively long calculation time. The change characteristics of the graph to be fitted are not considered when node selection is carried out, so that in the iteration process, the node selection is uniform, adjustment cannot be well carried out according to the actual fitting result, and the calculation speed is slow when the control points are continuously increased.
The fitting is performed by the method in the embodiment, and the obtained fitting image is shown in fig. 7; comparing fig. 6 with fig. 7, it can be seen that the number of control points of the complex graph is greatly reduced, the control points are more densely distributed at the position where the graph changes violently, and the control points are more sparsely distributed at the position where the graph is simple; automatic segmentation is carried out at the position with violent change, and because the upper limit of the control points can be restricted while automatic segmentation is carried out, no contour has excessive control points, and the calculation speed is greatly improved.
In addition, the form of dividing the contour into multiple segments at a time can also be adopted, for example, the cosine value can be divided into multiple segments, and the length of each segment is 0.1, namely: 0.9-1, 0.8-0.9, 0.7-0.8, and so on. When the maximum cosine value is in a certain interval, all included angles in the interval are used as the end points of automatic segmentation, so that the segmentation speed can be increased; processing in this way results in the results shown in fig. 8, where the segmentation of the same contour may be more, but faster, and better fitting results can be obtained than the results in fig. 7.
In the method of the embodiment, firstly, a newly added node in an iteration process is selected according to an error value of a last fitting result, so that new fitting can be guided well, and deviation is reduced; and secondly, the upper limit of the control point is added, grouping can be carried out at a reasonable position, the upper limit of the control point is constrained, the size of the matrix N is also constrained, and the size of the matrix N is a key influence parameter for solving the speed of the control point, so that the upper limit of single calculation time is constrained. The method can solve the problems that node selection is lack of pertinence and the calculation time is too long due to excessive control points in the prior art, can pertinently select the nodes and automatically select the segmentation points according to the graph complexity, so that the characteristics of the cubic B spline can be better exerted, fitting can be performed by using the control points as few as possible, the matrix dimensionality of inversion operation is reduced, and the calculation time is greatly reduced.
Referring to fig. 9, fig. 9 is a schematic structural diagram of an embodiment of the curve fitting apparatus 90 provided in the present application, including: a memory 91 and a processor 92 connected to each other, wherein the memory 91 is used for storing a computer program which, when executed by the processor 92, is used for implementing the cubic spline based fitting method in the above embodiments.
The processor 92 firstly uses fewer nodes to fit a curve, if the error of the fit is larger, the number of the nodes is automatically increased, whether the number of the control points exceeds the limit is judged, if the number of the control points exceeds the limit, the current data points are divided into two groups, the segmentation is carried out for fitting and repeated iteration, the precision is continuously improved in the iteration, and the automatic segmentation is carried out, so that the result with high precision and low calculated amount is finally obtained; by limiting the number of control points to perform the segmentation processing, the calculation time can be reduced.
Referring to fig. 10, fig. 10 is a schematic structural diagram of an embodiment of a storage medium provided in the present application, where the storage medium 100 is used to store a computer program 101, and the computer program 101 is used to implement the fitting method based on cubic spline in the foregoing embodiment when being executed by a processor.
The storage medium 100 may be a server, a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and various media capable of storing program codes.
In the several embodiments provided in the present application, it should be understood that the disclosed method and apparatus may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of modules or units is merely a logical division, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The above embodiments are merely examples, and not intended to limit the scope of the present application, and all modifications, equivalents, and flow charts using the contents of the specification and drawings of the present application, or those directly or indirectly applied to other related arts, are included in the scope of the present application.

Claims (10)

1. A fitting method based on cubic splines, comprising:
when the error between a fitting value obtained by curve fitting by using a first number of first nodes and a data point is larger than a first error threshold value, selecting a second number of nodes from a node vector and forming a second node by using the first nodes;
obtaining control points by using the second node, and judging whether the number of the control points is greater than the preset maximum number of the control points;
and if so, performing segmentation processing on the contour formed by all the data points, and respectively fitting each section of contour, so that the error between the fitting value on the fitted spline curve and the data point is smaller than the first error threshold value.
2. The cubic spline-based fitting method as claimed in claim 1, wherein the step of selecting a second number of nodes from the node vector and the first nodes to constitute a second node when an error of a fitting value obtained by curve fitting using the first number of first nodes with a data point is larger than a first error threshold comprises:
selecting the first number of nodes from the node vector as the first nodes, and obtaining first control points by using the first nodes;
obtaining a spline curve by using the first node and the first control point;
judging whether an error value between the data point and an estimated value on the spline curve is larger than the first error threshold value;
if not, stopping the operation and outputting the parameters of the spline curve; if yes, selecting a second number of nodes from the node vector and the first nodes to form the second nodes, storing the error value, and establishing a mapping table between the nodes and the error value.
3. The cubic spline-based fitting method of claim 2, wherein said step of selecting said first number of nodes from said node vectors as said first nodes and using said first nodes to obtain first control points is preceded by the step of:
parameterizing all the data points to obtain a parameter value corresponding to each data point;
and processing the parameter values to obtain nodes corresponding to each parameter value, and forming the node vector.
4. The cubic spline-based fitting method as claimed in claim 3, wherein the step of obtaining a first control point using the first node comprises:
processing the first nodes by using a least square method to obtain the first control points, wherein the number of the first control points is less than that of the first nodes;
the step of parameterizing all of the data points comprises:
parameterizing all the data points using a chord length parameterization method.
5. The cubic spline-based fitting method of claim 4, further comprising:
determining a second error threshold according to the first error threshold and the current iteration frequency, wherein the change trends of the second error threshold and the current iteration frequency are opposite to each other;
selecting a node corresponding to the local maximum error value from the mapping table and adding the node into the current node to form the second node;
calculating the number of second control points corresponding to the second nodes according to the number of the second nodes;
judging whether the number of the second control points exceeds the preset maximum control point number or not;
if yes, executing a step of carrying out segmentation processing on the contour formed by all the data points; if not, the iteration is continued.
6. The fitting method based on cubic spline of claim 5, wherein the step of selecting the node corresponding to the local maximum error value from the mapping table and adding the node to the current node to form the second node comprises:
recording a node having the error value greater than the second error threshold as a third node;
and comparing the third node with the error value corresponding to the node adjacent to the third node, and recording the node corresponding to the maximum error value as the second node.
7. The cubic spline-based fitting method as claimed in claim 5, wherein the step of piecewise processing the contour composed of all the data points comprises:
approximating the outline formed by all the data points by a polygon approximation method to obtain an outline polygon;
calculating cosine values of the vertexes of the outline polygon to obtain a cosine sequence table, wherein the cosine sequence table comprises vertex coordinates and cosine values corresponding to the vertex coordinates;
selecting a vertex corresponding to the maximum cosine value from the cosine sequence table as a separation point, separating the contour into two sub-contours at the separation point, respectively fitting data points corresponding to each sub-contour, returning to the step of parameterizing all the data points to obtain a parameter value corresponding to each data point, and continuing iteration until the error between the estimated value on each spline curve and the data point is less than the first error threshold.
8. The cubic spline-based fitting method according to claim 5,
when the current iteration number is less than a first preset iteration number, the second error threshold E2 ═ max { E1, k × EMWhere E1 is the first error threshold, k is an adjustment coefficient, EMIs the maximum of all the error values;
when the current iteration number is greater than or equal to the first preset iteration number and is less than or equal to a second preset iteration number, the second error threshold E2 ═ k × EM
When the current iteration number is greater than the second preset iteration number and is less than or equal to a preset maximum iteration number, the second error threshold E2 is min { E1 ═ (I)M-IC)*(1-k),k*EMIn which IMFor said preset maximum number of iterations, ICIs the current iteration number.
9. The cubic spline-based fitting method of claim 8, further comprising:
judging whether the current iteration times are equal to the preset maximum iteration times or not;
if yes, stopping iteration; if not, continuing the iteration.
10. A curve fitting apparatus comprising a memory and a processor connected to each other, wherein the memory is adapted to store a computer program which, when executed by the processor, is adapted to carry out the cubic spline based fitting method of any one of claims 1 to 9.
CN202010340312.2A 2020-04-26 2020-04-26 Fitting method based on cubic spline and curve fitting device Pending CN113554670A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010340312.2A CN113554670A (en) 2020-04-26 2020-04-26 Fitting method based on cubic spline and curve fitting device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010340312.2A CN113554670A (en) 2020-04-26 2020-04-26 Fitting method based on cubic spline and curve fitting device

Publications (1)

Publication Number Publication Date
CN113554670A true CN113554670A (en) 2021-10-26

Family

ID=78129894

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010340312.2A Pending CN113554670A (en) 2020-04-26 2020-04-26 Fitting method based on cubic spline and curve fitting device

Country Status (1)

Country Link
CN (1) CN113554670A (en)

Similar Documents

Publication Publication Date Title
CN109571473B (en) Error-controllable small line segment trajectory fairing method
CN109976262B (en) Global curvature continuous fairing method for micro-line segment processing
CN108062073B (en) Circular arc smooth compression interpolation method for high-quality machining
CN108073138B (en) Elliptical arc smooth compression interpolation algorithm suitable for high-speed high-precision machining
US5345546A (en) Method and apparatus for generating fillet surface between two surfaces
JPH0896147A (en) Curve without degradation and smoothing method of curved surface
CN112396690B (en) Curved surface high-precision reconstruction method based on improved centripetal parameterization method
US6553337B1 (en) Parameterization of subdivision surfaces
CN112947309B (en) Robot polishing path planning method and device based on equal residual height end face
CN110689492B (en) Image edge smoothing method and device
Park An approximate lofting approach for B-spline surface fitting to functional surfaces
CN104155915A (en) Optical element random processing path planning method
Albrecht et al. Convexity preserving interpolatory subdivision with conic precision
CN108415367B (en) Automatic wire laying track global curvature fairing algorithm
CN111610751A (en) Iterative calculation method for repeatedly subdividing interpolation errors of NURBS (non-uniform rational B-spline) interpolation curve of over-point set
Song et al. Projecting points onto planar parametric curves by local biarc approximation
CN114488941A (en) Trace fairing method and medium for micro line segments and machine tool numerical control equipment
CN113554670A (en) Fitting method based on cubic spline and curve fitting device
CN112305994B (en) Straight line segment smoothing method, device and equipment based on average filtering and storage medium
CN108628255B (en) Instruction point correction smoothing processing method
KR100344917B1 (en) Information system of roll-bending process for ship's hull plates
JP2005149245A (en) Cad system, curved surface analysis device, curved surface reproducing device, and method and program therefor
Hu et al. An adaptive configuration method of knots and data parameters for NURBS curve interpolation
CN112356025B (en) Robot movement method and device for approximating NURBS curve by double arcs
CN104699904B (en) A kind of uneven allowance method of adjustment of propeller

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination