Image matching method, image detection device and storage medium

By combining the pyramid image structure with squared difference and absolute value error algorithms, the problem of high computational complexity in matching templates for large field-of-view and high-resolution images is solved, achieving efficient image matching and improving online scanning speed.

CN121811079APending Publication Date: 2026-04-07FEICESIKAIPU (SHANGHAI) SEMICONDUCTOR TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-18
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Existing technologies suffer from high computational complexity in template matching for large field-of-view, high-resolution images, resulting in low efficiency and impacting online scanning speed.

Method used

By employing a pyramid image structure and combining squared difference and absolute value error algorithms, the squared difference algorithm is first used for preliminary matching at the top level of the image pyramid, and then the absolute value error algorithm is used for precise matching from the second-to-last level to the bottom level, thereby reducing computational complexity and improving efficiency.

Benefits of technology

While ensuring matching accuracy, it significantly reduces the computational complexity of template matching, improves the matching efficiency of high-resolution images, and reduces detection time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121811079A_ABST
    Figure CN121811079A_ABST
Patent Text Reader

Abstract

The invention relates to an image matching method, an image detection device and a storage medium, and the method comprises the steps: obtaining a template image and a to-be-detected image, constructing a first image of an image pyramid of the template image, and constructing a second image of the image pyramid of the to-be-detected image, matching the first image and the second image of the top layer based on a preset square difference and an algorithm to obtain a first matching position in the second image of the top layer, and mapping each first matching position as a matching initial position of a secondary top layer according to a pyramid mapping relation, and matching the first image and the second image of the second top layer based on a preset absolute value error and an algorithm until the matching of the bottom layer is completed, and obtaining an accurate matching area corresponding to each to-be-searched target in the to-be-detected image. According to the method, different algorithms are used for performing matching processing on different layers of images of the pyramid, and the calculation complexity is reduced on the premise of ensuring the matching alignment accuracy, so that the template matching efficiency is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image recognition technology, specifically to an image matching method, an image detection device, and a storage medium. Background Technology

[0002] Template matching is an indispensable part of semiconductor inspection technology. It is a crucial technique in computer vision and image processing, widely applied in fields such as object detection and image recognition. By comparing the image to be detected with a known image template, defects in the image can be identified and located. For example, object detection often uses image template matching for localization. This involves capturing a standard target image, extracting its contour features to create a template, and then searching for targets in the image to be detected that match the template features, thus determining the target's location.

[0003] In online scanning of large field-of-view scenarios, the speed of template matching directly affects the overall inspection WPH (Wafer Per Hour).

[0004] For images with large field of view and high resolution, the industry generally uses the pyramid alignment principle for template matching. Traditional matching methods are faster at the top of the pyramid, but from the second-to-last to the bottom, the alignment time increases as the image resolution increases due to the complexity of the calculations. Summary of the Invention

[0005] To address the aforementioned problems, the present invention aims to provide an image matching method, an image detection device, and a storage medium, thereby resolving the technical issues of high complexity and low template matching efficiency in existing image detection methods. These are described in detail below.

[0006] Firstly, this embodiment provides an image matching method, including:

[0007] Obtain the template image and the image to be detected. The image to be detected includes multiple targets to be found, and the template image is the matching template for the targets to be found.

[0008] A first image pyramid of a template image is constructed, comprising multiple images of different resolutions from the top to the bottom, and a second image pyramid of the image to be detected is constructed, comprising multiple images of different resolutions from the top to the bottom.

[0009] Based on a preset sum of squared differences algorithm, the first and second images of the top layer are matched to obtain the first matching position in the second image of the top layer corresponding to each target to be found;

[0010] Based on the pyramid mapping relationship, each initial matching position is mapped to the matching start position of the second-to-top layer. Based on the preset absolute value error and algorithm, the first and second images of the second-to-top layer are matched to obtain the rematch position in the second image of the second-to-top layer corresponding to each target to be found.

