Image matching method, device, electronic device and storage medium

By constructing an image pyramid and using ORB feature point matching technology, the problem of increased time consumption in the image block matching process is solved, and efficient image matching is achieved.

CN112233153BActive Publication Date: 2024-09-24YUANLI TUXIN (CHONGQING) TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011036436.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-27
Publication Date
2024-09-24
Estimated Expiration
2040-09-27

AI Technical Summary

Technical Problem

When the image size increases with the existing image block matching technology, the time consumption of the matching process increases in a quadratic curve, and there is a lack of efficient solutions.

Method used

By constructing the pyramid structure of the image, feature point matching and offset calculation are performed, and ORB feature points and Euclidean distance are used for matching relationship mapping and search, reducing the number of matching points and improving efficiency.

Benefits of technology

It achieves high efficiency of image matching, reduces the number of search matching points, and improves calculation efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112233153B
    Figure CN112233153B
Patent Text Reader

Abstract

The present application provides an image matching method, device, electronic device and storage medium. The method includes: constructing a first pyramid of a first image and a second pyramid of a second image respectively; performing feature point matching on the third layer images of the first pyramid and the second pyramid to obtain a first matching relationship between the first pyramid and the second pyramid in the third layer image; mapping the first matching relationship to the second layer images of the first pyramid and the second pyramid, and obtaining a first initial offset of the first pyramid relative to the second pyramid in the second layer image according to the first matching relationship; obtaining a second matching relationship of the first pyramid relative to the second pyramid in the second layer image according to the first initial offset; mapping the second matching relationship to the first layer images of the first pyramid and the second pyramid, and searching in the first layer image of the second pyramid to obtain a second pixel point that matches each first pixel point of the first image in the second image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer network technology, and in particular to an image matching method, device, electronic device and storage medium. Background Art

[0002] Image matching technology is a hot topic in computer vision and other fields, and is widely used in image fusion, image super resolution, stereo vision and other fields. How to quickly and high-quality complete the most similar block matching between two images is the research focus of image matching technology.

[0003] The existing mainstream technologies for image blocks include PatchMatch, TreeCANN, PAKT, etc. PatchMatch is an iterative non-tree-building method that does not involve data dimension reduction and tree structure building. It improves matching efficiency through random initialization and neighborhood block similarity propagation. However, directly using the original image blocks for comparison, the matching process is very time-consuming. As the size of the image blocks increases, the time consumption for image block comparison increases in a quadratic curve.

[0004] There is currently no effective technical solution to the above problems. Summary of the invention

[0005] The purpose of the embodiments of the present application is to provide an image matching method, device, electronic device and storage medium, which can improve the efficiency of image matching.

[0006] In a first aspect, an embodiment of the present application provides an image matching method, the method comprising:

[0007] Constructing a first pyramid for the first image and a second pyramid for the second image respectively, wherein the first pyramid and the second pyramid each include three layers of images, wherein the first layer of images of the first pyramid and the second pyramid are the first image and the second image respectively, and the resolution of the image of the first pyramid and the second pyramid that is closer to the first layer of images is greater;

[0008] Performing feature point matching on the third layer images of the first pyramid and the second pyramid to obtain a first matching relationship between the first pyramid and the second pyramid in the third layer image;

[0009] Mapping the first matching relationship to the second layer images of the first pyramid and the second pyramid, and acquiring a first initial offset of the first pyramid relative to the second pyramid in the second layer image according to the first matching relationship;

[0010] Obtaining a second matching relationship between the first pyramid and the second pyramid in the second layer image according to the first initial offset;

[0011] The second matching relationship is mapped to the first layer images of the first pyramid and the second pyramid, and a search is performed on the first layer image of the second pyramid to obtain a matching second pixel point of each first pixel point of the first image in the second image.

[0012] Optionally, in the image matching method described in the embodiment of the present application, the step of respectively constructing a first pyramid of the first image and a second pyramid of the second image includes:

[0013] Alternately performing at least two mean blurring processes and downsampling processes on the first image to construct a first pyramid of the first image;

[0014] The mean blurring process and the downsampling process are alternately performed at least twice on the second image to construct a second pyramid of the second image.

[0015] Optionally, in the image matching method described in the embodiment of the present application, performing feature point matching on the third layer images of the first pyramid and the second pyramid to obtain a first matching relationship between the first pyramid and the second pyramid in the third layer image includes:

[0016] Performing ORB feature point detection on the third layer image of the first pyramid to obtain a first feature point set, where the first feature point set includes a plurality of first feature points;

[0017] Performing ORB feature point detection on the third layer image of the second pyramid to obtain a second feature point set, where the second feature point set includes a plurality of second feature points;

[0018] The first feature point set and the second feature point set are matched based on Euclidean distance to obtain a first matching relationship; the first matching relationship includes a plurality of matching feature point pairs, each matching feature point pair includes a first feature point and a second feature point matching the first feature point.

[0019] Optionally, in the image matching method described in the embodiment of the present application, matching the first feature point set with the second feature point set based on the Euclidean distance to obtain a first matching relationship includes:

[0020] Selecting a second feature point with the smallest Euclidean distance for each first feature point in the first feature point set to obtain a plurality of initial matching feature point pairs;

[0021] The outlier points and noise points in the plurality of initial matching feature point pairs are deleted to obtain a first matching relationship.

[0022] Optionally, in the image matching method described in the embodiment of the present application, the first initial offset includes a first offset and a random offset;

[0023] Mapping the first matching relationship to the second layer image of the first pyramid and the second pyramid, and obtaining the first initial offset of the first pyramid and the second pyramid in the second layer image according to the first matching relationship, includes:

[0024] Determine each first feature point and a third pixel block corresponding to each first feature point in the second layer image of the first pyramid, wherein each first feature point is located at the center of the corresponding third pixel block;

[0025] Determine each second feature point and a fourth pixel block corresponding to each second feature point in the second layer image of the second pyramid, wherein each second feature point is located at the center of the corresponding fourth pixel block;

[0026] Determine a first offset of a third pixel block and a fourth pixel block that match each other according to the first matching relationship;

[0027] The offset of a third pixel point in the second layer image of the first pyramid with respect to a fourth pixel point in the second layer image of the second pyramid is randomly allocated to obtain a random offset, wherein the third pixel point is a pixel point outside a third pixel block in the second layer image of the first pyramid, and the fourth pixel point is a pixel point outside a fourth pixel block in the second layer image of the second pyramid.

[0028] Optionally, in the image matching method described in the embodiment of the present application, obtaining a second matching relationship between the first pyramid and the second pyramid in the second layer image according to the first initial offset includes:

[0029] The first initial offset is updated by using an ORB feature point four-neighborhood propagation method, and a second matching relationship between the first pyramid and the second pyramid in the second layer image is calculated based on the updated first initial offset.

[0030] Optionally, in the image matching method described in the embodiment of the present application, the updating of the first initial offset by using the ORB feature point four-neighborhood propagation method, and calculating the second matching relationship between the first pyramid and the second pyramid in the second layer image based on the updated first initial offset include:

[0031] Determine the fourth pixel point corresponding to each third pixel point according to the random offset amount thereof;

[0032] Calculating the initial similarity between the region block of each third pixel point and the region block of the corresponding fourth pixel point; wherein the region block is a preset range area centered on the corresponding pixel point;

[0033] Calculate a first similarity between a region block of four neighboring pixel points of each of the third pixel points and a region block corresponding to the fourth pixel point;

[0034] According to the initial similarity corresponding to each of the third pixel points and the multiple first similarities, each of the random offsets is updated to obtain a corresponding second offset;

[0035] A second matching relationship between the first pyramid and the second pyramid in the second layer image is acquired according to the first offset and the second offset.

[0036] Optionally, in the image matching method described in the embodiment of the present application, updating each of the random offsets according to the initial similarity of each of the fifth feature points and the multiple first similarities to obtain a corresponding second offset includes:

[0037] If the initial similarity corresponding to the third pixel point is greater than the first similarity corresponding to each of its four neighboring pixel points, the first initial offset corresponding to the third pixel point is set as its second offset;

[0038] If the initial similarity corresponding to the third pixel point is not greater than the first similarity corresponding to each of its four neighboring pixel points, the first initial offset is updated according to the four neighboring pixel points with the largest first similarity among its four neighboring pixel points to obtain a second offset.

[0039] Optionally, in the image matching method described in the embodiment of the present application, the first pixel point includes a plurality of fifth pixel points and a plurality of seventh pixel points;

[0040] The mapping the second matching relationship to the first layers of the first pyramid and the second pyramid, and searching the first layer image of the second pyramid to obtain the second pixel point with the greatest similarity to each first pixel point of the first image in the second image, includes:

[0041] Determine the fifth pixel block corresponding to each first feature point and the sixth pixel block corresponding to each second feature point in the first layer images of the first pyramid and the second pyramid respectively; each of the first feature points is located at the center of the corresponding fifth pixel block, and each of the fifth pixel blocks includes a plurality of fifth pixel points; each of the second feature points is located at the center of the corresponding sixth pixel block, and each of the sixth pixel blocks includes a plurality of sixth pixel points;

[0042] Determine a sixth pixel point that matches each fifth pixel point according to the second matching relationship;

[0043] Determine, in the first layer images of the first pyramid and the second pyramid, a seventh pixel block corresponding to each third pixel point and an eighth pixel block corresponding to each fourth pixel point; each of the fifth pixel blocks includes a plurality of seventh pixel points; each of the eighth pixel blocks includes a plurality of eighth pixel points;

[0044] An eighth pixel point matching each of the seventh pixel points is searched in the area where the eighth pixel block is located.

[0045] Optionally, in the image matching method described in the embodiment of the present application, searching for an eighth pixel point matching each of the seventh pixel points in the area where the eighth pixel block is located includes:

[0046] Taking a seventh pixel point among the plurality of seventh pixel points for which a matching point has not been searched as a current seventh pixel point;

[0047] Obtaining the Euclidean distance r of the second feature point closest to the eighth pixel point corresponding to the current seventh pixel point, and setting a preset search range with the corresponding eighth pixel point as the search center and the Euclidean distance r as the search radius;

[0048] Searching for a preset number of eighth pixel points within the preset search range, and selecting an eighth pixel point having the greatest similarity to the current seventh pixel point from the preset number of eighth pixel points;

[0049] Determine whether the preset search is completed;

[0050] If not completed, taking the eighth pixel point with the largest similarity as the search center, and reducing the search radius to obtain a new preset search range, and then returning to the step of randomly searching for a preset number of eighth pixel points within the preset search range;

[0051] If completed, the eighth pixel point with the greatest similarity is used as the matching point of the current seventh pixel point; and it is determined whether the matching points are all searched for the multiple seventh pixel points;

[0052] If there is a seventh pixel point for which no matching point has been found, returning to the step of using one of the plurality of seventh pixel points for which no matching point has been found as the current seventh pixel point;

[0053] If there is no seventh pixel point for which a matching point has not been found, the search ends.

[0054] In a second aspect, an embodiment of the present application provides an image matching device for matching a first image with a second image, the device comprising:

[0055] A construction module, configured to respectively construct a first pyramid for the first image and a second pyramid for the second image, wherein the first pyramid and the second pyramid each include three layers of images, wherein the first layer of images of the first pyramid and the second pyramid are the first image and the second image, respectively, and the resolution of the image of the first pyramid and the second pyramid that is closer to the first layer of images is greater;

[0056] A first matching module is used to perform feature point matching on the third layer images of the first pyramid and the second pyramid to obtain a first matching relationship between the first pyramid and the second pyramid in the third layer image;

[0057] A first acquisition module, configured to map the first matching relationship to the second layer images of the first pyramid and the second pyramid, and acquire a first initial offset of the first pyramid relative to the second pyramid in the second layer image according to the first matching relationship;

[0058] A second acquisition module, configured to obtain a second matching relationship between the first pyramid and the second pyramid in the second layer image according to the first initial offset;

[0059] A search module is used to map the second matching relationship to the first layer images of the first pyramid and the second pyramid, and search the first layer image of the second pyramid to obtain matching second pixel points of each first pixel point of the first image in the second image.

[0060] The image matching method and device provided by the embodiment of the present application respectively construct a first pyramid of a first image and a second pyramid of a second image, wherein the first pyramid and the second pyramid each include three layers of images, wherein the first layers of images of the first pyramid and the second pyramid are the first image and the second image respectively, and the resolution of the images of the first pyramid and the second pyramid that are closer to the first layer of images is greater; feature point matching is performed on the third layer of images of the first pyramid and the second pyramid to obtain a first matching relationship of the first pyramid with respect to the second pyramid in the third layer of images; the first matching relationship is mapped to the second layer of images of the first pyramid and the second pyramid, and a first initial offset of the first pyramid with respect to the second pyramid in the second layer of images is obtained according to the first matching relationship; a second matching relationship of the first pyramid with respect to the second pyramid in the second layer of images is obtained according to the first initial offset; the second matching relationship is mapped to the first layer of images of the first pyramid and the second pyramid, and a search is performed in the first layer of images of the second pyramid to obtain a matching second pixel point of each first pixel point of the first image in the second image; thereby image matching is achieved, and accurate matching relationships of more pixels are provided by feature point matching, thereby reducing the number of matching points that need to be searched, thereby improving efficiency.

[0061] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the embodiments of the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0063] Figure 1 A flowchart of the image matching method in an embodiment of the present application.

[0064] Figure 2 This is a flowchart of a matching point search method of an image matching method in an embodiment of the present application.

[0065] Figure 3 A structural schematic diagram of an image matching device in an embodiment of the present application.

[0066] Figure 4Schematic diagram of the structure of the search unit of the image matching device in the embodiment of the present application.

[0067] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0068] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0069] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0070] Please refer to Figure 1 , Figure 1 is a flowchart of an image matching method in some embodiments of the present application. The method comprises the following steps:

[0071] S101, constructing a first pyramid of a first image and a second pyramid of a second image respectively, wherein the first pyramid and the second pyramid each include three layers of images, wherein the first layer images of the first pyramid and the second pyramid are the first image and the second image respectively, and the resolution of each layer image of the first pyramid and the second pyramid decreases as the layer increases.

[0072] S102 : performing feature point matching on the third layer images of the first pyramid and the second pyramid, and obtaining a first matching relationship between the first pyramid and the second pyramid in the third layer image.

[0073] S103: Map the first matching relationship to the second layer images of the first pyramid and the second pyramid, and obtain a first initial offset of the first pyramid relative to the second pyramid in the second layer image according to the first matching relationship.

[0074] S104: Obtain a second matching relationship between the first pyramid and the second pyramid in the second layer image according to the first initial offset.

[0075] S105: Map the second matching relationship to the first layer images of the first pyramid and the second pyramid, and search the first layer image of the second pyramid to obtain matching second pixel points of each first pixel point of the first image in the second image.

[0076] Wherein, in the step S101, in the first pyramid and the second pyramid, the resolution of the image closer to the level of the first layer image is greater. In the present application, the commonly used method in the prior art can be used to construct the first pyramid of the first image and the second pyramid of the second image. Wherein, the first pyramid and the second pyramid both include three layers of images, and the three layers of images are respectively the first layer image, the second layer image and the third layer image with decreasing resolutions. Of course, it can be understood that in some embodiments, four layers of images or more layers of images can also be set. Wherein, in some embodiments, the downsampling rate from the first layer image to the second layer image of the first pyramid and the second pyramid is the same, and the downsampling rate from the second layer image to the third layer image of the first pyramid and the second pyramid is the same.

[0077] Specifically, in some embodiments, the step S101 includes the following sub-steps: S1011, alternately performing mean blur processing and downsampling processing on the first image at least twice to construct a first pyramid of the first image; S1012, alternately performing mean blur processing and downsampling processing on the second image at least twice to construct a second pyramid of the second image.

