B-spline curve fitting method for image edge inspection

By constructing a preconditioning submatrix using a graph neural network and employing a preprocessing conjugate gradient method, the spectral properties of the iterative system are optimized, and the control point update direction and step size are adjusted. This solves the problem of slow image-following B-spline curve fitting speed in existing technologies, achieving a faster fitting speed.

CN122176330APending Publication Date: 2026-06-09SOUTH CHINA UNIV OF TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SOUTH CHINA UNIV OF TECH
Filing Date
2026-03-31
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Existing LSPIA methods are slow to fit large-scale contour point sets in image edge-following scenarios, making it difficult to meet the real-time requirements of industrial equipment, especially when the number of control points is large, requiring multiple iterations to achieve the preset accuracy.

Method used

A graph neural network is used to construct a preconditioning submatrix. The spectral properties of the iterative system are optimized by preprocessing the conjugate gradient method, and the update direction and step size of the control point update vector are adjusted to reduce the number of iterations and improve the fitting speed.

Benefits of technology

Without significantly increasing the computational cost per iteration, the number of iterations for B-spline curve fitting is reduced, thereby improving the fitting speed in image edge-following.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122176330A_ABST
    Figure CN122176330A_ABST
Patent Text Reader

Abstract

This invention discloses a B-spline curve fitting method for image edge-finding, comprising: extracting a set of points to be fitted from the image and initializing the set; constructing a basis function matrix of the B-spline curve based on the initialization result; calculating a normal matrix based on the basis function matrix, preprocessing the normal matrix to extract corresponding node feature vectors and edge feature vectors; inputting the node feature vectors and edge feature vectors into a graph neural network to construct a precondition submatrix; iteratively updating the control points using the preprocessed conjugate gradient method based on the precondition submatrix; and generating the final required B-spline curve based on the basis functions and the control points obtained when the iteration stops. This invention uses a precondition submatrix constructed by a graph neural network to adjust the update vectors of the B-spline curve control points, reducing the number of iterations and improving the fitting speed of the B-spline curve in image edge-finding.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the technical field of curve fitting in computer-aided drawing, and in particular to a B-spline curve fitting method for image edge following. Background Technology

[0002] B-spline curve fitting is a fundamental technique in computer-aided design and computer graphics, widely used in reverse engineering, geometric reconstruction, path planning, and image edge tracking. In image edge tracking, by extracting image contours and obtaining their B-spline curve representations, precise processing paths can be provided for CNC cutting equipment. The core objective of B-spline curve fitting is to find a set of optimal control points for a given discrete point set, such that the generated B-spline curve approximates the target point set as closely as possible.

[0003] Based on the different methods of solving for control points, existing B-spline curve fitting methods are mainly divided into two categories: one is based on the direct solution of linear equations, and the other is based on the progressive and iterative approximation for least square fitting (LSPIA) method. LSPIA updates the control point coordinates iteratively by minimizing the gradient of the objective function. Compared to methods that directly solve linear systems, LSPIA does not require constructing and solving large linear equation systems, and has advantages such as strong geometric intuition, ease of parallel implementation, low memory consumption, simple implementation, and good numerical stability. Therefore, it has been widely used in engineering practice.

[0004] However, existing LSPIA methods and their variants still face the technical bottleneck of slow fitting speed when handling large-scale contour point set fitting tasks in image edge-tracing scenarios. Specifically, the contour point sets to be processed in image edge-tracing typically have the following characteristics: first, the number of control points increases significantly with the contour complexity; second, the contour data points are unevenly distributed, with higher point density in areas of drastic curvature changes and lower point density in flat areas. These characteristics lead to a deterioration in the condition number of the normal matrix, a decrease in the iterative convergence speed, and thus affect the efficiency of image edge-tracing.

[0005] Furthermore, industrial image-based edge-tracing equipment has high real-time requirements for path generation. Existing LSPIA-like methods often require dozens or even hundreds of iterations to achieve the preset accuracy when the number of control points is large, which is difficult to meet the production efficiency requirements of high-speed cropping scenarios. Therefore, how to optimize the spectral properties of the iterative system, reduce the condition number of the normal matrix, and improve the fitting speed without significantly increasing the computational cost per iteration, based on the characteristics of the contour point set in image edge-tracing, has become a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0006] The purpose of this invention is to overcome the shortcomings and deficiencies of the prior art and propose a B-spline curve fitting method for image edge following. This method can optimize the spectral properties of the iterative system and reduce the number of iterations for B-spline curve fitting without significantly increasing the computational cost per iteration, thereby improving the fitting speed.