[0011] Based on each rematch position, the first and second images of the next layer are matched according to the preset absolute error and algorithm until the bottom layer matching is completed, so as to obtain the accurate matching region in the image to be detected corresponding to each target to be found.

[0012] In one embodiment, the process of finding the first matching position includes:

[0013] The first image at the top layer is used as a window region to slide pixel-by-pixel across the second image at the top layer. The matching degree at each sliding position is calculated based on the sum of squared differences algorithm, and the sliding position with the smallest matching degree is selected as the best matching position.

[0014] Traverse the second image at the top layer to obtain multiple best matching positions corresponding to each target to be searched, and use each of them as the first matching position.

[0015] The process of constructing the image pyramid of the template image includes: reducing the resolution of the template image, generating multiple first images of different resolutions through downsampling, and combining them to form the image pyramid of the template image; the image pyramid of the template image has a multi-layer structure, with the resolution of each first image decreasing layer by layer from the bottom to the top.

[0016] The process of constructing the image pyramid of the image to be detected includes: reducing the resolution of the image to be detected by downsampling to generate multiple second images of different resolutions, and combining them to form the image pyramid of the image to be detected; the image pyramid of the image to be detected has a multi-layer structure, with each second image being reduced layer by layer from the bottom layer to the top layer.

[0017] In one embodiment, for the top-level image of the image pyramid, the matching formula for calculating the matching degree between the first image at the top level and the second image at the top level based on the sum of squared differences algorithm is as follows:

[0018] ;

[0019] T represents the grayscale of the first image at the top layer; I represents the grayscale of the second image at the top layer; (x', y') represents the coordinates of the first image at the top layer; This represents the coordinates of the first image at the top layer, which serves as the window region, on the second image at the top layer; where, (x,y) represents the SSD matching value between the first and second images at the top layer at the coordinate position. The smaller the SSD matching value, the higher the matching degree.

[0020] In one embodiment, the absolute value error and algorithm matching formula are as follows:

[0021] ;

[0022] Where (M, N) represents the size of the first image of the target layer, and any layer from the second-to-last to the bottom layer is configured as the target layer; (s, t) represents the coordinates of the first image of the target layer; T represents the grayscale of the first image that is not the top layer; and S represents the grayscale of the second image of the target layer. This represents the matching value between the first image of the target layer and the second image of the target layer at coordinate (i,j). The smaller the matching value, the higher the matching degree.

[0023] In one embodiment, the process of finding a rematching location or a precise matching region based on the absolute value error and algorithm includes:

[0024] Taking any layer from the second-to-last layer to the bottom layer as the target layer, within the constraint area of ​​the matching start position and its neighborhood, the SAD matching values ​​of the first and second images in the target layer are calculated using the absolute value error algorithm, and the rematch position of the next layer is determined accordingly; wherein the precise matching region is obtained based on the rematch position determined at the bottom layer.

[0025] In one embodiment, within the constrained region of the matching starting position and its neighborhood, the SAD matching values ​​of the first and second images in the target layer are calculated using an absolute value error and algorithm, and the rematching position of the next layer is determined accordingly, including:

[0026] The first image of the target layer is used as the window area. Based on the matching start position, the area to be matched is selected in the second image of the target layer, and the area to be matched is expanded by pixels in the width and height directions to obtain the expanded search area.

[0027] The first image of the target layer is slid pixel by pixel within the extended search area, and the matching degree at each sliding position is calculated based on the absolute value error and the algorithm.

[0028] The matching position of the next layer is determined based on the matching degree at each sliding position.

[0029] In one embodiment, determining the re-matching position of the next layer based on the matching degree at each sliding position includes:

[0030] Compare the matching degree at each sliding position. When the matching degree at the sliding position where the matching start position is located is the highest, the matching start position is used as the matching position for the next layer.

[0031] If the matching degree at the sliding position where the starting position is determined is not the highest, then the sliding position corresponding to the highest matching degree is taken as the new starting position for matching. The outer search area is reset and the matching degree is calculated based on the absolute value error algorithm until the matching degree at the sliding position where the new starting position is located in the reset outer search area is the highest. Then, the new starting position for matching is taken as the matching position for the next layer.