[0078] Among them, in step S1011, a square with a side length of 3*3 can be used to perform mean blurring on the first image. Of course, squares of other specifications can also be selected. The first image is used as the first layer image of the first pyramid. After the first round of mean blurring and the first round of downsampling are performed on the first image, the second layer image of the first pyramid is obtained. After the second round of mean blurring and the second round of downsampling are performed on the second layer image, the third layer image of the first pyramid is obtained. In step S1012, a square with a side length of 3*3 can be used to perform mean blurring on the second image. Of course, squares of other specifications can also be selected. However, it must be ensured that the first image and the second image use the same square specifications. The second image is used as the first layer image of the second pyramid. After the first round of mean blurring and the first round of downsampling are performed on the second image, the second layer image of the second pyramid is obtained. After the second round of mean blurring and the second round of downsampling are performed on the second layer image, the third layer image of the second pyramid is obtained. Of course, it is understandable that if the number of pyramid layers is other numbers, the corresponding mean blur and the number of downsampling rounds are also adjusted accordingly.

[0079] In step S102, feature points of the third layer images of the first pyramid and the second pyramid may be extracted by using an ORB feature point extraction method, and then feature matching may be performed to obtain a first matching relationship between the first pyramid and the second pyramid in the third layer image.

[0080] Specifically, in some embodiments, the step S102 includes the following sub-steps: S1021, performing ORB feature point detection on the third layer image of the first pyramid to obtain a first feature point set; S1022, performing ORB feature point detection on the third layer image of the second pyramid to obtain a second feature point set; S1023, matching the first feature point set with the second feature point set based on Euclidean distance to obtain a first matching relationship; the first matching relationship includes multiple matching feature point pairs, each of the matching feature point pairs includes a first feature point in the first feature point set and a second feature point in the second feature point set.

[0081] Among them, in step S1021, the ORB feature points of the image can be simply understood as more prominent points in the image, such as contour points, bright spots in darker areas, dark spots in brighter areas, etc. ORB feature point detection can use the FAST (features from accelerated segment test) algorithm. The first feature point set includes multiple first feature points. In step S1022, the same method as step S1021 can be used to collect ORB feature points. The second feature point set includes multiple second feature points. ORB feature points include first feature points and second feature points.

[0082] In step S1023, the Euclidean distance between a first feature point and each other second feature point can be calculated to find a second feature point whose similarity with the first feature point meets the preset conditions as its matching feature point, and then the first feature point and the second feature point matching it are used to form a matching feature point pair.

[0083] Specifically, in some embodiments, the step S1023 may specifically include the following steps: S10231, selecting a second feature point with the smallest Euclidean distance for each first feature point in the first feature point set to obtain multiple initial matching feature point pairs; S10232, deleting outliers and noise points in the multiple initial matching feature point pairs to obtain a first matching relationship. In the step S10231, the calculation of the Euclidean distance belongs to the prior art and does not need to be described in detail. If the Euclidean distances of two first feature points and one second feature point are the same, one of the first feature points is randomly selected to form an initial matching feature point pair with the second feature point. In the step S10232, the initial matching feature point pairs with Euclidean distances greater than a preset threshold are deleted as outliers, and the initial matching feature point pairs with similarities greater than three times the average similarities of the multiple initial matching feature point pairs are deleted as noise points. Of course, other methods can also be used to delete outliers and noise points.

[0084] Wherein, in step S103, the first initial offset includes a first offset and a random offset. Wherein, the first offset is calculated based on the first matching relationship, and the random offset is an offset set by randomly assigning values ​​to pixels outside the first matching relationship. Since the initial offset includes many first offsets with high accuracy, the number of pixels required for four-neighborhood propagation is greatly reduced when the feature points are subsequently updated, which reduces the amount of calculation and significantly improves the operating efficiency.

[0085] In some embodiments, step S103 includes the following sub-steps: S1031, determining each first feature point and the third pixel block corresponding to each first feature point in the second layer image of the first pyramid, and each first feature point is located at the center of the corresponding third pixel block. S1032, determining each second feature point and the fourth pixel block corresponding to each second feature point in the second layer image of the second pyramid, and each second feature point is located at the center of the corresponding fourth pixel block; S1033, confirming the first offset of the third pixel block and the fourth pixel block that match each other according to the first matching relationship; S1034, randomly assigning the offset of the third pixel point in the second layer image of the first pyramid with respect to the fourth pixel point in the second layer image of the second pyramid to obtain a random offset, wherein the third pixel point is a pixel point other than the third pixel block in the second layer image of the first pyramid, and the fourth pixel point is a pixel point other than the fourth pixel block in the second layer image of the second pyramid.

[0086] In step S1031, the third pixel block is generally a preset square area centered on the first feature point. The first feature point can be mapped to the second layer of the first pyramid in a projection manner. The size of the first pixel block is related to the scale ratio between the third layer image and the second layer image. If the scaling ratio of the third layer image relative to the second layer image is larger, the size of the third pixel block is larger. In step S1032, the fourth pixel block is generally a preset square area centered on the second feature point. The second feature point can be mapped to the second layer of the second pyramid in a projection manner. Of course, the size and shape of the third pixel block and the fourth pixel block are the same, that is, the third pixel block and the fourth pixel block have the same number of pixels. In step S1033, the offset of the first feature point relative to the second feature point can be calculated based on the matching relationship between the first feature point and the second feature point, that is, the offset can be calculated based on the coordinates of the first feature point in the second layer image of the first pyramid and the coordinates of the second feature point in the second layer image of the second pyramid. The offset is the first offset of the third pixel block relative to the fourth pixel block. In step S1034, the following random formula can be used to randomly assign random offsets of the third pixel and the fourth pixel. The calculation formula is as follows: δx=random(wb); δy=random(hb), where random(wb) means taking a random value within the range of wb, and random(hb) means taking a random value within the range of hb. Wherein, wb and hb are the width and height of the second layer image of the second pyramid, respectively. Of course, the horizontal component of the random offset cannot exceed the width of the second layer image of the second pyramid, and the vertical component of the random offset cannot exceed the height of the second layer image of the second pyramid.

[0087] In step S104, the random offset in the first initial offset may be corrected to obtain the correct offset of the pixel points outside the third pixel block and the fourth pixel block. In some embodiments, the random offset may be updated by propagating the feature point in four neighborhoods to obtain the correct second matching relationship.

[0088] Specifically, in some embodiments, the step S104 includes the following sub-steps: S1041, determining the corresponding fourth pixel point according to the random offset of each third pixel point; S1042, calculating the initial similarity between the region block of each third pixel point and the region block of the corresponding fourth pixel point; wherein the region block is a preset range area centered on the corresponding pixel point; S1043, calculating the first similarity between the region block of each of the four neighboring pixel points of each of the third pixel points and the region block corresponding to the fourth pixel point; S1044, updating each of the random offsets according to the initial similarity corresponding to each of the third pixel points and multiple first similarities to obtain the corresponding second offset; S1045, obtaining the second matching relationship between the first pyramid and the second pyramid in the second layer image according to the first offset and the second offset.

[0089] Wherein, in step S1041, the coordinates of the third pixel point are added to the random offset assigned to it to obtain the coordinates of the fourth pixel point corresponding to it. Wherein, in step S1042, the region block is generally a square block, each of the four neighborhood pixels corresponds to a region block, and the size and shape of each region block are the same. Wherein, the four neighborhood pixels of pixel point A can be one of the pixels in the four neighborhoods of pixel point A. When calculating the initial similarity, the similarity of the two region blocks can be calculated by calculating the Euclidean distance. Wherein, in step S1043, the corresponding fourth pixel point refers to the fourth pixel point associated with the third pixel point through the random offset. Similarly, in this step, the similarity of the two region blocks can be calculated by calculating the Euclidean distance. Of course, other common algorithms can also be used to calculate the similarity of the two region blocks. In step S1044, taking the fourth pixel point as a reference, the region block with the largest similarity to the region block corresponding to the fourth pixel point is selected to generate the second offset. In step S1045, the second matching relationship is generated based on the first offset and the second offset. The second matching relationship refers to the correspondence between the pixel points of the second layer image of the first pyramid and the second layer image of the second pyramid, that is, according to the second matching relationship, a pixel point of the second layer image of the first pyramid can find a matching pixel point in the second layer image of the second pyramid.

