Image bad line detection method, device and computer-readable storage medium
By detecting the pixel value differences of infrared thermal image pixels and identifying and replacing bad lines, the image quality problems caused by infrared detector cell abnormalities are solved, and high-accurate bad lines detection is achieved.
Patent Information
- Application Number
- CN202210730284.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-24
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2042-06-24
AI Technical Summary
The abnormal response rate of infrared detector cells causes bad points, bad clusters and bad columns on infrared thermal imaging images, affecting image quality.
By obtaining the pixel value distribution of the pixel lines of the image to be processed, the pixel value difference situation is determined, the pixel lines that meet the bad line conditions are selected as the bad line, and the mean filtering process is performed to reduce the influence of noise, and the distribution characteristics of the bad line are used for detection.
It improves the accuracy of bad line detection and reduces the impact of individual pixel abnormalities on the detection effect. It is suitable for various scenarios and is simple to operate.
Smart Images

Figure CN115272186B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a method, device, and computer-readable storage medium for detecting bad lines in an image. Background Art
[0002] Object imaging technology transfers the optical information of an object as energy to a photosensitive material, ultimately creating a visible image. For example, infrared thermal imaging utilizes the differences in the intensity of an object's infrared radiation to create an image. Its advantages, such as its unaffected by light and strong penetrating power, have led to its widespread application in security, military, and medical fields.
[0003] However, due to the influence of imaging technology equipment, for example, infrared thermal imaging technology is limited by the current infrared detector manufacturing process. The infrared detector pixels are prone to abnormal response rates, forming bad points, bad clusters, and even bad columns on the image, which greatly affects the image quality. Summary of the Invention
[0004] The main technical problem solved by the present application is to provide a method, device and computer-readable storage medium for detecting bad lines in an image, which can improve the accuracy of bad line detection.
[0005] In order to solve the above technical problems, a technical solution adopted in the present application is: to provide a bad line detection method for an image, the method comprising: obtaining an image to be processed; determining the pixel value distribution of each pixel line in the image to be processed, wherein the pixel line includes a number of in-line pixel points forming a line segment, and the pixel value distribution of the pixel line includes a first pixel value difference between the several in-line pixel points and / or a second pixel value difference between several out-line pixel points and several in-line pixel points, and the out-line pixel points are pixel points in the image to be processed that are located within a preset pixel distance of the pixel line; selecting a pixel line whose pixel value distribution meets the bad line condition as the bad line in the image to be processed.
[0006] Among them, determining the pixel value distribution of each pixel line in the image to be processed includes: for each pixel line, taking at least part of the in-line pixel points on the pixel line as the first current pixel points, obtaining the pixel difference between each first current pixel point and the corresponding first associated pixel point to obtain the first pixel value difference, wherein the first associated pixel point of the first current pixel point is the in-line pixel point on the pixel line that is spaced a first number of pixels away from the first current pixel point; and / or, for each pixel line, taking at least part of the in-line pixel points on the pixel line as the second current pixel points, obtaining the pixel difference between each second current pixel point and the corresponding second associated pixel point to obtain the second pixel value difference, wherein the second associated pixel point of the second current pixel point is the out-line pixel point that is spaced a second number of pixels away from the second current pixel point, and the second associated pixel point and the second current pixel point are connected to form a line segment in a first preset direction, and the angle between the first preset direction and the pixel line is greater than 0.
[0007] Among them, if the pixel value distribution includes a first pixel value difference situation, the bad line condition includes that the number of first current pixel points on the pixel line that meet the first difference condition is greater than a first threshold; and / or, if the pixel value distribution includes a second pixel value difference situation, the bad line condition includes that the number of second current pixel points on the pixel line that meet the second difference condition is greater than a second threshold.
[0008] Among them, the first current pixel point has two first-associated pixel points, and the first difference condition is that the product of the first pixel difference between the first current pixel point and one of the first-associated pixel points and the second pixel difference between the first current pixel point and the other first-associated pixel point is a positive number, and the absolute value of the first pixel difference is greater than the first pixel threshold, and the absolute value of the second pixel difference is greater than the second pixel threshold; the second current pixel point has two second-associated pixel points, and the second difference condition is that the third pixel difference between the second current pixel point and one of the second-associated pixel points is greater than the third pixel threshold, and the fourth pixel difference between the second current pixel point and the other second-associated pixel point is greater than the fourth pixel threshold, and the absolute value of the third pixel difference is less than the fifth pixel threshold, and the absolute value of the fourth pixel difference is less than the sixth pixel threshold; or, the third pixel difference is less than the inverse of the third pixel threshold, the fourth pixel difference is less than the inverse of the fourth pixel threshold, and the absolute value of the third pixel difference is less than the fifth pixel threshold, and the absolute value of the fourth pixel difference is less than the sixth pixel threshold.
[0009] In which, at least one of the first threshold and the second threshold is determined based on the resolution of the image to be processed; and / or, if the pixel value distribution includes a first pixel value difference, the bad line condition includes that the number of target pixel points on the pixel line is greater than the first threshold, and the target pixel point is the first current pixel point that meets the first difference condition and the preset distribution condition, and the preset distribution condition is that the target pixel point and at least some other target pixel points are continuously distributed to a preset length.
[0010] The first preset direction is perpendicular to the pixel line.
[0011] Among them, if the pixel value distribution includes a second pixel value difference, before determining the second pixel value difference of each pixel line in the image to be processed, the image bad line detection method also includes: performing mean filtering processing on the image to be processed in a second preset direction, and the second preset direction is the extension direction of the pixel line.
[0012] After selecting pixel lines whose pixel value distribution meets the bad line condition as bad lines in the image to be processed, the bad line detection method for an image further includes: replacing the bad lines with non-bad lines located at preset positions of the bad lines.
[0013] The pixel line is a pixel column or a pixel row, and / or the image to be processed is an infrared thermal imaging image.
[0014] To solve the above technical problems, another technical solution adopted in this application is: to provide an image bad line detection device, which includes a memory and a processor, the memory stores program instructions, and the processor is used to execute the program instructions to implement the above-mentioned image bad line detection method.
[0015] In order to solve the above technical problems, another technical solution adopted in the present application is: providing a computer-readable storage medium, wherein the computer-readable storage medium is used to store program instructions, and the program instructions can be executed to implement the above-mentioned bad line detection method for an image.
[0016] In the above embodiment, whether each pixel line in the image to be processed is a bad line is determined by determining whether its pixel value distribution satisfies the bad line condition. Therefore, performing bad line detection on the image to be processed based on its distribution characteristics can reduce the impact of individual pixel anomalies on bad line detection, improve the accuracy of bad line detection, and simplify operation. Furthermore, it is less affected by image scene information, brightness, and other factors, and has few limitations, making it applicable to a variety of scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 This is a flow chart of an embodiment of a bad line detection method for an image provided by the present application;
[0018] Figure 2 This is a global schematic diagram of an embodiment of a bad line provided by the present application;
[0019] Figure 3 This is a partially enlarged schematic diagram of an embodiment of a bad line provided by the present application;
[0020] Figure 4 This is a structural diagram of an embodiment of an image bad line detection device provided by the present application;
[0021] Figure 5 It is a structural diagram of an embodiment of a computer-readable storage medium provided by this application. DETAILED DESCRIPTION
[0022] The following describes the embodiments of the present application in detail with reference to the accompanying drawings.
[0023] In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures, interfaces, and technologies are provided to facilitate a thorough understanding of the present application.
[0024] The term "and / or" in this article is simply a description of the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects are in an "or" relationship. In addition, "many" in this article means two or more than two. In addition, the term "at least one" in this article means any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.
[0025] See also Figure 1 , Figure 1 It is a flow chart of an embodiment of the bad line detection method of the image provided by the present application. It should be noted that if there are substantially the same results, this embodiment does not use Figure 1 The process sequence shown is limited. Figure 1 As shown, this embodiment includes:
[0026] Step S11: Acquire the image to be processed.
[0027] The method of this embodiment is used to detect bad lines in an image to be processed. The image to be processed can be any image that requires bad line detection. The image to be processed described in this article can be, but is not limited to, high-resolution images with a resolution exceeding 4K, multi-eye stitched images, stitched panoramic images, etc., and no specific limitation is made here.
[0028] In one embodiment, the image to be processed can be obtained from local storage or cloud storage. It is understandable that in other embodiments, the image to be processed can also be obtained by capturing the current environment through an image capture device, which is not specifically limited here.
[0029] In one embodiment, the image to be processed is an infrared thermal image. Because infrared thermal imaging technology utilizes variations in infrared radiation intensity from an object to create an image, due to limitations in infrared detector manufacturing processes, infrared detector pixels are prone to abnormal response rates, resulting in the appearance of broken lines in the infrared thermal image. It is understood that in other embodiments, the image to be processed may also be a grayscale image, etc., and this is not specifically limited here.
[0030] Step S12: Determine the pixel value distribution of each pixel line in the image to be processed.
[0031] In this embodiment, the pixel value distribution of each pixel line in the image to be processed is determined. Since the pixel value distribution of the bad line is known, by determining the pixel value distribution of each pixel line in the image to be processed, it is possible to facilitate the subsequent determination of whether each pixel line in the image to be processed is a bad line based on the pixel value distribution of each pixel line and the pixel value distribution of the known bad line. In one embodiment, the pixel line can be a pixel row or pixel column of the image to be processed. It is understandable that in other embodiments, the pixel line can also be a pixel oblique line, a pixel curve, etc. in the image to be processed, which is not specifically limited here. It should be noted that, hereinafter, for the sake of ease of description, this application will take the pixel line as a pixel column as an example for description, but it is understandable that such a description does not limit the specific type of pixel line.
[0032] In which, the pixel line includes several in-line pixel points forming a line segment, and the pixel value distribution of the pixel line includes the first pixel value difference between the several in-line pixel points constituting the pixel line and / or the second pixel value difference between several out-line pixel points and the several in-line pixel points constituting the pixel line.
[0033] In one embodiment, for each pixel line, at least a portion of the pixels within the pixel line are used as first current pixels, and pixel differences between each first current pixel and a corresponding first associated pixel are obtained to obtain a first pixel value difference for the pixel line, wherein the first associated pixel of the first current pixel is a pixel on the pixel line that is spaced a first number of pixels from the first current pixel. In other words, for each pixel line, at least a portion of the pixels within the pixel line are used as first current pixels, and pixel differences between each first current pixel and a pixel on the corresponding pixel line that is spaced a first number of pixels from the first current pixel are obtained; then, the first pixel value difference for the pixel line is determined based on the pixel differences between each first current pixel and the corresponding first associated pixel.
[0034] Among them, the number of in-line pixel points on the pixel line as the first current pixel point is not limited, and can be specifically set according to actual use needs. For example, all the in-line pixel points included in the pixel line are respectively used as the first current pixel point, or two-thirds of the in-line pixel points included in the pixel line are respectively used as the first current pixel point. Exemplarily, each in-line pixel point on the pixel line is respectively used as the first current pixel point, and the pixel difference between each first current pixel point and the corresponding first associated pixel point is obtained to obtain the first pixel value difference of the pixel line; by using each in-line pixel point on the pixel line as the first current pixel point, each in-line pixel point on the pixel line is analyzed, so that each pixel line can be analyzed more comprehensively, so that the obtained first pixel value difference is more accurate, and thus the bad line in the image to be processed determined subsequently is more accurate, thereby improving the accuracy of bad line detection. In addition, the first number is not limited, and can be specifically set according to actual use needs. For example, the first number is an odd number such as 1, 3, 5 or 7. For example, the pixel line is pixel column A and the first number is 1; pixel column A includes in-line pixel points a1, in-line pixel points a2, in-line pixel points a3, in-line pixel points a4 and in-line pixel points a5 that are spaced apart; since the first number is 1, when in-line pixel point a1 is the first current pixel point, the first associated pixel point of in-line pixel point a1 that is the first current pixel point is in-line pixel point a2 that is spaced 1 pixel apart from in-line pixel point a1; and when in-line pixel point a2 is the first current pixel point, the first associated pixel point of in-line pixel point a1 that is the first current pixel point is in-line pixel point a2 that is spaced 1 pixel apart from in-line pixel point a1. 2 is the in-line pixel point a1 or the in-line pixel point a3 which is 1 pixel away from the in-line pixel point a2; and when the in-line pixel point a3 is the first current pixel point, the first associated pixel point of the in-line pixel point a3 which is the first current pixel point is the in-line pixel point a2 or the in-line pixel point a4 which is 1 pixel away from the in-line pixel point a3; and when the in-line pixel point a4 is the first current pixel point, the first associated pixel point of the in-line pixel point a4 which is the first current pixel point is the in-line pixel point a3 which is 1 pixel away from the in-line pixel point a4.
[0035] The specific formula for obtaining the pixel difference between each first current pixel and the corresponding first associated pixel is as follows:
[0036] diff1(i,j)=Img(i,j)-Img(ia,j)
[0037] diff2(i,j)=Img(i,j)-Img(i+a,j)
[0038] Among them, α represents the first number; (i, j) represents the coordinates of the first current pixel point; (i-α, j) and (i+α, j) both represent the coordinates of the pixel point on the pixel line that is separated from the first current pixel point by the first number of pixels; diff1(i, j) and diff2(i, j) both represent the pixel difference between the first current pixel point and the corresponding first associated pixel point.
[0039] In one embodiment, the first associated pixel point of the first current pixel point may be one. When the first associated pixel point of the first current pixel point is one, the first associated pixel point of the first current pixel point, i.e., the inline pixel point spaced a first number of pixels from the first current pixel point, may be the inline pixel point before it or the inline pixel point after it. For example, taking the pixel line as pixel column A as an example, when the first associated pixel point of the first current pixel point is one, for each first current pixel point in pixel column A, the inline pixel point spaced a first number of pixels from the first current pixel point may be the inline pixel point of the previous row or the inline pixel point of the next row. For another example, taking the pixel line as pixel row B as an example, when the first associated pixel point of the first current pixel point is one, for each first current pixel point in pixel row B, the inline pixel point spaced a first number of pixels from the first current pixel point may be the inline pixel point of the previous row or the inline pixel point of the next row. It is understandable that in other embodiments, the first associated pixel point of the first current pixel point may also be two, which is not specifically limited here. Among them, when the number of first associated pixel points of the first current pixel point is 2, for each first current pixel point in the pixel line, the first associated pixel point of the first current pixel point, that is, the pixel point in the line that is separated from the first current pixel point by the first number of pixels, is the pixel point in the line before it and the pixel point in the line after it.
[0040] Among them, for the above formula, it should be noted that when the first associated pixel point of the first current pixel point is one, the formula corresponding to diff1(i,j) or diff2(i,j) is used according to the specific situation to calculate the pixel difference between the first current pixel point and the corresponding first associated pixel point; and when the first associated pixel points of the first current pixel point are two, the formula corresponding to diff1(i,j) is used to calculate the pixel difference between the first current pixel point and one of the first associated pixel points, and the formula corresponding to diff2(i,j) is used to calculate the pixel difference between the first current pixel point and the other first associated pixel point. For example, take the pixel line as pixel column A, the first associated pixel point of the first current pixel point as 1, and the first quantity as 1 as an example; for the first current pixel point a1 in pixel column A, the in-line pixel point that is 1 pixel away from the first current pixel point a1 may be the in-line pixel point a2 in the previous row, or it may be the in-line pixel point a3 in the next row; therefore, when the in-line pixel point that is 1 pixel away from the first current pixel point a1 is the in-line pixel point a2 in the previous row, the formula corresponding to diff1(i,j) is used to calculate the pixel difference between the first current pixel point a1 and the in-line pixel point a2; and when the in-line pixel point that is 1 pixel away from the first current pixel point a1 is the in-line pixel point a3 in the next row, the formula corresponding to diff2(i,j) is used to calculate the pixel difference between the first current pixel point a1 and the in-line pixel point a3.
[0041] In one embodiment, for each pixel line, at least a portion of the inline pixel points on the pixel line are used as second current pixel points, and a pixel difference between each second current pixel point and a corresponding second associated pixel point is obtained to obtain a second pixel value difference of the pixel line, wherein the second associated pixel point of the second current pixel point is an off-line pixel point that is spaced a second number of pixels from the second current pixel point. In other words, for each pixel line, at least a portion of the inline pixel points on the pixel line are used as second current pixel points, and a pixel difference between each second current pixel point and an off-line pixel point that is spaced a second number of pixels from the second current pixel point is obtained; then, the second pixel value difference of the pixel line is determined based on the pixel difference between each second current pixel point and the corresponding second associated pixel point.
[0042] Among them, the number of in-line pixel points on the pixel line that serve as the second current pixel point is not limited, and can be specifically set according to actual use needs. For example, all in-line pixel points included in the pixel line are respectively used as the second current pixel points, or two-thirds of the in-line pixel points included in the pixel line are respectively used as the second current pixel points. Exemplarily, each in-line pixel point on the pixel line is respectively used as the second current pixel point, and the pixel difference between each second current pixel point and the corresponding second associated pixel point is obtained to obtain the second pixel value difference of the pixel line; by using each in-line pixel point on the pixel line as the second current pixel point, each in-line pixel point on the pixel line is analyzed, so that each pixel line can be analyzed more comprehensively, so that the obtained second pixel value difference is more accurate, and thus the bad line in the image to be processed determined subsequently is more accurate, thereby improving the accuracy of bad line detection. In addition, the second number is not limited, and can be specifically set according to actual use needs. For example, the second number is 1 or 2, etc. For example, the pixel line is a pixel column and the second number is 1; the image to be processed includes pixel column A, pixel column B, pixel column C and pixel column D that are spaced apart; since the second number is 1, when at least part of the in-line pixel points in pixel column A are the second current pixel points, the second associated pixel point of the second current pixel point in pixel column A is an out-line pixel point that is spaced 1 pixel apart from the second current pixel point, that is, the second associated pixel point of the second current pixel point in pixel column A is a pixel point on pixel column B; the second associated pixel point of the second current pixel point in pixel column B is a pixel point that is spaced 1 pixel apart from the second current pixel point. The second associated pixel point of the second current pixel point in pixel column B is a pixel point on pixel column A or pixel column C; the second associated pixel point of the second current pixel point in pixel column C is an out-of-line pixel point that is 1 pixel apart from the second current pixel point, that is, the second associated pixel point of the second current pixel point in pixel column C is a pixel point on pixel column B or pixel column D; the second associated pixel point of the second current pixel point in pixel column D is an out-of-line pixel point that is 1 pixel apart from the second current pixel point, that is, the second associated pixel point of the second current pixel point in pixel column D is a pixel point on pixel column C.
[0043] The specific formula for obtaining the pixel difference between each second current pixel and the corresponding second associated pixel is as follows:
[0044] diff3(i,j)=Img(i,j)-Img(i,jd)
[0045] diff4(i,j)=Img(i,j)-Img(i,j+d)
[0046] Wherein, d represents the second number; (i, j) represents the coordinates of the second current pixel point; (i, jd) and (i, j+d) both represent the coordinates of the off-line pixel point on the pixel line that is separated from the second current pixel point by the second number of pixels; diff3(i, j) and diff4(i, j) both represent the pixel difference between the second current pixel point and the corresponding second associated pixel point.
[0047] In one embodiment, the second associated pixel point of the second current pixel point may be one. When the second associated pixel point of the second current pixel point is one, the second associated pixel point of the second current pixel point, i.e., the off-line pixel point that is spaced a second number of pixels from the second current pixel point, may be the off-line pixel point before it or the off-line pixel point after it. For example, taking a pixel line as a pixel column as an example, when the second associated pixel point of the second current pixel point is one, for each second current pixel point in the pixel column, the off-line pixel point that is spaced a second number of pixels from the second current pixel point may be the off-line pixel point in the column before it or the off-line pixel point in the column after it. For another example, taking a pixel line as a pixel row as an example, when the second associated pixel point of the second current pixel point is one, for each second current pixel point in a pixel row, the off-line pixel point that is spaced a second number of pixels from the second current pixel point may be the off-line pixel point in the row before it or the off-line pixel point in the row after it. It is understandable that in other embodiments, the second associated pixel point of the second current pixel point may also be two, which is not specifically limited here. Among them, when the number of second associated pixel points of the second current pixel point is 2, for each second current pixel point in the pixel line, the second associated pixel point of the second current pixel point, that is, the off-line pixel point that is separated from the second current pixel point by the second number of pixels, is the off-line pixel point before it and the off-line pixel point after it.
[0048] Among them, for the above formula, it should be noted that when the second associated pixel point of the second current pixel point is one, the formula corresponding to diff3(i,j) or diff4(i,j) is used according to the specific situation to calculate the pixel difference between the second current pixel point and the corresponding second associated pixel point; and when the second associated pixel points of the second current pixel point are two, the formula corresponding to diff3(i,j) is used to calculate the pixel difference between the second current pixel point and one of the second associated pixel points, and the formula corresponding to diff4(i,j) is used to calculate the pixel difference between the second current pixel point and the other second associated pixel point. For example, take the pixel line as pixel column A, the second associated pixel point of the second current pixel point as 1, and the second quantity as 1 as an example; for the second current pixel point a1 in pixel column A, the out-of-line pixel point that is 1 pixel away from the second current pixel point a1 may be an out-of-line pixel point on its previous pixel column, i.e., pixel column B, or it may be an out-of-line pixel point on its subsequent pixel column, i.e., pixel column C; therefore, when the out-of-line pixel point that is 1 pixel away from the second current pixel point a1 is an out-of-line pixel point on its previous pixel column, i.e., pixel column B, the formula corresponding to diff3(i,j) is used to calculate the pixel difference between the second current pixel point a1 and the out-of-line pixel point; and when the out-of-line pixel point that is 1 pixel away from the second current pixel point a1 is an out-of-line pixel point on its subsequent pixel column, i.e., pixel column C, the formula corresponding to diff4(i,j) is used to calculate the pixel difference between the second current pixel point a1 and the out-of-line pixel point.
[0049] In addition, in the above embodiment, the second associated pixel point of the second current pixel point is connected to the second current pixel point to form a line segment of the first preset direction, and the angle between the first preset direction and the pixel line is greater than 0. In a specific embodiment, the angle between the first preset direction and the pixel line is equal to 90°. For example, taking the image to be processed as comprising pixel line A, pixel line B and pixel point C set at intervals, and the second number being 1 as an example; for each second current pixel point on pixel line B, when the off-line pixel point spaced 1 pixel away from the second current pixel point b is the off-line pixel point on the previous pixel column, i.e., pixel column A, the second associated pixel point of the second current pixel point b is the pixel point on pixel line A that is located in the same row as the second current pixel point b; and when the off-line pixel point spaced 1 pixel away from the second current pixel point b is the off-line pixel point on the next pixel column, i.e., pixel column C, the second associated pixel point of the second current pixel point b is the pixel point on pixel line C that is located in the same row as the second current pixel point b. It is understandable that in other specific implementations, the angle between the first preset direction and the pixel line may also be other degrees, which is not specifically limited here.
[0050] Since there may be noise points in the image to be processed, the second pixel value difference of each pixel line in the image to be processed is not determined accurately. Therefore, in one embodiment, before determining the second pixel value difference of each pixel line in the image to be processed, the image to be processed is subjected to mean filtering in a second preset direction to filter out the noise points in the image to be processed. The second preset direction is the extension direction of the pixel line. For example, when the pixel line is a pixel column of the image to be processed, the second preset direction is the extension direction of the pixel column, that is, the vertical direction of the image to be processed. At this time, the image to be processed is subjected to mean filtering in the vertical direction. For another example, when the pixel line is a pixel row of the image to be processed, the second preset direction is the extension direction of the pixel row, that is, the horizontal direction of the image to be processed. At this time, the image to be processed is subjected to mean filtering in the horizontal direction.
[0051] Specifically, the image to be processed is subjected to mean filtering processing with a window size of a preset number of rows and a preset number of columns. It should be noted that for edge data in the image to be processed, the edge can be padded by mirroring or copying the edge before performing mean filtering processing. Among them, the preset number of rows and the preset number of columns are not limited and can be specifically set according to actual use needs. For example, when the pixel line is a pixel column, the preset number of rows is 3 and the preset number of columns is 1. For another example, when the pixel line is a pixel row, the preset number of rows is 1 and the preset number of columns is 3.
[0052] Step S13: Select pixel lines whose pixel value distribution satisfies the bad line condition as bad lines in the image to be processed.
[0053] In this embodiment, pixel lines whose pixel value distribution satisfies the bad line condition are selected as bad lines in the image to be processed. Since the pixel value distribution of a pixel line that satisfies the bad line condition is considered to satisfy the bad line distribution characteristic, the pixel line whose pixel value distribution satisfies the bad line condition is considered to be a bad line.
[0054] Specifically, if Figure 2 、 Figure 3 As shown, Figure 2 This is a global schematic diagram of an embodiment of a bad line provided by this application. Figure 3This is a partially enlarged schematic diagram of an embodiment of a bad line provided by the present application. The pixel value distribution of pixel line 1 is a first pixel value difference. When the first pixel value difference of pixel line 1 meets the bad line condition, it can be regarded that the pixel value distribution of pixel line 1 meets the distribution characteristics of a bad line, so pixel line 1 is a bad line; and because the pixel value distribution of pixel line 1 meets the distribution characteristics of a bad line with alternating light and dark distribution characteristics, pixel line 1 is a bad line with alternating light and dark distribution characteristics. The pixel value distribution of pixel line 2 is a second pixel value difference. When the second pixel value difference of pixel line 2 meets the bad line condition, it can be regarded that the pixel value distribution of pixel line 2 meets the distribution characteristics of a bad line, so pixel line 2 is a bad line; and because the pixel value distribution of pixel line 2 meets the distribution characteristics of a through-line bad line, pixel line 2 is a through-line bad line. It should be noted that when the pixel value distribution of each pixel point in the image to be processed includes the first pixel value difference and the second pixel value difference, the bad line detection method for the image provided by the present application can simultaneously detect bad lines with alternating light and dark distribution characteristics and through-line bad lines.
[0055] In the above-mentioned embodiment, by determining whether the pixel value distribution of each pixel line in the image to be processed meets the bad line condition, it is determined whether each pixel line is a bad line in the image to be processed. Therefore, the image bad line detection method provided by this application performs bad line detection on the image to be processed based on the distribution characteristics of the bad line itself. It can reduce the impact of individual pixel abnormalities on the bad line detection effect, improve the accuracy of bad line detection, and is simple to operate. In addition, it is less affected by the scene information, brightness, etc. of the image and has few restrictions, making it applicable to various different scenes.
[0056] In one embodiment, if it is determined that the pixel value distribution of each pixel line in the image to be processed includes a first pixel value difference, then the bad line condition includes the number of first current pixel points on the pixel line that meet the first difference condition being greater than a first threshold. For example, taking the image to be processed as including pixel lines A, B, C, D, and E, and determining that the pixel value distribution of each pixel line in the image to be processed includes the first pixel value difference, since the number of first current pixel points on pixel lines B and D that meet the first difference condition is greater than the first threshold, pixel lines B and D are considered bad lines in the image to be processed.
[0057] The first threshold value is not limited and can be set specifically according to actual use needs. In one embodiment, the first threshold value is a fixed value, such as the first threshold value is 50, etc. In order to enhance the adaptability of the first threshold value and thus improve the accuracy of bad line detection of the image to be processed, in other embodiments, the first threshold value is determined based on the resolution of the image to be processed, that is, the first threshold value is associated with the resolution of the image to be processed, and the first threshold value can be set based on the adaptability of the resolution of the image to be processed. For example, taking the pixel line as the pixel column, if the resolution of the image to be processed is M rows × N columns, then the first threshold value can be set to a first preset ratio × M, etc.; wherein, the first preset ratio is not limited, such as the first preset ratio is 0.3, 0.4 or 0.5, etc.
[0058] In addition, the first difference condition is not limited and can be specifically set according to actual use needs. For each first current pixel point on each pixel line, when the first associated pixel point of the first current pixel point is 1, in one embodiment, the first difference condition is that the absolute value of the pixel difference between the first current pixel point and the corresponding first associated pixel point is greater than 0. Since when the absolute value of the pixel difference between the first current pixel point and the corresponding first associated pixel point is too small, the first current pixel point may not be a bad pixel. Therefore, in order to improve the accuracy of bad line detection of the image to be processed, in other embodiments, the first difference condition is that the absolute value of the difference between the first current pixel point and the corresponding first associated pixel point is greater than the first preset pixel threshold, wherein the size of the first preset pixel threshold is not specifically limited, so as to accurately judge whether the first current pixel point is a bad pixel, thereby accurately judging whether the pixel line to which the first current pixel point belongs is a bad line, thereby improving the accuracy of bad line detection.
[0059] For each first current pixel point on each pixel line, when there are two first associated pixel points of the first current pixel point, in one embodiment, the first difference condition is that the product of the first pixel difference between the first current pixel point and one of the first associated pixel points and the second pixel difference between the first current pixel point and the other first associated pixel point is a positive number, and the absolute value of the first pixel difference is greater than the first pixel threshold, and the absolute value of the second pixel difference is greater than the second pixel threshold; by determining whether the first current pixel point meets the first difference condition through the two first associated pixel points of the first current pixel point, the first current pixel point that meets the first difference condition in the pixel line can be determined more accurately, thereby enabling more accurate detection of bad lines in the image to be processed. The specific formula of the first difference condition is as follows:
[0060] diff1(i,j)*diff2(i,j)>0 and abs(diff1(i,j))>thr1 and abs(diff2(i,j))>thr2
[0061] In which, diff1(i,j) represents the first pixel difference; diff2(i,j) represents the second pixel difference; abs() represents the absolute value function; thr1 represents the first pixel threshold, wherein the first pixel threshold is not specifically limited; thr2 represents the second pixel threshold, wherein the second pixel threshold is not specifically limited, and the second pixel threshold and the first pixel threshold may be equal or different. It should be noted that, taking the pixel line as pixel column A and the first number as 1 as an example, pixel column A includes in-line pixel points a1, in-line pixel points a2, in-line pixel points a3 and in-line pixel points a4, which are spaced from top to bottom; when in-line pixel point a2 is the first current pixel point, in-line pixel point a1 and in-line pixel point a3 are the first associated pixel points of in-line pixel point a2 as the first current pixel point, and the first pixel difference and the second pixel difference between in-line pixel point a2 as the first current pixel point and the two first associated pixel points are both greater than 0; when in-line pixel point a3 is the first current pixel point, in-line pixel point a2 and in-line pixel point a4 are the first associated pixel points of in-line pixel point a3 as the first current pixel point, and the first pixel difference and the second pixel difference between in-line pixel point a3 as the first current pixel point and the two first associated pixel points are both less than 0; at this time, the in-line pixel points a2 and in-line pixel points a3 on pixel column A are distributed alternately in light and dark.
[0062] For each pixel line, if the first current pixel points that satisfy the first difference condition on the pixel line are intermittently distributed or continuously distributed for a short length, the pixel line may not be a bad line even if the number of first current pixel points that satisfy the first difference condition on the pixel line is greater than the first threshold. Therefore, in order to improve the accuracy of determining bad lines in the image to be processed, in other embodiments, if the pixel value distribution condition includes the first pixel value difference condition, the bad line condition may also include the number of target pixel points on the pixel line being greater than the first threshold, where the target pixel point is the first current pixel point that satisfies the first difference condition and a preset distribution condition, and the preset distribution condition is that the target pixel point and at least some other target pixel points are continuously distributed for a preset length. In other words, the bad line condition is that the number of first current pixel points on the pixel line that satisfy the first difference condition and the preset distribution condition is greater than the first threshold.
[0063] In one embodiment, if it is determined that the pixel value distribution of each pixel line in the image to be processed includes a second pixel value difference condition, then the bad line condition includes the number of second current pixel points on the pixel line that meet the second difference condition being greater than a second threshold. For example, taking the image to be processed as including pixel lines A, B, C, D, and E, and determining that the pixel value distribution of each pixel line in the image to be processed includes the second pixel value difference condition, since the number of second current pixel points on pixel lines B and D that meet the second difference condition is greater than the second threshold, pixel lines B and D are considered bad lines in the image to be processed.
[0064] The second threshold value is not limited and can be set according to actual use needs. In one embodiment, the second threshold value is a fixed value, such as 100. In order to enhance the adaptability of the second threshold value and thus improve the accuracy of bad line detection of the image to be processed, in other embodiments, the second threshold value is determined based on the resolution of the image to be processed, that is, the second threshold value is associated with the resolution of the image to be processed, and the second threshold value can be set based on the adaptability of the resolution of the image to be processed. For example, taking the pixel line as the pixel column, if the resolution of the image to be processed is M rows × N columns, then the first threshold value can be set to the second preset ratio × M, etc.; wherein, the second preset ratio is not limited, such as the second preset ratio is 0.3, 0.4 or 0.5, etc.
[0065] In addition, the second difference condition is not limited and can be specifically set according to actual use needs. For each second current pixel point on each pixel line, when the second current pixel point has one second associated pixel point, in one embodiment, the second difference condition is that the pixel difference between the second current pixel point and the corresponding second associated pixel point is greater than the second preset pixel threshold, wherein the size of the second preset pixel threshold is not limited, and at this time, the brightness of each pixel point in the bad line of the image to be processed is brighter than the brightness of each pixel point in the non-bad line of the image to be processed; or the second difference condition is that the pixel difference between the second current pixel point and the corresponding second associated pixel point is less than the inverse of the second preset pixel threshold, and at this time, the brightness of each pixel point in the bad line of the image to be processed is darker than the brightness of each pixel point in the non-bad line of the image to be processed.
[0066] For each second current pixel point on each pixel line, when there are two second associated pixel points of the second current pixel point, in one embodiment, the second difference condition is that the third pixel difference between the second current pixel point and one of the second associated pixel points is greater than the third pixel threshold, the fourth pixel difference between the second current pixel point and the other second associated pixel point is greater than the fourth pixel threshold, and the absolute value of the third pixel difference is less than the fifth pixel threshold, and the absolute value of the fourth pixel difference is less than the sixth pixel threshold. Determining whether the second current pixel point satisfies the second difference condition through the two second associated pixel points of the second current pixel point can more accurately determine the second current pixel point that satisfies the second difference condition, so as to more accurately detect the bad lines of the image to be processed; in addition, by setting the absolute value of the third pixel difference to be less than the fifth pixel threshold and the absolute value of the fourth pixel difference to be less than the sixth pixel threshold, the possibility that the edge lines of the image to be processed are determined as bad lines can be reduced, while protecting the edge information of the image to be processed, improving the detection accuracy of bad lines, and reducing the probability of false detection. The specific formula of the second difference condition is as follows:
[0067] diff3(i,j)>thr3 and diff4(i,j)>thr4 and abs(diff3(i,j))<thr5 and abs(diff4(i,j))<thr6
[0068] Among them, diff3(i,j) represents the third pixel difference; diff4(i,j) represents the fourth pixel difference; abs() represents the absolute value function; thr3 represents the third pixel threshold, and the third pixel threshold is not specifically limited; thr4 represents the fourth pixel threshold, and the fourth pixel threshold is not specifically limited. The third pixel threshold and the fourth pixel threshold can be equal or not equal. For example, both the third pixel threshold and the fourth pixel threshold are taken as 10; thr5 represents the fifth pixel threshold, and the fifth pixel threshold is not specifically limited; thr6 represents the sixth pixel threshold, and the sixth pixel threshold is not specifically limited. The fifth pixel threshold and the sixth pixel threshold can be equal or not equal. For example, both the fifth pixel threshold and the sixth pixel threshold are taken as 30.
[0069] Alternatively, the second difference condition is that the third pixel difference between the second current pixel and one of the second associated pixels is less than the negative of the third pixel threshold, the fourth pixel difference between the second current pixel and the other second associated pixel is less than the negative of the fourth pixel threshold, and the absolute value of the third pixel difference is less than the fifth pixel threshold, and the absolute value of the fourth pixel difference is less than the sixth pixel threshold. The specific formula for the second difference condition is as follows: diff3(i,j) < -thr3 and diff4(i,j) < -thr4 and abs(diff3(i,j)) < thr5 and abs(diff4(i,j)) < thr6
[0070] Among them, diff3(i,j) represents the third pixel difference; diff4(i,j) represents the fourth pixel difference; abs() represents the absolute value function; -thr3 represents the negative of the third pixel threshold, where the third pixel threshold is not specifically limited; -thr4 represents the negative of the fourth pixel threshold, where the fourth pixel threshold is not specifically limited, and the third pixel threshold and the fourth pixel threshold can be equal or unequal. For example, both the third pixel threshold and the fourth pixel threshold are taken as 10; thr5 represents the fifth pixel threshold, where the fifth pixel threshold is not specifically limited; thr6 represents the sixth pixel threshold, where the sixth pixel threshold is not specifically limited, and the fifth pixel threshold and the sixth pixel threshold can be equal or unequal. For example, both the fifth pixel threshold and the sixth pixel threshold are taken as 30.
[0071] In order to improve the image quality of the image to be processed and reduce the visual experience affected by the existence of bad lines in the image to be processed, in one embodiment, after selecting the pixel line whose pixel value distribution satisfies the bad line condition as the bad line in the image to be processed, the bad line is replaced with a non-bad line located at a preset position of the bad line, so as to eliminate the bad line in the image to be processed and complete the repair of the image to be processed. Among them, the preset position is not limited and can be specifically set according to actual use needs.
[0072] For example, a non-bad line located at a preset position of a bad line is a non-bad line that is spaced apart from the bad line by a third number of pixel lines, and the third number is not limited, such as 1 or 2. For example, assuming that the third number is 1, the image to be processed includes N pixel lines, wherein the second pixel line of the image to be processed is a bad line; since the first and third pixel lines of the image to be processed are both non-bad lines, the second pixel line of the image to be processed can be replaced with the first or third pixel line of the image to be processed, or the second pixel line of the image to be processed can be replaced with the average of the first and third pixel lines of the image to be processed. For example, assuming that the third number is 1, the image to be processed includes N pixel lines, wherein the second pixel line of the image to be processed is bad line 1, and the third pixel line is bad line 2; since the only non-bad line spaced apart from bad line 2 by one pixel line is the fourth pixel line, the third pixel line of the image to be processed is replaced with the fourth pixel line of the image to be processed.
[0073] It should be noted that if the pixel line that is separated from the bad line by a third number of pixel lines is still a bad line, then a non-bad line that is separated from the bad line by a fourth number of pixel lines is used to replace the bad line. The fourth number is greater than the third number, for example, the fourth number is 2 or 3.
[0074] See also Figure 4 , Figure 4 FIG2 is a schematic diagram of the structure of an embodiment of an image bad line detection device provided in this application. The image bad line detection device 40 includes a memory 41 and a processor 42 coupled to each other. The processor 42 is configured to execute program instructions stored in the memory 41 to implement the steps of any of the above-described image bad line detection method embodiments. In a specific implementation scenario, the image bad line detection device 40 may include, but is not limited to, a microcomputer or a server. Furthermore, the image bad line detection device 40 may also include mobile devices such as laptops and tablet computers, although this is not a limitation here.
[0075] Specifically, the processor 42 is used to control itself and the memory 41 to implement the steps of the above-mentioned bad line detection method embodiment of any image. The processor 42 can also be called a CPU (Central Processing Unit). The processor 42 may be an integrated circuit chip with signal processing capabilities. The processor 42 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 42 can be implemented by an integrated circuit chip.
[0076] See also Figure 5 , Figure 5 : This is a structural diagram of an embodiment of a computer-readable storage medium provided by the present application. The computer-readable storage medium 50 of the embodiment of the present application stores program instructions 51, and when the program instructions 51 are executed, the method provided by any embodiment of the bad line detection method of the image of the present application and any non-conflicting combination is implemented. Among them, the program instructions 51 can form a program file and be stored in the above-mentioned computer-readable storage medium 50 in the form of a software product, so that a computer device (which can be a personal computer, server, or network device, etc.) executes all or part of the steps of the methods of each embodiment of the present application. The aforementioned computer-readable storage medium 50 includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or terminal devices such as a computer, a server, a mobile phone, and a tablet.
[0077] If the technical solution of this application involves personal information, the product that applies the technical solution of this application has clearly informed the personal information processing rules and obtained the individual's voluntary consent before processing personal information. If the technical solution of this application involves sensitive personal information, the product that applies the technical solution of this application has obtained the individual's separate consent before processing sensitive personal information, and at the same time meets the "explicit consent" requirement. For example, on personal information collection devices such as cameras, a clear and prominent sign is set to inform that the personal information collection scope has been entered and personal information will be collected. If the individual voluntarily enters the collection scope, it is deemed that they agree to the collection of their personal information; or on the personal information processing device, when the personal information processing rules are notified by obvious signs / information, the individual's authorization is obtained through pop-up information or by asking the individual to upload their personal information; among which, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the type of personal information processed.
[0078] The above description is only an implementation method of the present application and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the description and drawings of this application, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A method for detecting bad lines in an image, characterized in that: The method comprises: Get the image to be processed; Determining a pixel value distribution of each pixel line in the image to be processed, wherein the pixel line includes a plurality of in-line pixel points forming a line segment, and the pixel value distribution of the pixel line includes a first pixel value difference between the plurality of in-line pixel points and / or a second pixel value difference between a plurality of out-line pixel points and the plurality of in-line pixel points, wherein the out-line pixel points are pixel points in the image to be processed that are located within a preset pixel distance of the pixel line; Selecting the pixel line whose pixel value distribution satisfies the bad line condition as the bad line in the image to be processed; Among them, if the pixel value distribution includes a first pixel value difference, the bad line condition includes that the number of first current pixel points on the pixel line that meet the first difference condition is greater than a first threshold, and the first current pixel point is at least part of the in-line pixel points on the pixel line. The first difference condition is that the product of the first pixel difference between the first current pixel point and one of the corresponding first associated pixel points and the second pixel difference between the first current pixel point and the corresponding other first associated pixel point is a positive number, and the absolute value of the first pixel difference is greater than the first pixel threshold, and the absolute value of the second pixel difference is greater than the second pixel threshold, and the first associated pixel point corresponding to the first current pixel point is the in-line pixel point on the pixel line that is separated from the first current pixel point by a first number of pixels.
2. The method according to claim 1, characterized in that Determining the pixel value distribution of each pixel line in the image to be processed includes: For each pixel line, at least some of the pixels on the pixel line are used as first current pixel points, and a pixel difference between each first current pixel point and a corresponding first associated pixel point is obtained to obtain the first pixel value difference; and / or, For each of the pixel lines, at least part of the in-line pixel points on the pixel line are used as the second current pixel points, and the pixel difference between each of the second current pixel points and the corresponding second associated pixel point is obtained to obtain the second pixel value difference, wherein the second associated pixel point of the second current pixel point is the out-of-line pixel point that is spaced from the second current pixel point by a second number of pixels, and the second associated pixel point is connected with the second current pixel point to form a line segment in a first preset direction, and the angle between the first preset direction and the pixel line is greater than 0.
3. The method according to claim 2, characterized in that If the pixel value distribution includes a second pixel value difference, the bad line condition includes that the number of the second current pixel points on the pixel line that meet the second difference condition is greater than a second threshold.
4. The method according to claim 3, characterized in that There are two second associated pixel points of the second current pixel point, and the second difference condition is that the third pixel difference between the second current pixel point and one of the second associated pixel points is greater than the third pixel threshold, the fourth pixel difference between the second current pixel point and the other second associated pixel point is greater than the fourth pixel threshold, and the absolute value of the third pixel difference is less than the fifth pixel threshold, and the absolute value of the fourth pixel difference is less than the sixth pixel threshold; or, the third pixel difference is less than the inverse of the third pixel threshold, the fourth pixel difference is less than the inverse of the fourth pixel threshold, and the absolute value of the third pixel difference is less than the fifth pixel threshold, and the absolute value of the fourth pixel difference is less than the sixth pixel threshold.
5. The method according to claim 3, characterized in that At least one of the first threshold and the second threshold is determined based on the resolution of the image to be processed; And / or, if the pixel value distribution includes a first pixel value difference, the bad line condition includes that the number of target pixel points on the pixel line is greater than the first threshold, and the target pixel point is the first current pixel point that satisfies the first difference condition and the preset distribution condition, and the preset distribution condition is that the target pixel point and at least some other target pixel points are continuously distributed to a preset length.
6. The method according to claim 2, characterized in that The first preset direction is perpendicular to the pixel line.
7. The method according to claim 1, characterized in that If the pixel value distribution includes the second pixel value difference, before determining the second pixel value difference of each pixel line in the image to be processed, the method further includes: Performing mean filtering processing on the image to be processed in a second preset direction, where the second preset direction is an extension direction of the pixel line.
8. The method according to claim 1, characterized in that After selecting the pixel line whose pixel value distribution satisfies the bad line condition as the bad line in the image to be processed, the method further includes: The bad line is replaced by a non-bad line located at a preset position of the bad line.
9. The method according to claim 1, characterized in that The pixel lines are pixel columns or pixel rows, and / or the image to be processed is an infrared thermal imaging image.
10. An image bad line detection device, characterized in that: The image bad line detection device includes a memory and a processor, the memory stores program instructions, and the processor is configured to execute the program instructions to implement the image bad line detection method according to any one of claims 1 to 9.
11. A computer-readable storage medium, characterized in that The computer-readable storage medium is used to store program instructions, and the program instructions can be executed to implement the image bad line detection method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Image dead pixel detection method and device
CN105338342A
Method for detecting bad line of fingerprint sensor and method for repairing bad line of fingerprint image
CN113505683A