[0032] Secondly, this embodiment provides an image detection device, including:

[0033] The processing module is used to acquire template images and images to be detected, construct image pyramids for template images and images to be detected, where the images to be detected include multiple targets to be found, and the template images are matching templates for the targets to be found.

[0034] The first matching module is used to obtain the first matching position in the top layer corresponding to each target to be searched by the image matching method as described in any embodiment of the first aspect;

[0035] The second matching module is used to perform layer-by-layer matching calculations based on the initial matching position down to the bottom layer using the image matching method of any embodiment of the first aspect, so as to obtain the precise matching region in the image to be detected corresponding to each target to be searched.

[0036] Thirdly, this embodiment provides a computer-readable storage medium storing a computer program that can be executed by a processor to implement the image matching method of the first aspect.

[0037] Compared with the prior art, the present invention has the following beneficial effects:

[0038] The image matching method of this invention efficiently combines the SSD (Sum of Squared Differences) algorithm and the SAD (Sum of Absolute Differences) algorithm when processing pyramid images. In particular, the SSD algorithm is used for the top image of the image pyramid, and the SAD algorithm is used for fast matching in the images from the second-to-last to the bottom of the image pyramid based on the matching results of the top image, thereby reducing the template matching time of the entire detection image.

[0039] The image matching method of this invention is based on pyramid image alignment and uses the squared difference matching algorithm and the SAD matching algorithm for detection. While ensuring alignment accuracy, it reduces computational complexity and effectively improves the template matching efficiency for high-resolution images. Attached Figure Description

[0040] Figure 1This is a schematic diagram of the main process of an image matching method in one embodiment;

[0041] Figure 2 This is a schematic diagram illustrating the construction of an image pyramid in an implementation.

[0042] Figure 3 This is a flowchart illustrating the top-level initial matching position calculation process of the image matching method in this embodiment.

[0043] Figure 4 This is an example image of a template in implementation;

[0044] Figure 5 for Figure 4 Example image of the first image at the top of the image pyramid shown in the template image;

[0045] Figure 6 Here is an example image pyramid of an image to be detected during implementation;

[0046] Figure 7 for Figure 6 A magnified view of the matching results of the image to be detected;

[0047] Figure 8 This is a flowchart illustrating the main process of calculating the target layer matching position in the image matching method of this embodiment.

[0048] Figure 9 for Figure 8 The flowchart of the matching degree comparison method is shown below;

[0049] Figure 10 This is a schematic diagram of the software modules of an optical measurement system in one embodiment;

[0050] Figure 11 for Figure 4 Example image of the first image at the second-to-top level of the template image shown;

[0051] Figure 12 for Figure 11 Example chart of SAD matching values ​​for the first image shown;

[0052] Figure 13 This is a software module diagram of an image detection device in one embodiment;

[0053] Figure 14 This is a hardware structure diagram of an image detection device in one embodiment. Detailed Implementation

[0054] The present invention will now be described in further detail with reference to specific embodiments and accompanying drawings. Similar elements in different embodiments are referred to by associated similar element reference numerals. In the following embodiments, many details are described to facilitate a better understanding of this application. However, those skilled in the art will readily recognize that some features may be omitted in different situations, or may be replaced by other elements, materials, or methods. In some cases, certain operations related to this application are not shown or described in the specification. This is to avoid obscuring the core parts of this application with excessive description. For those skilled in the art, detailed description of these related operations is not necessary; they can fully understand the related operations based on the description in the specification and general technical knowledge in the art.

[0055] Furthermore, the features, operations, or characteristics described in the specification can be combined in any suitable manner to form various embodiments. At the same time, the steps or actions in the method description can be rearranged or adjusted in a manner obvious to those skilled in the art. Therefore, the various orders in the specification and drawings are only for the clear description of a particular embodiment and do not imply a necessary order, unless otherwise stated that a particular order must be followed.

