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

By filtering and binarizing the test images of the CMOS image sensor, and calculating the linear fitting degree in blocks, the problems of high false detection rate and low efficiency in the detection of diagonal stripe anomalies in CMOS image sensors are solved, and efficient screening of linear diagonal stripes is achieved.

CN116416149BActive 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
2021-12-31
Publication Date
2026-04-24

AI Technical Summary

Technical Problem

In existing technologies, CMOS image sensors have a high false detection rate and low testing efficiency for detecting diagonal anomalies, and cannot effectively and specifically test straight diagonal patterns.

Method used

By acquiring a test image, filtering it, and then binarizing it, we can obtain a detail detection image of the feature points. The image is then divided into preset blocks, and the straight line fitting degree is calculated based on the feature points. The maximum value is defined as the abnormal straight line degree.

Benefits of technology

It achieves efficient screening and testing of straight-line diagonal patterns, reduces false test rate and improves testing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116416149B_ABST
    Figure CN116416149B_ABST
Patent Text Reader

Abstract

The application discloses an image processing method, computer equipment and a computer readable storage medium. The image processing method comprises the following steps: acquiring a test image; performing filtering 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 feature points are arranged; dividing the detail detection image into a plurality of blocks according to the size of a preset block; obtaining a straight line fitting degree of the feature points in the block based on the feature points; and defining the maximum value in the straight line fitting degree as an abnormal straight line degree of the test image. The application can complete screening test through one test for a straight line type twill.
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 a dirt test to detect diagonal stripe anomalies, excluding actually erasable dirt samples from the chip and classifying them as diagonal stripe anomalies. However, this method is not targeted, has a high false detection rate, and is inefficient. 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 complete the screening test for straight-line diagonal patterns in a single test.