[0090] Specifically, in some embodiments, the step S1044 specifically includes the following sub-steps: S10441. If the initial similarity corresponding to the third pixel point is greater than the first similarity corresponding to each of its four neighboring pixel points, the first initial offset corresponding to the third pixel point is set as its second offset; S10442. If the initial similarity corresponding to the third pixel point is not greater than the first similarity corresponding to each of its four neighboring pixel points, the random offset is updated according to the four neighboring pixel points with the largest first similarity among its four neighboring pixel points to obtain the second offset.

[0091] For example, the similarity corresponding to the third pixel is a1, and the first similarities corresponding to each of its four neighboring pixel points are a2, a3, a4, a5 and a6 respectively. Among them, the similarity corresponding to the four neighboring pixel points refers to the similarity between the area block corresponding to the four neighboring pixel points and the area block corresponding to the third pixel point. If a1 is greater than a2, a3, a4, a5 and a6, the random offset corresponding to the first initial offset of the third pixel point is used as the second offset. If a1 is not greater than a2, a3, a4, a5 and a6, the four neighboring pixel points corresponding to the maximum value of a2, a3, a4, a5 and a6 are updated as the matching points of the fourth pixel point, and the second offset is calculated based on the coordinates of the four neighboring pixel points corresponding to the maximum value and the coordinates of the fourth pixel point.

[0092] In step S105, the second matching relationship can be mapped to the first layer image of the first pyramid and the second layer image of the second pyramid, and then iterative optimization is performed to find the pixel point with the maximum similarity of each pixel point of the first image in the second image, that is, the matching pixel point.

[0093] Specifically, in some embodiments, the first pixel of the first image includes a plurality of fifth pixel points and a plurality of seventh pixel points, and the second pixel of the second image includes a plurality of sixth pixel points and a plurality of eighth pixel points. Step S105 may include the following sub-steps:

[0094] S1051, determine the fifth pixel block corresponding to each first feature point and the sixth pixel block corresponding to each second feature point in the first layer image of the first pyramid and the second pyramid respectively; each of the first feature points is located at the center of the corresponding fifth pixel block, and each of the fifth pixel blocks includes multiple fifth pixel points; each of the second feature points is located at the center of the corresponding sixth pixel block, and each of the sixth pixel blocks includes multiple sixth pixel points; S1052, determine the sixth pixel point matching each fifth pixel point according to the second matching relationship; S1053, determine the seventh pixel block corresponding to each third pixel point and the eighth pixel block corresponding to each fourth pixel point in the first layer image of the first pyramid and the second pyramid; each of the seventh pixel block includes multiple seventh pixel points; each of the eighth pixel block includes multiple eighth pixel points; S1054, search for the eighth pixel point matching each of the seventh pixel points in the area where the eighth pixel block is located.

[0095] That is, the fifth pixel point among the plurality of first pixels is the sixth pixel point among the plurality of second pixels through the matching relationship between the first feature point and the second feature point. The seventh pixel point among the plurality of first pixels is the eighth pixel point among the plurality of second pixels obtained by searching. Since the sixth pixel point in the second image that is most similar to the fifth pixel point of the first image has been found by matching the feature points, the number of the seventh pixel points that need to be searched for matching points is greatly reduced, thereby improving the operation efficiency.

[0096] Wherein, in step S1051, the size of the fifth pixel block corresponding to the first feature point is larger than the size of the third pixel block corresponding to the first feature point in the second layer image. The size of the fifth pixel block is positively correlated with the scaling ratio of the third layer image relative to the second layer image. The fifth pixel block includes a plurality of fifth pixel points. The first feature point is located at the center of the fifth pixel block. The fifth pixel block is square or circular. The size of the sixth pixel block corresponding to the second feature point is larger than the size of the fourth pixel block corresponding to the second feature point in the second layer image. Of course, the size of the fifth pixel block is the same as the size of the sixth pixel block.

[0097] Among them, in step S1052, the fifth pixel block and the sixth pixel block that match each other are first determined according to the first offset in the second matching relationship. The fifth pixel block that matches each other also corresponds to and matches the pixel points in the sixth pixel block. Therefore, the sixth pixel point in the sixth pixel block that matches the fifth pixel point in each fifth pixel block can also be determined according to the first offset.

[0098] In step S1053, the size and shape of the seventh pixel block are equal to the size and shape of the eighth pixel block, and are also equal to the size and shape of the fifth pixel block and the sixth pixel block. First, each third pixel point is mapped to the first layer image of the first pyramid, and each fourth pixel point is mapped to the second layer image of the second pyramid. During mapping, the coordinates of the third pixel point can be proportionally enlarged according to the proportional relationship between the scales of the second layer image and the first layer image, so as to obtain the mapping point of the third pixel point on the first layer image, and then the corresponding seventh pixel block is obtained based on the mapping point. The coordinates of the fourth pixel point can be proportionally enlarged according to the proportional relationship between the scales of the second layer image and the first layer image, so as to obtain the mapping point of the fourth pixel point on the first layer image, and then the corresponding eighth pixel block is obtained based on the mapping point. The seventh pixel block is a square pixel block centered on the corresponding mapping point. The eighth pixel block is a square pixel block centered on the corresponding mapping point.

[0099] Among them, in this step S1054, a method of searching one by one can be adopted to obtain the eighth pixel point with the greatest similarity to the seventh pixel point as the matching point of the seventh pixel point. Of course, in order to improve efficiency, the search can also be performed within a certain range.

[0100] In some embodiments, Figure 2 As shown, step S1054 may include:

[0101] S10541. Take one of the plurality of seventh pixels that has not been searched for a matching point as the current seventh pixel. S10542. Obtain the Euclidean distance r of the second feature point closest to the eighth pixel corresponding to the current seventh pixel, and set a preset search range with the corresponding eighth pixel as the search center and the Euclidean distance r as the search radius. S10543. Search for a preset number of eighth pixels within the preset search range, and select the eighth pixel with the greatest similarity to the current seventh pixel from the preset number of eighth pixels. S10544. Determine whether the preset number of searches is completed. S10545. If not completed, take the eighth pixel with the greatest similarity as the search center, reduce the search radius to obtain a new preset search range, and then return to the step of randomly searching for a preset number of eighth pixels within the preset search range. S10546. If completed, take the eighth pixel with the greatest similarity as the matching point of the current seventh pixel; and determine whether all the plurality of seventh pixels have been searched for matching points. S10547: If there is a seventh pixel point for which no matching point is found, return to the step of using a seventh pixel point among the plurality of seventh pixels for which no matching point is found as the current seventh pixel point. S10548: If there is no seventh pixel point, end the search.

[0102] Wherein, in step S10541, the coordinates of each seventh pixel point can be selected in sequence to obtain the current seventh pixel point. Of course, other methods can also be used, as long as the search for the matching point of each seventh pixel point in the second image is finally completed. Wherein, in step S10542, the Euclidean distance r can be calculated using the calculation method in the prior art. Of course, it can be understood that the preset search range can also be set in other ways. Within the preset search range, a random search method can be used to obtain the preset number of eighth pixel points. The preset number can be 100 or 200. Of course, it can also be set according to the total number of eighth pixel points in the preset search range. For example, if the total number is x, 0.1x eighth pixel points can be randomly searched. Wherein, in step S10543, the specific number of the preset times can be set according to the actual situation, or it can be an empirical value obtained after multiple experiments. Wherein, in step S10544, it can be reduced to half of the current search radius each time. Of course, it can also be reduced to other proportions, for example, 1 / 3. Among them, in step S10545, the eighth pixel point with the greatest similarity is the matching point of the current seventh pixel point. Of course, the eighth pixel point may not be the best, but after multiple iterations, the probability of it being a matching point has met the requirements. Of course, if higher accuracy is required, a one-to-one matching method can be adopted, but this will increase the amount of calculation. Among them, in step S10546, if it exists, the search for the seventh pixel point of the manual is not completed, and the above steps S10541-S10545 need to be repeated until the search for the matching point of each seventh pixel point is completed.