[0056] The serial numbers assigned to components in this document, such as "first" and "second," are used solely to distinguish the described objects and have no sequential or technical meaning. "Multiple" means two or more. Unless otherwise specified, "connection" or "linkage" in this application includes both direct and indirect connections (linkages).

[0057] Please refer to Figure 1 The diagram shows the main flowchart of the image matching method in this embodiment. This image matching method is based on pyramid image alignment and uses the squared difference matching algorithm and the SAD matching algorithm to find targets in the image to be detected that match the features of the template image, thus quickly and efficiently locating the precise matching region of the target.

[0058] The image matching method in this embodiment includes steps S100-S500, which are described below.

[0059] Step S100: Obtain the template image and the image to be detected. The image to be detected includes multiple targets to be found, and the template image is the matching template for the targets to be found. Take a standard target image and then extract contour features to create the template image.

[0060] It should be noted that the object of detection here can be a wafer, circuit board, display panel, control panel, etc. If it is a wafer, the target to be found can be the regularly distributed grains on the wafer surface, and the template image is the image of a single standard grain.

[0061] Step S200: Construct an image pyramid of a template image with multiple first images of different resolutions from top to bottom, and construct an image pyramid of the image to be detected with multiple second images of different resolutions from top to bottom.

[0062] like Figure 2 As shown in the left view, the process of constructing the image pyramid of the template image includes: reducing the resolution of the template image 10, generating multiple first images with different resolutions through downsampling, such as the bottom first image L10 and the top first image L50, and combining them to form the image pyramid of the template image; the image pyramid of the template image has a multi-layer structure, and the resolution of each first image in the bottom layer decreases layer by layer from the bottom layer to the top layer. For example, the bottom first image L10 has the highest resolution, and the resolution of the top first image L50 is reduced to the lowest level through downsampling.

[0063] like Figure 2 The right-hand view shows that when constructing the image pyramid of the image to be detected, the following steps are taken: reducing the resolution of the image to be detected 1 by downsampling to generate multiple second images with different resolutions, such as the bottom second image L1 and the top second image L5, and combining them to form the image pyramid of the image to be detected; the image pyramid of the image to be detected has a multi-layer structure, with each second image decreasing layer by layer from the bottom to the top, for example, the bottom second image L1 has the highest resolution, and the resolution of the top second image L5 is reduced to the lowest layer by layer through downsampling.

[0064] Step S300: Match the first and second images of the top layer based on the preset sum of squared differences (SSD) algorithm to obtain the first matching position in the second image of the top layer corresponding to each target to be searched.

[0065] Please refer to Figure 3 The process of finding the initial matching position includes:

[0066] Step S310: Using the first image at the top layer as a window region, slide the second image at the top layer pixel by pixel. Calculate the matching degree at each sliding position based on the sum of squared differences algorithm, and select the sliding position with the smallest matching degree as the best matching position.

[0067] Step S320: Traverse the second image at the top layer to obtain multiple best matching positions corresponding to each target to be searched, and use them one by one as the first matching position.

[0068] For the top-level image of the image pyramid, the matching formula for the first and second images at the top level, calculated using the sum of squared differences (SSD) algorithm, is as follows:

[0069] (1)

[0070] T represents the grayscale of the first image at the top layer; I represents the grayscale of the second image at the top layer; (x', y') represents the coordinates of the first image at the top layer; This represents the coordinates of the first image at the top layer, which serves as the window region, on the second image at the top layer; where, The SSD matching value between the first and second images at the top layer at the (x,y) coordinate position indicates a higher degree of matching.

[0071] Figure 4 as well as Figure 5 This is an example of an image pyramid for template images. The bottommost template image has the highest pixel count, such as... Figure 4 The size shown is 448*440 pixels. The second-to-top-level template image size is 224*220 pixels. The top-level template image has the lowest pixel count, as shown below. Figure 5 The size shown is 112*110 pixels. Please refer to it. Figure 6 Image 50 to be detected contains multiple targets to be found, and its size is 3586*16000 pixels. Image 55, the top layer of the image pyramid, has a size of 964*4000 pixels.

