An image processing method, a computer device and a computer readable storage medium

By filtering and binarizing the test images of the CMOS image sensor, a detail detection image is generated, and anomaly clusters are created. This solves the problem of dirt detection in the imaging process of the CMOS image sensor and enables accurate assessment of the size and number of dirt.

CN116542861BActive Publication Date: 2026-04-24SMARTSENS TECH (SHANGHAI) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SMARTSENS TECH (SHANGHAI) CO LTD
Filing Date
2022-01-26
Publication Date
2026-04-24

AI Technical Summary

Technical Problem

Existing CMOS image sensors are prone to diagonal stripe-like anomalies during imaging, and conventional dirt detection methods are difficult to effectively detect the size and number of dirt particles.

Method used

By acquiring test images, filtering and binarizing them, a detail detection image is generated. Anomaly clusters are created by traversing anomaly points, and the size and number of anomaly clusters are calculated to determine the size and number of dirt.

Benefits of technology

It enables accurate calculation and evaluation of the size and number of contaminants, facilitating image testing and processing and improving detection efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116542861B_ABST
    Figure CN116542861B_ABST
Patent Text Reader

Abstract

The application discloses an image processing method, computer equipment and a computer readable storage medium, and relates to the technical field of image processing. The image processing method comprises the following steps: acquiring a test image, wherein the test image comprises a plurality of pixels, each of which has corresponding pixel data; performing filter processing on the test image to obtain a filtered image; performing binaryzation processing on the filtered image to obtain a detail detection image in which abnormal points are arranged; traversing the detail detection image, and creating an abnormal point cluster based on the abnormal points; based on the traversal of the detail detection image and at least one abnormal point cluster obtained, calculating the size and number of the abnormal point cluster of the detail detection image, so as to determine the size and number of dirt of the test image. The application can calculate and evaluate the size and number of dirt.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to an image processing method, a computer device, and a computer-readable storage medium. Background Technology

[0002] With the rapid development of technology and the internet, digital images have become an indispensable part of people's information acquisition, leading to the wider application of image sensors. Image sensors mainly include CMOS image sensors and CCD sensors. From CP testing after wafer fabrication to FT testing after packaging, CMOS image sensors encounter anomalies such as diagonal stripes in the chip image due to process inconsistencies or uneven dark current. These anomalies cannot be controlled using conventional dead pixel detection methods.

[0003] Currently, CMOS image sensors typically use mean filtering on regions of fixed location but different sizes for contamination detection, followed by difference calculation to obtain image difference data. Because the filtered areas are fixed in location, the resulting difference data cannot accurately reflect detailed anomalies in specific locations, nor can it effectively detect the size and number of contaminants. Summary of the Invention

[0004] The purpose of this invention is to provide an image processing method, computer device, and computer-readable storage medium that can calculate and evaluate the size and number of contaminants, thereby facilitating image testing and processing.

[0005] This invention provides an image processing method, comprising: acquiring a test image, the test image including a plurality of pixels, each pixel having corresponding pixel data; filtering the test image to obtain a filtered image; binarizing the filtered image to obtain a detail detection image with anomaly points arranged thereon; traversing the detail detection image and creating anomaly point clusters based on the anomaly points; based on the traversal of the detail detection image and obtaining at least one anomaly point cluster, calculating the size and number of anomaly point clusters in the detail detection image to determine the size and number of contaminants in the test image.

[0006] The present invention also discloses a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described image processing method.

[0007] The present invention also discloses a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the above-described image processing method.

[0008] The image processing method, computer equipment, and computer-readable storage medium described above can calculate and evaluate the size and number of contaminants, facilitating image testing and processing. Attached Figure Description

[0009] Figure 1 This is a schematic diagram of an image processing method according to an embodiment of the present invention.

[0010] Figures 2(a) to 2(c) These are, respectively, a test image, a difference image, and a detail detection image according to an embodiment of the present invention.

[0011] Figure 3 This is a schematic diagram of the position of a pixel in a test image and the first region centered on that pixel, according to an embodiment of the present invention.

[0012] Figure 4 This is a schematic diagram of a column-wise fast calculation method for mean filtering according to an embodiment of the present invention.

[0013] Figure 5 This is a schematic diagram illustrating the addition of a first extended pixel according to an embodiment of the present invention.

[0014] Figure 6 This is a schematic diagram of a method for detecting outlier clusters in an image based on computational detail, according to an embodiment of the present invention.

[0015] Figure 7 This is a schematic diagram of a method for obtaining anomaly clusters according to an embodiment of the present invention.

[0016] Figures 8(a) to 8(c) for Figure 7 A detailed schematic diagram illustrating the connection in the embodiment. Detailed Implementation

[0017] To further illustrate the technical methods and effects of the present invention in order to achieve the intended purpose, the specific implementation methods, structure, features and effects of the present invention will be described in detail below with reference to the accompanying drawings and embodiments.

[0018] Figure 1 This is a schematic diagram of an image processing method according to an embodiment of the present invention. Figures 2(a) to 2(c) These are, respectively, a test image, a difference image, and a detail detection image according to an embodiment of the present invention. Please refer to... Figure 1 , Figures 2(a) to 2(c) In this embodiment, the image processing method for detail detection includes:

[0019] Step S1: Obtain a test image. The test image includes several pixels, and each pixel has corresponding pixel data.

