A multi-angle template matching method based on gradient topology sparse coding

CN121236424BActive Publication Date: 2026-10-30JILIN PROVINCE BELONG AUTOMOTIVE EQUIP & TECH CO
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511649647.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-12
Publication Date
2026-10-30
Estimated Expiration
2045-11-12

AI Technical Summary

Technical Problem

[0002]在传统模板匹配算法在多角度、多尺度及噪声干扰条件下存在鲁棒性差和计算量高的问题

Benefits of technology

[0045]利用本发明的技术方案制作的一种基于梯度拓扑稀疏编码的多角度模板匹配方法,基于梯度拓扑骨架的特征对光照变化不敏感,能有效克服灰度偏移和噪声干扰,提升在复杂环境下的匹配稳定性。通过构建系数域旋转映射关系,无需对图像进行物理旋转重建,显著减少多角度匹配的计算开销,提升搜索效率,利用稀疏编码对图像结构进行紧凑表示,增强对局部形变和部分遮挡的适应能力,在匹配结果后处理中引入非极大值抑制与梯度上升角度微调,进一步提升定位与角度估计的精度,方法适用于工业视觉定位、机器人抓取、医疗图像配准等多种需要高精度模板匹配的场景。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121236424B_ABST
    Figure CN121236424B_ABST
Patent Text Reader

Abstract

The application discloses a kind of multi-angle template matching methods based on gradient topological sparse coding, comprising the following steps: step S1: template image gradient topological skeleton extraction;Step S2: skeleton sparse dictionary construction and coding;Step S3: coefficient domain rotation mapping construction;Step S4: multi-angle matching and similarity calculation;Step S5: result fusion and optimization.The application relates to the technical field of computer vision and image processing, and the beneficial effects of the application are that the features based on gradient topological skeleton are not sensitive to illumination changes, can effectively overcome gray offset and noise interference, and improve the matching stability in complex environments.By constructing the rotation mapping relationship in the coefficient domain, there is no need to physically rotate and reconstruct the image, which significantly reduces the computational overhead of multi-angle matching, improves the search efficiency, uses sparse coding to compactly represent the image structure, and enhances the adaptability to local deformation and partial occlusion.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision and image processing, and in particular to a multi-angle template matching method based on gradient topological sparse coding. Background Technology

[0002] Traditional template matching algorithms suffer from poor robustness and high computational cost under conditions of multi-angle, multi-scale, and noise interference. Common matching methods include gray-scale-based correlation matching and histogram of orientation (HOG)-based matching methods, but these methods usually require multi-angle rotation of the template to generate multiple template samples, resulting in a significant increase in computational cost.

[0003] Furthermore, traditional methods only utilize local pixel or gradient intensity information in the image, ignoring the spatial topology of the gradient field, thus limiting their adaptability to occlusion, illumination changes, and rotational distortion. Therefore, a novel template matching mechanism is needed that can express image structural features in a more compact way and maintain similarity stability under varying rotation angles. Summary of the Invention

[0004] The purpose of this invention is to solve the above problems by designing a multi-angle template matching method based on gradient topological sparse coding.

[0005] The technical solution of the present invention to achieve the above objectives is a multi-angle template matching method based on gradient topological sparse coding, comprising the following steps:

[0006] Step S1: Gradient topological skeleton extraction of the template image;

[0007] Step S2: Skeleton sparse dictionary construction and encoding;

[0008] Step S3: Construct the coefficient domain rotation map;

[0009] Step S4: Multi-angle matching and similarity calculation;

[0010] Step S5: Result fusion and optimization.

[0011] In step S1, the input data includes:

[0012] Template image T(x,y);

[0013] Search image ;

[0014] Algorithm control parameters: including topology threshold sparse regularization coefficient Angle search range Angle step size And the maximum number of iterations T.

[0015] The initialization phase first calculates the gradient vector field of the template image: ;

[0016] Meaning: Calculate the gradient vector of the template image T(x,y) at each pixel (x,y) (Gx is the gradient in the x-direction, and Gy is the gradient in the y-direction).

[0017] Logical reasoning: Gradients are the "fingerprints" of image edges—they are insensitive to changes in illumination (overall shifts in grayscale values ​​do not affect the gradient) and can accurately describe edge direction (the gradient direction is perpendicular to the edge). Compared to directly matching grayscale values, gradient features are more robust.

[0018] Define the topological potential function Let the divergence of the gradient field be: ;

[0019] In step S2: To simulate the sparse representation and efficient matching of image structural features, this invention constructs a skeleton sparse dictionary. And obtain the coefficient vector through sparse coding. :

[0020] ;