[0072] Multiple matches were found in the match result 60, for example Figure 6 There is a matching target in the area highlighted in red. Figure 7 In the magnified view of the matching results, it can be seen that the SSD matching value at the location within the green box is the smallest, which is an optimal target matching point.

[0073] Step S400: Further reference Figure 1 According to the pyramid mapping relationship, each first matching position obtained from the matching result of the top layer of the pyramid is mapped to the matching start position of the second layer. Based on the preset absolute error sum algorithm (SAD), the first and second images of the second layer are matched to obtain the rematch position in the second image of the second layer corresponding to each target to be found.

[0074] After obtaining the matching result of the top layer of the pyramid, the formula for matching the first and second images of the second-to-bottom layer based on the preset Sum of Absolute Error (SAD) algorithm is as follows:

[0075] (2)

[0076] Where (M, N) represents the size of the first image of the target layer, and any layer from the second-to-last to the bottom layer is configured as the target layer; (s, t) represents the coordinates of the first image of the target layer; T represents the grayscale of the first image that is not the top layer; and S represents the grayscale of the second image of the target layer. This represents the SAD matching value between the first image of the target layer and the second image of the target layer at coordinate (i,j). The smaller the SAD matching value, the higher the matching degree.

[0077] In this embodiment, the process of finding the rematching position or precise matching region based on the Sum of Absolute Errors (SAD) algorithm includes: taking any layer from the second-to-last layer to the bottom layer as the target layer, within the constraint region of the matching start position and its neighborhood, using the SAD matching value of the first image and the second image in the target layer to calculate the SAD matching value, and determining the rematching position of the next layer accordingly; it can be understood that when the bottom layer performs image matching, the bottom layer matching is completed, and the precise matching region corresponding to each target to be found in the image to be detected can be obtained based on the rematching position determined at the bottom layer.

[0078] Please refer to Figure 8 Within the constrained region of the matching starting position and its neighborhood, the SAD matching values ​​of the first and second images in the target layer are calculated using the absolute value error algorithm, and the rematch position of the next layer is determined accordingly, including:

[0079] Step S410: Use the first image of the target layer as the window region. In this embodiment, the target layer can be any layer from the second-to-last layer to the bottom layer. The matching starting position is determined by selecting the region to be matched in the second image of the target layer, and then expanding the region to be matched by pixels in both width and height directions to obtain the expanded search region.

[0080] Figure 10 The example shown illustrates the expansion search region. After obtaining the initial matching position L(x, y) of the top layer, the matching starting position of the second image at the second-to-last layer is L1(2x, 2y). The region to be matched is selected and expanded pixel-wise in both width and height directions to obtain the desired result. Figure 10 The extended search area shown contains 9 matching values. Figure 10 In the case of expanding by one pixel, it is of course possible to expand by two or more pixels.

[0081] Step S420: Slide the first image of the target layer pixel by pixel within the extended search area. Calculate the matching degree at each sliding position based on the absolute error and the algorithm. This matching degree is related to the SAD matching value. The smaller the SAD matching value, the higher the matching degree.

[0082] Please refer to this as well. Figure 9 as well as Figure 10 The following is a comparison process for matching scores:

[0083] Step S421: Compare the matching degree at each sliding position.

[0084] Step S422: Determine whether the matching degree is highest at the sliding position where the matching start position is located.

[0085] Step S423: When the matching degree is highest at the sliding position where the matching start position is located, the matching start position is used as the matching position for the next layer.

[0086] Step S425: When it is determined that the matching degree at the sliding position where the matching start position is located is not the highest, the sliding position corresponding to the highest matching degree is taken as the new matching start position.

[0087] Step S426: Reset the outer search area.

[0088] Step S427: Calculate the matching degree based on the absolute value error and the algorithm until the matching degree is highest at the sliding position where the new matching starting position is located in the re-set outer search area.