[0020] In step S1, the user needs to obtain a test image first. For example, the user can send an acquisition command to a test device to enable the test device to start image testing and generate a test image. The test image includes several pixels, and each pixel has corresponding pixel data, as shown in Figure 2(a). In one example, the test image can be an image after the pixels have been converted by an ADC and processed by existing image processing (such as ISP processing), with a pixel value corresponding to each pixel.

[0021] Step S2: Filter the test image to obtain the filtered image;

[0022] Step S3: Binarize the filtered image to obtain a detail detection image with anomaly points.

[0023] In one embodiment, a method for binarizing a filtered image to obtain a detail detection image with outliers includes: defining a preset threshold, defining pixels in the filtered image whose pixel values ​​are greater than the preset threshold as outliers, and obtaining a detail detection image with outliers.

[0024] In step S3, binarization can be performed first based on a reasonable threshold, and then the detail detection image with anomalies can be obtained based on the binarization result. A reasonable threshold can be set for example: select an x*y region in the detail detection image (where x and y are integers greater than 1), calculate the mean of that region, and define the mean of that region as the reasonable threshold. Understandably, the size or position of the x*y region can be set according to different needs. For example, one way to set the x*y region is to calculate the mean difference of the difference image and select a region where more than 80% of the differences are above the mean difference as the x*y region; another way is to analyze the cumulative probability distribution map of the entire difference image data and set the threshold at the front of the "tail" part of the distribution map (where the difference is large and the proportion is small). Then, the image data of each pixel in the difference image is binarized, as shown in Figure 2(c). During binarization, values ​​greater than the threshold are set to 1, and values ​​less than the threshold are set to 0, thus obtaining the detail detection image. The region with a value of 1 can be defined as a defect area, and other regions can be ignored. In one embodiment, a difference matrix can be obtained based on the difference image, and the region with relatively large values ​​can be determined according to the numerical distribution of the difference matrix, and the size of the threshold can be defined based on the region.

[0025] It should be noted that setting a threshold helps the processed binarized image retain the detailed features of the original image. At the same time, the number of outliers should not exceed a certain percentage of the number of pixels in the original image, such as no more than 30%, which helps reduce test calculation time and improve efficiency.

[0026] Step S4: Traverse the detail detection image and create anomaly clusters based on the anomalies.

[0027] In step S4, all anomalies can be traversed by iterating through the detail detection image. Anomalies can be obtained from the pixel data obtained through binarization in step S3. For example, if in step S3, values ​​greater than a threshold are set to 1 and values ​​less than a threshold are set to 0 during binarization, then the corresponding values ​​of elements in the detail detection image will be 1 or 0. When an element in the detail detection image is 1, that element can be identified as an anomaly. Anomaly clusters can be created based on adjacent anomalies, thus creating corresponding anomaly clusters based on the anomalies.

[0028] Step S5: Based on the traversal of the detail detection image and obtaining at least one cluster of abnormal points, calculate the size and number of the clusters of abnormal points in the detail detection image to determine the size and number of dirt in the test image.

[0029] In step S5, after completing the traversal of the detail detection image, it can be determined that all anomaly points have been traversed, and at least one anomaly point cluster can be obtained. Therefore, based on the size and number of the obtained anomaly point clusters, the size and number of contaminants in the test image can be determined.

[0030] In one embodiment of the invention, a method for determining the size and number of contaminants in a test image by obtaining a detail detection image from a detail detection image and calculating the size and number of outlier clusters in the detail detection image includes: determining whether the connected component area of ​​the outlier cluster is greater than an area threshold; if so, the outlier cluster is considered contaminant; otherwise, the outlier cluster is considered noise. However, this embodiment is not limited to determining whether contaminant is contaminant based on whether the connected component area of ​​the outlier cluster is greater than an area threshold; for example, contaminant can also be determined based on whether the number of outlier clusters is greater than a number threshold.

[0031] The image processing method in this embodiment can calculate and evaluate the size and number of dirt, which facilitates image testing and processing.

[0032] Figure 3 This is a schematic diagram of the position of a pixel in a test image and the first region centered on that pixel, according to an embodiment of the present invention. Figure 4 This is a schematic diagram of a column-wise fast calculation method for mean filtering according to an embodiment of the present invention. Please refer to... Figure 3 and Figure 4The embodiments of the present invention are basically the same as the foregoing embodiments, except that: the method of defining the pixel to be processed may include: taking the previous pixel as the pixel to be processed to obtain the first region, the first filter value, the second region and the second filter value corresponding to the previous pixel; taking the pixel after the previous pixel as the pixel to be processed to obtain the first region, the first filter value, the second region and the second filter value corresponding to the next pixel; wherein, the previous pixel and the next pixel are adjacent pixels, such that the first region corresponding to the previous pixel and the first region corresponding to the next pixel overlap, and also such that the second region corresponding to the previous pixel and the second region corresponding to the next pixel overlap.

[0033] Specifically, because the first region is constructed centered on each pixel of the test image, rather than a region at a fixed location, the first regions constructed during mean filtering overlap, which can effectively highlight detail anomalies in specific locations. Similarly, the second regions constructed during mean filtering also overlap, effectively highlighting detail anomalies in specific locations. Furthermore, the first and second regions are of different sizes. First and second filter values ​​are obtained based on the first and second regions, respectively. These first and second regions represent the processing results of the pixels to be processed. The difference image obtained from the difference between the first and second filter means can effectively highlight detail anomalies in specific locations.