[0103] As can be seen from the above, the image matching method provided by the embodiment of the present application constructs a first pyramid of the first image and a second pyramid of the second image respectively, wherein the first pyramid and the second pyramid each include three layers of images, wherein the first layers of the first pyramid and the second pyramid are the first image and the second image respectively, and the resolution of the image of the first pyramid and the second pyramid that is closer to the first layer of the image is larger; feature point matching is performed on the third layer of the first pyramid and the second pyramid to obtain a first matching relationship between the first pyramid and the second pyramid in the third layer of the image; the first matching relationship is mapped to the second layer of the first pyramid and the second pyramid, and a first initial offset of the first pyramid relative to the second pyramid in the second layer of the image is obtained according to the first matching relationship; a second matching relationship of the first pyramid relative to the second pyramid in the second layer of the image is obtained according to the first initial offset; the second matching relationship is mapped to the first layer of the first pyramid and the second pyramid, and a search is performed in the first layer of the second pyramid to obtain a matching second pixel point of each first pixel point of the first image in the second image; thereby image matching is achieved, and since accurate matching points of more pixels are provided by feature point matching, the number of matching points that need to be searched is reduced, thereby improving efficiency.

[0104] Please refer to Figure 3 , Figure 3 It is a structural schematic diagram of an image matching device in some embodiments of the present application, which is used to match a first image with a second image. The image matching device includes: a construction module 201, a first matching module 202, a first acquisition module 203, a second acquisition module 204 and a search module 205.

[0105] The construction module 201 is used to construct a first pyramid of the first image and a second pyramid of the second image, respectively. The first pyramid and the second pyramid each include three layers of images, respectively. The first layers of the first pyramid and the second pyramid are the first image and the second image, respectively. The resolution of each layer of the first pyramid and the second pyramid decreases as the level increases. In the first pyramid and the second pyramid, the resolution of the image closer to the level of the first layer image is greater. In the present application, the commonly used method in the prior art can be used to construct the first pyramid of the first image and the second pyramid of the second image. In the first pyramid and the second pyramid each include three layers of images, and the three layers of images are respectively the first layer image, the second layer image and the third layer image with successively decreasing resolutions. Of course, it can be understood that in some embodiments, four layers of images or more layers of images can also be set. In some embodiments, the downsampling rate from the first layer image to the second layer image of the first pyramid and the second pyramid is the same, and the downsampling rate from the second layer image to the third layer image of the first pyramid and the second pyramid is the same.

[0106] Specifically, in some embodiments, the construction module 201 is specifically used to: alternately perform at least two mean blurring processes and downsampling processes on the first image to construct a first pyramid of the first image; alternately perform at least two mean blurring processes and downsampling processes on the second image to construct a second pyramid of the second image.

[0107] Among them, the construction module 201 can use a square with a side length of 3*3 to perform mean blur on the first image. Of course, squares of other specifications can also be selected. The first image is used as the first layer image of the first pyramid. After the first round of mean blur and the first round of downsampling are performed on the first image, the second layer image of the first pyramid is obtained. After the second round of mean blur and the second round of downsampling are performed on the second layer image, the third layer image of the first pyramid is obtained. In this step, the construction module 201 can use a square with a side length of 3*3 to perform mean blur on the second image. Of course, squares of other specifications can also be selected. However, it must be ensured that the first image and the second image use the same square specifications. The second image is used as the first layer image of the second pyramid. After the first round of mean blur and the first round of downsampling are performed on the second image, the second layer image of the second pyramid is obtained. After the second round of mean blur and the second round of downsampling are performed on the second layer image, the third layer image of the second pyramid is obtained. Of course, it can be understood that if the number of layers of the pyramid is other numbers, the corresponding mean blur and the number of rounds of downsampling are also adjusted accordingly.

[0108] The first matching module 202 is used to perform feature point matching on the third layer images of the first pyramid and the second pyramid, and obtain a first matching relationship between the first pyramid and the second pyramid in the third layer image. The first matching module 202 can extract feature points of the third layer images of the first pyramid and the second pyramid by an ORB feature point extraction method, and then perform feature matching to obtain a first matching relationship between the first pyramid and the second pyramid in the third layer image.

[0109] Specifically, in some embodiments, the first matching module 202 is specifically used to: perform ORB feature point detection on the third layer image of the first pyramid to obtain a first feature point set; perform ORB feature point detection on the third layer image of the second pyramid to obtain a second feature point set; match the first feature point set with the second feature point set based on Euclidean distance to obtain a first matching relationship; the first matching relationship includes a plurality of matching feature point pairs, each of which includes a first feature point in the first feature point set and a second feature point in the second feature point set. Among them, the ORB feature points of the image can be simply understood as more prominent points in the image, such as contour points, bright spots in darker areas, dark spots in brighter areas, etc. ORB feature point detection can use the FAST (features from accelerated segment test) algorithm. The first feature point set includes a plurality of first feature points. The second feature point set includes a plurality of second feature points. ORB feature points include first feature points and second feature points.

[0110] Among them, the first matching module 202 can calculate the Euclidean distance between a certain first feature point and each other second feature point, find out the second feature point whose similarity with the first feature point meets the preset conditions as its matching feature point, and then use the first feature point and the second feature point matching it to form a matching feature point pair.

[0111] Specifically, in some embodiments, the first matching module 202 is specifically used to: select a second feature point with the smallest Euclidean distance for each first feature point in the first feature point set to obtain multiple initial matching feature point pairs; delete the outliers and noise points in the multiple initial matching feature point pairs to obtain a first matching relationship. The calculation of the Euclidean distance belongs to the prior art and does not need to be described in detail. If the Euclidean distances of two first feature points and a second feature point are the same, one of the first feature points is randomly selected to form an initial matching feature point pair with the second feature point. Among them, the initial matching feature point pairs with a Euclidean distance greater than a preset threshold are deleted as outliers, and the initial matching feature point pairs with a similarity greater than three times the average similarity of the multiple initial matching feature point pairs are deleted as noise points. Of course, other methods can also be used to delete outliers and noise points.

[0112] The first acquisition module 203 is used to map the first matching relationship to the second layer image of the first pyramid and the second pyramid, and obtain the first initial offset of the first pyramid relative to the second pyramid in the second layer image according to the first matching relationship. The first initial offset includes a first offset and a random offset. The first offset is calculated based on the first matching relationship, and the random offset is an offset set by randomly assigning values ​​to pixels outside the first matching relationship. Since the initial offset includes many first offsets with high accuracy, the number of pixels required for four-neighborhood propagation is greatly reduced when the feature points are subsequently updated, which reduces the amount of calculation and significantly improves the operating efficiency.