[0007] To achieve the above objectives, the technical solution provided by this invention is: a B-spline curve fitting method for image edge following, comprising the following steps:

[0008] S1: Extract the set of points to be fitted from the image, and initialize the set of points to obtain the parameter values, node vectors, basis functions and control points of the B-spline curve;

[0009] S2: Construct the basis function matrix of the B-spline curve based on the parameter values, node vectors, and basis functions obtained from the initialization process;

[0010] S3: Calculate the normal matrix based on the basis function matrix, preprocess the normal matrix to obtain the matrix element values. The normal matrix between them is obtained, and the preprocessed normal matrix is ​​converted into graph structure data for feature extraction, extracting the corresponding node feature vectors and edge feature vectors;

[0011] S4: Input the node feature vectors and edge feature vectors into the pre-trained graph neural network, output an auxiliary matrix with the same sparse structure as the normal matrix, and construct a symmetric positive definite precondition submatrix based on the auxiliary matrix.

[0012] S5: Based on the precondition submatrix, the control points are iteratively updated using the preprocessing conjugate gradient method. In each iteration, the update direction and step size of the control point update vector are adjusted using the precondition submatrix until the fitting error of the B-spline curve meets the preset accuracy or the maximum number of iterations is reached, at which point the iteration stops.

[0013] S6: Based on the basis functions of the B-spline curve and the control points obtained when the iteration stops, generate the final required B-spline curve and use this B-spline curve as the output result of image edge-tracing.

[0014] Furthermore, the specific steps of step S1 are as follows:

[0015] S11: Extract contours from the target image using a contour extraction algorithm, and use the extracted contours as the set of points to be fitted. For point sets The parameter values ​​are obtained through chord length parameterization. :

[0016] ;

[0017] In the formula, Indicates the first Parameter values, Indicates the first -1 parameter value, Represents a point set The number of midpoints Represents the first point in the point set. One point, Represents the first point in the point set. -1 point, Indicates L2 normal form;

[0018] S12: For parameter values The node vector is obtained by uniform partitioning. :

[0019] ;

[0020] ;

[0021] ;

[0022] ;

[0023] In the formula, Indicates the first 1 node Indicates the first Parameter values, Indicates the first Parameter values, This represents the weighting coefficient for the parameter values. The index scaling factor represents the parameter value. Indicates the number of control points. Indicates rounding down;

[0024] S13: Use the obtained node vector Define the basis functions of B-spline curves ,in Indicates the first One basis function;

[0025] S14: From the point set Selecting evenly Control points :

[0026] ;

[0027] In the formula, Indicates the first One control point.

[0028] Furthermore, in step S2, the parameterization... Substitute into the basis functions of the B-spline curve The first Parameter values In the basis functions basis function values ​​on Using basis function values Constructing the basis function matrix of B-spline curves :

[0029] ;

[0030] In the formula, Represents a point set The number of midpoints This indicates the number of control points.

[0031] Furthermore, the specific steps of step S3 are as follows:

[0032] S31: For the basis function matrix normal matrix Through the basis function matrix The transpose of the matrix multiplied by the basis function matrix get:

[0033] In the normal matrix Before converting to a graph structure, preprocessing is performed to obtain the matrix element values. normal matrix between :

[0034] ;

[0035] In the formula, Representation matrix The maximum value of the non-zero elements;

[0036] S32: From the preprocessed normal matrix Extract the edge and node information of the graph to form graph structure data. ,in, Represents the normal matrix obtained from the preprocessing. Edge information composed of non-zero elements This represents node information where all values ​​are 1;

[0037] S33: For graph-structured data Feature extraction was performed using two multilayer perceptrons with two network layers and the GELU activation function, respectively, to obtain node feature vectors and edge feature vectors:

[0038] ;

[0039] ;

[0040] In the formula, Indicates the first Each node's feature vector Indicates the first Each edge feature vector The value of 1 represents the first Node information, The representation value is the normal matrix. No. Edge information of non-zero elements, This represents a multilayer perceptron used for node feature extraction. This represents a multilayer perceptron used for edge feature extraction.

[0041] Furthermore, the specific steps of step S4 are as follows:

[0042] S41: Constructing a system containing A graph neural network consisting of one message-passing layer and one decoding layer. The message-passing layer mixes node feature vectors and edge feature vectors in a high-dimensional space to obtain new node feature vectors and edge feature vectors. Each message-passing layer consists of three multilayer perceptrons. The components are message mapping multilayer perceptron. Node feature vector update multilayer perceptron Updating the multilayer perceptron with edge feature vectors These are used for message mapping, node feature vector update, and edge feature vector update, respectively:

[0043] ;

[0044] ;

[0045] ;

[0046] In the formula, They represent the times after which The message passing layer obtains the first Individual information feature vectors and node feature vectors They represent the times after which The message passing layer obtains the first Individual information feature vectors and node feature vectors Indicates after the first The corresponding message passing layer obtained by the first layer The node and the first The edge feature vectors of each node. Indicates after the first The corresponding message passing layer obtained by the first layer The node and the first The edge feature vectors of each node. Represents a node The neighborhood group, This indicates an aggregation operation that does not change the substitution.

[0047] Each multilayer sensor It consists of a fully connected layer and a GELU activation function:

[0048] In the formula, Indicates a fully connected layer;

[0049] The decoding layer consists of a multilayer perceptron, which maps the edge feature vectors of the last layer to an auxiliary matrix. Each edge feature vector is mapped to an auxiliary matrix. One of the elements;

[0050] S42: Input the node feature vectors and edge feature vectors extracted from the graph structure data into the pre-trained graph neural network, and output the normal matrix. Auxiliary matrices with the same sparse structure Using auxiliary matrix Constructing the precondition submatrix :

[0051] ;

[0052] In the formula, Representative auxiliary matrix The transpose of the matrix, Represents a constant greater than 0. Represents the identity matrix;

[0053] S43: Construct the training dataset for the graph neural network. The training dataset contains multiple normal matrices. Samples were used to pre-train the graph neural network using the loss function:

[0054] ;

[0055] In the formula, This represents the preprocessed normal matrix. Represents a random vector. This represents the square of the L2 norm.

[0056] Furthermore, the specific steps of step S5 are as follows:

[0057] S51: The control points are iteratively updated using the preprocessed conjugate gradient method. Each iteration updates the control points based on the point set. The basis function matrix of B-spline curves and control points Calculate the control point update vector :

[0058] ;

[0059] In the formula, Representing the basis function matrix The transpose of the matrix, Indicates the first Control point update vector in the next iteration Indicates the first Control points at the next iteration;

[0060] S52: In each iteration, the preconditioning submatrix is... This is applied to the control point update vector to optimize the update direction and step size of the control point update vector:

[0061] ;

[0062] In the formula, Indicates the first The corrected control point update vector in the next iteration, the corrected control point update vector As a preprocessing vector for the conjugate gradient method, update the control points;

[0063] S53: Record the current iteration number and use the fitting error of the B-spline curve to measure the current fitting accuracy:

[0064] ;

[0065] In the formula, express The fitting error of the B-spline curve after the first iteration Represents a point set The number of midpoints Represents a point set The first in One point, Indicates the number of control points. Indicates the first Parameter values In the basis functions The basis function values ​​on, express After the nth iteration One control point, Indicates L2 normal form;

[0066] When the fitting error of the B-spline curve Less than the preset fitting accuracy Or reach the maximum number of iterations Stop iterating when the time comes.

[0067] Furthermore, in step S6, the final required B-spline curve is generated. Represented as:

[0068] ;

[0069] In the formula, Indicates the number of control points. Indicates the first basis functions This indicates the result obtained when the iteration stops. One control point.

[0070] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0071] 1. This invention designs a precondition submatrix for constructing an iterative system using a graph neural network. Applying this to B-spline curve fitting can effectively optimize the spectral properties of the iterative system.

[0072] 2. This invention utilizes the learning capability of graph neural networks to reduce the number of iterations without significantly increasing the computational cost of a single iteration for B-spline curve fitting.

[0073] 3. This invention utilizes a precondition submatrix to adjust the update direction and step size of the control point update vector during the iterative process of B-spline curve fitting, thereby improving the fitting speed of B-spline curves in image edge-following.

[0074] In summary, this invention can construct a precondition submatrix for an iterative system using a graph neural network, optimize the spectral properties of the iterative system using the precondition submatrix, and adjust the update direction and step size of the B-spline curve control point update vector during the iteration process, thereby reducing the number of iterations and improving the fitting speed of B-spline curves in image edge following. Attached Figure Description