[0034] In one embodiment of the invention, the mean filtering method for the first region and / or the second region includes: obtaining a first calculated value and a second calculated value based on the pixel data of the first region corresponding to the previous pixel, wherein the first calculated value is the sum of the pixel data in the first column of the first region corresponding to the previous pixel, and the second calculated value is the sum of the data in the second to nth columns of the first region corresponding to the previous pixel; obtaining a first filtered value corresponding to the previous pixel based on the first calculated value and the second calculated value, where n is the column number of the first region; defining the sum of the data in the nth column of the pixel data of the first region corresponding to the next pixel as a third calculated value; obtaining a first filtered value corresponding to the next pixel based on the second calculated value and the third calculated value.

[0035] And / or, based on the pixel data of the second region corresponding to the previous pixel, obtain the fourth and fifth calculated values. The fourth calculated value is the sum of the pixel data in the first column of the second region corresponding to the previous pixel, and the fifth calculated value is the sum of the data in the second to m columns of the second region corresponding to the previous pixel. Based on the fourth and fifth calculated values, obtain the second filtered value corresponding to the previous pixel, where m is the column number of the second region. Define the sum of the data in the m column of the pixel data of the second region corresponding to the next pixel as the sixth calculated value. Based on the fifth and sixth calculated values, obtain the second filtered value corresponding to the next pixel.

[0036] Specifically, in this embodiment, since the steps for calculating the mean of the filtered pixel based on the first region and the second region are largely the same, the following explanation will only use the calculation of the mean of the filtered pixel based on the first region as an example. First, the previous pixel can be used as the pixel to be processed to obtain the first region, the first filtered value, the second region, and the second filtered value corresponding to the previous pixel. Centered on the pixel to be processed, a corresponding filtering region, such as the first region, can be established as follows: Figure 3 As shown, the pixel to be processed can be located at the center of the first region Block. Therefore, in the process of... Figure 3 When performing mean filtering calculation on the pixel to be processed, the data of all pixels in the first region are summed and then averaged. That is, the filtered mean value of the pixel to be processed is Pixel = Average(Block). Of course, the embodiments of the present invention are not limited to this. Figure 3 The first region is defined as shown.

[0037] like Figure 4 As shown, the pixel following the previous pixel can also be used as the pixel to be processed to obtain the first region, the first filtered value, the second region, and the second filtered value corresponding to the next pixel. Here, the previous pixel and the next pixel are adjacent pixels, such that the first region corresponding to the previous pixel and the first region corresponding to the next pixel overlap, and also that the second region corresponding to the previous pixel and the second region corresponding to the next pixel overlap. Because the first region corresponding to the previous pixel overlaps with the first region corresponding to the next pixel, the pixel data used in the mean filtering also overlaps. Assuming the mean-filtered data for the previous pixel is Pixel(t-1), and the first region corresponding to the previous pixel is Block(t-1), i.e., columns 1 to n, and the mean-filtered data for the next pixel is Pixel(t), and the first region corresponding to the next pixel is Block(t), i.e., columns 2 to n+1, then both the first region Block(t-1) corresponding to the previous pixel and the first region Block(t) corresponding to the next pixel have n columns of data, and they share n-1 identical columns (columns 2 to n), differing only in one column. Accordingly, the first filter values ​​for the previous and next pixels are calculated as follows:

[0038] Pixel(t-1)=Average(Block(t-1))=Average(Col 1~n)

[0039] =Average(Col 1)+Average(Col 2~n)

[0040] Pixel(t)=Average(Block(t))=Average(Col 2~n+1)

[0041] =Average(Col 2~n)+Average(Col n+1)

[0042] Therefore, both Pixel(t-1) and Pixel(t) are related to Average(Col 2~n), and corresponding substitutions can be made to obtain:

[0043] Pixel(t)=Pixel(t-1)-Average(Col 1)+Average(Col n+1);

[0044] Therefore, based on the pixel data of the first region corresponding to the previous pixel, a first calculated value and a second calculated value can be obtained. The first calculated value is the sum of the pixel data in the first column of the first region corresponding to the previous pixel, that is, the sum of the pixel data in the first column of Average(Col 1). The second calculated value is the sum of the data in the second to nth columns of the first region corresponding to the previous pixel, that is, the sum of the pixel data in the second to nth columns of Average(Col2~n). Based on the first and second calculated values, the first filtered value corresponding to the previous pixel, i.e., Pixel(t-1), is obtained, where n is the column number of the first region corresponding to the previous pixel. The sum of the nth column of the pixel data in the first region corresponding to the next pixel is defined as the third calculated value, that is, the sum of the data in the (n+1)th column of Average(Coln+1). Based on the second and third calculated values, the first filtered value corresponding to the next pixel, i.e., Pixel(t), is obtained.

[0045] Because the first region corresponding to the previous pixel and the first region corresponding to the next pixel have overlapping n-1 columns of data, the calculation of the first filtered value of the next pixel does not require the calculation of the first n-1 columns of pixel data. That is, the second calculated value can be obtained based on the first filtered value and the first calculated value of the previous pixel, and then the first filtered value of the next pixel can be obtained based on the second calculated value and the third calculated value. This reduces the overall amount of calculation and saves a lot of computing time.