[0021] Explanation of formula parameters:

[0022] : Local feature blocks extracted from the skeleton point set S (such as gradient features of the k*k region around each skeleton point (x,y), or high-dimensional feature vectors that combine gradient and divergence).

[0023] : A complete dictionary;

[0024] : Sparse coefficient vector;

[0025] : Sparse regularization coefficient.

[0026] In step S3: Establish the correspondence between spatial domain rotation and coefficient domain mapping. For the rotation angle... There exists a linear mapping matrix. , so that:

[0027] ;

[0028] Explanation of formula parameters:

[0029] Spatial domain rotation operation (rotating the template or its reconstructed result) Rotation Angle, obtained );

[0030] Original sparsity coefficients (for skeleton sub-plots when the template is not rotated) The sparse coding result, i.e. );

[0031] Rotation The sparse coefficients (hopefully obtained through coefficient field mapping) are such that... (This is the result of reconstructing the template after rotation).

[0032] : Through a complete dictionary (a learned sparse dictionary used to reconstruct skeleton features).

[0033] In step S4: skeleton coefficients are extracted from the sliding window of the search image. Calculate the template at the angle coefficients below The matching score is defined as: ;

[0034] Explanation of formula parameters:

[0035] Rotation The sparse coefficients of the template are obtained through a rotation mapping of the coefficient domain. ,in It is the sparsity coefficient of the original template. It is a pre-learned linear mapping matrix.

[0036] : Sparse coefficient of candidate region in search image: Extract skeleton sub-patterns from the sliding window (candidate region) of the search image and obtain them through sparse coding (consistent with the sparse coding process of template: extract skeleton → sparse coding).

[0037] : and The dot product measures the degree of overlap (directional consistency) between two vectors.

[0038] In step S5: the matching results of each candidate window are subjected to non-maximum suppression and local angle fine-tuning, and the angle is optimized using the gradient ascent method.

[0039] .

[0040] Explanation of formula parameters:

[0041] : The angle of the current iteration (the angle of the t-th iteration, such as the candidate angle found in step S4 as the initial value). =3°).

[0042] : The angle of the next iteration (the angle of the (t+1)th iteration, such as 3°+0.1°=3.1°).

[0043] Learning rate (step size) (controls the angle adjustment range in each iteration) >0, such as 0.1° or 0.01°).

[0044] The gradient of score with respect to θ (the rate at which score changes with angle, i.e., "how fast the score increases").

[0045] This invention presents a multi-angle template matching method based on gradient topological sparse coding. The gradient topological skeleton features are insensitive to illumination changes, effectively overcoming grayscale shifts and noise interference, and improving matching stability in complex environments. By constructing a coefficient domain rotation mapping relationship, physical rotation and reconstruction of the image are eliminated, significantly reducing the computational overhead of multi-angle matching and improving search efficiency. Sparse coding provides a compact representation of the image structure, enhancing adaptability to local deformations and partial occlusion. Non-maximum suppression and gradient ascent angle fine-tuning are introduced in the post-processing of the matching results to further improve the accuracy of localization and angle estimation. This method is applicable to various scenarios requiring high-precision template matching, such as industrial vision localization, robot grasping, and medical image registration. Attached Figure Description

[0046] Figure 1 This is a flowchart of a multi-angle template matching method based on gradient topological sparse coding as described in this invention. Detailed Implementation

[0047] The present invention will now be described in detail with reference to the accompanying drawings, such as... Figure 1 As shown, a multi-angle template matching method based on gradient topological sparse coding is described, with step S1: extraction of gradient topological skeleton from the template image.

[0048] This invention uses multi-angle template matching as the optimization objective. The input data includes: (1) template image T(x,y); (2) search image. (3) Algorithm control parameters, including topology threshold. sparse regularization coefficient Angle search range Angle step size And the maximum number of iterations T.

[0049] The initialization phase first calculates the gradient vector field of the template image: ;

[0050] Formula logic:

[0051] Meaning: Calculate the gradient vector of the template image T(x,y) at each pixel (x,y) (Gx is the gradient in the x-direction, and Gy is the gradient in the y-direction).

[0052] Logical reasoning: Gradients are the "fingerprints" of image edges—they are insensitive to changes in illumination (overall shifts in grayscale values ​​do not affect the gradient) and can accurately describe edge direction (the gradient direction is perpendicular to the edge). Compared to directly matching grayscale values, gradient features are more robust.

[0053] Define the topological potential function Let the divergence of the gradient field be: ;

[0054] Formula logic:

[0055] Meaning: Calculates the divergence of the gradient vector field, measuring the degree of divergence of the gradient vector at pixel (x,y).

