A multi-scale machine vision matching method
Through the multi-scale machine vision matching method, pyramid sampling and scale factor calculation are used to solve the problem that traditional visual matching algorithms are difficult to identify scaling targets, and the high accuracy and robustness positioning of multiple scale targets is achieved.
Patent Information
- Application Number
- CN202510174931.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-18
- Publication Date
- 2025-06-10
- Estimated Expiration
- 2045-02-18
AI Technical Summary
Traditional visual matching algorithms can only recognize targets of a single scale, and if the targets are scaled, it is difficult to identify and locate.
A multi-scale machine vision matching method is provided. Through pyramid sampling and scale factor calculation, a collection of pyramid feature points corresponding to different scale factors is obtained, and feature correction and template similarity calculation are performed to achieve effective positioning of multiple scale targets.
The accuracy of visual positioning is improved, and position recognition positioning with high accuracy and strong robustness can be achieved in search images containing multiple targets.
Smart Images

Figure CN119649068B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of visual matching, and particularly to a multi-scale machine vision matching method. Background Art
[0002] Visual matching technology is one of the key technologies for realizing target recognition and positioning. Through machine vision matching technology, industrial equipment can automatically adjust processing strategies to achieve flexible manufacturing. Visual image matching refers to the process of finding the same or similar area as the template image in the target image by analyzing the similarity and consistency of features such as gray scale, edges, shape structures, and corresponding relationships in the template image and the target image. The pattern matching process of an image generally includes two stages: learning and matching. In the learning stage, the algorithm extracts feature information for image matching from the template image and stores them in the template image in a search-friendly manner for later use.
[0003] Traditional visual matching algorithms can only recognize targets at a single scale, and it is difficult to recognize and locate targets if there is scaling.
[0004] Therefore, how to provide a multi-scale visual matching method that can effectively locate targets at multiple scales is a technical problem that needs to be solved urgently by those skilled in the art. Summary of the Invention
[0005] For this reason, the present invention provides a multi-scale machine vision matching method to solve the problem of inaccurate recognition and positioning caused by the fact that traditional visual matching algorithms can only recognize targets at a single scale in the prior art.
[0006] To achieve the above object, the present invention provides the following technical solutions:
[0007] A multi-scale machine vision matching method includes the following steps:
[0008] Step S1: Based on the search image I input by the user 0 , determine the original-scale template image I 1 , and obtain the set of template feature points under each layer of the pyramid in the original-scale template image I 1 ;
[0009] Step S2: Calculate the template scale step s according to the distribution of the template feature points under the 0th layer of the pyramid in the original-scale template image I 1 ;
[0010] Step S3: Calculate the upper limit s max and the lower limit s min of the template scale based on the upper and lower limits of the target scale input by the user;
[0011] Step S4: According to the upper and lower limits of the template scale and the scale step, redundantly calculate the scale factor set S;
[0012] Step S5: Traverse the scale factor set S, and according to the set of template feature points under each layer of the pyramid in the original scale template image I obtained in Step S1 1 to obtain the set of pyramid feature points corresponding to different scale factors;
[0013] Step S6: Traverse the scale factor set S, and perform feature correction on the set of pyramid feature points with scale factors less than 1 for each layer;
[0014] Step S7: Calculate the set of pyramid image sequences of the search image I input by the user 0 ;
[0015] Step S8: Use the set of pyramid feature points corresponding to each corrected scale factor to calculate the similarity of the top-layer pyramid image in the search image I 0 to obtain the top-layer matching result;
[0016] Step S9: Perform neighborhood suppression on all top-layer matching results to obtain the set of top-layer matching results;
[0017] Step S10: Based on the set of top-layer matching results, adopt a layer-by-layer approximation method to traverse all pyramid layers, and the obtained matching result is the final matching result.
[0018] Furthermore, in Step S1, based on the search image I input by the user 0 to determine the original scale template image I 1 and obtain the set of template feature points under each layer of the pyramid in the original scale template image I 1 , specifically including:
[0019] The user inputs the search image I 0 , according to the ROI of any target input by the user, combined with the search image I 0 to determine the original scale template image I 1 ;
[0020] According to the number of pyramid layers n input by the user, perform pyramid sampling on the original scale template image I 1 to obtain the set of n-layer template pyramid image sequences M;
[0021] For each layer of the template pyramid image M i , where i = 0, 1, 2…n-1, perform grayscale conversion and Gaussian blur processing;
[0022] Based on the processed pyramid image, an edge extraction algorithm is used to extract edges, and the obtained edge points are used as template feature points and added to the set P of template feature points corresponding to this layer of the pyramid, where i = 0, 1, 2... n - 1. i Among them, i = 0, 1, 2…n - 1.
[0023] Further, in step S2, according to the distribution of the template feature points under the 0th layer pyramid in the original scale template image I 1 , calculate the template scale step s, specifically:
[0024] Traverse all the feature points in the set P of the 0th layer template 0 and record the minimum value x 0 and the maximum value x 1 of the x coordinates of the feature points. At the same time, record the minimum value y 0 and the maximum value y 1 of the y coordinates of the feature points. Then the calculation formula for the template scale step s is:
[0025] ;
[0026] ;
[0027] ;
[0028] where max() is the operation of taking the maximum value, indicating taking the maximum value of the data in the parentheses, c 0 is the step constant, D x and D y are the template differences in the x - direction and y - direction respectively, w is the width of the original scale template image I 1 , and h is the height of the original scale template image I 1 .
[0029] Further, in step S3, based on the upper and lower limits of the target scale input by the user, calculate the upper limit s max and the lower limit s min of the template scale, specifically:
[0030] The calculation formula for the lower limit s min of the template scale is:
[0031] ;
[0032] The calculation formula for the upper limit s max of the template scale is:
[0033] ;
[0034] where e 0 is the upper limit of the target scale input by the user, e1 is the lower limit of the target scale input by the user, min() is the minimum value operation, and c 1 is the scale constant.
[0035] Furthermore, in step S4, according to the upper and lower limits of the template scale and the scale step, the scale factor set S is redundantly calculated, specifically including:
[0036] Within the range from the upper limit s max to the lower limit s min of the template scale, starting from the lower limit s min as the starting scale, sample the scale at intervals of each step s, and add the sampled scale factors to the scale factor set S;
[0037] Meanwhile, perform redundant addition by additionally adding a maximum scale factor e 3 to the scale factor set S, and the calculation formula for e 3 is:
[0038] ;
[0039] where e 4 is the maximum scale factor in the scale factor set S.
[0040] Furthermore, in step S5, traverse the scale factor set S, and according to the set of template feature points under each layer of the pyramid in the original scale template image I 1 obtained in step S1, obtain the set of pyramid feature points corresponding to different scale factors, specifically including:
[0041] For the nth layer pyramid corresponding to the scale factor S j , calculate the width w 1 and height h 1 of the template image corresponding to this layer of the pyramid, and their calculation formulas are:
[0042] ;
[0043] ;
[0044] where w 0 and h 0 are the width and height of the original scale template image corresponding to this layer of the pyramid, round is the rounding function, and S j is the numerical value of the scale factor, j = 0, 1, 2... m - 1, and m is the number of scale factors in the set S;
[0045] According to the set of template feature points P i calculated in step S1, calculate the set of pyramid feature points Q j corresponding to the scale factor Sj-i ;
[0046] For each point coordinate ( j-i in Q , ), its calculation formula is:
[0047] ;
[0048] ;
[0049] where, ( , ) is the corresponding coordinate in the template feature point set P i in, k = 0, 1, 2... H - 1, and H is the total number of feature points in the set P i .
[0050] Furthermore, in the step S6, traverse the scale factor set S, and perform feature correction on each layer of pyramid feature point sets with scale factors less than 1. Specifically:
[0051] Obtain all the feature point coordinates under each layer of pyramid corresponding to each scale factor S less than 1 j . If the rounded x and y coordinates of the feature points are the same, calculate the average value of the x and y coordinates of the above feature points, remove the above feature points from the original each layer of pyramid feature point sets, and add the average value of the x and y coordinates to the original each layer of pyramid feature point sets.
[0052] Furthermore, in the step S7, calculate the pyramid image sequence set of the search image I 0 input by the user. Specifically:
[0053] Perform grayscale processing on the search image I 0 input by the user to obtain the grayscale processed image I 2 . According to the number of pyramid layers n input in the step S1, perform downsampling on the grayscale processed image I 2 to obtain the pyramid image sequence set N of the search image I 0 ;
[0054] In the step S8, use the corrected each layer of pyramid feature point sets corresponding to each scale factor to perform top - layer template similarity calculation on the top - layer pyramid image in the search image I 0 , and obtain the top - layer matching result. Specifically including:
[0055] Obtain the top - layer pyramid image N 0 in the search image I n-1 , and at the same time traverse each scale factor. For each scale factor S j, the sliding window algorithm is adopted to calculate the similarity between the feature points corresponding to the pyramid at this scale factor and each region of image N n-1 ;
[0056] The central coordinate values of the sliding windows with template similarity greater than the similarity threshold t 0 , together with their corresponding scale factors and similarities, are used as the top-level matching results.
[0057] Furthermore, in step S9, neighborhood suppression is performed on all top-level matching results to obtain a set of top-level matching results, specifically:
[0058] For each top-level matching result, denoted as the first matching result, check whether there are other second matching results within the a×a neighborhood of the first matching result. If there are other second matching results, compare the similarity of the first matching result with the second matching similarity, and remove the result with the smaller similarity from the top-level matching results to obtain a set of top-level matching results.
[0059] Furthermore, in step S10, based on the set of top-level matching results, a layer-by-layer approximation method is used to traverse all pyramid layers, and the obtained matching results are the final matching results, specifically:
[0060] Repeat steps S8 - S9 to traverse the matching result sets of the other n - 1 pyramid layers to obtain the best similarity;
[0061] If the best similarity is greater than the similarity threshold t 0 , then replace the matching result set corresponding to this best similarity with the matching result set of the previous layer, otherwise directly remove the matching result set of the previous layer;
[0062] Traverse all pyramid layers until n is 0, and the obtained matching result set is the final pixel-level result.
[0063] The present invention has the following advantages:
[0064] Based on the search image I input by the user 0 , the original scale template image I is determined 1 , and the set of template feature points under each pyramid layer in the original scale template image I is obtained; according to the distribution of the template feature points under the 0th layer pyramid in the original scale template image I 1 , the template scale step s is calculated; based on the upper and lower limits of the target scale input by the user, the upper limit s of the template scale 1 and the lower limit s max are calculated; according to the upper and lower limits of the template scale and the scale step, the scale factor set S is redundantly calculated; traverse the scale factor set S, and according to the original scale template image I obtained in step S1 min ; 1The set of template feature points under each layer of the pyramid in [the relevant context] is obtained to get the set of feature points of each layer of the pyramid corresponding to different scale factors; traverse the scale factor set S, and perform feature correction on the set of feature points of each layer of the pyramid with a scale factor less than 1; calculate the pyramid image sequence set of the search image I 0 input by the user; use the set of feature points of each layer of the pyramid corresponding to each corrected scale factor to 0 perform top-layer template similarity calculation on the top-layer pyramid image in the search image I, and obtain the top-layer matching result; perform neighborhood suppression on all top-layer matching results to obtain the top-layer matching result set; based on the top-layer matching result set, adopt a layer-by-layer approximation method to traverse all pyramid layers, and the obtained matching result is the final matching result.
[0065] This application obtains the set of feature points of each layer of the pyramid corresponding to different scale factors according to the original scale template image, then obtains the corresponding scale factor according to the feature points in each layer of the pyramid in the search image, and performs visual positioning according to its scale factor and coordinate points, improving the accuracy of visual positioning. This application can achieve high-accuracy and strong-robustness position recognition and positioning in a search image containing multiple targets. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only exemplary, and for those of ordinary skill in the art, without creative efforts, other implementation drawings can also be obtained according to the provided drawings.
[0067] The structures, ratios, sizes, etc. shown in this specification are only used to cooperate with the content disclosed in the specification for those skilled in this technology to understand and read, and are not used to limit the limited conditions under which the present invention can be implemented. Therefore, they do not have technical substance. Any modification of the structure, change of the proportional relationship, or adjustment of the size, without affecting the effects that the present invention can produce and the purposes that can be achieved, should still fall within the scope that can be covered by the technical content disclosed in the present invention.
[0068] Figure 1 is a flowchart of a multi-scale machine vision matching method provided by the present invention;
[0069] Figure 2 is a search image containing multiple targets provided by the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0070] The following specific embodiments illustrate the implementation manners of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0071] A multi-scale machine vision matching method, as Figure 1 shown, includes the following steps:
[0072] Step S1: Based on the search image I containing multiple targets input by the user 0 , determine the original scale template image I 1 , and obtain the set of template feature points under each layer of the pyramid in the original scale template image I 1 , specifically including:
[0073] The search image I containing multiple targets input by the user 0 , as Figure 2 shown, the search image I 0 is a search image containing 3 targets of different scales. Then, according to the ROI of any target input by the user, combined with the search image I 0 , determine the original scale template image I 1 ;
[0074] According to the number of pyramid layers n input by the user, perform pyramid sampling on the original scale template image I 1 to obtain a set M of n-layer template pyramid image sequences;
[0075] For each layer of the template pyramid image M i , where i = 0, 1, 2... n - 1, perform grayscale conversion and Gaussian blur processing;
[0076] Based on the processed pyramid image, use an edge extraction algorithm to extract edges, and take the obtained edge points as template feature points and add them to the set P i of template feature points corresponding to this layer of the pyramid, where i = 0, 1, 2... n - 1.
[0077] Step S2: According to the distribution of the template feature points under the 0th layer of the pyramid in the original scale template image I 1 , calculate the template scale step s, specifically including:
[0078] Traverse all the feature points in the set P 0 of the 0th layer template feature points, and record the minimum value x 0 and the maximum value x 1, while recording the minimum value y of the y - coordinates of the feature points 0 and the maximum value y 1 , then the calculation formula for the template scale step s is:
[0079] ;
[0080] ;
[0081] ; where, max() is the operation of taking the maximum value, representing taking the maximum value of the data within the brackets, c 0 is the step constant, D x and D y are the template differences in the x - direction and y - direction respectively, w is the width of the original scale template image I 1 and h is the height of the original scale template image I 1 .
[0082] Step S3: The upper and lower limits of the scale of the actual template made are different from those input by the user. Based on the target scale upper and lower limits input by the user, calculate the template scale upper limit s max and the lower limit s min , specifically including:
[0083] The calculation formula for the template scale lower limit s min is:
[0084] ;
[0085] The calculation formula for the template scale upper limit s max is:
[0086] ;
[0087] where, e 0 is the target scale upper limit input by the user, e 1 is the target scale lower limit input by the user, min() is the operation of taking the minimum value, c 1 is the scale constant.
[0088] Step S4: According to the template scale upper and lower limits and the scale step, redundantly calculate the scale factor set S, specifically including:
[0089] Within the range of the template scale upper limit s max to the lower limit s min , starting from the lower limit s min as the starting scale, sample the scale at intervals of each step s, and add the sampled scale factors to the scale factor set S;
[0090] Meanwhile, perform redundant addition and additionally add a maximum scale factor e3 into the scale factor set S, e 3 The calculation formula of is:
[0091] ;
[0092] where e 4 is the maximum scale factor in the scale factor set S.
[0093] Step S5: Traverse the scale factor set S, and according to the original scale template image I 1 obtained in step S1, get the set of template feature points under each layer of the pyramid, and obtain the set of pyramid feature points corresponding to different scale factors, specifically including:
[0094] For the nth layer pyramid corresponding to the scale factor S j calculate the width w 1 and height h 1 of the template image corresponding to this layer of the pyramid. The calculation formula is:
[0095] ;
[0096] ;
[0097] where w 0 and h 0 are the width and height of the original scale template image corresponding to this layer of the pyramid, round is the rounding function, and S j is the numerical value of the scale factor, j = 0, 1, 2... m - 1, and m is the number of scale factors in the set S;
[0098] According to the set of template feature points P i calculated in step S1, calculate the set of pyramid feature points Q j corresponding to the scale factor S j-i ;
[0099] For each point coordinate ( j-i in Q , ), the calculation formula is:
[0100] ;
[0101] ;
[0102] where ( , ) is the corresponding coordinate in the set of template feature points P i , k = 0, 1, 2... H - 1, and H is the total number of feature points in the set P i .
[0103] So far, the features under each layer of the pyramid of each scale template have completed the preliminary calculation.
[0104] Step S6: Traverse the scale factor set S, and correct the features of the feature point sets of each layer of the pyramid with scale factors less than 1. Specifically:
[0105] Obtain each scale factor S with a value less than 1 j For all the coordinate values of the feature points under the corresponding layer of the pyramid, if the rounded x and y coordinates of the feature points are the same, calculate the average value of the x and y coordinates of the above-mentioned feature points, remove the above-mentioned feature points from the original feature point set of each layer of the pyramid, and add the average value of the x and y coordinates to the original feature point set of each layer of the pyramid.
[0106] Step S7: Calculate the pyramid image sequence set of the search image I 0 input by the user. Specifically:
[0107] Grayscale the search image I 0 input by the user to obtain the grayscale processed image I 2 , and perform downsampling on the grayscale processed image I 2 according to the number of pyramid layers n input in Step S1 to obtain the pyramid image sequence set N of the search image I 0 ;
[0108] Step S8: Use the feature point sets of each layer of the pyramid corresponding to the corrected scale factors to calculate the similarity of the top layer template for the top layer pyramid image in the search image I 0 to obtain the top layer matching result. The top layer calculation only involves the top layer pyramid image N n-1 of the input search image and the templates corresponding to the top layer pyramids (n - 1 layers) under each scale factor. Specifically including:
[0109] Obtain the top layer pyramid image N 0 in the search image I n-1 , and at the same time traverse each scale factor. For each scale factor S j , use the sliding window algorithm to calculate the template similarity between the feature points corresponding to the pyramid at this scale factor and each region of the image N n-1 ;
[0110] Take the center coordinate value of the sliding window with a template similarity greater than the similarity threshold t 0 , and its corresponding scale factor and similarity as the top layer matching result.
[0111] The value of the template similarity is the average of the accumulated sum of the similarities of each feature point. The value of the similarity of a single feature point is the similarity between the current template feature point and the image Nn-1 Calculate the similarity of the points corresponding to the sliding window in , and the calculation method can adopt the traditional gradient direction calculation or the traditional edge gradient calculation.
[0112] Step S9: Perform neighborhood suppression on all top-level matching results to obtain a set of top-level matching results, specifically:
[0113] For each top-level matching result, denoted as the first matching result, check whether there are other second matching results in the a×a neighborhood of the first matching result. If there are other second matching results, then compare the similarity of the first matching result with the similarity of the second matching result, and remove the result with the smaller similarity from the top-level matching results to obtain a set of top-level matching results.
[0114] Step S10: Based on the set of top-level matching results, adopt a layer-by-layer approximation method to traverse all pyramid layers, and the obtained matching results are the final matching results, specifically:
[0115] Repeat steps S8 - S9, traverse the matching result sets of the other n - 1 pyramid layers to obtain the best similarity;
[0116] If the best similarity is greater than the similarity threshold t 0 , then replace the matching result set corresponding to the best similarity with the matching result set of the previous layer, otherwise directly remove the matching result set of the previous layer;
[0117] Traverse all pyramid layers until n is 0, and the obtained matching result set is the final pixel-level result.
[0118] Step S8 only performs matching on the top-level pyramid, and refined similarity calculations need to be performed on other pyramid layers. For the nth pyramid layer, traverse the matching results of each scale of the other n - 1 pyramid layers, specifically: For the current matching result R i , in the pyramid image Nn of the search image, within the b×b neighborhood centered on the R i matching result, perform similarity calculation in the same way as step S8, and select the highest similarity score in this neighborhood as the best similarity of this neighborhood calculation.
[0119] If the best similarity is greater than the similarity threshold t 0 then replace the coordinates and similarity corresponding to the best similarity with the original values in R i , otherwise directly remove R i . Traverse all pyramid layers until n is 0, and the obtained result is the final pixel-level result.
[0120] The present application obtains sets of pyramid feature points corresponding to different scale factors based on the original scale template image, then obtains the corresponding scale factors according to the feature points in each layer of the pyramid in the search image, and performs visual positioning based on the scale factors and coordinate points, thereby improving the accuracy of visual positioning. The present application can achieve high-accuracy and strong-robustness position recognition and positioning in a search image containing multiple targets.
[0121] Although the present invention has been described in detail with general descriptions and specific embodiments above, on the basis of the present invention, some modifications or improvements can be made, which are obvious to those skilled in the art. Therefore, these modifications or improvements made without departing from the spirit of the present invention all fall within the scope of protection required by the present invention.
Claims
1. A multi-scale machine vision matching method, characterized in that: The following steps are involved: Step S1: Based on the search image I0 input by the user, determine the original scale template image I1, and obtain the template feature point set under each layer of the pyramid in the original scale template image I1; Step S2: Calculate the template scale step s according to the distribution of the template feature points under the 0th layer pyramid in the original scale template image I1, specifically: Traverse all feature points in the 0th layer template feature point set P0, record the minimum x0 and maximum x1 of the feature point's x coordinate, and record the minimum y0 and maximum y1 of the feature point's y coordinate. The calculation formula of the template scale step s is: Among them, max() is the maximum value operation, which means taking the maximum value of the data in the brackets, c0 is the step constant, D x and D y are the template differences in the x direction and the y direction respectively, w is the width of the original scale template image I1, and h is the height of the original scale template image I1; Step S3: Calculate the template scale upper limit s based on the target scale upper limit and lower limit input by the user max and the lower limit s min ; Step S4: redundantly calculating a scale factor set S according to the upper and lower limits of the template scale and the scale step; Step S5: traverse the scale factor set S, and obtain the set of feature points of each layer of the pyramid corresponding to different scale factors according to the set of template feature points under each layer of the pyramid in the original scale template image I1 obtained in step S1; Step S6: traverse the scale factor set S, and perform feature correction on the pyramid feature point sets of each layer whose scale factor is less than 1; Step S7: Calculate a pyramid image sequence set of the search image I0 input by the user; Step S8: using the pyramid feature point sets corresponding to the corrected scale factors, perform top-layer template similarity calculation on the top-layer pyramid image in the search image I0 to obtain a top-layer matching result; Step S9: performing neighborhood suppression on all top-level matching results to obtain a top-level matching result set; Step S10: Based on the top-level matching result set, all pyramid layers are traversed in a layer-by-layer approximation manner, and the obtained matching result is the final matching result.
2. The multi-scale machine vision matching method according to claim 1, characterized in that: In the step S1, based on the search image I0 input by the user, the original scale template image I1 is determined, and a set of template feature points under each layer of the pyramid in the original scale template image I1 is obtained, which specifically includes: The user inputs a search image I0, and the original scale template image I1 is determined based on the ROI of any target input by the user and the search image I0; According to the number of pyramid layers n input by the user, pyramid sampling is performed on the original scale template image I1 to obtain an n-layer template pyramid image sequence set M; For each layer of template pyramid image M i , where i = 0, 1, 2…n-1, grayscale and Gaussian blur processing is performed; Based on the processed pyramid image, an edge extraction algorithm is used to extract the edge, and the obtained edge points are used as template feature points and added to the template feature point set P corresponding to the pyramid layer. i In which, i=0, 1, 2…n-1.
3. The multi-scale machine vision matching method according to claim 2, characterized in that: In step S3, the template scale upper limit s is calculated based on the target scale upper limit and lower limit input by the user. max and the lower limit s min , specifically: Template size lower limit min The calculation formula is: Template size upper limit max The calculation formula is: s max =max(s min ,max(e0,e1)); Among them, e0 is the upper limit of the target scale input by the user, e1 is the lower limit of the target scale input by the user, min() is the minimum value operation, and c1 is the scale constant.
4. The multi-scale machine vision matching method according to claim 3, characterized in that: In step S4, redundantly calculating a scale factor set S according to the template scale upper and lower limits and the scale step size specifically includes: At the upper limit of the template scale s max To the lower limit s min Within the following limits min is the starting scale, the scale is sampled at intervals of s, and the sampled scale factors are added to the scale factor set S; At the same time, redundant addition is performed, and an additional maximum scale factor e3 is added to the scale factor set S. The calculation formula of e3 is: e3=e4+s; Among them, e4 is the maximum scale factor in the scale factor set S.
5. The multi-scale machine vision matching method according to claim 4, characterized in that: In the step S5, the scale factor set S is traversed, and the template feature point sets under each pyramid layer in the original scale template image I1 obtained in step S1 are used to obtain the pyramid feature point sets corresponding to different scale factors, specifically including: For the scale factor S j Corresponding to the nth layer of the pyramid, calculate the width w1 and height h1 of the template image corresponding to this layer of the pyramid, and the calculation formula is: w1=round(w0*S j ); h1=round(h0*S j ); Among them, w0 and h0 are the width and height of the original scale template image corresponding to the pyramid layer, round is the rounding function, S j That is, the numerical value of the scale factor, j = 0, 1, 2...m-1, m is the number of scale factors in the set S; According to the template feature point set P calculated in step S1 i , calculate the scale factor S j The corresponding pyramid feature point set Q j-i ; For Q j-i The coordinates of each point in The calculation formula is: in, is the template feature point set P i Corresponding coordinates, k = 0, 1, 2…H-1, H is the set P i The total number of feature points in .
6. The multi-scale machine vision matching method according to claim 5, characterized in that: In step S6, the scale factor set S is traversed, and feature correction is performed on the pyramid feature point sets of each layer whose scale factor is less than 1, specifically: Get the scale factor S for each value less than 1 j For all feature point coordinates under each corresponding pyramid layer, if there are feature points with the same x and y coordinates after rounding, the average x and y coordinates of the feature points are calculated, the feature points are removed from the original feature point sets of each pyramid layer, and the average x and y coordinates are added to the original feature point sets of each pyramid layer.
7. The multi-scale machine vision matching method according to claim 6, characterized in that: In step S7, a pyramid image sequence set of the search image I0 input by the user is calculated, specifically: Grayscale the search image I0 input by the user to obtain a grayscale processed image I2, and downsample the grayscale processed image I2 according to the number of pyramid levels n input in step S1 to obtain a pyramid image sequence set N of the search image I0; In step S8, the top-layer template similarity calculation is performed on the top-layer pyramid image in the search image I0 using the set of pyramid feature points of each layer corresponding to each corrected scale factor to obtain the top-layer matching result, which specifically includes: Get the top pyramid image N in the search image I0 n-1 , while traversing each scale factor, for each scale factor S j , using the sliding window algorithm, calculate the feature points corresponding to the pyramid under the scale factor and the image N n-1 Template similarity of each region; The center coordinate value of the sliding window whose template similarity is greater than the similarity threshold t0, and its corresponding scale factor and similarity are taken as the top-level matching result.
8. The multi-scale machine vision matching method according to claim 7, characterized in that: In step S9, neighborhood suppression is performed on all top-level matching results to obtain a top-level matching result set, which is specifically: For each top-level matching result, record it as the first matching result, check whether there are other second matching results in the a×a neighborhood of the first matching result. If there are other second matching results, compare the similarity of the first matching result with the similarity of the second matching result, and remove the results with smaller similarity from the top-level matching results to obtain the top-level matching result set.
9. The multi-scale machine vision matching method according to claim 8, characterized in that: In step S10, based on the top-level matching result set, all pyramid layers are traversed in a layer-by-layer approximation manner, and the matching result obtained is the final matching result, which is specifically: Repeat steps S8-S9 to traverse the matching result sets of other n-1 layers of pyramids to obtain the best similarity; If the best similarity is greater than the similarity threshold t0, the matching result set corresponding to the best similarity replaces the previous matching result set, otherwise the previous matching result set is directly eliminated; Traverse all pyramid levels until n is 0, and the resulting matching result set is the final pixel-level result.
Citation Information
Patent Citations
Robust multi-scale template matching method based on nearest neighbor feature point matching
CN111709434A
Image matching method and device, electronic equipment and storage medium
CN113159103A