[0046] Furthermore, the calculation of the second filtered value for the next pixel can also employ the row-by-row fast calculation method of the mean filtering of the first filtered value, as described above, and will not be elaborated upon here. The method for performing mean filtering on the second region includes: obtaining a fourth and a fifth calculated value based on the pixel data of the second region corresponding to the previous pixel. The fourth calculated value is the sum of the pixel data in the first column of the second region corresponding to the previous pixel, and the fifth calculated value is the sum of the data in the second to m columns of the second region corresponding to the previous pixel. Based on the fourth and fifth calculated values, the second filtered value corresponding to the previous pixel is obtained, where m is the column number of the second region. The sum of the data in the m-th column of the pixel data in the second region corresponding to the next pixel is defined as the sixth calculated value. Based on the fifth and sixth calculated values, the second filtered value corresponding to the next pixel is obtained.

[0047] However, this embodiment of the invention does not limit the two adjacent pixels, i.e., the previous pixel and the next pixel, to be two pixels from left to right. Those skilled in the art can set the two pixels to be two pixels that are vertically adjacent, or other adjacent relationships, such that the first region corresponding to the previous pixel and the first region corresponding to the next pixel overlap, and the second region corresponding to the previous pixel and the second region corresponding to the next pixel also overlap. Thus, the column-wise fast calculation method for mean filtering in this embodiment can be changed to the row-wise fast calculation method for mean filtering, etc. Such calculation methods are conventional transformations of the technical solution of this embodiment and should also fall within the protection scope of this invention.

[0048] Figure 5 This is a schematic diagram illustrating the addition of a first extended pixel according to an embodiment of the present invention. Figure 5 As shown, this embodiment is basically the same as the previous embodiment, except that before performing mean filtering on the first region, it further includes: acquiring edge pixels, adding a first extended pixel centered on the edge pixels based on the size of the first region, and performing edge completion on the first extended pixel; and / or, before performing mean filtering on the second region, it further includes: acquiring edge pixels, adding a second extended pixel centered on the edge pixels based on the size of the second region, and performing edge completion on the second extended pixel.

[0049] Specifically, such as Figure 5 As shown, the test image is centered. Edge pixels are selected, and based on the size of the first region, a first extended pixel is generated around the test image. The first extended pixel can be assigned values ​​for edge completion. For example, if the size of the first region is 3*3, then all pixels around the outermost edge of the test image can be considered edge pixels. By forming the first extended pixel, each edge pixel can form a first region centered on the 3*3 region. Similarly, edge pixels can be selected, and based on the size of the second region, a second extended pixel is generated around the test image. The second extended pixel can be assigned values ​​for edge completion. Edge completion gives the first extended pixel corresponding pixel data, which can be directly used when the pixel to be processed is mean-filtered based on the first region. And / or edge completion gives the second extended pixel corresponding pixel data, which can be directly used when the pixel to be processed is mean-filtered based on the second region.

[0050] In one embodiment of the invention, the method of edge completion for the first extended pixel and / or the second extended pixel includes: mirroring the row containing the topmost or bottommost edge pixel as the axis of symmetry to complete the pixel data of the extended pixel; and mirroring the column containing the leftmost or rightmost edge pixel as the axis of symmetry to complete the pixel data of the extended pixel. However, this embodiment of the invention does not limit the order of mirroring the row containing the topmost or bottommost edge pixel and mirroring the column containing the leftmost or rightmost edge pixel as the axis of symmetry during edge completion. Of course, in other embodiments, at least two rows and two columns can be flipped and extended, depending on the actual area size, etc.

[0051] For example, in this embodiment, edge pixels can be defined as pixels located in the top row, bottom row, leftmost column, and leftmost column. The first region can be set to 3x3. Then, based on the edge pixels and the first region being 3x3 in size, we can obtain the first extended pixels by adding a row to the top row, a row to the bottom row, a column to the left of the leftmost column, and a column to the right of the rightmost column, according to the test image. Figure 5 As shown. Edge completion can be performed as follows: A symmetrical flip is made with a single edge pixel as the center, such as left-right symmetry, top-bottom symmetry, top-left and bottom-right symmetry, or bottom-left and top-right symmetry; or, the top or bottom edge pixel in the image before expansion is directly mirrored along the axis of symmetry to complete the pixel data of the first expanded pixel. Then, the pixel data of the second row of pixels, with the top row as the axis of symmetry, can complete the pixel data of the first expanded pixel in the top row by mirroring the flip, and the pixel data of the second-to-last row of pixels, with the bottom row as the axis of symmetry, can complete the pixel data of the first expanded pixel in the bottom row by mirroring the flip; then, the left or right edge pixel in the image before expansion is mirrored along the axis of symmetry to complete the pixel data of the first expanded pixel. Then, the pixel data of the second column of pixels, with the leftmost column as the axis of symmetry, can complete the pixel data of the first expanded pixel in the left column by mirroring the flip, and the pixel data of the second-to-last column of pixels, with the rightmost column as the axis of symmetry, can complete the pixel data of the first expanded pixel in the right column by mirroring the flip, thus completing the pixel data of the first expanded pixel. By mirroring and flipping to complete the pixel data of extended pixels, the time required for edge completion can be reduced.