[0075] Figure 1 This is a schematic diagram of the logical flow of the method of the present invention.

[0076] Figure 2 This is a schematic diagram of a multilayer perceptron structure example.

[0077] Figure 3 This is a schematic diagram of an example of a graph neural network structure. Detailed Implementation

[0078] The present invention will be further described in detail below with reference to the embodiments and accompanying drawings, but the embodiments of the present invention are not limited thereto.

[0079] like Figure 1As shown, this embodiment discloses a B-spline curve fitting method for image edge following. It utilizes a graph neural network to construct a preconditioning submatrix for the iterative system and employs a preprocessing conjugate gradient method to iteratively update the control points. In each iteration, the preconditioning submatrix is ​​used to adjust the update direction and step size of the control point update vector. The method includes the following steps:

[0080] 1) Initialization of point sets:

[0081] Extract the set of points to be fitted from the image, and initialize the set of points to obtain the parameter values, node vectors, basis functions, and control points of the B-spline curve. The specific steps are as follows:

[0082] 1.1) Extract contours from the target image using a contour extraction algorithm, and use the extracted contours as the set of points to be fitted. For point sets The parameter values ​​are obtained through chord length parameterization. :

[0083] ;

[0084] In the formula, Indicates the first Parameter values, Indicates the first -1 parameter value, Represents a point set The number of midpoints Represents the first point in the point set. One point, Represents the first point in the point set. -1 point, Indicates L2 normal form;

[0085] 1.2) Regarding parameter values The node vector is obtained by uniform partitioning. :

[0086] ;

[0087] ;

[0088] ;

[0089] ;

[0090] In the formula, Indicates the first 1 node Indicates the first Parameter values, Indicates the first Parameter values, This represents the weighting coefficient for the parameter values. The index scaling factor represents the parameter value. Indicates the number of control points. Indicates rounding down;

[0091] 1.3) Use the obtained node vector Define the basis functions of B-spline curves ,in Indicates the first One basis function;

[0092] 1.4) From the point set Selecting evenly Control points :

[0093] ;

[0094] In the formula, Indicates the first One control point.

[0095] 2) Construction of the basis function matrix for B-spline curves:

[0096] Based on the parameter values ​​obtained from the initialization process Node vectors and basis functions Construct the basis function matrix of the B-spline curve, specifically by parameterizing... Substitute into the basis functions of the B-spline curve The first Parameter values In the basis functions basis function values ​​on Using basis function values Constructing the basis function matrix of B-spline curves :

[0097] ;

[0098] In the formula, Represents a point set The number of midpoints This indicates the number of control points.

[0099] 3) Feature vector extraction:

[0100] The normal matrix is ​​calculated based on the basis function matrix. The normal matrix is ​​then preprocessed and converted into graph structure data for feature extraction. The corresponding node feature vectors and edge feature vectors are extracted. The specific steps are as follows:

[0101] 3.1) For the basis function matrix normal matrix Multiplying the basis function matrix by the transpose of the basis function matrix get:

[0102] ;

[0103] In the formula, Representing the basis function matrix The transpose of .

[0104] In the normal matrix Before converting to a graph structure, preprocessing is performed to obtain the matrix element values. normal matrix between :

[0105] ;

[0106] In the formula, Representation matrix The maximum value of non-zero elements.

[0107] 3.2) From the preprocessed normal matrix Extract the edge and node information of the graph to form graph structure data. ,in, Represents the normal matrix obtained from the preprocessing. Edge information composed of non-zero elements This represents node information where all values ​​are 1.

[0108] 3.3) For example Figure 2 As shown, for graph structure data Feature extraction was performed using two multilayer perceptrons with two network layers and the GELU activation function, respectively, to obtain node feature vectors and edge feature vectors:

[0109] ;

[0110] ;

[0111] In the formula, Indicates the first Each node's feature vector Indicates the first Each edge feature vector The value of 1 represents the first Node information, The representation value is the normal matrix. No. Edge information of non-zero elements, This represents a multilayer perceptron used for node feature extraction. This represents a multilayer perceptron used for edge feature extraction.

[0112] 4) Constructing preconditioning submatrices using graph neural networks:

[0113] The node feature vectors and edge feature vectors are input into a pre-trained graph neural network, which outputs an auxiliary matrix with the same sparse structure as the normal matrix. A symmetric positive definite precondition submatrix is ​​then constructed based on the auxiliary matrix, which includes the following steps:

[0114] 4.1) As Figure 3 As shown, the construction includes A graph neural network consisting of one message-passing layer and one decoding layer. The message-passing layer mixes node feature vectors and edge feature vectors in a high-dimensional space to obtain new node feature vectors and edge feature vectors. Each message-passing layer consists of three multilayer perceptrons. The components are message mapping multilayer perceptron. Node feature vector update multilayer perceptron Updating the multilayer perceptron with edge feature vectors These are used for message mapping, node feature vector update, and edge feature vector update, respectively:

[0115] ;

[0116] ;

[0117] ;

[0118] In the formula, They represent the times after which The message passing layer obtains the first Individual information feature vectors and node feature vectors They represent the times after which The message passing layer obtains the first Individual information feature vectors and node feature vectors Indicates after the first The corresponding message passing layer obtained by the first layer The node and the first The edge feature vectors of each node. Indicates after the first The corresponding message passing layer obtained by the first layer The node and the first The edge feature vectors of each node. Represents a node The neighborhood group, This indicates an aggregation operation that does not change the substitution.

[0119] Each multilayer sensor It consists of a fully connected layer and a GELU activation function:

[0120] ;

[0121] In the formula, Indicates a fully connected layer;

[0122] The decoding layer consists of a multilayer perceptron, which maps the edge feature vectors of the last layer to an auxiliary matrix. Each edge feature vector is mapped to an auxiliary matrix. One of the elements;

[0123] 4.2) The node feature vectors and edge feature vectors extracted from the graph structure data are input into the pre-trained graph neural network, and the output is the normal matrix. Auxiliary matrices with the same sparse structure Using auxiliary matrix Constructing the precondition submatrix :

[0124] ;

[0125] In the formula, Representative auxiliary matrix The transpose of the matrix, Represents a constant greater than 0. Represents the identity matrix.

[0126] 4.3) Construct the training dataset for the graph neural network, generating 12,800 control points using a random generation method. The B-spline curves between the given points are initialized, and their normal matrices are calculated. These normal matrices are then used as samples in the training dataset, and the graph neural network is pre-trained using the loss function `loss`.

[0127] ;

[0128] In the formula, This represents the preprocessed normal matrix. Represents the identity matrix. Represents a random vector. This represents the square of the L2 norm.

[0129] 5) Update control points using preconditional submatrices:

[0130] Based on the preconditioning submatrix, the preprocessed conjugate gradient method is used to iteratively update the control points. In each iteration, the preconditioning submatrix is ​​used to adjust the update direction and step size of the control point update vector until the fitting error of the B-spline curve meets the preset accuracy or the maximum number of iterations is reached, at which point the iteration stops. The specific operation steps are as follows:

[0131] 5.1) The control points are iteratively updated using the preprocessed conjugate gradient method. Each iteration updates the control points based on the point set. The basis function matrix of B-spline curves and control points Calculate the control point update vector :

[0132] ;

[0133] In the formula, Representing the basis function matrix The transpose of the matrix, Indicates the first Control point update vector in the next iteration Indicates the first Control point during the next iteration.

[0134] 5.2) In each iteration, the precondition submatrix is... This is applied to the control point update vector to optimize the update direction and step size of the control point update vector:

[0135] ;

[0136] In the formula, Indicates the first The control point update vector corrected in the next iteration.

[0137] 5.3) Update the corrected control point vectors As a control point for updating the preprocessing vector in the conjugate gradient method :

[0138] ;

[0139] ;

[0140] In the formula, Indicates the first Control point update vector in the next iteration This indicates the transpose operation. Indicates the first The conjugate vector at the next iteration The normal matrix of the B-spline is represented by... Indicates the first The control point at the next iteration is set as follows: .

[0141] 5.4) Record the current iteration number and use the fitting error of the B-spline curve to measure the current fitting accuracy:

[0142] ;

[0143] In the formula, express The fitting error of the B-spline curve after the first iteration Represents a point set The number of midpoints Represents a point set The first in One point, Indicates the number of control points. Indicates the first Parameter values In the basis functions The basis function values ​​on, express After the nth iteration One control point, This represents the L2 paradigm.

[0144] When the fitting error of the B-spline curve Less than the preset fitting accuracy Or reach the maximum number of iterations Stop iterating when the time comes.

[0145] 6) Generate B-spline curves:

[0146] Based on the B-spline basis functions and the control points obtained at the stopping iteration, the final required B-spline curve is generated, and this curve is used as the output of image edge-tracing. Represented as:

[0147] ;

[0148] In the formula, Indicates the number of control points. Indicates the first basis functions This indicates the result obtained when the iteration stops. One control point.

[0149] To verify the effectiveness of the method of the present invention, experiments were conducted on four contour point sets extracted from the image. Contour 1 has 5267 points and 800 control points, contour 2 has 14256 points and 1000 control points, contour 3 has 26330 points and 1500 control points, and contour 4 has 21873 points and 2000 control points. The results were compared with LSPIA, MLSPIA, TLSPIA, HLSPIA, ALSPIA, and CG-LSPIA methods. The experimental results are shown in Table 1.

[0150] Table 1. Analysis of Experimental Results

[0151]

[0152] Experimental results fully demonstrate the effectiveness of the method of this invention. By constructing a precondition submatrix for the iterative system using a graph neural network, and employing the preprocessing conjugate gradient method to iteratively update the control points, the update direction and step size of the control point update vector are adjusted using the precondition submatrix in each iteration, which can improve the fitting speed of B-spline curves.

[0153] Experimental Conclusion: To address the issue of slow fitting speed in image edge-finding tasks involving large-scale point sets, this invention proposes a B-spline curve fitting method for image edge-finding. Experimental evaluation on four contour point sets extracted from the image shows that the method of this invention significantly improves the fitting speed of B-spline curves, outperforming existing methods.

[0154] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.

Claims

1. A B-spline curve fitting method for image edge following, characterized in that, Includes the following steps: S1: Extract the set of points to be fitted from the image, and initialize the set of points to obtain the parameter values, node vectors, basis functions and control points of the B-spline curve; S2: Construct the basis function matrix of the B-spline curve based on the parameter values, node vectors, and basis functions obtained from the initialization process; S3: Calculate the normal matrix based on the basis function matrix, preprocess the normal matrix to obtain the matrix element values. The normal matrix between them is obtained, and the preprocessed normal matrix is ​​converted into graph structure data for feature extraction, extracting the corresponding node feature vectors and edge feature vectors; S4: Input the node feature vectors and edge feature vectors into the pre-trained graph neural network, output an auxiliary matrix with the same sparse structure as the normal matrix, and construct a symmetric positive definite precondition submatrix based on the auxiliary matrix. S5: Based on the precondition submatrix, the control points are iteratively updated using the preprocessing conjugate gradient method. In each iteration, the update direction and step size of the control point update vector are adjusted using the precondition submatrix until the fitting error of the B-spline curve meets the preset accuracy or the maximum number of iterations is reached, at which point the iteration stops. S6: Based on the basis functions of the B-spline curve and the control points obtained when the iteration stops, generate the final required B-spline curve and use this B-spline curve as the output result of image edge-tracing.

2. The B-spline curve fitting method for image edge following according to claim 1, characterized in that, The specific steps for step S1 are as follows: S11: Extract contours from the target image using a contour extraction algorithm, and use the extracted contours as the set of points to be fitted. For point sets The parameter values ​​are obtained through chord length parameterization. : ; In the formula, Indicates the first Parameter values, Indicates the first -1 parameter value, Represents a point set The number of midpoints Represents the first point in the point set. One point, Represents the first point in the point set. -1 point, Indicates L2 normal form; S12: For parameter values The node vector is obtained by uniform partitioning. : ; ; ; ; In the formula, Indicates the first 1 node Indicates the first Parameter values, Indicates the first Parameter values, This represents the weighting coefficient for the parameter values. The index scaling factor represents the parameter value. Indicates the number of control points. Indicates rounding down; S13: Use the obtained node vector Define the basis functions of B-spline curves ,in Indicates the first One basis function; S14: From the point set Selecting evenly Control points : ; In the formula, Indicates the first One control point.

3. The B-spline curve fitting method for image edge following according to claim 2, characterized in that, In step S2, parameterization is performed. Substitute into the basis functions of the B-spline curve The first Parameter values In the basis functions basis function values ​​on Using basis function values Constructing the basis function matrix of B-spline curves : ; In the formula, Represents a point set The number of midpoints This indicates the number of control points.