[0089] Step S428: Use the new matching start position as the rematch position for the next layer.

[0090] For example, in Figure 10 As shown in the expanded search area, if the D value at L1(2x, 2y) is the smallest, then this point is considered the best matching point of the second-to-last layer; otherwise, for example, if L1(2x-1, 2y-1) is the minimum point, then this point is used as the starting matching point again, and the expanded search area is used for matching. The search stops when the SAD matching value of the starting matching point is the smallest.

[0091] The following examples illustrate this. Figure 11 The second-to-top-level template image shown is used as the first image, and the size of this second-to-top-level first image is 224*220 pixels. (For...) Figure 6 The red box in the top-level matching result is used to calculate and generate... Figure 12 The SAD calculation result for a single matching target in the second image of the second-level top layer is shown. From Figure 12 The calculation results chart shows that the minimum value of the SAD matching result of the detected target is in the center position. The search can be stopped and SAD matching of other detected targets can be performed until all the targets to be detected in the second-to-top layer are matched.

[0092] Step S430: In Figure 8 In this process, the matching position of the next layer is determined based on the matching degree at each sliding position.

[0093] The above completes the re-matching position calculation for the target layer.

[0094] Step S500: Based on each rematch position of the target layer, continue to match the first and second images of the next layer based on the preset absolute error sum algorithm (SAD) until the bottom layer matching is completed, and obtain the accurate matching region in the image to be detected corresponding to each target to be found.

[0095] For example, based on the matching result of the second-to-top level, repeat the process from step S410 to step S430 until the SAD matching value of the bottom level is matched.

[0096] The table below compares the results of our image matching method with those of the commercial Halcon software:

[0097] Alignment method Template size Search image size Search Target Search time Squared difference + SAD 448*440 3586*16000 217 25.473ms NCC (halcon) 448*440 3586*16000 217 49.142ms

[0098] According to the table above, when the template size, search image size, and number of search targets are the same, the squared difference + SAD algorithm used in this embodiment can complete the image matching process in only 25.473ms, while the commercial Halcon algorithm used in the prior art requires 49.142ms to complete the image matching process. The time difference between the two is almost double, and the solution in this embodiment has a greater advantage in processing efficiency.

[0099] Please refer to Figure 13 The diagram shows a software module schematic of the image detection device of this embodiment. The image detection device includes a processing module 610, a first matching module 620, and a second matching module 630.

[0100] The processing module 610 is used to acquire a template image and an image to be detected, construct an image pyramid of the template image and an image pyramid of the image to be detected. The image to be detected includes multiple targets to be found, and the template image is a matching template of the targets to be found.

[0101] The first matching module 620 is used to obtain the first matching position in the top layer corresponding to each target to be searched using the image matching method mentioned above. For example, the first image of the top layer is used as a window area to slide pixel by pixel on the second image of the top layer. The matching degree at each sliding position is calculated based on the sum of squared differences algorithm. The sliding position with the smallest matching degree is selected as the best matching position. The second image of the top layer is traversed to obtain multiple best matching positions corresponding to each target to be searched, and each of these is used as the first matching position. For the specific processing, please refer to the corresponding content above, which will not be repeated here.

[0102] The second matching module 630 is used to perform layer-by-layer matching calculations from the initial matching position down to the bottom layer using the image matching method mentioned above, in order to obtain the precise matching region in the image to be detected corresponding to each target to be found. For example, any layer from the second-to-last layer to the bottom layer is taken as the target layer. Within the constraint region of the matching start position and its neighborhood, the SAD matching values ​​of the first and second images in the target layer are calculated using the absolute value error algorithm, and the rematch position of the next layer is determined accordingly; the precise matching region is obtained based on the rematch position determined at the bottom layer. For the specific processing procedure, please refer to the corresponding content above, which will not be repeated here.