[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 arranged feature points; dividing the detail detection image into multiple blocks according to a preset block size, obtaining the linear fitting degree of the feature points within the corresponding blocks based on the feature points, and defining the maximum value of the linear fitting degree as the abnormal linearity of the test image.

[0006] In one embodiment, a 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.

[0007] In one embodiment, 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; where a and b are not equal and are both odd numbers greater than 1.

[0008] In one embodiment, the method of defining the first region and / or 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 / or, the second region corresponding to the previous pixel and the second region corresponding to the next pixel overlap.

[0009] In one embodiment, the mean filtering of 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 process involves obtaining a first filtered value corresponding to the next pixel; and / or, based on the pixel data of the second region corresponding to the previous pixel, obtaining a fourth calculated value and a fifth calculated value, 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; and obtaining a second filtered value corresponding to the previous pixel based on the fourth calculated value and the fifth calculated value, where m is the column number of the corresponding second region; defining the sum of the data in the m column of the pixel data in the second region corresponding to the next pixel as a sixth calculated value, and obtaining a second filtered value corresponding to the next pixel based on the fifth calculated value and the sixth calculated value.

[0010] In one embodiment, before performing mean filtering on the first region, the method further includes: acquiring edge pixels, adding a first extended pixel centered on the corresponding edge pixel based on the size of the first region, and performing edge padding on the first extended pixel; and / or, before performing mean filtering on the second region, the method further includes: acquiring edge pixels, adding a second extended pixel centered on the corresponding edge pixel based on the size of the second region, and performing edge padding on the second extended pixel.

[0011] In one embodiment, the edge completion method for the first extended pixel includes: mirroring the row containing the edge pixel as the axis of symmetry to complete the pixel data of the first extended pixel; mirroring the column containing the edge pixel as the axis of symmetry to complete the pixel data of the first extended pixel; and / or, the edge completion method for the second extended pixel includes: mirroring the row containing the edge pixel as the axis of symmetry to complete the pixel data of the second extended pixel; mirroring the column containing the edge pixel as the axis of symmetry to complete the pixel data of the second extended pixel.

[0012] In one embodiment, before defining the pixel to be processed, the method further includes scaling the test image.

[0013] In one embodiment, the scaling process for 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 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.

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

[0015] In one embodiment, a method for obtaining the linear fitting degree of feature points within a block based on the feature points includes: establishing a rectangular coordinate system and obtaining the rectangular coordinate values ​​(X, Y) of the feature points within the block; converting the rectangular coordinate system to a polar coordinate system, setting a preset polar angle θ, and obtaining the parameter ρ corresponding to the feature point based on the rectangular coordinate values ​​(X, Y) of the feature points within the block and the preset polar angle θ, and obtaining the perpendicular polar coordinate value (ρ, θ) of the feature point; calculating the number of identical polar coordinate values ​​among the feature points within the block, and obtaining the cumulative value of the number of each polar coordinate value.

[0016] In one embodiment, the method for obtaining the linear fitting degree of the corresponding feature points within the block based on the feature points further includes: defining the ratio of the maximum value among the accumulated values ​​to the average value among the accumulated values ​​as the linear fitting degree of the feature points within the block; or, adding the accumulated value of the number of polar coordinate values ​​and the accumulated value of the number of polar coordinate values ​​with the same preset polar angle θ and adjacent parameter ρ, respectively, and defining the ratio of the maximum value among the accumulated values ​​to the average value among the accumulated values ​​as the linear fitting degree of the feature points within the block.

[0017] In one embodiment, a method for obtaining the perpendicular polar coordinates (ρ, θ) of a feature point based on its rectangular coordinates (X, Y) and the preset polar angle θ includes: substituting the rectangular coordinates (X, Y) and the preset polar angle θ of the feature point within the block into ρ = Xcosθ + Ysinθ to obtain the parameter ρ; obtaining the number of identical parameters ρ for each feature point under the same preset polar angle θ and accumulating them to obtain the accumulated value of the number of polar coordinates; calculating the ratio of the maximum value to the average value of the accumulated values ​​for each block under different parameters ρ and the preset polar angle θ to determine the linear fitting degree of the feature points within each block.

[0018] 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 image processing method described in any of the preceding claims.

[0019] 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 image processing method described in any of the preceding claims.

[0020] The image processing method, computer equipment, and computer-readable storage medium described above can complete the screening test for straight-line diagonal patterns in a single test, facilitating image testing and processing. Attached Figure Description

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

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

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

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

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

[0026] Figure 6 This is a schematic diagram illustrating the conversion of a rectangular coordinate system to a polar coordinate system according to an embodiment of the present invention.

[0027] Figure 7 This is a schematic diagram of a two-dimensional lookup table established according to an embodiment of the present invention. Detailed Implementation

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

[0029] 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:

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

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

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

[0033] Step S3: Binarize the filtered image to obtain a detail detection image with arranged feature points;

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

[0035] In step S3, binarization can be performed first based on a reasonable threshold, and then a detail detection image with arranged feature points can be obtained based on the result of the binarization. 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.

[0036] 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 feature points 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.

[0037] Step S4: Obtain several feature points from the detail detection image, divide the detail detection image into multiple blocks according to the size of the preset block, obtain the straight-line fitting degree of the feature points in the corresponding block based on the feature points, and define the maximum value of the straight-line fitting degree as the abnormal straightness of the test image.

[0038] In step S4, several feature points are first obtained from the detail detection image; these feature points can be obtained from the pixel data obtained through binarization in step S4. To quickly analyze the anomaly of diagonal stripes in the test image, the detail detection image can be divided into multiple blocks according to a preset block size. Understandably, the size or position of the blocks can be set according to different needs. For example, the blocks can be set as a square pixel matrix, and the side length of the square block can be one-fifth of the width of the detail test image. The linear fitting degree of the feature points in each block can be calculated, and the maximum value of the linear fitting degree can be determined based on the linear fitting degree of the feature points in each block. This maximum value is the abnormal straightness of the test image. The greater the abnormal straightness of the test image, the more feature points are on the same straight line, and the more obvious the diagonal stripes on the test image.

[0039] The image processing method of this embodiment can complete the screening test for straight diagonal patterns in one test, which facilitates the testing and processing of images.

[0040] In one embodiment of the invention, a method for filtering a test image to obtain a filtered image may include: 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; the first region and the second region are of different sizes; 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.

[0041] Understandably, the method for obtaining a detail detection image with arranged feature points during the binarization process of the filtered image includes: defining pixels in the difference image whose pixel value is greater than a preset threshold as feature points, and obtaining a detail detection image with arranged feature points.

[0042] Specifically, each pixel in the test image needs to undergo two mean filtering processes, one in a first region and the other in a second region of different sizes. The pixel to be processed is defined by selecting pixels one by one in the test image sequentially, such as by row or column. A first region centered on the pixel to be processed is established, and mean filtering is performed on this region to obtain the first filtered value. This process is repeated to obtain the first filtered value for each pixel in the test image, resulting in the first filtered image. Similarly, a second region centered on the pixel to be processed is established, and mean filtering is performed on this region to obtain the second filtered value. This process is repeated to obtain the second filtered value for each pixel in the test image, resulting in the second filtered image. The first and second regions are different in size, and the number of pixels in the first region differs from the number of pixels in the second region. For example, the first region might be a 3x3 pixel area, and the second region a 5x5 pixel area. This embodiment does not limit the order in which the pixels to be processed undergo two mean filtering operations based on the first and second regions. The pixels to be processed can be mean filtered first based on either the first or second region, or simultaneously based on both regions. Then, the difference between the first and second filtered images can be calculated by subtracting the first and second filtered values ​​for each pixel; the difference can be the absolute value. Based on the difference between the first and second filtered images, a difference image can be obtained, which is the filtered image, as shown in Figure 2(b).

[0043] In this embodiment, because the first region is established centered on each pixel of the test image, rather than a region at a fixed location, the first regions established by the pixels of the test image during mean filtering overlap, which can better reflect detail anomalies in specific locations. Similarly, the second regions established by the pixels of the test image during mean filtering also overlap, which can better reflect detail anomalies in specific locations. In addition, the first and second regions are of different sizes. The first and second filter values ​​are obtained based on the first and second regions, respectively. The first and second regions represent the processing results of the pixels to be processed, respectively. The difference image obtained by the difference between the first filter mean and the second filter mean can better reflect detail anomalies in specific locations.

[0044] In one embodiment of the invention, the method of establishing a first region centered on the pixel to be processed includes: selecting a matrix block of size a*a as the first region centered on the pixel to be processed; the method of establishing a second region centered on the pixel to be processed includes: selecting a matrix block of size b*b as the second region centered on the pixel to be processed; where a and b are not equal and are both odd numbers greater than 1.

[0045] 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 4 The method of defining the pixel to be processed may include: taking the previous pixel as the pixel to be processed, and obtaining 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, and obtaining 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 that the second region corresponding to the previous pixel and the second region corresponding to the next pixel overlap.

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

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

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

[0049] like Figure 4As 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:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[0065] The method for obtaining the linear fit of feature points within a corresponding block based on feature points can be implemented using the Hough transform, which is a very important method for detecting the shape of discontinuities. It achieves the fitting of lines and curves by transforming the image coordinate space to the parameter space. Figure 6 This is a schematic diagram illustrating the conversion from a Cartesian coordinate system to a polar coordinate system according to an embodiment of the present invention. Figure 6 As shown, the image processing method in this embodiment is basically the same as that in the above embodiment, except that: the method for obtaining the linear fitting degree of feature points within a corresponding block based on feature points includes: establishing a rectangular coordinate system and obtaining the rectangular coordinate values ​​(X, Y) of the feature points within the block; converting the rectangular coordinate system to a polar coordinate system, setting a preset polar angle θ, and obtaining the parameter ρ corresponding to the feature point based on the rectangular coordinate values ​​(X, Y) and the preset polar angle θ of the feature points within the block, and obtaining the perpendicular polar coordinate values ​​(ρ, θ) of the feature points; calculating the number of identical polar coordinate values ​​among the feature points within the block, and obtaining the cumulative value of the number of each polar coordinate value. It can be understood that the cumulative value of the number of identical polar coordinate values ​​here refers to obtaining the feature points with the same perpendicular polar coordinate values ​​(ρ, θ), and counting them to obtain the cumulative value. For example, if there are two identical perpendicular polar coordinate values, it is counted as one accumulation, i.e., the cumulative value is 1.

[0066] Specifically, the linear fit degree is obtained for each of the divided blocks. Taking the linear fit degree of one block as an example, if there are two feature points in the block that are both on the same straight line, then when the parameter θ is a set value, the parameter ρ obtained from the coordinates of these two feature points, such as rectangular coordinates (X, Y), should be the same. When judging whether the parameter ρ obtained by substituting the coordinates of the feature points in the block into the set value of parameter θ is the same, if they are the same, they are accumulated. That is, if the parameter θ is a set value, the more feature points in the block that make the parameter ρ the same, the larger the accumulated value will be, indicating that there are accumulated values ​​+ 1 feature points in the block that are on the same straight line. According to different parameters θ, the coordinates of the feature points in the block are substituted to obtain the corresponding parameter ρ, and the same parameter ρ is accumulated; thus, the block has different accumulated values ​​under different parameters ρ and parameter θ.

[0067] In one embodiment of the invention, the method for obtaining the linear fitting degree of feature points within a corresponding block based on feature points further includes: defining the ratio of the maximum value among the accumulated values ​​to the average value among the accumulated values ​​as the linear fitting degree of the feature points within the block; or, adding the accumulated value of the number of polar coordinate values ​​and the accumulated value of the number of polar coordinate values ​​having the same preset polar angle θ and being adjacent to at least one parameter ρ, respectively, and defining the ratio of the maximum value among the accumulated values ​​to the average value among the accumulated values ​​as the linear fitting degree of the feature points within the block. Specifically, the ratio of the maximum value to the average value of the accumulated values ​​for each block under different parameters ρ and θ is calculated, and the average value is the average of all accumulated values, thereby determining the linear fitting degree of the feature points within the block based on the magnitude of this ratio. Furthermore, the cumulative value of each polar coordinate value and the cumulative value of polar coordinate values ​​with the same preset polar angle θ and at least one adjacent parameter ρ can be added together. That is, when the mutual spacing of multiple straight lines obtained from feature points is within a set threshold, the lines can be widened. Multiple straight lines with mutual spacing within the set threshold can be considered as the same straight line, and the corresponding feature points can be considered to lie on this straight line. The spacing can be calculated by difference based on parameter ρ. This method of calculating the straight line fitting degree can correct for minor deviations during calculation, resulting in better detection of straight-line diagonal patterns.

[0068] In one embodiment of the invention, a method for obtaining the perpendicular polar coordinates (ρ, θ) of a feature point based on its rectangular coordinates (X, Y) and a preset polar angle θ includes: substituting the rectangular coordinates (X, Y) and the preset polar angle θ of the feature point within the block into ρ = Xcosθ + Ysinθ to obtain the parameter ρ; obtaining the number of identical parameters ρ for each feature point under the same preset polar angle θ and accumulating them to obtain the accumulated value of the number of polar coordinates; calculating the ratio of the maximum value to the average value of the accumulated values ​​for each block under different parameters ρ and preset polar angle θ to determine the linear fitting degree of the feature point within each block. In this embodiment, the rectangular coordinates (X, Y) and the preset polar angle θ of the feature point within the block can be substituted into the formula ρ = Xcosθ + Ysinθ to obtain the parameter ρ, and this parameter ρ can be used to calculate the linear fitting degree.

[0069] It is understood that those skilled in the art can make corresponding transformations to the above-described embodiments. For example, a coordinate system and a linear equation ρ = Xcosθ + Ysinθ can be established, where different straight lines are obtained based on different values ​​of parameters ρ and θ. Then, different parameters ρ and θ are set, and it is determined whether the coordinate values ​​of feature points within at least one block satisfy the linear equation. If they do, the values ​​are accumulated to obtain the accumulated values ​​of at least one block under different parameters ρ and θ. The ratio of the maximum value to the average value of the accumulated values ​​of at least one block under different parameters ρ and θ is calculated to determine the linear fit of the feature points within at least one block. This transformation scheme should also fall within the protection scope of this embodiment.

[0070] It is understood that those skilled in the art can obtain the linear fit degree without being limited to the above-described embodiments.

[0071] In one embodiment of the invention, the method for establishing a rectangular coordinate system includes: establishing a rectangular coordinate system with the center of at least one block as the origin. However, the embodiments of the invention are not limited thereto; for example, a rectangular coordinate system may be established with the upper left corner of the block as the origin.

[0072] Figure 7 This is a schematic diagram of a two-dimensional lookup table established according to an embodiment of the present invention. In one embodiment, the image processing method includes: setting a preset polar angle θ to traverse from 0 to 360 degrees to obtain the polar coordinate values ​​of each feature point under the preset polar angle θ of 0 to 360 degrees, thereby obtaining a two-dimensional array (ρ, θ); based on the two-dimensional array (ρ, θ), obtaining the cumulative value of each block under different parameters ρ and the preset polar angle θ, and establishing a two-dimensional lookup table.

[0073] like Figure 7As shown, a two-dimensional array (ρ, θ) is created. This array corresponds to a straight line when the parameters θ and ρ are determined. The parameter θ is iterated through from 0 to 360 degrees (e.g., 1°, 2°, ... to 360°). When the obtained parameter ρ is the same, the sum is accumulated. This allows the accumulated value to be filled in the corresponding positions of the parameters θ and ρ in a two-dimensional lookup table. For example... Figure 7 It is relatively easy to see that the maximum cumulative value of the feature points in this block is 3, meaning that there are at most 4 feature points on the same straight line in this block. Therefore, the distribution of the straight-line diagonal stripes can be easily observed. Based on the corresponding parameters θ and ρ, the position and shape of the straight-line diagonal stripes can be determined. In one embodiment, the corresponding straight line can be drawn according to a two-dimensional reference table to obtain the diagonal stripe test pattern.

[0074] The image processing method of this embodiment can complete the screening test for straight diagonal patterns in one test, which facilitates the testing and processing of images.

[0075] 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. For implementation details of the computer device in this embodiment, please refer to the foregoing embodiments; repeated details will not be described again.

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

[0077] Because existing technologies do not specifically test for straight diagonal lines, but instead use methods similar to testing for dirt, they cannot effectively distinguish between real dirt and diagonal lines. However, the image processing method, computer device, and computer-readable storage medium for detail detection provided in this invention can quantify image diagonal lines of different degrees into numbers of different sizes. The test can be completed simply by determining the control specifications, and a single test can be used to screen straight diagonal lines, which facilitates image testing and processing.

[0078] 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 arranged feature points. The detail detection image is divided into multiple blocks according to the size of a preset block. The straight-line fitting degree of the corresponding feature points in the block is obtained based on the feature points. The maximum value of the straight-line fitting degree is defined as the abnormal straightness of 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 is given; 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. Based on the fourth calculated value and the fifth calculated value, the second filtered value corresponding to the previous pixel is obtained, where m is the column number of the corresponding 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 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 scaling process for 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 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, A method for binarizing the filtered image to obtain a detail detection image with the arranged feature points includes: Define a preset threshold, and define the pixel values ​​of pixels in the filtered image that are greater than the preset threshold as the feature points, and obtain a detail detection image with the feature points arranged in it.

8. The image processing method as described in claim 1, characterized in that, A method for obtaining the linear fitting degree of feature points within the corresponding block based on the feature points includes: Establish a Cartesian coordinate system and obtain the Cartesian coordinates (X, Y) of the feature points within the block; The rectangular coordinate system is converted to a polar coordinate system, a preset polar angle θ is set, and based on the rectangular coordinate values ​​(X, Y) of the feature points in the block and the preset polar angle θ, the parameter ρ corresponding to the feature point is obtained, and the perpendicular polar coordinate values ​​(ρ, θ) of the feature point are obtained. Calculate the number of identical polar coordinate values ​​among the feature points within the block, and obtain the cumulative value of the number of each polar coordinate value.

9. The image processing method as described in claim 8, characterized in that, The method for obtaining the linear fitting degree of the corresponding feature points within the block based on the feature points further includes: The ratio of the maximum value among the accumulated values ​​to the average value among the accumulated values ​​is defined as the linear fit degree of the feature points within the block; Alternatively, the sum of the number of each polar coordinate value and the sum of the number of polar coordinate values ​​having the same preset polar angle θ and being adjacent to at least one parameter ρ are added together, and the ratio of the maximum value to the average of the sums is defined as the linear fitting degree of the feature points within the block.

10. The image processing method as described in claim 8, characterized in that, A method for obtaining the perpendicular polar coordinates (ρ, θ) of a feature point based on its rectangular coordinates (X, Y) and the preset polar angle θ, includes: Substitute the rectangular coordinates (X, Y) of the feature points within the block with the preset polar angle θ into ρ=Xcosθ+Ysinθ to obtain the parameter ρ. Then, obtain the number of times the parameter ρ of each feature point is the same under the same preset polar angle θ and accumulate them to obtain the accumulated value of the number of each polar coordinate value. The ratio of the maximum value to the average value of the accumulated values ​​of each block under different parameters ρ and the preset polar angle θ is calculated to determine the linear fit of the feature points within each block.

11. The image processing method as described in claim 8, characterized in that, include: The preset polar angle θ is traversed from 0 to 360 degrees to obtain the polar coordinate values ​​of each feature point under the preset polar angle θ from 0 to 360 degrees, and a two-dimensional array (ρ, θ) is obtained. Based on the two-dimensional array (ρ, θ), the cumulative value of each block under different parameters ρ and preset polar angles θ is obtained, and a two-dimensional comparison table is established.

12. The image processing method as described in claim 8, characterized in that, The method for establishing a rectangular coordinate system includes: The rectangular coordinate system is established with the center of the block as the origin; Alternatively, the Cartesian coordinate system can be established with the top left corner of the detail detection image as the origin.

13. 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 12.

14. 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 12.

Citation Information

Patent Citations

  • Straight line detection method and straight line detection device

    CN105069786A

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

    EP2827298A1