Image template generation method and device and electronic equipment
By segmenting the image and filtering out high-complexity areas to generate template images, the problems of large data volume and low precision in the image matching process are solved, and efficient and accurate image matching is achieved.
Patent Information
- Application Number
- CN202510736909.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-04
- Publication Date
- 2025-09-19
AI Technical Summary
In the existing technology, the image matching process has problems such as large data volume, high storage space occupancy, slow matching rate and low accuracy. Especially in multi-template scenarios, manual labeling is time-consuming and labor-intensive, and the matching accuracy decreases.
By segmenting the first image, determining a second image whose image complexity is higher than a preset threshold, and generating a corresponding fourth image as a template image for matching, the amount of data is reduced while retaining key information.
This improves the efficiency and accuracy of image matching, reduces equipment operating costs and storage requirements, and avoids the trouble of manually selecting inappropriate areas.
Smart Images

Figure CN120673093A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image matching technology, and in particular to an image template generation method, device and electronic equipment. Background Art
[0002] The first step in image detection is template matching, which is used to determine whether the captured image is a detectable object for subsequent detection. The requirement for judging it as a detectable object is that it is the same image as the template image and is placed in the correct position.
[0003] In existing technologies, when using the entire template image, the template data volume is large and takes up a lot of storage space. Traditional template libraries store redundant feature data, resulting in exponential storage space growth and slow matching speeds in multi-template scenarios. When selecting partial areas of the template image as template matching areas, manually labeling the partial matching areas of different templates in multi-template scenarios is time-consuming and labor-intensive. Furthermore, if a computer uses the same locations as matching areas across different templates to build a template library, some areas may be completely featureless, resulting in reduced matching accuracy. Summary of the Invention
[0004] The present invention provides an image template generation method, device and electronic equipment to solve the problems of slow speed and / or low precision of existing image matching.
[0005] According to one aspect of the present invention, a method for generating an image template is provided, the method comprising:
[0006] Determine a first image; the first image is a template image in the image matching process;
[0007] Determine at least two second images based on the first image; the second images are obtained by performing image segmentation on the first image;
[0008] Determining at least one third image based on each second image, wherein the image complexity of the third image is greater than the first preset image complexity; the image complexity is used to describe the richness of information contained in the image;
[0009] A fourth image corresponding to the first image is generated based on each third image; the fourth image is used to replace the first image for image matching.
[0010] The determination of image complexity includes:
[0011] For each pixel in the second image, determining a grayscale value difference between each pixel and surrounding pixels;
[0012] The image complexity of the second image is determined according to the grayscale value differences of all pixels of the second image.
[0013] The determination of image complexity includes:
[0014] Determination of image complexity, including:
[0015] For each pixel in the second image, determining the absolute value of the difference between the grayscale value of the pixel and the grayscale value of the pixel in eight grids surrounding the pixel;
[0016] The absolute values of the differences corresponding to the pixels are summed, and the image complexity of the second image is determined based on the summation result and the number of pixels in the second image; the image complexity is obtained according to the ratio of the summation result to the number of pixels in the second image.
[0017] The determination of image complexity includes:
[0018] For each pixel in the second image, determining the grayscale gradient difference between the horizontal direction and the vertical direction of the pixel;
[0019] The grayscale gradient difference of each pixel in the second image is summed to obtain the image complexity of the second image.
[0020] The determination of image complexity includes:
[0021] For each pixel in the second image, determining the grayscale gradient difference between the horizontal direction and the vertical direction of the pixel;
[0022] The grayscale gradient difference of each pixel in the second image is summed to obtain the image complexity of the second image.
[0023] Before determining at least two second images based on the first image, the method further includes:
[0024] Performing region division on the first image to generate at least two first sub-images;
[0025] Accordingly, determining at least two second images based on the first image includes:
[0026] According to the first sub-image, the first sub-image is segmented to generate at least two second images; wherein each second image corresponds to only one first sub-image region;
[0027] Accordingly, determining at least one third image according to each second image includes:
[0028] For each first sub-image, at least one third image is selected from each second image corresponding to the first sub-image according to the image complexity of each second image.
[0029] Determining at least one third image based on each second image includes:
[0030] Performing region division on the first image to generate at least two first sub-images;
[0031] For each second image, determining a first sub-image corresponding to the second image;
[0032] For each first sub-image, at least one third image is selected from each second image corresponding to the first sub-image according to the image complexity of each second image.
[0033] The step of determining at least two second images based on the first image includes:
[0034] Taking any corner point of the first image as a starting corner point, the first image is divided into equal-sized parts to generate at least two second images.
[0035] The step of determining at least two second images based on the first image includes:
[0036] Taking any corner point of the first image as a starting corner point, the first image is divided into equal-size segments to generate at least one fifth image;
[0037] If the remaining area of the first image cannot be divided into equal sizes, then the first image is divided into equal sizes starting from other corner points of the starting corner point of the first image until the remaining area is divided into images, and then at least one sixth image is generated, and the fifth image and the sixth image have the same size;
[0038] At least two second images are obtained according to each fifth image and each sixth image.
[0039] Before determining at least two second images based on the first image, the method further includes:
[0040] Determine at least one preset sub-image, where the preset sub-image is a sub-image pre-divided from the first image;
[0041] determining an image complexity of a predetermined sub-image;
[0042] If the image complexity of the preset sub-image is greater than the complexity of the first preset image, the preset sub-image is used as the fourth image to replace the first image for image matching.
[0043] According to another aspect of the present invention, there is provided an image template generating device, the device comprising:
[0044] A first image determination module is used to determine a first image; the first image is a template image in the image matching process;
[0045] A second image determination module is used to determine at least two second images based on the first image; the second images are obtained by performing image segmentation on the first image;
[0046] a third image determination module, configured to determine at least one third image based on each second image, wherein the image complexity of the third image is greater than the first preset image complexity; the image complexity is used to describe the richness of information contained in the image;
[0047] The fourth image determination module is used to generate a fourth image corresponding to the first image based on each third image; the fourth image is used to replace the first image for image matching.
[0048] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0049] at least one processor; and
[0050] a memory communicatively connected to at least one processor; wherein,
[0051] The memory stores a computer program that can be executed by at least one processor. The computer program is executed by the at least one processor so that the at least one processor can execute the image template generation method according to any embodiment of the present invention.
[0052] According to another aspect of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores computer instructions, which are used to enable a processor to implement the image template generation method of any embodiment of the present invention when executed.
[0053] The technical solution of the embodiment of the present invention is to determine a first image; determine at least two second images based on the first image; determine at least one third image based on each second image, and the image complexity of the third image is greater than the first preset image complexity; finally, generate a fourth image corresponding to the first image based on each third image, so that the generated fourth image contains the area with higher image complexity in the first image, and the data volume of the fourth image is smaller than the data volume of the first image. At this time, when using the fourth image as a template image for image matching, it is possible to ensure the accuracy of image matching while improving the image matching efficiency.
[0054] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0056] Figure 1 This is a flowchart of a method for generating an image template according to the first embodiment of the present invention;
[0057] Figure 2 is a schematic diagram of segmentation of a second image applicable to the embodiment of the present invention;
[0058] Figure 3 is a flowchart of another image template generation method provided in accordance with the second embodiment of the present invention;
[0059] Figure 4 Schematic diagram of the division of image areas applicable to the embodiment of the present invention;
[0060] Figure 5 is a schematic diagram of another image region division applicable to an embodiment of the present invention;
[0061] Figure 6 This is a flowchart of another method for generating an image template according to the third embodiment of the present invention;
[0062] Figure 7 is a schematic diagram of rectangular area generation applicable to an embodiment of the present invention;
[0063] Figure 8 Schematic diagram of the division of regional screening areas applicable to the embodiment of the present invention;
[0064] Figure 9 This is a structural diagram of an image template generating device provided according to a third embodiment of the present invention;
[0065] Figure 10 It is a structural diagram of an electronic device for implementing the image template generation method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0066] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0067] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0068] Example 1
[0069] Figure 1 A flowchart of an image template generation method is provided for the first embodiment of the present invention. This embodiment is applicable to the case where a replacement image of a template image is generated before image matching. The method can be executed by an image template generation device, which can be implemented in the form of hardware and / or software. The image template generation device can be configured in an electronic device with data processing capabilities. Figure 1 As shown, the method includes:
[0070] S110: Determine a first image, where the first image is a template image in an image matching process.
[0071] The first image serves as a reference standard in image matching. The matching process involves finding the same image region as the first image within a single image, or finding the same image region or image region as the first image across multiple images. The first image can be at least one of the following: a grayscale template image, a color template image, a feature template image, or a binary template image. For example, the first image can be a wafer image used in wafer inspection or a standard workpiece image used in production. The template image can be in the following shapes: polygonal or circular.
[0072] Image matching is used to find similarities between one or more images and a template image. Image matching compares the image features of the two images to find similarities. Image features include at least one of the following: grayscale value, color, texture, and shape. The first image in the image matching process is the template image.
[0073] S120: Determine at least two second images based on the first image.
[0074] The second image is obtained by performing image segmentation on the first image.
[0075] Image segmentation is a method of dividing a first image into two parts according to a preset segmentation method to generate at least two second images. The preset segmentation method can be a combination of one or more of the following: threshold-based segmentation, region-based segmentation, edge-based segmentation, clustering-based segmentation, etc. The image segmentation operation can be performed on the same device as the image template generation method or on a different device. The shape of the second image can be any of the following: polygonal or circular.
[0076] For example, if the first image includes two regions, red and yellow, the red and yellow regions can be separated to obtain a second image. Alternatively, the red and a portion of the yellow region can be divided into one second image, and the remaining region can be divided into another second image.
[0077] Optionally, determining at least two second images based on the first image includes:
[0078] Taking the upper left corner of the first image as a starting point, the first image is divided into equal-sized parts to generate at least two second images.
[0079] The equal-size segmentation means that when the first image is segmented to generate at least two second images, the image sizes of the second images are the same. The image size can be at least one of the following: number of pixels, resolution.
[0080] During the image segmentation process, arbitrary image division methods may result in different sizes of segmented images, which makes it difficult to determine the complexity of each image after image segmentation.
[0081] Therefore, when dividing the image, the first image is divided into equal-sized segments starting from the upper left corner of the first image. Since the first images may not be divided into equal-sized segments due to different sizes, the first image is divided into equal-sized segments starting from the upper left corner of the first image to obtain at least two second images and a remaining image. The remaining image is used as the second image, ultimately obtaining at least three second images.
[0082] When the first image is divided into equal sizes, the division starting point may also be one of the following: the lower left corner, the upper right corner, and the lower right corner.
[0083] Optionally, determining at least two second images based on the first image includes:
[0084] Taking the upper left corner of the first image as a starting point, the first image is divided into equal-sized segments to generate at least one fifth image;
[0085] If the first image can be divided into a plurality of fifth images of equal size and there is no remaining area, no further image segmentation is performed; if the remaining area of the first image cannot be divided into equal sizes, the image segmentation size is reset based on the size of the remaining area of the first image, with the lower left corner and / or lower right corner of the first image as the starting point, and then the remaining area of the first image is divided into equal sizes using the reset image segmentation size until the remaining area is divided, thereby generating at least one sixth image;
[0086] At least two second images are obtained according to each fifth image and each sixth image.
[0087] Optionally, at least two second images are determined based on the first image. In addition to the above image segmentation, the following image segmentation method is also included: starting from the upper left corner of the first image, the first image is divided into equal sizes to generate at least one fifth image and the remaining images; starting from the lower left corner and / or lower right corner of the first image, the first image is divided into equal sizes according to the size of the fifth image, and the process stops after the remaining images are divided to generate at least one sixth image; wherein the fifth image and the sixth image have the same size, and at least one fifth image and at least one sixth image are used as second images.
[0088] The reason for selecting the lower left corner and / or lower right corner as the starting point is that segmentation is performed from the upper left corner during the segmentation process. In the actual segmentation process, the starting point can be adjusted according to actual conditions.
[0089] For example, see Figure 2 The starting and ending column coordinates of the last candidate column are: col1 = col2 – cSize col2 = the total image width; the starting and ending row coordinates of the last candidate row are: row1 = row2 – cSize, row2 = the total image height, where cSize = the partition size. In the figure, this is 512. In this case, the last row of images overlaps with the second-to-last row of images, and the last column of images overlaps with the second-to-last column of images. The partition size is determined by 512. This is to accommodate the 1024 computer rule, and 521*512 is more convenient for storage. The sub-images in the last row and column are also partitioned into 512*512, rather than the remaining area, for storage convenience. Furthermore, images of the same size generally have the same amount of image information, such as the same number of pixels, which facilitates the calculation and determination of image complexity.
[0090] Optionally, in addition to the above segmentation methods, when the remaining image is segmented, the image can also be segmented using two corner points as starting points, including using the lower left corner as the starting point for horizontal image segmentation and using the lower right corner as the starting point for vertical image segmentation;
[0091] Take the lower left corner as the starting point for horizontal image segmentation; take the upper right corner as the starting point for vertical image segmentation;
[0092] The lower right corner is used as the starting point for horizontal image segmentation, and the upper right corner is used as the starting point for vertical image segmentation.
[0093] S130. Determine at least one third image based on each second image, where the image complexity of the third image is greater than the first preset image complexity; the image complexity is used to describe the richness of information contained in the image.
[0094] The third image may be a second image having an image complexity greater than a first preset image complexity among the second images. The first preset image complexity may be a predetermined minimum image complexity of the third image. Image complexity is used to describe the richness of information contained in an image. Image complexity refers to the expression of multiple or single factors such as the number, size, shape, and color contained in the third image, which expresses the richness of details, information content, and the difficulty of understanding and processing the image in the third image. Image complexity may be at least one of the following: spatial complexity, grayscale complexity, color complexity, texture complexity, and structural complexity.
[0095] Specifically, determining the image complexity of each second image includes comparing the image complexity of each second image with a first preset image complexity, and taking a second image whose image complexity is greater than the first preset image complexity as the third image.
[0096] In an optional solution, determining at least one third image based on each second image includes steps A1-A3:
[0097] Step A1: determining the image complexity of each second image;
[0098] Step A2: sort the second images in descending order of image complexity to obtain a sorting result;
[0099] Step A3: Determine at least one third image according to the sorting result.
[0100] When determining the third image, to ensure that the determined third image has a sufficiently high image complexity, it is necessary to first determine the image complexity of each second image. The second images are then sorted according to their image complexity to generate a sorting result. A third image having an image complexity greater than a first predetermined image complexity is then selected from the sorting result.
[0101] The reason for constructing the ranking is that in some cases, there may be a large number of second images with a greater complexity than the first preset image complexity. Depending on the actual situation, only a small number of third images may be needed. Therefore, the ranking is generated first, and then the selection is made based on the ranking results and the actual situation.
[0102] In an optional solution, determining at least one third image according to the sorting result includes steps B1-B3:
[0103] Step B1, determining image matching efficiency;
[0104] Step B2: If the image matching efficiency is lower than the preset efficiency, determine a second image among the second images that satisfies a first condition as the third image; the first condition being that the image complexity is greater than a first preset image complexity and the image complexity is less than a second preset image complexity; wherein the first preset image complexity is less than the second preset image complexity;
[0105] Step B3: If the image matching efficiency is greater than the preset efficiency, determine the second image that meets the second condition among the second images as the third image; the second condition is that the image complexity is greater than the second preset image complexity.
[0106] Image matching efficiency can be the number of image matches that can be completed per unit time by an image matching device. Image matching efficiency is affected by at least one of the following: image complexity, image resolution, and image noise level.
[0107] In the actual application of image matching, different devices can achieve different image matching efficiencies during image matching. When the image matching efficiency is high, that is, the image matching efficiency is greater than the preset efficiency, the selection of the third image can be further improved, that is, the second image with an image complexity greater than the second preset image complexity is determined as the third image, thereby further improving the accuracy of image matching.
[0108] In the case of low image matching efficiency, that is, the image matching efficiency is less than the preset efficiency, the selection of the third image can be reduced again, that is, the second image whose image complexity is greater than the first preset image complexity and less than the second preset image complexity is determined as the third image, so as to avoid excessive operating pressure on the device.
[0109] In an optional solution, determining at least one third image based on each second image may include steps C1-C3:
[0110] Step C1, determining the image complexity of each second image;
[0111] Step C2: for each second image, if the image complexity of the second image is less than the preset image complexity, the second image is eliminated to obtain a seventh image;
[0112] Step C3: Determine at least one third image from the seventh image.
[0113] When determining the third image, in addition to the above method, the second image that is significantly lower than the preset image complexity can be eliminated first, thereby reducing the amount of sorting data in the subsequent sorting process and improving sorting efficiency, and then determining at least one third image from the seventh image.
[0114] In an optional solution, determining at least one third image from the seventh image includes steps D1-D3:
[0115] Step D1, determining image matching efficiency;
[0116] Step D2: If the image matching efficiency is lower than the preset efficiency, determine, among the seventh images, the seventh image that satisfies the first condition as the third image; the first condition being that the image complexity is greater than the first preset image complexity and the image complexity is less than the second preset image complexity; wherein the first preset image complexity is less than the second preset image complexity;
[0117] Step D3: If the image matching efficiency is greater than the preset efficiency, determine the seventh image that meets the second condition as the third image in the seventh image; the second condition is that the image complexity is greater than the second preset image complexity.
[0118] S140 . Generate a fourth image corresponding to the first image based on each third image; the fourth image is used to replace the first image for image matching.
[0119] The fourth image may be used instead of the first image for image matching when image matching is subsequently performed on the first image. The data size of the fourth image is smaller than that of the first image.
[0120] The third images are stitched together to generate a fourth image, and during the stitching process, positions of the third images in the first image are determined.
[0121] The image position is the relative position of the third image within the first image. The image position can be represented by at least one of the following: coordinates, a two-dimensional index, or a mask image. When using the fourth image instead of the first image for image matching, a subimage of the image to be matched is obtained based on the image position, and a fourth image to be matched is generated based on the subimage. Based on the matching result between the fourth image to be matched and the fourth image, it is determined whether the image to be matched is the first image. The image to be matched can be the image to be image matched. The resolution of the image to be matched is the same as that of the first image. The fourth image to be matched can be cropped and spliced from the image to be matched based on the image position.
[0122] Since the third image is an image of the second image with a greater complexity than the first preset image, and the second image is generated by segmenting the first image, the third image is clearly an image of the area of the first image with higher complexity. Therefore, by using the third image to generate a fourth image corresponding to the first image, and subsequently replacing the first image with the fourth image for image matching, the accuracy of the image matching process can be guaranteed. In addition, since the fourth image is only an image composed of a portion of the first image, the data volume of the fourth image is smaller than that of the first image, thereby improving matching efficiency and reducing equipment operating costs and pressure.
[0123] According to the technical solution of the embodiment of the present invention, a first image is determined; based on the first image, at least two second images are determined; based on each second image, at least one third image is determined, and finally, based on each third image, a fourth image corresponding to the first image is generated. This allows the generated fourth image to contain areas with higher image complexity in the first image, while the amount of data in the fourth image is smaller than that in the first image. At this time, when the fourth image is used as a template image for image matching, the accuracy of image matching can be guaranteed while improving the efficiency of image matching. This application improves matching efficiency, reduces equipment operating costs and operating pressure, takes into account matching speed, avoids the situation of storing large amounts of data, avoids the situation of manually selecting areas when a large number of templates are used, and avoids the situation of inappropriate area selection.
[0124] Example 2
[0125] Figure 3 The present invention provides a flowchart of another method for generating an image template. This embodiment further optimizes the process of determining at least two second images before determining the first image and based on the first image in the above embodiment. This embodiment can be combined with various optional solutions in one or more of the above embodiments. Figure 3 As shown, the image template generation method of this embodiment may include the following steps:
[0126] S210 , determining a first image; the first image is a template image in the image matching process.
[0127] S220: Divide the first image into regions to generate at least two first sub-images.
[0128] The first sub-images can be regions formed by dividing the first image into equal proportions, or regions formed by dividing the first image into regions based on bit positions. The regions of the first sub-images can be the same or different in size. The region size can be at least one of the following: number of pixels or resolution. The shape of the image region can be any of the following: polygonal or circular.
[0129] See also Figure 4 , the first image is divided into regions according to positions, thereby dividing into multiple regions, that is, dividing into at least two first sub-images, such as five first sub-images in the figure.
[0130] When determining the third image in the second image, in order to further improve the accuracy of the matching result.
[0131] S230 . Perform image segmentation on the first sub-image according to the first sub-image to generate at least two second images.
[0132] Each second image corresponds to only one sub-image area.
[0133] Optionally, performing image segmentation on the first sub-image to generate at least two second images includes:
[0134] Taking the upper left corner of the first sub-image as a starting point, the first sub-image is divided into equal-sized parts to generate at least two second images.
[0135] The equal-size segmentation means that when the first sub-image is segmented to generate at least two second images, the image sizes of the second images are the same. The image size can be at least one of the following: number of pixels, resolution.
[0136] During the image segmentation process, arbitrary image division methods may result in different sizes of segmented images, which makes it difficult to determine the complexity of each image after image segmentation.
[0137] Therefore, when dividing the image, the first sub-image is divided into equal-sized segments starting from the upper left corner of the first sub-image. Since the first sub-images may not be divided into equal-sized segments due to their different sizes, the first sub-image is divided into equal-sized segments starting from the upper left corner of the first sub-image to obtain at least two second images and a remaining image. The remaining image is used as the second image, ultimately obtaining at least three second images.
[0138] When the first sub-image is divided into equal sizes, the division starting point may also be one of the following: the lower left corner, the upper right corner, and the lower right corner.
[0139] Optionally, determining at least two second images based on the first sub-image includes:
[0140] Taking the upper left corner of the first sub-image as a starting point, the first sub-image is divided into equal-size segments to generate at least one fifth image;
[0141] If the first sub-image can be divided into a number of fifth images of equal size and there is no remaining area, no further image segmentation is performed; if the remaining area of the first sub-image cannot be divided into equal sizes, the image segmentation size is reset based on the size of the remaining area of the first sub-image, with the lower left corner and / or lower right corner of the first sub-image as the starting point, and the remaining area of the first sub-image is then divided into equal sizes using the reset image segmentation size until the remaining area is divided into images, thereby generating at least one sixth image;
[0142] At least two second images are obtained according to each fifth image and each sixth image.
[0143] For example, see Figure 5 , Figure 5 The first image is divided into five first sub-images. The first sub-image in the lower left corner is segmented to generate multiple second images. The image segmentation is performed horizontally from bottom to top, starting at the lower right corner of the first sub-image, to generate multiple fifth images. The remaining images are segmented starting at the upper left corner to generate multiple sixth images of different sizes from the fifth images.
[0144] Optionally, at least two second images are determined based on the first sub-image. In addition to the above image segmentation, the following image segmentation method is also included: starting from the upper left corner of the first sub-image, the first sub-image is divided into equal sizes to generate at least one fifth image and the remaining images; starting from the lower left corner and / or lower right corner of the first sub-image, the first sub-image is divided into equal sizes according to the size of the fifth image, and the process stops after the remaining images are divided to generate at least one sixth image; and at least one fifth image and at least one sixth image are used as second images.
[0145] The reason for selecting the lower left corner and / or lower right corner as the starting point is that segmentation is performed from the upper left corner during the segmentation process. In the actual segmentation process, the starting point can be adjusted according to actual conditions.
[0146] Exemplarily, the first sub-image is executed as follows Figure 2 The image shown is segmented to form a second image. The difference is that the image segmentation object here is the first sub-image instead of the first image.
[0147] S240 . For each first sub-image, select at least one third image from each second image corresponding to the first sub-image according to the image complexity of each second image.
[0148] To further improve the quality of the fourth image generation and thus improve the accuracy of subsequent matching, and to ensure that the third images are as non-adjacent as possible, the third images can be selected from different image regions, ie, from each first sub-image.
[0149] Determining the third image in different image regions can prevent the third images from all coming from the same region in the first image, thereby avoiding the problem of subsequent image mismatching.
[0150] Optionally, determination of image complexity, including:
[0151] For each pixel in the second image, determining a grayscale value difference between each pixel and surrounding pixels;
[0152] The image complexity of the second image is determined according to the grayscale value differences of all pixels of the second image.
[0153] Since image complexity essentially reflects the richness and change pattern of information in the image, and the grayscale value represents the brightness of the pixel, the grayscale value difference between a pixel and its surrounding pixels can directly reflect the richness and change of the area where the pixel and its surrounding pixels are located. Therefore, when calculating image complexity, the grayscale value difference between each pixel in the second image and its surrounding pixels is calculated, and the image complexity of the second image is determined according to the size of the grayscale value difference.
[0154] More specifically, the determination of image complexity includes:
[0155] For each pixel in the second image, determining the absolute value of the difference between the grayscale value of the pixel and the grayscale value of the pixel in eight grids surrounding the pixel;
[0156] The absolute values of the differences corresponding to the pixels are summed to obtain the image complexity of the second image.
[0157] Optionally, determination of image complexity, including:
[0158] For each pixel in the second image, determining the absolute value of the difference between the grayscale value of the pixel and the grayscale value of the pixel in eight grids surrounding the pixel;
[0159] The absolute values of the differences corresponding to the pixels are summed, and the image complexity of the second image is determined based on the summation result and the number of pixels in the second image; the image complexity is obtained according to the ratio of the summation result to the number of pixels in the second image.
[0160] Since some second images may have different numbers of pixels when they are divided and generated, the summation result directly obtained by summing the absolute values may not represent the true image complexity of the second image. Therefore, the image complexity is determined by calculating the ratio of the summation result and the number of pixels of the second image. This can determine the more realistic image complexity of the second image when the second image has different numbers of pixels.
[0161] Optionally, the image complexity is determined by using the Tenegrad evaluation function to improve computational efficiency and accuracy of the calculation results. In the prior art, the Tenegrad evaluation function is often used to evaluate image clarity. This includes:
[0162] For each pixel in the second image, determining the grayscale gradient difference between the horizontal direction and the vertical direction of the pixel;
[0163] The grayscale gradient difference of each pixel in the second image is summed to obtain the image complexity of the second image.
[0164] Specifically, the evaluation function calculates the grayscale gradient difference S(i, j) in the horizontal and vertical directions of the pixel based on the pixel, then adds the grayscale value gradient differences of all pixels in the sub-image, and performs the exponential method to obtain f(I), and then compares f(I). The larger f(I), the more complex the image.
[0165] The calculation of the grayscale gradient difference f(I) can be obtained by the following formula:
[0166]
[0167] Among them, S(i,j)>T.
[0168] Where T is the evaluation function threshold, which is set according to the actual situation. When S(i,j)<T, the evaluation function is not used.
[0169] In addition, the calculation of the gray gradient difference f(I) can also be obtained by the following formula:
[0170]
[0171] Among them, S(i,j)>T.
[0172] Where T is the evaluation function threshold, which is set according to the actual situation. When S(i,j)<T, the evaluation function is not used.
[0173] In addition, the calculation of the gray gradient difference f(I) can also be obtained by the following formula:
[0174]
[0175] Among them, S(i,j)>T.
[0176] Wherein T is the evaluation function threshold, which is set according to the actual situation. When S(i, j) < T, the evaluation function is not used, and n is the number of pixels in the second image.
[0177] in,
[0178] in,
[0179] in,
[0180] The Si and Sj matrices are set up to assign values based on the distance to the target pixel. The closer the distance, the larger the assigned value. Larger values amplify the difference between the target pixel and surrounding pixels, while minimizing the difference between the target pixel and distant pixels, making the final calculated grayscale gradient difference more accurate.
[0181] A is a third-order matrix of the absolute value of the difference between the grayscale value of the target pixel and the grayscale values of the eight pixels around the target pixel. For example:
[0182] The grayscale values of the target pixel and the eight surrounding pixels are:
[0183]
[0184] but
[0185] S250 . Generate a fourth image corresponding to the first image based on each third image; the fourth image is used to replace the first image for image matching.
[0186] According to the technical solution of an embodiment of the present invention, at least two second images are generated by performing image segmentation on the first sub-image based on the first sub-image; for each first sub-image, at least one third image is screened out from the second images corresponding to the first sub-image based on the image complexity of the second images, so as to avoid the third images all coming from the same area in the first image, thereby avoiding the problem of subsequent image mismatching.
[0187] Example 3
[0188] Figure 6 The present invention provides a flowchart of another method for generating an image template. This embodiment further optimizes the process after determining at least two second images based on the first image in the above embodiment. This embodiment can be combined with various optional solutions in one or more of the above embodiments. Figure 6As shown, the image template generation method of this embodiment may include the following steps:
[0189] S310: Determine a first image; the first image is a template image in the image matching process.
[0190] S320: Determine at least two second images based on the first image; the second images are obtained by performing image segmentation on the first image.
[0191] S330: Divide the first image into regions to generate at least two first sub-images.
[0192] S340: For each second image, determine a first sub-image corresponding to the second image.
[0193] After dividing the area, for matching the second image with the corresponding first sub-image, the image area corresponding to the second image can be determined based on the image area corresponding to the pixel at the center of the second image. That is, the image area where the pixel at the center of the second image is located is the first sub-image corresponding to the second image.
[0194] Optionally, after dividing the area, for matching the second image with the corresponding first sub-image, the image area corresponding to the second image can be determined based on the image area corresponding to the pixels at the corner points of the second image. For example, the image area where the pixels in the upper left corner of the second image are located is the image area corresponding to the second image.
[0195] By first determining the second image, then dividing the first image into regions to generate at least two image regions, and then determining the image region corresponding to each second image, the occurrence of residual regions can be effectively reduced, thereby reducing the number of second images.
[0196] For details, see Figure 2 and Figure 5 , Figure 5 In the example, each first sub-image will have a residual area. When each residual area is segmented, if the middle area can be completely segmented and there is no residual area, the four sub-images around it will generate 6 new second images, that is, Figure 5 The second image adjacent to the middle first sub-image in the image, so that the four first sub-images adjacent to the middle first sub-image will have a total of 24 images, and Figure 2 First, the second image is divided, and then the number of the second images in the remaining area of the first sub-image is determined. Figure 2 The number of second images at the bottom and rightmost of the first image is only 17. Therefore, segmenting the second image first and then dividing the first sub-region can reduce the number of second images. This reduces the number of images required to calculate image complexity, speeds up image complexity calculation, accelerates the generation of the third image, and thus speeds up image template generation.
[0197] S350 : For each first sub-image, select at least one third image from each second image corresponding to the first sub-image according to the image complexity of each second image.
[0198] S360: Generate a fourth image corresponding to the first image based on each third image; the fourth image is used to replace the first image for image matching.
[0199] According to the technical solution of the embodiments of the present invention, the first image is divided into regions to generate at least two image regions. For each second image, the corresponding image region of the second image is determined, that is, which first sub-image the second image is located in. This sequential method effectively reduces the occurrence of excess regions and the number of second images. This, in turn, saves image storage space, improves the efficiency of determining the third image, and speeds up template generation.
[0200] Example 4
[0201] An embodiment of the present invention provides a method for generating an image template for practical application in a wafer inspection process, which may include the following steps:
[0202] Assume that the image size of the first image is (width, height), and the coordinates of the center pixel are (cenRow, cenCol).
[0203] Generate rectangular areas of size 512*512 at the following pixel coordinates in the image, such as Figure 7 shown.
[0204] Coordinate 1: (cenRow, cenCol),
[0205] Coordinate 2: (cenRow-height / 4,cenCol-width / 4),
[0206] Coordinate 3: (cenRow-height / 4,cenCol+width / 4),
[0207] Coordinate 4: (cenRow+height / 4,cenCol-width / 4),
[0208] Coordinate 5: (cenRow+height / 4,cenCol+width / 4),
[0209] The above five areas are five preset sub-images, which are located in the center, upper left, upper right, lower left and lower right of the Golden image respectively; while representing the image texture features to the greatest extent, the area size of template creation is reduced, thereby reducing the time consumption of template creation and subsequent image matching.
[0210] If the image complexity of the preset sub-image is greater than the complexity of the first preset image, it indicates that the preset sub-images have more features / textures / edges and the image complexity is higher. At this time, the preset sub-image can be directly used as the fourth image to represent the first image for matching, thereby saving the time required to regenerate the fourth image.
[0211] If the image complexity of the selected preset sub-image is less than or equal to the complexity of the first preset image, the template is invalid. This invalid template usually indicates that the preset area has few features, textures, or edges. In this case, the image is divided into 512*512 equal-sized rectangular areas starting from the upper left corner of the image to generate a second image. All second images are template candidate areas.
[0212] If the image width and height are not divisible by 512, that is, the last column or row of candidate regions cannot meet the 512*512 size, the region position is adjusted. The starting and ending column coordinates of the last column candidate region are: col1: = col2 – cSize col2: = width – 1; the starting and ending row coordinates of the last row candidate region are: row2: = Height - 1 row1: = row2 – cSize, where cSize = 512.
[0213] The texture complexity of the candidate region is obtained based on the Tenegrad evaluation function.
[0214] The Tenegrad function first estimates the horizontal and vertical gradient values of the image based on the Sobel operator and amplifies the edge gradient of the image using a square operation. The evaluation function f(I) is defined as the sum of the squares of the gradients. A threshold T is introduced to adjust the sensitivity of the evaluation function. The calculation of the grayscale gradient difference f(I) can be obtained by the following formula:
[0215]
[0216] Among them, S(i,j)>T.
[0217] Where T is the evaluation function threshold, which is set according to the actual situation. When S(i,j)<T, the evaluation function is not used.
[0218] In addition, the calculation of the gray gradient difference f(I) can also be obtained by the following formula:
[0219]
[0220] Among them, S(i,j)>T.
[0221] Where T is the evaluation function threshold, which is set according to the actual situation. When S(i,j)<T, the evaluation function is not used.
[0222] In addition, the calculation of the gray gradient difference f(I) can also be obtained by the following formula:
[0223]
[0224] Among them, S(i,j)>T.
[0225] Wherein T is the evaluation function threshold, which is set according to the actual situation. When S(i, j) < T, the evaluation function is not used, and n is the number of pixels in the second image.
[0226] in,
[0227] in,
[0228] in,
[0229] The image is divided into five sections with equal areas. These five sections are the first sub-images, such as Figure 4 shown.
[0230] The position coordinates of area A are (cenRow-height / varNum / 2,cenCol-width / varNum / 2,height / varNum,width / varNum);
[0231] Where varNum:=sqrt(5).
[0232] Region B is the upper left part of the image, with position coordinates of (0, 0, height / 2, width / 2), and takes the difference set with region A; region C is the upper right part of the image, with position coordinates of (0, width / 2, height / 2, width / 2), and takes the difference set with region A; region D is the lower left part of the image, with position coordinates of (height / 2, 0, height / 2, width / 2), and takes the difference set with region A; region E is the lower right part of the image, with position coordinates of (height / 2, width / 2, height / 2, width / 2), and takes the difference set with region A.
[0233] like Figure 8, the five first sub-images A, B, C, D, and E all yield a 512*512 filtered region with the highest texture complexity. Filtered region e intersects with partitions A, D, and E, but its center point lies within partition E, so it belongs to region E. Dividing the first image into five regions (first sub-images) and filtering for regions with complex textures within each region to create a fourth image avoids the template concentration problem that arises when searching for regions with complex textures across the entire image. This process, with the five candidate regions selected in various locations within the first image, improves overall registration accuracy during template matching.
[0234] Traverse the five segmented regions A, B, C, D, and E (the first sub-image) and obtain the 512*512 candidate region with the highest complexity in each.
[0235] Take the A partition area as an example:
[0236] If the coordinates of the center point of the candidate region are within region A, then the current candidate region is determined to belong to region A;
[0237] Obtain the region with the highest texture complexity among all 512*512 candidate regions in region A. This serves as the template selection region for region A. Perform the same operation for regions B, C, D, and E. Obtain a total of five selection regions (the third image). Create the fourth image by taking the union of these five regions. Determine whether the created fourth image is valid. If the template is valid, return the template matching handle. If not, destroy the template and return a template selection failure flag. If this step returns the template selection failure flag, it indicates that the first image does not contain any texture regions; therefore, detection can proceed directly without registration.
[0238] In this embodiment, before determining at least two second images based on the first image, the method further includes: determining at least one preset sub-image, where the preset sub-image is a sub-image pre-divided from the first image; determining the image complexity of the preset sub-image; and if the image complexity of the preset sub-image is greater than the first preset image complexity, using the preset sub-image as a fourth image to replace the first image for image matching. Specifically, before generating a template, a template matching region is generated using preset coordinates. If the template matching region contains few image features, textures, or edges, the image template generation method is then executed. This method helps reduce template creation time, thereby reducing template matching time.
[0239] Example 5
[0240] Figure 9The present invention provides a structural block diagram of an image template generation device. This embodiment is applicable to the situation where a replacement image of a template image is generated before image matching. The image template generation device can be implemented in the form of hardware and / or software. The image template generation device can be configured in an electronic device with data processing capabilities. Figure 9 As shown, the image template generation device of this embodiment may include: a first image determination module 310, a second image determination module 320, a third image determination module 330 and a fourth image determination module 340. Among them:
[0241] A first image determination module 310 is configured to determine a first image; the first image is a template image in the image matching process;
[0242] The second image determination module 320 is configured to determine at least two second images based on the first image; the second images are obtained by performing image segmentation on the first image;
[0243] A third image determination module 330 is configured to determine at least one third image based on each second image, wherein the image complexity of the third image is greater than the first preset image complexity; the image complexity is used to describe the richness of information contained in the image;
[0244] The fourth image determination module 340 is configured to generate a fourth image corresponding to the first image based on each third image; the fourth image is used to replace the first image for image matching.
[0245] Based on the above embodiment, optionally, determining the image complexity includes:
[0246] For each pixel in the second image, determining a grayscale value difference between each pixel and surrounding pixels;
[0247] The image complexity of the second image is determined according to the grayscale value differences of all pixels of the second image.
[0248] More specifically, determining the image complexity includes: for each pixel in the second image, determining an absolute value of a difference between the grayscale value of the pixel and the grayscale value of eight pixels surrounding the pixel;
[0249] The absolute values of the differences corresponding to the pixels are summed to obtain the image complexity of the second image.
[0250] Based on the above embodiment, optionally, determining the image complexity includes:
[0251] For each pixel in the second image, determining the absolute value of the difference between the grayscale value of the pixel and the grayscale value of the pixel in eight grids surrounding the pixel;
[0252] The absolute values of the differences corresponding to the pixels are summed, and the image complexity of the second image is determined based on the summation result and the number of pixels in the second image; the image complexity is obtained according to the ratio of the summation result to the number of pixels in the second image.
[0253] Based on the above embodiment, optionally, determining the image complexity includes:
[0254] For each pixel in the second image, determining the grayscale gradient difference between the horizontal direction and the vertical direction of the pixel;
[0255] The grayscale gradient difference of each pixel in the second image is summed to obtain the image complexity of the second image.
[0256] On the basis of the above embodiment, optionally, before the second image determination module 320, the following steps are included:
[0257] Performing region division on the first image to generate at least two first sub-images;
[0258] Accordingly, determining at least two second images based on the first image includes:
[0259] According to the first sub-image, the first sub-image is segmented to generate at least two second images; wherein each second image corresponds to only one first sub-image region;
[0260] Accordingly, determining at least one third image according to each second image includes:
[0261] For each first sub-image, at least one third image is selected from each second image corresponding to the first sub-image according to the image complexity of each second image.
[0262] Based on the above embodiment, optionally, the third image determination module 330 includes:
[0263] Performing region division on the first image to generate at least two first sub-images;
[0264] For each second image, determining a first sub-image corresponding to the second image;
[0265] For each first sub-image, at least one third image is selected from each second image corresponding to the first sub-image according to the image complexity of each second image.
[0266] Based on the above embodiment, optionally, the second image determination module 320 includes:
[0267] Taking any corner point of the first image as a starting corner point, the first image is divided into equal-sized parts to generate at least two second images.
[0268] Based on the above embodiment, optionally, the second image determination module 320 includes:
[0269] Taking any corner point of the first image as a starting corner point, the first image is divided into equal-size segments to generate at least one fifth image;
[0270] If the remaining area of the first image cannot be divided into equal sizes, then using other corner points of the starting corner point of the first image as starting points, the first image is divided into equal sizes until the remaining area is divided into images, and then stopping to generate at least one sixth image, wherein the fifth image and the sixth image have the same size;
[0271] At least two second images are obtained according to each fifth image and each sixth image.
[0272] Based on the above embodiment, optionally, before the second image determination module 320, the following further comprises:
[0273] Determine at least one preset sub-image, where the preset sub-image is a sub-image pre-divided from the first image;
[0274] determining an image complexity of a predetermined sub-image;
[0275] If the image complexity of the preset sub-image is greater than the complexity of the first preset image, the preset sub-image is used as the fourth image to replace the first image for image matching.
[0276] The image template generation device provided in the embodiment of the present invention can execute the image template generation method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0277] Example 6
[0278] Figure 10 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.
[0279] like Figure 10As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., which is communicatively connected to the at least one processor 11. The memory stores a computer program that can be executed by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. Various programs and data required for the operation of the electronic device 10 can also be stored in the RAM 13. The processor 11, ROM 12, and RAM 13 are connected to each other via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0280] Multiple components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0281] The processor 11 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the image template generation method.
[0282] In some embodiments, the image template generation method can be implemented as a computer program that is tangibly contained in a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the image template generation method described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to perform the image template generation method in any other appropriate manner (e.g., by means of firmware).
[0283] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0284] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0285] In the context of the present invention, computer-readable storage media can be tangible media that can contain or store a computer program for use with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Computer-readable storage media can include but are not limited to electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, computer-readable storage media can be machine-readable signal media. More specific examples of machine-readable storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0286] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0287] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0288] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.
[0289] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.
[0290] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.
Claims
1. A method for generating an image template, characterized in that: include: determining a first image; The first image is a template image in the image matching process; determining at least two second images based on the first image; The second image is obtained by performing image segmentation on the first image; Determining at least one third image based on each second image, wherein the image complexity of the third image is greater than the first preset image complexity; the image complexity is used to describe the richness of information contained in the image; A fourth image corresponding to the first image is generated based on each third image; the fourth image is used to replace the first image for image matching.
2. The method according to claim 1, characterized in that The determination of the image complexity includes: For each pixel in the second image, determining a grayscale value difference between each pixel and surrounding pixels; The image complexity of the second image is determined according to the grayscale value differences of all pixels of the second image.
3. The method according to claim 2, characterized in that The determination of the image complexity includes: For each pixel in the second image, determining the grayscale gradient difference between the horizontal direction and the vertical direction of the pixel; The grayscale gradient difference of each pixel in the second image is summed to obtain the image complexity of the second image.
4. The method according to claim 2, characterized in that The determination of the image complexity includes: For each pixel in the second image, determining the grayscale gradient difference between the horizontal direction and the vertical direction of the pixel; Summing the grayscale gradient difference of each pixel in the second image to obtain a summation result; The image complexity of the second image is determined according to the summation result and the number of pixels of the second image; the image complexity is the ratio of the summation result to the number of pixels of the second image.
5. The method according to claim 1, wherein Before determining at least two second images according to the first image, the method further includes: performing region division on the first image to generate at least two first sub-images; Accordingly, determining at least two second images based on the first image includes: According to the first sub-image, performing image segmentation on the first sub-image to generate at least two second images; wherein each second image corresponds to only one first sub-image region; Accordingly, determining at least one third image according to each second image includes: For each first sub-image, at least one third image is selected from each second image corresponding to the first sub-image according to the image complexity of each second image.
6. The method according to claim 1, characterized in that Determining at least one third image based on each second image includes: performing region division on the first image to generate at least two first sub-images; For each second image, determining a first sub-image corresponding to the second image; For each first sub-image, at least one third image is selected from each second image corresponding to the first sub-image according to the image complexity of each second image.
7. The method according to claim 1, characterized in that Determining at least two second images according to the first image includes: Taking any corner point of the first image as a starting corner point, the first image is divided into equal-sized parts to generate at least two second images.
8. The method according to claim 7, characterized in that Determining at least two second images according to the first image includes: Taking any corner point of the first image as a starting corner point, the first image is divided into equal-size segments to generate at least one fifth image; If the remaining area of the first image cannot be divided into equal sizes, dividing the first image into equal sizes using other corner points of the starting corner point of the first image as starting points until the remaining area is divided into images, and then stopping to generate at least one sixth image, where the fifth image and the sixth image have the same size; At least two second images are obtained according to each fifth image and each sixth image.
9. The method according to claim 1, characterized in that Before determining at least two second images according to the first image, the method further includes: determining at least one preset sub-image, where the preset sub-image is a sub-image pre-divided from the first image; determining an image complexity of a predetermined sub-image; If the image complexity of the preset sub-image is greater than the complexity of the first preset image, the preset sub-image is used as a fourth image to replace the first image for image matching.
10. An image template generating device, characterized in that: include: A first image determining module, configured to determine a first image; The first image is a template image in the image matching process; A second image determination module is configured to determine at least two second images based on the first image; the second images are obtained by performing image segmentation on the first image; a third image determination module, configured to determine, based on each second image, at least one third image, wherein the image complexity of the third image is greater than the first preset image complexity; the image complexity is used to describe the richness of information contained in the image; The fourth image determination module is used to generate a fourth image corresponding to the first image based on each third image; the fourth image is used to replace the first image for image matching.