[0056] Logically: Divergence is a topological feature that accurately captures key structural points in an image (such as corners, edge intersections, and inflection points). The gradient direction of straight edges is consistent, with a divergence Φ≈0 (gradient vectors are parallel and do not diverge). At corners (such as the corners of a rectangle), the gradient direction diverges outwards from the corner, resulting in a large absolute value of divergence Φ (vectors spreading outwards from the point have positive divergence; or converging inwards have negative divergence). Therefore, extracting skeleton points using divergence essentially preserves the pixels in the template that best represent its topological structure. These points are the matching "anchor points," and their divergence features can still be stably identified even if the template is rotated.

[0057] Then in Extract the skeleton point set from the region and with gradient magnitude As skeleton weights, the gradient magnitude of each skeleton point is calculated and used as its matching weight. The gradient magnitude is a measure of edge strength—a larger gradient magnitude indicates a clearer and more prominent edge at that point. In subsequent matching, skeleton points with larger weights contribute more to the matching result (for example, when calculating the similarity between the template and the search image, the similarity of each skeleton point is multiplied by its corresponding M(x,y)). The purpose of this design is to make the matching algorithm focus more on the clearest and most representative feature points in the template, reducing the interference of noise points (points with small gradient magnitudes) on the matching.

[0058] Step S2: Skeleton sparse dictionary construction and encoding;

[0059] To simulate sparse representation and efficient matching of image structural features, this invention constructs a skeleton sparse dictionary. And obtain the coefficient vector through sparse coding. :

[0060] ;

[0061] Explanation of formula parameters:

[0062] : Local feature blocks extracted from the skeleton point set S (such as gradient features of the k*k region around each skeleton point (x,y), or high-dimensional feature vectors that combine gradient and divergence).

[0063] : A complete dictionary;

[0064] : Sparse coefficient vector;

[0065] : Sparse regularization coefficient.

[0066] Formula logic:

[0067] The core of the formula is that the goal of the optimization problem is to find the optimal sparsity coefficients. To minimize the reconstruction error (using Accurate representation ); As sparse as possible (represented by only a few atoms) ).

[0068] Reconstruction error term: ;

[0069] Meaning: Using a dictionary Sum of coefficients Reconstruct skeleton subplots The error, using Norm squared metric (the most commonly used "distance" metric in linear algebra).

[0070] Logic: Ensuring the accuracy of sparse coding – after reconstruction Must be with the original Highly similar, otherwise it will be lost. Key features (such as gradient and divergence information of skeleton points).

[0071] Sparse regularization terms: ;

[0072] Meaning: Use Norm (sum of absolute values) measure sparsity, It is the "sparseness weight".

[0073] logic: The unique property of norms is that they can produce "sparse solutions" (i.e., (Most elements are 0), while Norms (sum of squares) cannot do this ( The contour lines are circular, so optimization tends to favor small and dense solutions rather than sparse ones.

[0074] For example: If (Only the 3rd and 5th elements are non-zero), then =0.8 + 0.3 = 1.1, indicating strong sparsity; if If all elements are very small (e.g., 0.1, 0.1, ..., 0.1), then... =20 (assuming 200 elements), which has very poor sparsity. Its purpose is to balance "reconstruction accuracy" and "sparseness":

[0075] like Too big: Will be forced Excessive sparsity (many non-zero elements are compressed to 0) leads to reconstruction errors. Increase (loss of key features);

[0076] like Too small: The sparsity is insufficient (many redundant elements are non-zero), which cannot reduce the amount of computation or filter noise.

[0077] By using sparse coding, high-dimensional skeleton features are mapped to a low-dimensional sparse space, significantly reducing the computational cost of subsequent matching.

[0078] step : Construction of coefficient domain rotation mapping;

[0079] Establish the correspondence between spatial domain rotation and coefficient domain mapping. For rotation angle... There exists a linear mapping matrix. , so that:

[0080] ;

[0081] Explanation of formula parameters:

[0082] Spatial domain rotation operation (rotating the template or its reconstructed result) Rotation Angle, obtained );

[0083] Original sparsity coefficients (for skeleton sub-plots when the template is not rotated) The sparse coding result, i.e. );

[0084] Rotation The sparse coefficients (hopefully obtained through coefficient field mapping) are such that... (This is the result of reconstructing the template after rotation).

[0085] : Through a complete dictionary (a learned sparse dictionary used to reconstruct skeleton features).

[0086] Formula logic:

[0087] Rotating a template in the spatial domain alters its appearance (e.g., pixel positions, gradient directions), but its essential topological features (e.g., corners, edges) remain unchanged. Assumption: This appearance change can be simulated by a linear transformation of sparse coefficients—that is, the reconstructed result of the rotated template. You can use a dictionary Multiply by the sparsity coefficient after rotation To approximate: Rotating the template ≈ using new coefficients Refactor the template, and From the original coefficients Obtained through linear mapping.

[0088] In order to obtain an accurate linear mapping A regularized least squares optimization method was designed.

[0089] ;

[0090] Explanation of formula parameters:

[0091] Number of training samples (e.g., those extracted from the template) There are 3 skeleton sub-plots, each sub-plot corresponding to a sparsity coefficient. );

[0092] : No. The original sparse coefficients of the training samples ( );

[0093] : No. Spatial domain rotation results of training samples (to Rotation (angle, resulting image patch)

[0094] : No. The coefficient domain mapping results of each training sample (using...) Transformation Then use Refactoring);

[0095] Regularization parameters ( ,control (To reduce complexity and prevent overfitting).

[0096] Formula logic:

[0097] Reconstruction error term: ;

[0098] Meaning: Average reconstruction error (per unit) Training samples), metric coefficient domain mapping results ( ) and spatial domain rotation results ( The difference.

[0099] Logic: Each training sample The spatial domain result corresponding to a skeleton sub-plot after rotation It is the true value, while the coefficient field mapping result is... These are predicted values. The reconstruction error term requires that the "predicted value" be as close as possible to the "true value," ensuring... It can accurately simulate the effect of rotation.

[0100] For example: If It is the sparsity coefficient of the "corner points", rotation back, This is the rotated corner image. It should be highly similar to the image (with minimal error).

[0101] Regularization term: ;

[0102] meaning: Regularization, measurement The "size" (the sum of squares of the matrix elements).

[0103] Logic: Prevent Overfitting training data (i.e.) The elements are too large, causing them to be overly sensitive to small changes in the training samples, thus failing to generalize to new samples.

[0104] like No regularization It will perfectly fit the training data, which may lead to overfitting (e.g., when there is noise in the training samples). (You will learn the characteristics of noise).

[0105] like Too large: Regularization terms dominate. It will be very small (even close to zero matrix), unable to accurately simulate the rotation effect (large reconstruction error). Therefore, Its purpose is to balance "mapping accuracy" and "model generalization ability".

[0106] By using coefficient domain rotation mapping, we avoid enumerating multi-angle templates in the image space; Angle established With sparsity coefficient A linear relationship; This is a regularization parameter to prevent overfitting.

[0107] step Multi-angle matching and similarity calculation;

[0108] Skeleton coefficients are extracted from the sliding window of the search image. Calculate the template at the angle coefficients below The matching score is defined as: ;

[0109] Explanation of formula parameters:

[0110] Rotation The sparse coefficients of the template are obtained through a rotation mapping of the coefficient domain. ,in It is the sparsity coefficient of the original template. It is a pre-learned linear mapping matrix.

[0111] : Sparse coefficient of candidate region in search image: Extract skeleton sub-patterns from the sliding window (candidate region) of the search image and obtain them through sparse coding (consistent with the sparse coding process of template: extract skeleton → sparse coding).

[0112] : and The dot product measures the degree of overlap (directional consistency) between two vectors.

[0113] Formula logic:

[0114] 1. Generate the coefficients after rotation: for each angle (within the angle search range) Inside, according to step size (Value selection), using pre-learned... Transform the sparsity coefficients of the original template ,get (No need to rotate the template image).

[0115] 2. Extract coefficients from the search image: Perform a sliding window scan on the search image (the window size is consistent with the template skeleton sub-blocks), extract the skeleton sub-blocks for each window, and obtain them through sparse coding. (Consistent with the sparse coding process of templates).

[0116] 3. Calculate the matching score: For each And for each sliding window, calculate (Cosine similarity).

[0117] 4. Find the optimal match: Iterate through all And sliding window, take highest The optimal rotation angle and the corresponding sliding window position (target position) are used as the matching result.

[0118] Step S5: Result fusion and optimization;

[0119] Non-maximum suppression and local angle fine-tuning are applied to the matching results of each candidate window, and the angle is optimized using the gradient ascent method:

[0120] .

[0121] Explanation of formula parameters:

[0122] : The angle of the current iteration (the angle of the t-th iteration, such as the candidate angle found in step S4 as the initial value). =3°).

[0123] : The angle of the next iteration (the angle of the (t+1)th iteration, such as 3°+0.1°=3.1°).

[0124] Learning rate (step size) (controls the angle adjustment range in each iteration) >0, such as 0.1° or 0.01°).

