Image alignment method, computer device and computer storage medium

By using gradient images and mask images in image alignment technology, the problem of noise data affecting image alignment success rate is solved, clearer texture feature display and higher alignment success rate are achieved, and the accuracy of grain defect detection is ensured.

CN119784624APending Publication Date: 2025-04-08SKYVERSE TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202311262992.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-27
Publication Date
2025-04-08

AI Technical Summary

Technical Problem

The existing image alignment technology has a low success rate when processing noise-containing grayscale images, which affects the accuracy of grain defect detection.

Method used

By acquiring the gradient image of the target image, determining the gradient reference value, performing grayscale value binarization processing, retaining or eliminating non-zero pixels, obtaining a mask image, and then performing grayscale value alignment.

Benefits of technology

Effectively eliminate noise data, improve the clarity of the image display of texture features, improve the success rate of image alignment, and ensure the accuracy of grain defect detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119784624A_ABST
    Figure CN119784624A_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses an image alignment method, a computer device and a computer storage medium. The embodiment of the present application includes: the computer device can determine the gradient corresponding to each pixel in the target image, obtain the gradient image corresponding to the target image, perform grayscale binarization processing on each pixel in the gradient image according to the gradient reference value, and obtain a binary image. In the binary image, for each non-zero grayscale pixel, according to the relationship between the grayscale value of the non-zero grayscale pixel and its associated pixel and the gradient reference value, the non-zero grayscale pixel is retained or the non-zero grayscale pixel is eliminated to obtain a mask image, and the mask image can be used for grayscale alignment. Therefore, the noise data in the target image can be eliminated, thereby eliminating the interference of the noise data on the display of the image texture features, making the image display of the texture features clearer and more obvious, thereby improving the success rate of image alignment and ensuring the defect detection of grains.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of image technology, and specifically to an image alignment method, a computer device, and a computer storage medium. Background Art

[0002] After the production process of semiconductor wafers is completed, the wafers need to be inspected, for example, to detect whether there are any defects (such as foreign objects, scratches, etc.) on the surface of the die on the wafer to confirm whether the product is qualified. Existing inspection technologies, for example, analyze and process the grayscale image of the die to be tested to detect the defect location. During the inspection, the reference image and the grayscale image of the die to be tested need to be aligned so as to detect the defects of the die to be tested based on the alignment results.

[0003] However, the grayscale image of the grain to be tested may contain noise data due to various reasons, or the texture features displayed by the grayscale image may not be clear or obvious, which may reduce the success rate of image alignment and further affect the defect detection of the grain to be tested. Summary of the invention

[0004] The embodiments of the present application provide an image alignment method, a computer device, and a computer storage medium for removing noise data in a target image, thereby making the image display more obvious in terms of texture features and improving the success rate of image alignment.

[0005] A first aspect of an embodiment of the present application provides an image alignment method, the method comprising:

[0006] Acquire a target image to be processed, determine the gradient corresponding to each pixel in the target image, and obtain a gradient image corresponding to the target image; the gradient reference value is determined based on the distribution of each gradient in the gradient image;

[0007] Determine a gradient reference value, and perform grayscale binarization processing on each pixel in the gradient image according to the gradient reference value to obtain a binarized image;

[0008] In the binary image, for each non-zero grayscale pixel, according to the relationship between the grayscale values ​​of the non-zero grayscale pixel and its associated pixels and the gradient reference value, the non-zero grayscale pixel is retained or eliminated to obtain a mask image;

[0009] Grayscale value alignment is performed according to the mask image.

[0010] A second aspect of an embodiment of the present application provides a computer device, including:

[0011] A determination unit, used to obtain a target image to be processed, determine a gradient corresponding to each pixel in the target image, and obtain a gradient image corresponding to the target image;

[0012] A binarization processing unit, used to determine a gradient reference value, and perform a grayscale binarization process on each pixel in the gradient image according to the gradient reference value to obtain a binarized image;