[0052] In one embodiment of the invention, before defining the pixels to be processed, the method may further include scaling the test image. Scaling can be understood as increasing or decreasing the number of corresponding pixels in the test image through different processing methods. In one embodiment, scaling the test image may include: dividing the test image into several regions of size t*t, and redefining these regions as pixels of the test image; summing and averaging the pixel data of each region within the several regions to obtain the pixel data of each pixel in the test image, where t is a natural number greater than 1. This can be considered as each region corresponding to an updated pixel, and obtaining an updated pixel value for each updated pixel, for example, by summing and averaging as described above, to obtain an updated test image; wherein, in subsequent steps, the pixels to be processed are selected from the updated pixels in the updated test image. It should be noted that all the method steps described above for the test image in this embodiment are applicable to the updated test image here. For example, in a specific embodiment, a 16*16 test image may be scaled down, with t chosen as 4, to obtain a 4*4 updated test image. In this embodiment, by reducing the size of the test image, the overall computational load is reduced, saving a significant amount of processing time. Of course, in some embodiments, an updated test image can also be obtained by increasing the number of corresponding pixels in the test image using different methods.

[0053] Figure 6 This is a schematic diagram of a method for detecting outlier clusters in an image based on computational detail, according to an embodiment of the present invention. Figure 6 As shown, this embodiment is basically the same as the previous embodiment, except that the method for creating anomaly clusters includes: traversing the detail detection image; when the current traversed element of the detail detection image is determined to be an anomaly to be connected, establishing an anomaly detection region centered on the current traversed element to obtain anomalies within the anomaly detection region, marking the anomalies within the anomaly detection region as connected anomalies, creating an anomaly cluster based on the connected anomalies; and calculating the size and number of anomaly clusters.

[0054] Specifically, the detail detection image is traversed, and it is simultaneously determined whether the currently traversed element is an outlier to be connected. If so, the outlier to be connected is obtained. An outlier detection region centered on the currently traversed element is established to obtain the outliers within the region. These outliers are marked as connected outliers, and an outlier cluster is created based on these connected outliers. The outlier detection region centered on the currently traversed element refers to establishing the region with the currently traversed element (determined as an outlier to be connected) as the starting point for connection. Adjacent unconnected outliers are searched, and then the search continues based on these adjacent unconnected outliers, and so on, connecting adjacent outliers and ultimately creating an outlier cluster. Thus, when the detail detection image is traversed, at least one outlier cluster is obtained. Finally, the size and number of outlier clusters are calculated. For example, the size, number, shape, and orientation features of the connected components can be determined based on the outlier clusters to achieve the purpose of detecting dirt in the test image.

[0055] In one embodiment of the invention, establishing an anomaly detection region to obtain anomalies within the anomaly detection region includes: defining the first anomaly obtained by traversing the detail detection image as the starting point of an anomaly cluster and marking it as a connected anomaly; establishing a first anomaly detection region centered on the starting point of the anomaly cluster and traversing the first anomaly detection region; determining whether the currently detected traversed element in the first anomaly detection region is an unconnected anomaly; if so, defining the currently detected traversed element as the first anomaly and marking it as a connected anomaly; establishing a second anomaly detection region centered on the first anomaly and traversing the second anomaly detection region; and so on, determining whether the currently detected traversed element in the current anomaly detection region is an unconnected anomaly; if so, marking the currently detected traversed element as a connected anomaly and traversing the anomaly detection region centered on the currently detected traversed element until the next anomaly detection region. All outliers within the image are considered connected. At the end of this traversal, all connected outliers from this traversal are obtained, and a first outlier cluster is created. If the condition is not met, this traversal ends, and the starting point of the outlier cluster is defined as the first outlier cluster, meaning the first outlier cluster contains only one outlier. The detail detection image then proceeds to the next traversal. The process of proceeding to the next traversal of the detail detection image is similar to the first traversal process described above. The first outlier obtained in the next traversal is defined as the starting point of another outlier cluster, and an outlier detection region is established based on this starting point. Unconnected outliers are then searched within the outlier detection region, and so on, until all outliers in the detail detection image have undergone at least one traversal. This completes the traversal of all outliers in the detail detection image, yielding all outlier clusters, the number of connected outliers within each outlier cluster, and the pixel matrix size of the corresponding outlier cluster.

[0056] However, the embodiments of the present invention are not limited to obtaining anomaly clusters only by this method. For example, it is also possible to first traverse the elements of the detail detection image and determine all anomalies, and then obtain anomaly clusters based on all anomalies. Such technical solutions should also be within the protection scope of the present invention.

[0057] In one embodiment of the invention, establishing an anomaly detection region to obtain anomalies within the anomaly detection region includes: defining the first anomaly obtained by traversing the detail detection image as the starting point of an anomaly cluster and marking it as a connected anomaly; establishing a first anomaly detection region centered on the starting point of the anomaly cluster and traversing the first anomaly detection region; determining whether the currently detected traversed element within the first anomaly detection region is an unconnected anomaly; if so, defining the currently detected traversed element as the first anomaly and marking it as a connected anomaly; establishing a second anomaly detection region centered on the first anomaly and traversing the second anomaly detection region; and so on, determining whether the currently detected element within the current anomaly detection region is an unconnected anomaly; if so, defining the currently detected element as the first anomaly and marking it as a connected anomaly; establishing a second anomaly detection region centered on the first anomaly and traversing the second anomaly detection region; and so on, determining the current detected element within the current anomaly detection region. If an element is an unconnected outlier, it is marked as a connected outlier. The outlier detection area centered on the current element is then traversed until the next outlier detection area contains no outliers except the central outlier, or all outliers are connected. This round of traversal ends, and all connected outliers in this round are obtained, creating the first outlier cluster. If no outlier is found, this round of traversal ends, the starting point of the outlier cluster is defined as the first outlier cluster, and the detail detection image proceeds to the next round of traversal. All outlier traversals are completed to obtain all outlier clusters, and the number of connected outliers within each outlier cluster and the pixel matrix size of the corresponding outlier cluster are obtained.