[0103] like Figure 14 The image detection device 700 shown includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to computer program instructions stored in a read-only memory 702 (ROM) or loaded from a storage unit into a random access memory 703 (RAM). The RAM can also store various programs and data required for device operation. The CPU, ROM, and RAM are interconnected via a bus. An input / output (I / O) interface 705 is also connected to the bus.

[0104] Multiple components in the device are connected to the I / O interface, including: input unit 706, such as a keyboard, mouse, etc.; output unit 707, such as various types of displays, speakers, etc.; storage unit, such as a disk, optical disk, etc.; and communication unit 709, such as a network card, modem, wireless transceiver, etc. The communication unit allows the device to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0105] The processing unit executes the various methods and processes described above, such as the series of method steps S100 to S500. For example, in some embodiments, method steps S100 to S500 may be implemented as a computer software program tangibly contained in a machine-readable medium, such as a storage unit. In some embodiments, part or all of the computer program may be loaded and / or installed on the device via ROM and / or a communication unit. When the computer program is loaded into RAM and executed by the CPU, one or more steps of the method steps S100 to S500 described above may be performed. Alternatively, in other embodiments, the CPU may be configured to execute method steps S100 to S500 by any other suitable means (e.g., by means of firmware).

[0106] Those skilled in the art will understand that all or part of the functions of the various methods in the above embodiments can be implemented by hardware or by computer programs. When all or part of the functions in the above embodiments are implemented by computer programs, the program can be stored in a computer-readable storage medium, which may include: read-only memory, random access memory, disk, optical disk, hard disk, etc., and the program is executed by a computer to achieve the above functions. For example, the program can be stored in the memory of a device, and when the program in the memory is executed by the processor, all or part of the above functions can be achieved. In addition, when all or part of the functions in the above embodiments are implemented by computer programs, the program can also be stored in a server, another computer, disk, optical disk, flash drive, or external hard drive, etc., and can be downloaded or copied to the memory of a local device, or the system of the local device can be updated. When the program in the memory is executed by the processor, all or part of the functions in the above embodiments can be achieved.

[0107] The above examples illustrate the present invention only to aid in understanding it and are not intended to limit the scope of the invention. Those skilled in the art can make various simple deductions, modifications, or substitutions based on the principles of this invention.

Claims

1. An image matching method, characterized in that, include: Obtain a template image and an image to be detected, wherein the image to be detected includes multiple targets to be found, and the template image is a matching template for the targets to be found; The template image is constructed with an image pyramid consisting of multiple first images of different resolutions from the top to the bottom, and the image to be detected is constructed with an image pyramid consisting of multiple second images of different resolutions from the top to the bottom. Based on a preset sum of squared differences algorithm, the first and second images of the top layer are matched to obtain the first matching position in the second image of the top layer corresponding to each of the targets to be found; According to the pyramid mapping relationship, each initial matching position is mapped to the matching start position of the second-to-top layer. Based on the preset absolute value error and algorithm, the first and second images of the second-to-top layer are matched to obtain the rematch position in the second image of the second-to-top layer corresponding to each of the targets to be found. Based on each rematch position, the first and second images of the next layer are matched according to the preset absolute error and algorithm until the bottom layer matching is completed, so as to obtain the accurate matching region in the image to be detected corresponding to each target to be found.

2. The image matching method as described in claim 1, characterized in that, The process of finding the first matching position includes: The first image at the top layer is used as a window area to slide pixel-by-pixel across the second image at the top layer. The matching degree at each sliding position is calculated based on the sum of squared differences algorithm, and the sliding position with the smallest matching degree is selected as the best matching position. Traverse the second image at the top layer to obtain multiple best matching positions corresponding to each of the targets to be searched, and use each of them as the first matching position.

3. The image matching method as described in claim 1, characterized in that, Constructing the image pyramid of the template image includes: reducing the resolution of the template image, generating multiple first images of different resolutions through downsampling, and aggregating them to form the image pyramid of the template image; the image pyramid of the template image has a multi-layered structure, with the resolution of each first image decreasing layer by layer from the bottom to the top; and The process of constructing the image pyramid of the image to be detected includes: reducing the resolution of the image to be detected, generating multiple second images of different resolutions through downsampling, and combining them to form the image pyramid of the image to be detected; the image pyramid of the image to be detected has a multi-layer structure, with each second image decreasing in resolution from the bottom layer to the top layer.