[0113] In some embodiments, the first acquisition module 203 is specifically used to: determine each first feature point and the third pixel block corresponding to each first feature point in the second layer image of the first pyramid, and each first feature point is located at the center of the corresponding third pixel block. Determine each second feature point and the fourth pixel block corresponding to each second feature point in the second layer image of the second pyramid, and each second feature point is located at the center of the corresponding fourth pixel block; confirm the first offset of the third pixel block and the fourth pixel block that match each other according to the first matching relationship; randomly assign the offset of the third pixel point in the second layer image of the first pyramid with respect to the fourth pixel point in the second layer image of the second pyramid to obtain a random offset, wherein the third pixel point is a pixel point other than the third pixel block in the second layer image of the first pyramid, and the fourth pixel point is a pixel point other than the fourth pixel block in the second layer image of the second pyramid. The third pixel block is generally a preset square area centered on the first feature point. The first feature point can be mapped to the second layer of the first pyramid in a projection manner. The size of the first pixel block is related to the scale ratio between the third layer image and the second layer image. If the scaling ratio of the third layer image relative to the second layer image is larger, the size of the third pixel block is larger. The fourth pixel block is generally a preset square area centered on the second feature point. The second feature point can be mapped to the second layer of the second pyramid in a projection manner. Of course, the third pixel block and the fourth pixel block have the same size and shape, that is, the third pixel block and the fourth pixel block have the same number of pixels. The offset of the first feature point relative to the second feature point can be obtained based on the matching relationship between the first feature point and the second feature point, that is, the offset can be calculated based on the coordinates of the first feature point in the second layer image of the first pyramid and the coordinates of the second feature point in the second layer image of the second pyramid. The offset is the first offset of the third pixel block relative to the fourth pixel block. The following random formula can be used to randomly assign the random offsets of the third pixel point and the fourth pixel point. The calculation formula is as follows: δx=random(wb); δy=random(hb), where random(wb) means taking a random value within the range of wb, and random(hb) means taking a random value within the range of hb. Wherein, wb and hb are the width and height of the second layer image of the second pyramid, respectively. Of course, the horizontal component of the random offset cannot exceed the width of the second layer image of the second pyramid, and the vertical component of the random offset cannot exceed the height of the second layer image of the second pyramid.

[0114] The second acquisition module 204 is used to obtain a second matching relationship between the first pyramid and the second pyramid in the second layer image according to the first initial offset. The random offset in the first initial offset can be corrected, and then the correct offset of the pixel points outside the third pixel block and the fourth pixel block can be obtained. In some embodiments, the random offset can be updated by four-neighborhood propagation of feature points to obtain the correct second matching relationship.

[0115] Specifically, in some embodiments, the second acquisition module 204 is specifically used to: determine the corresponding fourth pixel point according to the random offset of each third pixel point; calculate the initial similarity between the region block of each third pixel point and the region block of the corresponding fourth pixel point; wherein the region block is a preset range area centered on the corresponding pixel point; calculate the first similarity between the region block of each of the four neighboring pixel points of each third pixel point and the region block corresponding to the fourth pixel point; update each of the random offsets according to the initial similarity corresponding to each of the third pixel points and multiple first similarities to obtain the corresponding second offset; obtain the second matching relationship between the first pyramid and the second pyramid in the second layer image according to the first offset and the second offset. wherein the coordinates of the third pixel point are added to the random offset assigned to it to obtain the coordinates of the fourth pixel point corresponding to it. the region block is generally a square block, each of the four neighboring pixel points corresponds to a region block, and the size and shape of each region block are the same. wherein the four neighboring pixel points of pixel point A can be one of the pixel points in the four neighboring areas of pixel point A. when calculating the initial similarity, the similarity of two region blocks can be calculated by calculating the Euclidean distance. The corresponding fourth pixel point refers to the fourth pixel point associated with the third pixel point through the random offset. Similarly, in this step, the similarity of the two area blocks can be calculated by calculating the Euclidean distance. Of course, other common algorithms can also be used to calculate the similarity of the two area blocks. Taking the fourth pixel point as a reference, the area block with the greatest similarity to the area block corresponding to the fourth pixel point is selected to generate the second offset. The second matching relationship is generated based on the first offset and the second offset. Among them, the second matching relationship refers to the correspondence between the pixel points of the second layer image of the first pyramid and the second layer image of the second pyramid, that is, according to the second matching relationship, a pixel point of the second layer image of the first pyramid can find a matching pixel point in the second layer image of the second pyramid.

[0116] Specifically, in some embodiments, the second acquisition module 204 can be used to: if the initial similarity corresponding to the third pixel point is greater than the first similarity corresponding to each of its four neighboring pixel points, then the first initial offset corresponding to the third pixel point is set as its second offset; if the initial similarity corresponding to the third pixel point is not greater than the first similarity corresponding to each of its four neighboring pixel points, then the random offset is updated according to the four neighboring pixel points with the largest corresponding first similarity among its four neighboring pixel points to obtain the second offset.

[0117] For example, the similarity corresponding to the third pixel is a1, and the first similarities corresponding to each of its four neighboring pixel points are a2, a3, a4, a5 and a6 respectively. Among them, the similarity corresponding to the four neighboring pixel points refers to the similarity between the area block corresponding to the four neighboring pixel points and the area block corresponding to the third pixel point. If a1 is greater than a2, a3, a4, a5 and a6, the random offset corresponding to the first initial offset of the third pixel point is used as the second offset. If a1 is not greater than a2, a3, a4, a5 and a6, the four neighboring pixel points corresponding to the maximum value of a2, a3, a4, a5 and a6 are updated as the matching points of the fourth pixel point, and the second offset is calculated based on the coordinates of the four neighboring pixel points corresponding to the maximum value and the coordinates of the fourth pixel point.

[0118] The search module 205 is used to map the second matching relationship to the first layer image of the first pyramid and the second pyramid, and search in the first layer image of the second pyramid to obtain the matching second pixel points of each first pixel point of the first image in the second image. The search module 205 can map the second matching relationship to the first layer image of the first pyramid and the second layer image of the second pyramid, and then perform iterative optimization to find the pixel point with the maximum similarity of each pixel point of the first image in the second image, that is, the matching pixel point.

[0119] Specifically, in some embodiments, the first pixel points of the first image include a plurality of fifth pixel points and a plurality of seventh pixel points, and the second pixel points of the second image include a plurality of sixth pixel points and a plurality of eighth pixel points.

[0120] like Figure 4 As shown, the search module 205 specifically includes: a first determination unit 2051 , a second determination unit 2052 , a third determination unit 2053 and a search unit 2054 .

[0121] The first determining unit 2051 is used to determine the fifth pixel block corresponding to each first feature point and the sixth pixel block corresponding to each second feature point in the first layer image of the first pyramid and the second pyramid respectively; each of the first feature points is located at the center of the corresponding fifth pixel block, and each of the fifth pixel blocks includes a plurality of fifth pixel points; each of the second feature points is located at the center of the corresponding sixth pixel block, and each of the sixth pixel blocks includes a plurality of sixth pixel points. The size of the fifth pixel block corresponding to the first feature point is larger than the size of the third pixel block corresponding to the first feature point in the second layer image. The size of the fifth pixel block is positively correlated with the scaling ratio of the third layer image to the second layer image. The fifth pixel block includes a plurality of fifth pixel points. The first feature point is located at the center of the fifth pixel block. The fifth pixel block is in a square or circular shape. The size of the sixth pixel block corresponding to the second feature point is larger than the size of the fourth pixel block corresponding to the second feature point in the second layer image. Of course, the size of the fifth pixel block is the same as the size of the sixth pixel block.

[0122] Wherein, the second determining unit 2052 is used to determine the sixth pixel point that matches each fifth pixel point according to the second matching relationship. The second determining unit 2052 first determines the fifth pixel block and the sixth pixel block that match each other according to the first offset in the second matching relationship. The fifth pixel block that matches each other also corresponds to and matches the pixel points in the sixth pixel block one by one. Therefore, the sixth pixel point in the sixth pixel block that matches the fifth pixel point in each fifth pixel block can also be determined according to the first offset.

[0123] The third determination unit 2053 is used to determine the seventh pixel block corresponding to each third pixel point and the eighth pixel block corresponding to each fourth pixel point in the first layer image of the first pyramid and the second pyramid; each of the seventh pixel blocks includes a plurality of seventh pixel points; each of the eighth pixel blocks includes a plurality of eighth pixel points. The size and shape of the seventh pixel block are equal to those of the eighth pixel block, and are also equal to those of the fifth pixel block and the sixth pixel block. First, each third pixel point is mapped to the first layer image of the first pyramid, and each fourth pixel point is mapped to the second layer image of the second pyramid. During mapping, the coordinates of the third pixel point can be proportionally enlarged according to the proportional relationship between the scales of the second layer image and the first layer image, so as to obtain the mapping point of the third pixel point on the first layer image, and then the corresponding seventh pixel block is obtained based on the mapping point. The coordinates of the fourth pixel point can be proportionally enlarged according to the proportional relationship between the scales of the second layer image and the first layer image, so as to obtain the mapping point of the fourth pixel point on the first layer image, and then the corresponding eighth pixel block is obtained based on the mapping point. The seventh pixel block is a square pixel block centered on the corresponding mapping point. The eighth pixel block is a square pixel block centered at the corresponding mapping point.