[0013] a pixel processing unit, configured to retain or remove, for each non-zero grayscale pixel in the binary image, the non-zero grayscale pixel according to a relationship between the grayscale values ​​of the non-zero grayscale pixel and its associated pixels and the gradient reference value, to obtain a mask image;

[0014] An image alignment unit is used to perform grayscale value alignment according to the mask image.

[0015] A third aspect of an embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the method of the first aspect when executing the computer program.

[0016] A fourth aspect of an embodiment of the present application provides a computer storage medium, in which instructions are stored. When the instructions are executed on a computer, the computer executes the method of the first aspect.

[0017] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:

[0018] The computer device can determine the gradient corresponding to each pixel in the target image, obtain the gradient image corresponding to the target image, perform grayscale binarization processing on each pixel in the gradient image according to the gradient reference value, and obtain the binarized image. In the binarized image, for each non-zero grayscale pixel, according to the relationship between the grayscale value of the non-zero grayscale pixel and its associated pixel and the gradient reference value, the non-zero grayscale pixel is retained or the non-zero grayscale pixel is eliminated to obtain the mask image, and the mask image can be used for grayscale alignment. Therefore, the noise data in the target image can be eliminated, thereby eliminating the interference of the noise data on the display of the image texture features, making the image display of the texture features clearer and more obvious, thereby improving the success rate of image alignment and ensuring the defect detection of grains. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 A schematic diagram of a flow chart of an image alignment method in an embodiment of the present application;

[0020] Figure 2 This is another flow chart of the image alignment method in the embodiment of the present application;

[0021] Figure 3 An exemplary schematic diagram of determining a gradient corresponding to a pixel based on a pixel of a target image in an embodiment of the present application;

[0022] Figure 4 An exemplary schematic diagram of determining a first projection value and a second projection value based on pixels of a binary image in an embodiment of the present application;

[0023] Figure 5 A schematic diagram of an exemplary effect of expanding and dilating a region composed of pixels with non-zero grayscale values ​​in an embodiment of the present application;

[0024] Figure 6 A schematic diagram of an exemplary display effect of images corresponding to each process node from the target image processing to the mask image processing of a local area of ​​a certain grain to be tested in an embodiment of the present application;

[0025] Figure 7 A schematic diagram of the structure of a computer device in an embodiment of the present application. DETAILED DESCRIPTION

[0026] The embodiments of the present application provide an image alignment method, a computer device, and a computer storage medium for removing noise data in a target image, thereby making the image display more obvious in terms of texture features and improving the success rate of image alignment.

[0027] The following describes the image alignment method in the embodiment of the present application:

[0028] See also Figure 1 In the embodiment of the present application, an image alignment method includes:

[0029] 101. Acquire a target image to be processed, determine the gradient corresponding to each pixel in the target image, and obtain a gradient image corresponding to the target image;

[0030] In this embodiment, the computer device can obtain an image of the grain to be tested, which is the target image to be processed, for identifying and removing noise data. After obtaining the target image, the gradient corresponding to each pixel in the target image is further determined, and all pixels in the target image and their corresponding gradients constitute a gradient image. The gradient corresponding to a pixel represents the rate of change of multiple pixels within a preset range centered on the pixel.

[0031] 102. Determine a gradient reference value, and perform grayscale binarization processing on each pixel in the gradient image according to the gradient reference value to obtain a binarized image;

[0032] The computer device can perform grayscale binarization processing on each pixel in the gradient image according to the gradient reference value, that is, according to the gradient reference value, the grayscale value of each pixel is either set to 0 or to 255, thereby obtaining a corresponding binary image.

[0033] Among them, the gradient reference value can be determined based on the distribution of each gradient in the gradient image, so that the gradient reference value can represent the change of the pixel grayscale value of the target image, such as representing that the pixel grayscale value difference of the target image is large, or representing that the pixel grayscale value difference of the target image is small.