[0058] In one embodiment of the invention, a method for establishing a first anomaly detection region and a second anomaly detection region includes: setting the pixel matrix of the first anomaly detection region and the second anomaly detection region to a size of 3x3. It is understood that during the traversal process, the pixel matrix size of all anomaly detection regions is consistent; optionally, the pixel matrix of all anomaly detection regions is 3x3.

[0059] In one embodiment of the invention, establishing an anomaly detection region to obtain anomalies within the region further includes: when there are multiple anomalies in the first anomaly detection region excluding the central anomaly, creating anomaly sub-clusters based on each anomaly in the first anomaly detection region excluding the central anomaly, according to a traversal order. The first anomaly cluster contains the anomaly sub-clusters of each anomaly in the first anomaly detection region excluding the central anomaly. Based on this method, those skilled in the art can also establish a next-level anomaly sub-cluster based on each anomaly in the anomaly sub-cluster excluding the central anomaly, so that the anomaly sub-cluster can contain the next-level anomaly sub-cluster, and so on. The first anomaly sub-cluster can connect adjacent anomalies according to the hierarchical relationship between sub-clusters. Therefore, a first anomaly cluster can be created based on the starting point of the anomaly cluster and at least one anomaly in a first anomaly sub-cluster.

[0060] Figure 7 This is a schematic diagram of a method for obtaining anomaly clusters according to an embodiment of the present invention. Figure 7As shown, this embodiment is basically the same as the previous embodiment, except that the method for establishing an anomaly detection region to obtain anomalies within the anomaly detection region includes: starting to traverse the detail detection image; when the current traversed element is determined to be an anomaly to be connected, defining the current traversed element as the starting point of the anomaly cluster and marking it as a connected anomaly; establishing a first anomaly detection region centered on the starting point of the anomaly cluster and traversing the first anomaly detection region; determining whether the current traversed element within the first anomaly detection region is an unconnected anomaly; if so, marking the current traversed element as a connected anomaly and establishing a first anomaly detection region centered on the starting point of the anomaly cluster. The first anomaly detection region is traversed, starting with the element centered on the first anomaly detection region. This process continues until all elements in the current anomaly detection region have been traversed. Then, the process returns to the previous anomaly detection region. This continues until the first anomaly detection region has been traversed. This completes the current traversal, and all connected anomalies in this traversal are obtained, creating the first anomaly cluster. This process continues, traversing the detail detection image to complete the traversal of all anomalies, obtaining all anomaly clusters, and obtaining the number of connected anomalies within each anomaly cluster and the size of the corresponding pixel matrix of the anomaly cluster.

[0061] Specifically, Figures 8(a) to 8(c) for Figure 7 A detailed schematic diagram illustrating the connectivity of the embodiment is provided. See also the following: Figure 7 and Figures 8(a) to 8(c)The process begins by traversing the detail detection image to identify disconnected outliers, such as the outlier represented by number 1 in Figure 8(a), which can be defined as the starting point of an outlier cluster. Then, the starting point of the outlier cluster is marked as a connected outlier, and connectivity is established based on this starting point. Specifically, a first outlier detection region is established centered on the starting point of the outlier cluster. For example, the first outlier detection region shown in Figure 8(a) is a 3x3 pixel matrix, and then the elements of the first outlier detection region are traversed. Determine whether the elements of the first anomaly detection area being traversed are disconnected anomalies. If so, mark the current traversed element as a connected anomaly. Establish a second anomaly detection area centered on the starting point of the anomaly cluster and traverse the second anomaly detection area centered on the current traversed element. For example, traverse each element of the first anomaly detection area in Figure 8(a) to determine whether it is a disconnected anomaly. The anomaly represented by the number 2 in Figure 8(a) can be identified and recorded as the first anomaly. Record the first anomaly as a connected anomaly and establish a second anomaly detection area centered on the first anomaly. Traverse the second anomaly detection area, which is Figure 8(b). Similarly, determine whether the elements of the currently traversed pixel matrix are disconnected outliers. If so, mark the currently traversed element as a connected outlier, and traverse the current outlier detection area centered on the currently traversed element. For example, traverse each element of the second outlier detection area in Figure 8(b) to determine if it is a disconnected outlier. The outlier represented by number 3 in Figure 8(b) can be recorded as the second outlier. This second outlier is then marked as a connected outlier, and the third outlier detection area centered on the second outlier, i.e., Figure 8(c), is traversed. This process continues until all traversed elements of the current outlier detection area have been traversed. Then, return to the previous outlier detection area to continue traversing. This process continues until the first outlier detection area is traversed. This round of traversal ends, obtaining all connected outliers in this round of traversal and creating the first outlier. Cluster; for example, in Figure 8(c), all elements in the third anomaly detection area are traversed, that is, all traversed elements in the third anomaly detection area are determined not to be disconnected anomalies. Then, return to Figure 8(b) to continue traversing the second anomaly detection area. After completing the traversal of the second anomaly detection area in Figure 8(b), return to Figure 8(a) to continue traversing the first anomaly detection area. Thus, when the traversal of the first anomaly detection area is completed, this round of traversal ends. All connected anomalies in this round of traversal can be obtained and the first anomaly cluster can be created. For example, at the end of this round of traversal, the connected anomalies include the starting point of the anomaly cluster represented by number 1, the first anomaly represented by number 2, and the second anomaly represented by number 3. Then, the first anomaly cluster can be created based on the starting point of the anomaly cluster represented by number 1, the first anomaly represented by number 2, and the second anomaly represented by number 3.By analogy, the detail detection image is traversed to complete the traversal of all anomalies, obtain all anomaly clusters, and obtain the number of connected anomalies within each anomaly cluster and the pixel matrix size of the corresponding anomaly cluster.