[0125] The gradient of score with respect to θ (the rate at which score changes with angle, i.e., "how fast the score increases").

[0126] Formula logic:

[0127] Gradient direction: express From the current perspective The rate of change at that point. If the gradient is positive ( ), indicating an increase It will make Increase (should be towards) (Update in the direction of increase); if the gradient is negative ( ), indicating a reduction It will make Increase (should be towards) (Update in decreasing direction).

[0128] Learning rate Control the magnitude of each update. Too large and it may cause oscillation (exceeding) The maximum value point fluctuates back and forth; a small η may lead to slow convergence (requiring many iterations to find the optimal angle). This is usually adjusted experimentally. (If we take 0.1°, it will decrease if there is oscillation, and increase if there is slow convergence).

[0129] The above technical solutions only embody the preferred technical solutions of the present invention. Any modifications that may be made by those skilled in the art to certain parts thereof embody the principles of the present invention and fall within the protection scope of the present invention.

Claims

1. A multi-angle template matching method based on gradient topological sparse coding, characterized in that, Includes the following steps: Step S1: Gradient topological skeleton extraction of the template image; Step S2: Skeleton sparse dictionary construction and encoding; Step S3: Construct the coefficient domain rotation map; Step S4: Multi-angle matching and similarity calculation; Step S5: Result fusion and optimization; In step S4: skeleton coefficients are extracted from the sliding window of the search image. Calculate the template at the angle coefficients below The matching score is defined as: ; Explanation of formula parameters: Rotation The sparse coefficients of the template are obtained through a rotation mapping of the coefficient domain. ,in It is the sparsity coefficient of the original template. It is a pre-learned linear mapping matrix; : Sparse coefficients of candidate regions in the search image: Extract skeleton sub-plots from the sliding window of the search image, i.e., the candidate region, and obtain them through sparse coding. The sparse coding process is the same as that of the template: extract skeleton → sparse coding. : and The dot product measures the degree of overlap and directional consistency between two vectors. In step S5: the matching results of each candidate window are subjected to non-maximum suppression and local angle fine-tuning, and the angle is optimized using the gradient ascent method. ; Explanation of formula parameters: : The angle of the current iteration, the angle of the t-th iteration, such as the candidate angle found in step S4 as the initial value. =3°; The angle for the next iteration, the angle for the (t+1)th iteration, such as 3° + 0.1° = 3.1°; The learning rate, or step size, controls the magnitude of angle adjustment in each iteration. >0, such as 0.1° or 0.01°; The gradient of score with respect to θ is the rate at which score changes with the angle, i.e., "how fast the score increases".

2. The multi-angle template matching method based on gradient topological sparse coding according to claim 1, characterized in that, In step S1, the input data includes: Template image T(x,y); Search image ; Algorithm control parameters: including topology threshold sparse regularization coefficient Angle search range Angle step size and the maximum number of iterations T; The initialization phase first calculates the gradient vector field of the template image: ; Meaning: Calculate the gradient vector of the template image T(x,y) at each pixel (x,y), where Gx is the gradient in the x-direction and Gy is the gradient in the y-direction; Define the topological potential function Let the divergence of the gradient field be: .

3. The multi-angle template matching method based on gradient topological sparse coding according to claim 1, characterized in that, In step S2: a skeleton sparse dictionary is constructed to simulate the sparse representation and efficient matching of image structural features. And obtain the coefficient vector through sparse coding. : ; Explanation of formula parameters: : Local feature blocks extracted from the skeleton point set S, gradient features of the surrounding k*k region, or high-dimensional feature vectors that combine gradient and divergence. : A complete dictionary; : Sparse coefficient vector; : Sparse regularization coefficient.

4. The multi-angle template matching method based on gradient topological sparse coding according to claim 1, characterized in that, In step S3: A correspondence is established between spatial domain rotation and coefficient domain mapping, for the rotation angle... There exists a linear mapping matrix. , so that: ; Explanation of formula parameters: Spatial domain rotation operation, which rotates the template or its reconstructed result. Rotation Angle, obtained ; Original sparsity coefficients, skeleton sub-plots when the template is not rotated. The sparse coding result, i.e. ; Rotation The sparse coefficients are expected to be obtained through coefficient field mapping, such that... This is the result of reconstructing the template after rotation; : A complete dictionary, a learned sparse dictionary, is used to reconstruct skeleton features.

Citation Information

Patent Citations

  • LiDAR and unmanned aerial vehicle image fusion processing method applied to complex mountain land

    CN120298227A

  • Distance-weighted sparse representation priori-based image restoration and matching integration method

    WO2019174068A1