[0034] 103. In the binary image, for each non-zero grayscale pixel, retain the non-zero grayscale pixel or remove the non-zero grayscale pixel according to the relationship between the grayscale values ​​of the non-zero grayscale pixel and its associated pixels and the gradient reference value, to obtain a mask image;

[0035] The computer device can further determine, for each non-zero grayscale pixel in the binary image, whether the non-zero grayscale pixel is a pixel corresponding to noise according to the relationship between the grayscale value of the non-zero grayscale pixel and its associated pixel and the gradient reference value, and if it is a pixel corresponding to noise, remove the non-zero grayscale pixel; if it is not a pixel corresponding to noise, retain the non-zero grayscale pixel. After completing the processing of all non-zero grayscale pixels in the binary image, a mask image corresponding to the binary image is obtained.

[0036] 104. Perform grayscale value alignment according to the mask image;

[0037] After noise removal is completed, grayscale alignment can be performed based on the mask image from which noise has been removed, that is, grayscale alignment can be performed between the mask image and the reference image to obtain an alignment result, and then grain defect detection can be performed based on the alignment result.

[0038] In this embodiment, the computer device can determine the gradient corresponding to each pixel in the target image, obtain the gradient image corresponding to the target image, perform grayscale binarization processing on each pixel in the gradient image according to the gradient reference value, and obtain a binarized image. In the binarized image, for each non-zero grayscale pixel, according to the relationship between the grayscale value of the non-zero grayscale pixel and its associated pixel and the gradient reference value, the non-zero grayscale pixel is retained or the non-zero grayscale pixel is eliminated to obtain a mask image, and the mask image can be used for grayscale alignment. Therefore, the noise data in the target image can be eliminated, thereby eliminating the interference of the noise data on the display of the image texture features, making the image display of the texture features clearer and more obvious, thereby improving the success rate of image alignment and ensuring the defect detection of grains.

[0039] The following will be Figure 1Based on the embodiment shown, the embodiment of the present application is further described in detail. Figure 2 Another embodiment of the image alignment method in the embodiment of the present application includes:

[0040] 201. Acquire a target image to be processed, determine a gradient corresponding to each pixel in the target image, and obtain a gradient image corresponding to the target image;

[0041] In this embodiment, a method for determining the gradient corresponding to each pixel in the target image may be to determine, for each pixel of the target image, the difference between the maximum grayscale value and the minimum grayscale value of the pixel in the intersection of a rectangle centered on the pixel and the target image, and use the difference as the gradient of the pixel to obtain a gradient image; wherein the size of the rectangle is n pixel units × m pixel units, and n and m are both odd numbers greater than 1.

[0042] For example, Figure 3 As shown, assuming that n corresponds to the row direction and its value is 7; m corresponds to the column direction and its value is 3, then for the pixel (1, 1), a rectangle with a size of 7 pixels × 3 pixels is determined with it as the center, that is, the dotted rectangular box shown in the figure. This rectangle and the target image have an intersection, and the intersection includes 8 pixels (1, 1), (1, 2), (1, 3), (1, 4), (2, 1), (2, 2), (2, 3), (2, 4). Therefore, the difference between the maximum grayscale value and the minimum grayscale value of these 8 pixels can be determined, and this difference is used as the gradient corresponding to the pixel (1, 1). Similarly, the gradients corresponding to other pixels in the target image can be determined in turn. All pixels of the target image and their corresponding gradients constitute a gradient image.

[0043] 202. Determine a gradient reference value, and perform grayscale binarization processing on each pixel in the gradient image according to the gradient reference value to obtain a binarized image;

[0044] In this embodiment, one way to determine the gradient reference value may be to determine the number of pixels to be retained based on the size of the target image, count the number of pixel distributions corresponding to each gradient in the gradient image, accumulate the number of pixel distributions corresponding to each gradient in order from large to small, stop accumulating when the accumulated value is greater than the number of pixels to be retained, and use the gradient corresponding to the last accumulated number of pixel distributions as the gradient reference value.