[0062] In one embodiment of the invention, the method for establishing a first anomaly detection area and a second anomaly detection area includes setting the pixel matrix of the first anomaly detection area and the second anomaly detection area to a size of 3x3.

[0063] The image processing method in this embodiment can obtain all abnormal points, obtain all abnormal point clusters based on all abnormal points, and thus obtain the size and number of abnormal point clusters, thereby calculating and evaluating the size and number of dirt, which facilitates image testing and processing.

[0064] This invention also provides a computer device, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the image processing method described in the above embodiments. The implementation of the computer device in this embodiment is similar to the foregoing embodiments; repeated details will not be described again.

[0065] This invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the image processing method described above. For the implementation of the computer-readable storage medium in this embodiment, please refer to the foregoing embodiments; repeated details will not be described again.

[0066] The image processing method, computer device, and computer-readable storage medium for detail detection provided in this invention can calculate and evaluate the size and number of contaminants, facilitating image testing and processing.

[0067] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent changes and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the scope of the present invention.

Claims

1. An image processing method, characterized in that, include: A test image is acquired, the test image comprising a plurality of pixels, each of which has corresponding pixel data; The test image is filtered to obtain the filtered image; The filtered image is binarized to obtain a detail detection image with anomalies. Traverse the detailed detection image and create anomaly clusters based on the anomalies; Based on the traversal of the detail detection image and obtaining at least one cluster of anomalous points, the size and number of the clusters of anomalous points in the detail detection image are calculated to determine the size and number of contaminants in the test image. The method for filtering the test image to obtain a filtered image includes: defining a pixel to be processed; establishing a first region centered on the pixel to be processed; performing mean filtering on the first region to obtain a first filtered value for the pixel to be processed, thereby obtaining a first filtered image of the test image; establishing a second region centered on the pixel to be processed; performing mean filtering on the second region to obtain a second filtered value for the pixel to be processed, thereby obtaining a second filtered image of the test image; wherein the first region and the second region are of different sizes; and obtaining a difference image based on the difference between the first filtered image and the second filtered image, wherein the difference image is the filtered image. The method for defining the first region and the second region includes: obtaining the first region and the second region corresponding to the previous pixel based on the previous pixel; obtaining the first region and the second region corresponding to the next pixel based on the next pixel; wherein the previous pixel and the next pixel are adjacent pixels, the first region corresponding to the previous pixel and the first region corresponding to the next pixel overlap, and the second region corresponding to the previous pixel and the second region corresponding to the next pixel overlap; The method for performing mean filtering on the first region and / or the second region includes: obtaining a first calculated value and a second calculated value based on the pixel data of the first region corresponding to the previous pixel, wherein the first calculated value is the sum of the pixel data in the first column of the first region corresponding to the previous pixel, and the second calculated value is the sum of the data in the second to nth columns of the first region corresponding to the previous pixel; obtaining a first filtered value corresponding to the previous pixel based on the first calculated value and the second calculated value, where n is the column number of the corresponding first region; defining the sum of the data in the nth column of the pixel data of the first region corresponding to the next pixel as a third calculated value, and obtaining a first filtered value based on the second calculated value and the third calculated value. The first filtered value corresponding to the next pixel; and / or, based on the pixel data of the second region corresponding to the previous pixel, a fourth calculated value and a fifth calculated value are obtained, wherein the fourth calculated value is the sum of the pixel data in the first column of the second region corresponding to the previous pixel, and the fifth calculated value is the sum of the data in the second to m columns of the second region corresponding to the previous pixel; the second filtered value corresponding to the previous pixel is obtained based on the fourth calculated value and the fifth calculated value, where m is the column number of the corresponding second region; the sum of the data in the m column of the pixel data in the second region corresponding to the next pixel is defined as a sixth calculated value, and the second filtered value corresponding to the next pixel is obtained based on the fifth calculated value and the sixth calculated value.

2. The image processing method as described in claim 1, characterized in that, The method of establishing the first region centered on the pixel to be processed includes: selecting a matrix block of size a*a centered on the pixel to be processed as the first region; The method of establishing the second region centered on the pixel to be processed includes: selecting a matrix block of size b*b centered on the pixel to be processed as the second region; a and b are not equal and are both odd numbers greater than 1.

3. The image processing method as described in claim 1, characterized in that, Before performing mean filtering on the first region, the method further includes: Obtain edge pixels, add a first extended pixel centered on the corresponding edge pixel based on the size of the first region, and perform edge completion on the first extended pixel; And / or, before performing mean filtering on the second region, the method further includes: Obtain edge pixels, add second extended pixels centered on the corresponding edge pixels based on the size of the second region, and perform edge completion on the second extended pixels.

4. The image processing method as described in claim 3, characterized in that, The method for edge completion of the first extended pixel includes: mirroring the edge pixel along the row of symmetry to supplement the pixel data of the first extended pixel; mirroring the edge pixel along the column of symmetry to supplement the pixel data of the first extended pixel; and / or, The method for edge completion of the second extended pixel includes: mirroring the edge pixel with the row as the axis of symmetry to supplement the pixel data of the second extended pixel; and mirroring the edge pixel with the column as the axis of symmetry to supplement the pixel data of the second extended pixel.