[0124] The search unit 2054 is used to search for an eighth pixel point that matches each of the seventh pixel points in the area where the eighth pixel block is located. The eighth pixel point with the greatest similarity to the seventh pixel point can be obtained as the matching point of the seventh pixel point by searching one by one in sequence. Of course, in order to improve efficiency, the search can also be performed within a certain range.

[0125] In this embodiment, the fifth pixel point among the plurality of first pixels is the sixth pixel point among the plurality of second pixels through the matching relationship between the first feature point and the second feature point. The seventh pixel point among the plurality of first pixels is the eighth pixel point among the plurality of second pixels obtained by searching. Since the sixth pixel point in the second image that is most similar to the fifth pixel point of the first image has been found by matching the feature points, the number of the seventh pixel points that need to be searched for matching points is greatly reduced, thereby improving the operation efficiency.

[0126] In some embodiments, the search unit 2054 can be used to: take a seventh pixel point among multiple seventh pixels that has not been searched for a matching point as the current seventh pixel point. Obtain the Euclidean distance r of the second feature point closest to the eighth pixel point corresponding to the current seventh pixel point, and set a preset search range with the corresponding eighth pixel point as the search center and the Euclidean distance r as the search radius. Search for a preset number of eighth pixels within the preset search range, and select the eighth pixel point with the greatest similarity to the current seventh pixel point from the preset number of eighth pixels. Determine whether the preset search is completed. If not completed, take the eighth pixel point with the greatest similarity as the search center, reduce the search radius to obtain a new preset search range, and then return to the step of randomly searching for a preset number of eighth pixels within the preset search range. If completed, take the eighth pixel point with the greatest similarity as the matching point of the current seventh pixel point; and determine whether all the multiple seventh pixels have been searched for matching points. If there is a seventh pixel point that has not been searched for a matching point, return to the step of taking a seventh pixel point among multiple seventh pixels that has not been searched for a matching point as the current seventh pixel point. If not, end the search.

[0127] Among them, the search unit 2054 can select in sequence based on the coordinates of each seventh pixel point to obtain the current seventh pixel point. Of course, other methods can also be used, as long as the search for the matching point of each seventh pixel point in the second image is finally completed. Among them, in this step, the Euclidean distance r can be calculated using the calculation method in the prior art. Of course, it can be understood that the preset search range can also be set in other ways. A random search method can be used within the preset search range to obtain the preset number of eighth pixels. The preset number can be 100 or 200. Of course, it can also be set according to the total number of eighth pixels in the preset search range. For example, if the total number is x, 0.1x eighth pixels can be randomly searched. Among them, the specific number of the preset times can be set according to the actual situation, or it can be an empirical value obtained after multiple experiments. Among them, it can be reduced to half of the current search radius each time. Of course, it can also be reduced to other proportions, such as 1 / 3. Among them, the eighth pixel point with the largest similarity is the matching point of the current seventh pixel point. Of course, the eighth pixel point may not be the best, but after multiple iterations, the probability of it being a matching point has met the requirements. Of course, if higher accuracy is required, a one-by-one matching method can be used, but this will increase the amount of calculation.

[0128] As can be seen from the above, the image matching device provided by the embodiment of the present application constructs a first pyramid of the first image and a second pyramid of the second image respectively, wherein the first pyramid and the second pyramid each include three layers of images, wherein the first layers of images of the first pyramid and the second pyramid are the first image and the second image respectively, and the resolution of the images of the first pyramid and the second pyramid that are closer to the first layer of images is greater; feature point matching is performed on the third layer of images of the first pyramid and the second pyramid to obtain a first matching relationship of the first pyramid with respect to the second pyramid in the third layer of images; the first matching relationship is mapped to the second layer of images of the first pyramid and the second pyramid, and a first initial offset of the first pyramid with respect to the second pyramid in the second layer of images is obtained according to the first matching relationship; a second matching relationship of the first pyramid with respect to the second pyramid in the second layer of images is obtained according to the first initial offset; the second matching relationship is mapped to the first layer of images of the first pyramid and the second pyramid, and a search is performed in the first layer of images of the second pyramid to obtain a matching second pixel point of each first pixel point of the first image in the second image; thereby image matching is realized, and since the feature point matching method is adopted to provide accurate matching relationships of more pixels, the number of matching points that need to be searched is reduced, thereby improving efficiency.

[0129] Please refer to Figure 5 , Figure 5 This is a structural diagram of an electronic device provided in an embodiment of the present application. The present application provides an electronic device 3, including: a processor 301 and a memory 302. The processor 301 and the memory 302 are interconnected and communicate with each other through a communication bus 303 and / or other forms of connection mechanisms (not marked). The memory 302 stores a computer program executable by the processor 301. When the computing device is running, the processor 301 executes the computer program to execute the method in any optional implementation of the above-mentioned embodiment.

[0130] The embodiment of the present application provides a storage medium, and when the computer program is executed by the processor, the method in any optional implementation of the above embodiment is executed. Wherein, the storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read Only Memory, referred to as EPROM), programmable read-only memory (Programmable Red-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, disk or optical disk.

[0131] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0132] In addition, the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0133] Furthermore, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.

[0134] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.

[0135] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. An image matching method, characterized in that: The method comprises: Constructing a first pyramid for the first image and a second pyramid for the second image respectively, wherein the first pyramid and the second pyramid each include three layers of images, wherein the first layer of images of the first pyramid and the second pyramid are the first image and the second image respectively, and the resolution of the image of the first pyramid and the second pyramid that is closer to the first layer of images is greater; Performing feature point matching on the third layer images of the first pyramid and the second pyramid to obtain a first matching relationship between the first pyramid and the second pyramid in the third layer image; Mapping the first matching relationship to the second layer images of the first pyramid and the second pyramid, and acquiring a first initial offset of the first pyramid relative to the second pyramid in the second layer image according to the first matching relationship; Obtaining a second matching relationship between the first pyramid and the second pyramid in the second layer image according to the first initial offset; Mapping the second matching relationship to the first layer images of the first pyramid and the second pyramid, and searching the first layer image of the second pyramid to obtain a matching second pixel point of each first pixel point of the first image in the second image; The first initial offset includes a first offset and a random offset; The mapping the first matching relationship to the second layer images of the first pyramid and the second pyramid, and obtaining a first initial offset of the first pyramid relative to the second pyramid in the second layer image according to the first matching relationship, includes: Determine each first feature point and a third pixel block corresponding to each first feature point in the second layer image of the first pyramid, wherein each first feature point is located at the center of the corresponding third pixel block; the first feature point is obtained by performing ORB feature point detection on the third layer image of the first pyramid; Determine each second feature point and a fourth pixel block corresponding to each second feature point in the second layer image of the second pyramid, wherein each second feature point is located at the center of the corresponding fourth pixel block; the second feature point is obtained by performing ORB feature point detection on the third layer image of the second pyramid; Determine a first offset of a third pixel block and a fourth pixel block that match each other according to the first matching relationship; The offset of a third pixel point in the second layer image of the first pyramid with respect to a fourth pixel point in the second layer image of the second pyramid is randomly allocated to obtain a random offset, wherein the third pixel point is a pixel point outside a third pixel block in the second layer image of the first pyramid, and the fourth pixel point is a pixel point outside a fourth pixel block in the second layer image of the second pyramid.