[0045] Among them, the number of pixels corresponding to each gradient in the gradient image is counted, that is, the number of pixels corresponding to each gradient is counted. For example, if there are 100 pixels with a gradient of 75, the number of pixels corresponding to the gradient of 75 is 100. The statistical result can be represented by a histogram, that is, the horizontal axis in the histogram is each gradient, each gradient has a corresponding column, and the column in the histogram represents the number of pixels corresponding to the gradient. The longer the column, the more pixels corresponding to the gradient; conversely, the fewer pixels corresponding to the gradient.

[0046] The number of pixels to be retained is determined according to the size of the target image. The user can preset a percentage rate, such as 1%, and then calculate the length × width × rate of the target image (the length and width can be expressed in multiple pixel units), and the obtained product can be used as the number of pixels to be retained.

[0047] After obtaining the histogram and determining the number of pixels to be retained, the number of pixel distributions corresponding to each column in the histogram can be accumulated from right to left, that is, the number of pixel distributions corresponding to each gradient can be accumulated in order from large to small. When the accumulated value is greater than the number of pixels to be retained, the accumulation is stopped, and the gradient corresponding to the last accumulated number of pixel distributions is used as the gradient reference value.

[0048] When the grayscale value of each pixel in the gradient image is binarized according to the gradient reference value, the grayscale value of the pixel in the gradient image whose gradient is less than the gradient reference value can be set to 0, and the grayscale value of the pixel in the gradient image whose gradient is greater than the gradient reference value can be set to 255 to obtain a binary image.

[0049] 203. In the binary image, for each non-zero grayscale pixel, retain the non-zero grayscale pixel or remove the non-zero grayscale pixel according to the relationship between the grayscale values ​​of the non-zero grayscale pixel and its associated pixels and the gradient reference value, to obtain a mask image;

[0050] In this embodiment, based on the relationship between the grayscale values ​​of the non-zero grayscale pixels and their associated pixels and the gradient reference value, the non-zero grayscale pixels are retained or eliminated. One implementation method may be to calculate the projection value corresponding to the non-zero grayscale pixels based on the grayscale values ​​of the non-zero grayscale pixels and their associated pixels. If the difference between the projection value and the gradient reference value is greater than or equal to a preset gradient threshold, the non-zero grayscale pixel is retained; if the difference between the projection value and the gradient reference value is less than the preset gradient threshold, the non-zero grayscale pixel is eliminated.

[0051] The preset gradient threshold value can be determined based on the change of the pixel grayscale value of the target image. For example, the difference between the preset gradient threshold value and the gradient reference value can be adjusted according to the change of the pixel grayscale value of the target image, such as setting the preset gradient threshold value = gradient reference value / adjustment parameter. The adjustment parameter can be adjusted within a certain value range according to the change of the pixel grayscale value of the target image, such as between [2, 5]. If the pixel grayscale value of the target image changes dramatically, the visual perception is that the brightness of the target image changes dramatically. At this time, the difference between the preset gradient threshold value and the gradient reference value can be reduced, and the adjustment parameter is set to 2 or other smaller values; if the size distribution of the pixel grayscale value of the target image is relatively uniform, that is, the pixel grayscale value changes slightly, and the visual perception is that the brightness of the target image changes slightly, then the difference between the preset gradient threshold value and the gradient reference value can be increased, and the adjustment parameter is set to 4 or 5 or other larger values.