5. The image processing method as described in claim 1, characterized in that, Before defining the pixel to be processed, the method further includes scaling the test image.

6. The image processing method as described in claim 5, characterized in that, The method of scaling the test image includes: dividing the test image into several regions of size t*t, summing the pixel data of each region and averaging the sums to obtain updated pixel values, and obtaining an updated test image of the test image based on each updated pixel value, wherein the pixels to be processed are selected from the updated pixels in the updated test image; where t is a natural number greater than 1.

7. The image processing method as described in claim 1, characterized in that, The filtered image is binarized to obtain a detail detection image with the anomaly points arranged in it, specifically including: Define a preset threshold, and define the pixels in the filtered image whose pixel values ​​are greater than the preset threshold as the outliers, and obtain a detail detection image with the outliers arranged in it.

8. The image processing method as described in claim 1, characterized in that, The method for creating the aforementioned cluster of anomalies includes: Traverse the detail detection image. When the current traversed element of the detail detection image is determined to be an outlier to be connected, establish an outlier detection region centered on the current traversed element to obtain the outliers within the outlier detection region. Mark the outliers within the outlier detection region as connected outliers and create the outlier cluster based on the connected outliers. Calculate the size and number of the abnormal point clusters.

9. The image processing method as described in claim 8, characterized in that, Establishing the anomaly detection region to obtain the anomalies within the anomaly detection region includes: The first anomaly obtained by traversing the detail detection image is defined as the starting point of the anomaly cluster and marked as a connected anomaly. A first anomaly detection area is established with the starting point of the anomaly cluster as the center, and the first anomaly detection area is traversed. Determine whether the currently traversed element within the first anomaly detection area is an unconnected anomaly. If the determination is yes, then the current traversed element is defined as the first abnormal point and marked as a connected abnormal point. A second abnormal point detection area centered on the first abnormal point is established, and the second abnormal point detection area is traversed. This process continues, determining whether the current traversed element in the current abnormal point detection area is an unconnected abnormal point. If the determination is yes, then the current traversed element is marked as a connected abnormal point, and the abnormal point detection area centered on the current traversed element is traversed until all abnormal points in the next abnormal point detection area are connected abnormal points. This round of traversal ends, and all connected abnormal points in this round of traversal are obtained and a first abnormal point cluster is created. If the determination is negative, the current round of traversal ends, the starting point of the abnormal point cluster is defined as the first abnormal point cluster, and the detail detection image proceeds to the next round of traversal. Complete the traversal of all the aforementioned anomaly points to obtain all the aforementioned anomaly point clusters, and obtain the number of connected anomaly points within each of the aforementioned anomaly point clusters and the pixel matrix size of the corresponding anomaly point cluster.

10. The image processing method as described in claim 9, characterized in that, Establishing the anomaly detection region to obtain the anomalies within the anomaly detection region further includes: When there are multiple anomalies in the first anomaly detection area other than the central anomaly, anomaly sub-clusters based on each anomaly in the first anomaly detection area other than the central anomaly are created in traversal order, wherein the first anomaly cluster contains the anomaly sub-clusters of each anomaly in the first anomaly detection area other than the central anomaly.

11. The image processing method as described in claim 8, characterized in that, Establishing the anomaly detection region to obtain the anomalies within the anomaly detection region includes: The process begins to traverse the detail detection image. When the current traversed element is determined to be an outlier to be connected, the current traversed element is defined as the starting point of the outlier cluster and marked as a connected outlier. A first outlier detection area is established with the starting point of the outlier cluster as the center, and the first outlier detection area is traversed. Determine whether the currently traversed element in the first anomaly detection area is an unconnected anomaly. If so, mark the currently traversed element as a connected anomaly, establish a second anomaly detection area centered on the currently traversed element, and traverse the second anomaly detection area. Continue in this manner until all traversed elements in the current anomaly detection area have been traversed, then return to the previous anomaly detection area to continue traversing. Continue in this manner until the traversal of the first anomaly detection area is completed. Then, this round of traversal ends, and all connected anomalies in this round of traversal are obtained and a first anomaly cluster is created. Similarly, the traversal of the detail detection image continues to complete the traversal of all the anomaly points, obtain all the anomaly point clusters, and obtain the number of connected anomaly points in all the anomaly point clusters and the pixel matrix size of the corresponding anomaly point cluster.

12. The image processing method as described in claim 9 or 11, characterized in that, The method for establishing the first anomaly detection region and the second anomaly detection region includes: The pixel matrix of the first anomaly detection area and the second anomaly detection area is set to a size of 3x3.

13. The image processing method as described in claim 1, characterized in that, A method for calculating the size and number of outlier clusters in the detail detection image to determine the size and number of contaminants in the test image includes: Determine whether the area of ​​the connected region of the abnormal point cluster is greater than the area threshold; if yes, the abnormal point cluster is dirt; if no, the abnormal point cluster is noise.

14. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the image processing method according to any one of claims 1 to 13.

15. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the image processing method according to any one of claims 1 to 13.

Citation Information

Patent Citations

  • Stain detection method, device and system for imaging module, and storage medium

    CN111476750A

  • Method and computer program for filtering and particularly segmenting and / or analyzing anatomic structures in a digital image

    EP2827298A1