4. The B-spline curve fitting method for image edge following according to claim 3, characterized in that, The specific steps for step S3 are as follows: S31: For the basis function matrix normal matrix Through the basis function matrix The transpose of the matrix multiplied by the basis function matrix get: In the normal matrix Before converting to a graph structure, preprocessing is performed to obtain the matrix element values. normal matrix between : ; In the formula, Representation matrix The maximum value of the non-zero elements; S32: From the preprocessed normal matrix Extract the edge and node information of the graph to form graph structure data. ,in, Represents the normal matrix obtained from the preprocessing. Edge information composed of non-zero elements This represents node information where all values ​​are 1; S33: For graph-structured data Feature extraction was performed using two multilayer perceptrons with two network layers and the GELU activation function, respectively, to obtain node feature vectors and edge feature vectors: ; ; In the formula, Indicates the first Each node's feature vector Indicates the first Each edge feature vector The value of 1 represents the first Node information, The representation value is the normal matrix. No. Edge information of non-zero elements, This represents a multilayer perceptron used for node feature extraction. This represents a multilayer perceptron used for edge feature extraction.

5. The B-spline curve fitting method for image edge following according to claim 4, characterized in that, The specific steps for step S4 are as follows: S41: Constructing a system containing A graph neural network consisting of one message-passing layer and one decoding layer. The message-passing layer mixes node feature vectors and edge feature vectors in a high-dimensional space to obtain new node feature vectors and edge feature vectors. Each message-passing layer consists of three multilayer perceptrons. The components are message mapping multilayer perceptron. Node feature vector update multilayer perceptron Updating the multilayer perceptron with edge feature vectors These are used for message mapping, node feature vector update, and edge feature vector update, respectively: ; ; ; In the formula, They represent the times after which The message passing layer obtains the first Individual information feature vectors and node feature vectors They represent the times after which The message passing layer obtains the first Individual information feature vectors and node feature vectors Indicates after the first The corresponding message passing layer obtained by the first layer The node and the first The edge feature vectors of each node. Indicates after the first The corresponding message passing layer obtained by the first layer The node and the first The edge feature vectors of each node. Represents a node The neighborhood group, This indicates an aggregation operation that does not change the substitution. Each multilayer sensor It consists of a fully connected layer and a GELU activation function: In the formula, Indicates a fully connected layer; The decoding layer consists of a multilayer perceptron, which maps the edge feature vectors of the last layer to an auxiliary matrix. Each edge feature vector is mapped to an auxiliary matrix. One of the elements; S42: Input the node feature vectors and edge feature vectors extracted from the graph structure data into the pre-trained graph neural network, and output the normal matrix. Auxiliary matrices with the same sparse structure Using auxiliary matrix Constructing the precondition submatrix : ; In the formula, Representative auxiliary matrix The transpose of the matrix, Represents a constant greater than 0. Represents the identity matrix; S43: Construct the training dataset for the graph neural network. The training dataset contains multiple normal matrices. Samples were used to pre-train the graph neural network using the loss function: ; In the formula, This represents the preprocessed normal matrix. Represents a random vector. This represents the square of the L2 norm.

6. The B-spline curve fitting method for image edge following according to claim 5, characterized in that, The specific steps for step S5 are as follows: S51: The control points are iteratively updated using the preprocessed conjugate gradient method. Each iteration updates the control points based on the point set. The basis function matrix of B-spline curves and control points Calculate the control point update vector : ; In the formula, Representing the basis function matrix The transpose of the matrix, Indicates the first Control point update vector in the next iteration Indicates the first Control points at the next iteration; S52: In each iteration, the preconditioning submatrix is... This is applied to the control point update vector to optimize the update direction and step size of the control point update vector: ; In the formula, Indicates the first The corrected control point update vector in the next iteration, the corrected control point update vector As a preprocessing vector for the conjugate gradient method, update the control points; S53: Record the current iteration number and use the fitting error of the B-spline curve to measure the current fitting accuracy: ; In the formula, express The fitting error of the B-spline curve after the first iteration Represents a point set The number of midpoints Represents a point set The first in One point, Indicates the number of control points. Indicates the first Parameter values In the basis functions The basis function values ​​on, express After the nth iteration One control point, Indicates L2 normal form; When the fitting error of the B-spline curve Less than the preset fitting accuracy Or reach the maximum number of iterations Stop iterating when the time comes.

7. The B-spline curve fitting method for image edge following according to claim 6, characterized in that, In step S6, the final required B-spline curve is generated. Represented as: ; In the formula, Indicates the number of control points. Indicates the first basis functions This indicates the result obtained when the iteration stops. One control point.