[0052] Among them, the associated pixel of the non-zero grayscale value pixel may be a pixel in the same row or in the same column as the non-zero grayscale value pixel. Therefore, when calculating the projection value corresponding to the non-zero grayscale value pixel according to the grayscale value of the non-zero grayscale value pixel and its associated pixel, the first projection value corresponding to all pixels in the intersection of the first rectangle centered on the non-zero grayscale value pixel and the binary image may be calculated, and the length of the first rectangle is n pixel units and the width is 1 pixel unit, and n is an odd number greater than 1; or the second projection value corresponding to all pixels in the intersection of the second rectangle centered on the non-zero grayscale value pixel and the binary image may be calculated, and the length of the second rectangle is 1 pixel unit and the width is m pixel units, and m is an odd number greater than 1. If the difference between the first projection value and the gradient reference value is greater than or equal to the preset gradient threshold, or the difference between the second projection value and the gradient reference value is greater than or equal to the preset gradient threshold, the non-zero pixel of the grayscale value is retained; if the difference between the first projection value and the gradient reference value is less than the preset gradient threshold, and the difference between the second projection value and the gradient reference value is less than the preset gradient threshold, the non-zero pixel of the grayscale value is discarded.

[0053] like Figure 4 As shown, for a pixel with a grayscale value of 255, a first projection value corresponding to 5 pixels in the intersection of a first rectangle centered on the pixel and the binary image can be calculated, or a second projection value corresponding to 5 pixels in the intersection of a second rectangle centered on the pixel and the binary image can be calculated. The first projection value can be the average of the grayscale values ​​of the 5 pixels in the intersection of the first rectangle and the binary image, and the second projection value can be the average of the grayscale values ​​of the 5 pixels in the intersection of the second rectangle and the binary image.

[0054] Therefore, assuming that the intersection of the first rectangle and the binary image has only one pixel (i.e., the grayscale value is non-zero pixel), and the intersection of the second rectangle and the binary image also has only one pixel (i.e., the grayscale value is non-zero pixel), that is, the grayscale value non-zero pixel may be an isolated point, and the isolated point can be considered as a noise point, then the calculated first projection value or the second projection value will be very small, resulting in the difference between the first projection value and the gradient reference value being less than the preset gradient threshold, and the difference between the second projection value and the gradient reference value being less than the preset gradient threshold, and the grayscale value non-zero pixel can be eliminated at this time. Therefore, by comparing the difference between the first projection value and the gradient reference value with the preset gradient threshold, and comparing the difference between the second projection value and the gradient reference value with the preset gradient threshold, the isolated point among several grayscale value non-zero pixels of the binary image can be determined, and then the isolated point can be eliminated to eliminate the noise data.

[0055] After obtaining the mask image, the isolated points in the mask image can be further filtered. Therefore, in a preferred embodiment, after obtaining the mask image, for each non-zero grayscale pixel in the mask image, if the grayscale values ​​of the preset number of pixels in the same row centered on the non-zero grayscale pixel are all 0 and the grayscale values ​​of the preset number of pixels in the same column centered on the non-zero grayscale pixel are all 0, it is equivalent to that the non-zero grayscale pixel is surrounded by pixels with a grayscale value of 0, and only its grayscale value is non-0, which means that the non-zero grayscale pixel is very likely to be a noise point, and the non-zero grayscale pixel can be removed; if the preset number of pixels in the same row centered on the non-zero grayscale pixel has a non-zero grayscale value, or the preset number of pixels in the same column centered on the non-zero grayscale pixel has a non-zero grayscale value, it indicates that there are pixels of the same grayscale around the non-zero grayscale pixel, that is, the non-zero grayscale pixel is not an isolated point, and the non-zero grayscale pixel can be retained.

[0056] For example, a preset number of pixels in the same row centered on a pixel with a non-zero grayscale value may be 11 pixels in the same row centered on the pixel with a non-zero grayscale value, including 5 pixels to the left, 5 pixels to the right, and the non-zero grayscale value pixel itself; the grayscale value of a preset number of pixels in the same column centered on a pixel with a non-zero grayscale value may be 11 pixels in the same column centered on the pixel with a non-zero grayscale value, including 5 pixels above, 5 pixels below, and the non-zero grayscale value pixel itself.

[0057] In addition, after obtaining the mask image, for each non-zero grayscale pixel in the mask image, the grayscale values ​​of the other pixels except the non-zero grayscale pixel in the n×m pixels centered on the non-zero grayscale pixel can be set to 255, which is equivalent to expanding more non-zero grayscale pixels around the non-zero grayscale pixel, which is equivalent to expanding the non-zero grayscale pixel. Wherein, n and m are both odd numbers greater than 1.