4. The image matching method as described in claim 2, characterized in that, For the top-level image of the image pyramid, the matching formula for calculating the matching degree between the first image of the top level and the second image of the top level based on the sum of squared differences algorithm is as follows: ; T represents the grayscale of the first image at the top layer; I represents the grayscale of the second image at the top layer; (x', y') represents the coordinates of the first image at the top layer; This represents the coordinates of the first image at the top layer as the window region on the second image at the top layer. in, The SSD matching value is the value between the first image and the second image at the top layer at the (x,y) coordinate position. The smaller the SSD matching value, the higher the matching degree.

5. The image matching method as described in claim 3, characterized in that, The absolute value error and algorithm matching formula are as follows: ; Where (M, N) represents the size of the first image of the target layer, and any layer from the second-to-last to the bottom layer is configured as the target layer; (s, t) represents the coordinates of the first image of the target layer; T represents the grayscale of the first image that is not the top layer; S represents the grayscale of the second image of the target layer; the... The SAD matching value represents the SAD matching value between the first image of the target layer and the second image of the target layer at coordinate (i,j). The smaller the SAD matching value, the higher the matching degree.

6. The image matching method as described in claim 1, characterized in that, The process of finding the rematching position or the precise matching region based on the absolute value error and algorithm includes: Taking any layer from the second-to-last layer to the bottom layer as the target layer, within the constraint area of ​​the matching start position and its neighborhood, the SAD matching values ​​of the first and second images in the target layer are calculated using the absolute value error and algorithm, and the rematch position of the next layer is determined accordingly; wherein the precise matching region is obtained based on the rematch position determined at the bottom layer.

7. The image matching method as described in claim 6, characterized in that, Within the constrained region of the matching starting position and its neighborhood, the SAD matching values ​​of the first and second images in the target layer are calculated using the absolute value error and algorithm, and the rematching position of the next layer is determined accordingly, including: Using the first image of the target layer as a window region, a region to be matched is selected in the second image of the target layer based on the matching start position, and the region to be matched is expanded outward by pixels in the width and height directions to obtain the expanded search region. The first image of the target layer is slid pixel by pixel within the extended search area, and the matching degree at each sliding position is calculated based on the absolute error and the algorithm. The matching position of the next layer is determined based on the matching degree at each sliding position.

8. The image matching method as described in claim 7, characterized in that, The step of determining the next matching position based on the matching degree at each sliding position includes: Compare the matching degree at each sliding position. When the matching degree at the sliding position where the matching start position is located is the highest, the matching start position is used as the matching position for the next layer. When it is determined that the matching degree at the sliding position where the matching start position is located is not the highest, the sliding position corresponding to the highest matching degree is taken as the new matching start position. The outer search area is reset and the matching degree is calculated based on the absolute value error and algorithm until the matching degree at the sliding position where the new matching start position is located in the reset outer search area is the highest. The new matching start position is then taken as the matching position for the next layer.

9. An image detection device, characterized in that, include: The processing module is used to acquire a template image and an image to be detected, construct an image pyramid of the template image and an image pyramid of the image to be detected, wherein the image to be detected includes multiple targets to be found, and the template image is a matching template for the targets to be found; The first matching module is used to obtain the first matching position in the top layer corresponding to each of the targets to be searched by the image matching method as described in any one of claims 1 to 8; The second matching module is used to perform layer-by-layer matching calculations based on the initial matching position to the bottom layer using the image matching method as described in any one of claims 1 to 8, so as to obtain the precise matching region in the image to be detected corresponding to each target to be searched.

10. A computer-readable storage medium, characterized in that, The storage medium stores a computer program that can be executed by a processor to implement the image matching method as described in any one of claims 1 to 8.