2. The image matching method according to claim 1, characterized in that: The step of respectively constructing a first pyramid for the first image and a second pyramid for the second image comprises: Alternately performing at least two mean blurring processes and downsampling processes on the first image to construct a first pyramid of the first image; The mean blurring process and the downsampling process are alternately performed at least twice on the second image to construct a second pyramid of the second image.

3. The image matching method according to claim 1 or 2, characterized in that: The performing feature point matching on the third layer images of the first pyramid and the second pyramid to obtain a first matching relationship between the first pyramid and the second pyramid in the third layer image includes: Performing ORB feature point detection on the third layer image of the first pyramid to obtain a first feature point set, where the first feature point set includes a plurality of first feature points; Performing ORB feature point detection on the third layer image of the second pyramid to obtain a second feature point set, where the second feature point set includes a plurality of second feature points; The first feature point set and the second feature point set are matched based on Euclidean distance to obtain a first matching relationship; the first matching relationship includes a plurality of matching feature point pairs, each matching feature point pair includes a first feature point and a second feature point matching the first feature point.

4. The image matching method according to claim 3, characterized in that: The matching the first feature point set and the second feature point set based on the Euclidean distance to obtain a first matching relationship includes: Selecting a second feature point with the smallest Euclidean distance for each first feature point in the first feature point set to obtain a plurality of initial matching feature point pairs; The outlier points and noise points in the plurality of initial matching feature point pairs are deleted to obtain a first matching relationship.

5. The image matching method according to claim 1, characterized in that: Obtaining a second matching relationship between the first pyramid and the second pyramid in the second layer image according to the first initial offset includes: The first initial offset is updated by using an ORB feature point four-neighborhood propagation method, and a second matching relationship between the first pyramid and the second pyramid in the second layer image is calculated based on the updated first initial offset.

6. The image matching method according to claim 5, characterized in that: The method of updating the first initial offset by using the ORB feature point four-neighborhood propagation method, and calculating the second matching relationship between the first pyramid and the second pyramid in the second layer image based on the updated first initial offset, includes: Determine the fourth pixel point corresponding to each third pixel point according to the random offset amount thereof; Calculating the initial similarity between the region block of each third pixel point and the region block of the corresponding fourth pixel point; wherein the region block is a preset range area centered on the corresponding pixel point; Calculate a first similarity between a region block of four neighboring pixel points of each of the third pixel points and a region block corresponding to the fourth pixel point; According to the initial similarity corresponding to each of the third pixel points and the multiple first similarities, each of the random offsets is updated to obtain a corresponding second offset; A second matching relationship between the first pyramid and the second pyramid in the second layer image is acquired according to the first offset and the second offset.

7. The image matching method according to claim 6, characterized in that: The updating of each of the random offsets according to the initial similarity corresponding to each of the third pixel points and the plurality of first similarities to obtain a corresponding second offset includes: If the initial similarity corresponding to the third pixel point is greater than the first similarity corresponding to each of its four neighboring pixel points, the first initial offset corresponding to the third pixel point is set as its second offset; If the initial similarity corresponding to the third pixel point is not greater than the first similarity corresponding to each of its four neighboring pixel points, the first initial offset is updated according to the four neighboring pixel points with the largest first similarity among its four neighboring pixel points to obtain a second offset.

8. The image matching method according to claim 6, characterized in that: The first pixel points include a plurality of fifth pixel points and a plurality of seventh pixel points; The step of mapping the second matching relationship to the first layers of the first pyramid and the second pyramid, and searching the first layer image of the second pyramid to obtain the second pixel point with the greatest similarity to each first pixel point of the first image in the second image, includes: Determine the fifth pixel block corresponding to each first feature point and the sixth pixel block corresponding to each second feature point in the first layer images of the first pyramid and the second pyramid respectively; each of the first feature points is located at the center of the corresponding fifth pixel block, and each of the fifth pixel blocks includes a plurality of fifth pixel points; each of the second feature points is located at the center of the corresponding sixth pixel block, and each of the sixth pixel blocks includes a plurality of sixth pixel points; Determine a sixth pixel point that matches each fifth pixel point according to the second matching relationship; Determine, in the first layer images of the first pyramid and the second pyramid, a seventh pixel block corresponding to each third pixel point and an eighth pixel block corresponding to each fourth pixel point; each of the fifth pixel blocks includes a plurality of seventh pixel points; each of the eighth pixel blocks includes a plurality of eighth pixel points; An eighth pixel point matching each of the seventh pixel points is searched in the area where the eighth pixel block is located.

9. The image matching method according to claim 8, characterized in that: The step of searching, in the area where the eighth pixel block is located, for an eighth pixel point that matches each of the seventh pixel points comprises: Taking a seventh pixel point among the plurality of seventh pixel points for which a matching point has not been searched as a current seventh pixel point; Obtaining the Euclidean distance r of the second feature point closest to the eighth pixel point corresponding to the current seventh pixel point, and setting a preset search range with the corresponding eighth pixel point as the search center and the Euclidean distance r as the search radius; Searching for a preset number of eighth pixel points within the preset search range, and selecting an eighth pixel point having the greatest similarity to the current seventh pixel point from the preset number of eighth pixel points; Determine whether the preset search is completed; If not completed, taking the eighth pixel point with the largest similarity as the search center, and reducing the search radius to obtain a new preset search range, and then returning to the step of randomly searching for a preset number of eighth pixel points within the preset search range; If completed, the eighth pixel point with the greatest similarity is used as the matching point of the current seventh pixel point, and it is determined whether the plurality of seventh pixel points are all searched for matching points; If there is a seventh pixel point for which no matching point has been found, returning to the step of using one of the plurality of seventh pixel points for which no matching point has been found as the current seventh pixel point; If there is no seventh pixel point for which a matching point has not been found, the search ends.

10. An image matching device for matching a first image with a second image, characterized in that: The device comprises: A construction module, configured to respectively construct a first pyramid for the first image and a second pyramid for the second image, wherein the first pyramid and the second pyramid each include three layers of images, wherein the first layer of images of the first pyramid and the second pyramid are the first image and the second image, respectively, and the resolution of the image of the first pyramid and the second pyramid that is closer to the first layer of images is greater; A first matching module is used to perform feature point matching on the third layer images of the first pyramid and the second pyramid to obtain a first matching relationship between the first pyramid and the second pyramid in the third layer image; A first acquisition module is configured to map the first matching relationship to the second layer images of the first pyramid and the second pyramid, and acquire a first initial offset of the first pyramid relative to the second pyramid in the second layer image according to the first matching relationship; the first initial offset includes a first offset and a random offset; mapping the first matching relationship to the second layer images of the first pyramid and the second pyramid, and acquiring a first initial offset of the first pyramid relative to the second pyramid in the second layer image according to the first matching relationship, comprising: determining each first feature point and a third pixel block corresponding to each first feature point in the second layer image of the first pyramid, each first feature point being located at the center of the corresponding third pixel block; the first feature point is obtained by performing a random offset on the third layer image of the first pyramid. RB feature point detection is obtained; each second feature point and the fourth pixel block corresponding to each second feature point are determined in the second layer image of the second pyramid, and each second feature point is located at the center of the corresponding fourth pixel block; the second feature point is obtained by performing ORB feature point detection on the third layer image of the second pyramid; according to the first matching relationship, the first offset of the third pixel block and the fourth pixel block that match each other is confirmed; the offset of the third pixel point in the second layer image of the first pyramid with respect to the fourth pixel point in the second layer image of the second pyramid is randomly allocated to obtain a random offset, the third pixel point is a pixel point outside the third pixel block in the second layer image of the first pyramid, and the fourth pixel point is a pixel point outside the fourth pixel block in the second layer image of the second pyramid; A second acquisition module, configured to obtain, according to the first initial offset, a second matching relationship between the first pyramid and the second pyramid in the second layer image; A search module is used to map the second matching relationship to the first layer images of the first pyramid and the second pyramid, and search the first layer image of the second pyramid to obtain matching second pixel points of each first pixel point of the first image in the second image.

11. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the method according to any one of claims 1 to 9 is executed.

12. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is executed.