[0058] For example, Figure 5 As shown in the figure, the image before processing is on the left side of the arrow, where the pixels in the white area are the non-zero grayscale pixels. For each non-zero grayscale pixel, the grayscale values ​​of the n×m pixels centered on the non-zero grayscale pixel except the non-zero grayscale pixel are set to 255, so that the white area is expanded and thickened, thereby covering the edge position and pixel missing position in the mask image, making the edge position in the mask image more obvious, the display of texture features more prominent, and adding more alignment information, thereby improving the accuracy and precision of image alignment.

[0059] 204. Perform grayscale value alignment according to the mask image;

[0060] After the mask image is obtained, the noise data has been eliminated from the mask image, which can prevent the noise data from interfering with the image alignment. Therefore, grayscale value alignment can be performed based on the mask image and the reference image to obtain an alignment result for defect detection of the grain to be tested.

[0061] Therefore, through the processing of the above steps, a mask image more suitable for image alignment can be obtained. Figure 6 The images corresponding to each process node from the target image processing to the mask image processing of a local area of ​​a certain grain to be tested are shown. It can be seen that the target image of the grain to be tested has been processed through the above steps, the noise data has been eliminated, the texture features in the image are displayed more clearly, and more alignment information has been added, which has improved the accuracy and success rate of image alignment and ensured the efficient detection of grain defects.

[0062] The computer device in the embodiment of the present application is described below. Figure 7 In the embodiment of the present application, one embodiment of the computer device includes:

[0063] The computer device 700 may include one or more central processing units (CPU) 701 and a memory 705 , wherein the memory 705 stores one or more application programs or data.

[0064] The memory 705 may be a volatile storage or a persistent storage. The program stored in the memory 705 may include one or more modules, each of which may include a series of instruction operations in the computer device. Furthermore, the central processing unit 701 may be configured to communicate with the memory 705 and execute a series of instruction operations in the memory 705 on the computer device 700.

[0065] The computer device 700 may also include one or more power supplies 702, one or more wired or wireless network interfaces 703, one or more input and output interfaces 704, and / or one or more operating systems, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.

[0066] The CPU 701 can execute the aforementioned Figure 1 to Figure 2 The operations performed by the computer device in the illustrated embodiment will not be described in detail here.

[0067] The present application also provides a computer storage medium, wherein one embodiment includes: the computer storage medium stores instructions, and when the instructions are executed on a computer, the computer executes the aforementioned Figure 1 to Figure 2 The operations performed by the computer device in the illustrated embodiment.

[0068] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0069] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as 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 an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0070] 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.

[0071] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0072] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk and other media that can store program code.

Claims

1. An image alignment method, characterized in that: The method comprises: Acquire a target image to be processed, determine the gradient corresponding to each pixel in the target image, and obtain a gradient image corresponding to the target image; Determine a gradient reference value, and perform grayscale binarization processing on each pixel in the gradient image according to the gradient reference value to obtain a binarized image; the gradient reference value is determined based on the distribution of each gradient in the gradient image; In the binary image, for each non-zero grayscale pixel, according to the relationship between the grayscale values ​​of the non-zero grayscale pixel and its associated pixels and the gradient reference value, the non-zero grayscale pixel is retained or eliminated to obtain a mask image; Grayscale value alignment is performed according to the mask image.

2. The method according to claim 1, characterized in that The retaining or removing the non-zero grayscale pixel according to the relationship between the grayscale value of the non-zero grayscale pixel and the grayscale value of its associated pixel and the gradient reference value comprises: Calculate the projection value corresponding to the non-zero grayscale pixel according to the grayscale value of the non-zero grayscale pixel and its associated pixels; If the difference between the projection value and the gradient reference value is greater than or equal to a preset gradient threshold, the non-zero pixel grayscale value is retained; the preset gradient threshold is determined based on the change of the pixel grayscale value of the target image; If the difference between the projection value and the gradient reference value is smaller than the preset gradient threshold, the pixels with non-zero grayscale values ​​are removed.

3. The method according to claim 2, characterized in that The calculating the projection value corresponding to the non-zero grayscale pixel according to the grayscale value of the non-zero grayscale pixel and the grayscale value of its associated pixel comprises: Calculate first projection values ​​corresponding to all pixels in the intersection of a first rectangle centered on the pixel with non-zero grayscale value and the binary image, where the length of the first rectangle is n pixel units and the width is 1 pixel unit, and n is an odd number greater than 1; or, Calculate second projection values ​​corresponding to all pixels in the intersection of a second rectangle centered on the pixel with non-zero grayscale value and the binary image, where the second rectangle has a length of 1 pixel unit and a width of m pixel units, where m is an odd number greater than 1; If the difference between the first projection value and the gradient reference value is greater than or equal to the preset gradient threshold, or the difference between the second projection value and the gradient reference value is greater than or equal to the preset gradient threshold, the non-zero pixel of the gray value is retained; If the difference between the first projection value and the gradient reference value is smaller than the preset gradient threshold, and the difference between the second projection value and the gradient reference value is smaller than the preset gradient threshold, the non-zero grayscale pixels are removed.

4. The method according to claim 1, characterized in that: Determining the gradient reference value includes: Determining the number of pixels to be retained according to the size of the target image; Counting the number of pixel distributions corresponding to each gradient in the gradient image; The number of pixel distributions corresponding to each gradient is accumulated in order from large to small, and the accumulation is stopped when the accumulated value is greater than the number of pixels to be retained, and the gradient corresponding to the last accumulated number of pixel distributions is used as the gradient reference value.

5. The method according to claim 1, characterized in that The step of performing a grayscale binarization process on each pixel in the gradient image according to the gradient reference value to obtain a binarized image comprises: The grayscale values ​​of pixels in the gradient image whose gradient is less than the gradient reference value are set to 0, and the grayscale values ​​of pixels in the gradient image whose gradient is greater than the gradient reference value are set to 255, so as to obtain the binary image.

6. The method according to claim 1, characterized in that The step of determining the gradient corresponding to each pixel in the target image to obtain a gradient image corresponding to the target image includes: For each pixel of the target image, determine the difference between the maximum grayscale value and the minimum grayscale value of the pixel in the intersection of a rectangle centered on the pixel and the target image, use the difference as the gradient of the pixel, and obtain the gradient image; wherein the size of the rectangle is n pixel units × m pixel units, and n and m are both odd numbers greater than 1.

7. The method according to claim 1, characterized in that After obtaining the mask image, the method further includes: For each non-zero grayscale pixel in the mask image, if the grayscale values ​​of a preset number of pixels in the same row centered on the non-zero grayscale pixel are all 0 and the grayscale values ​​of a preset number of pixels in the same column centered on the non-zero grayscale pixel are all 0, then the non-zero grayscale pixel is removed; If there are non-zero grayscale pixels in a preset number of pixels in the same row centered on the non-zero grayscale pixel, or if there are non-zero grayscale pixels in a preset number of pixels in the same column centered on the non-zero grayscale pixel, the non-zero grayscale pixel is retained.

8. The method according to claim 1, characterized in that After obtaining the mask image, the method further includes: For each non-zero grayscale pixel in the mask image, the grayscale values ​​of the other pixels except the non-zero grayscale pixel in n×m pixels centered on the non-zero grayscale pixel are set to 255; wherein n and m are both odd numbers greater than 1.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 8 is implemented.

10. A computer storage medium, characterized in that: The computer storage medium stores instructions, and when the instructions are executed on a computer, the computer is caused to perform the method according to any one of claims 1 to 8.

Citation Information

Cited By

  • Complex line alignment matching method, device and equipment and readable storage medium

    CN121685377A