Detailed Description
The following describes embodiments of the present application in detail with reference to the drawings.
In the following description, for purposes of explanation and not limitation, specific details are set forth such as the particular system architecture, interfaces, techniques, etc., in order to provide a thorough understanding of the present application.
The term "and/or" is merely an association relationship describing the associated object, and means that three relationships may exist, for example, a and/or B may mean that a exists alone, while a and B exist together, and B exists alone. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship. Further, "a plurality" herein means two or more than two. In addition, the term "at least one" herein means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, C, may mean including any one or more elements selected from the group consisting of A, B and C.
Referring to fig. 1, fig. 1 is a flowchart illustrating an embodiment of a method for detecting a bad line of an image according to the present application. It should be noted that, if there are substantially the same results, the present embodiment is not limited to the flow sequence shown in fig. 1. As shown in fig. 1, the present embodiment includes:
and S11, acquiring an image to be processed.
The method of the present embodiment is used for detecting a broken line in an image to be processed, and the image to be processed may be any image requiring broken line detection, and the image to be processed described herein may be, but is not limited to, a high resolution image with a resolution exceeding 4K, a multi-view stitched image, a stitched panoramic image, and the like, which is not specifically limited herein.
In an embodiment, the image to be processed may be obtained from a local storage or a cloud storage. It will be appreciated that, in other embodiments, the image to be processed may also be acquired by the image capturing device in the current environment, which is not limited herein.
In one embodiment, the image to be processed is an infrared thermographic image. Because the infrared thermal imaging technology uses the difference of the infrared radiation intensities of objects to image, but is limited by the manufacturing process of the infrared detector, the problem of abnormal response rate of the infrared detector pixels is easy to occur, and bad lines are easy to occur on the infrared thermal imaging image. It will be appreciated that in other embodiments, the image to be processed may be a gray scale image, etc., and is not specifically limited herein.
And step S12, determining the pixel value distribution condition of each pixel line in the image to be processed.
In this embodiment, a pixel value distribution of each pixel line in the image to be processed is determined. Since the pixel value distribution condition of the bad line is known, by determining the pixel value distribution condition of each pixel line in the image to be processed, it is convenient to determine whether each pixel line in the image to be processed is a bad line or not according to the pixel value distribution condition of each pixel line and the known pixel value distribution condition of the bad line. In an embodiment, the pixel line may be a pixel row or a pixel column of the image to be processed. It will be appreciated that, in other embodiments, the pixel lines may also be pixel oblique lines, pixel curves, etc. in the image to be processed, which are not specifically limited herein. It should be noted that, hereinafter, for convenience of description, the present application will be described by taking a pixel line as a pixel column as an example, but it should be understood that such description is not limited to a specific type of pixel line.
The pixel line comprises a plurality of in-line pixel points forming a line segment, and the pixel value distribution condition of the pixel line comprises a first pixel value difference condition among a plurality of in-line pixel points forming the pixel line and/or a second pixel value difference condition among a plurality of out-of-line pixel points and a plurality of in-line pixel points forming the pixel line.
In an embodiment, for each pixel line, at least part of in-line pixel points on the pixel line are respectively used as first current pixel points, and pixel difference values between each first current pixel point and corresponding first associated pixel points are obtained to obtain first pixel value difference conditions of the pixel lines, wherein the first associated pixel points of the first current pixel points are in-line pixel points which are spaced by a first number of pixel points from the first current pixel points on the pixel line. That is, for each pixel line, at least part of the in-line pixel points on the pixel line are respectively used as first current pixel points, pixel difference values between each first current pixel point and the in-line pixel points which are separated from the first current pixel point by a first number of pixel points on the corresponding pixel line are obtained, and then the first pixel value difference condition of the pixel line is determined through the pixel difference values between each first current pixel point and the corresponding first associated pixel points.
The number of the pixel points in the line, which is the first current pixel point, on the pixel line is not limited, and the pixel points can be specifically set according to actual use requirements. For example, all in-line pixels included in the pixel line are respectively used as the first current pixel points, or two-thirds in-line pixels included in the pixel line are respectively used as the first current pixel points. The method comprises the steps of taking each in-line pixel point on a pixel line as a first current pixel point, obtaining a pixel difference value before each first current pixel point and a corresponding first associated pixel point to obtain a first pixel value difference condition of the pixel line, analyzing each in-line pixel point on the pixel line by taking each in-line pixel point on the pixel line as the first current pixel point, analyzing each pixel line more comprehensively, enabling the obtained first pixel value difference condition to be more accurate, enabling bad lines in a to-be-processed image to be more accurate, and improving the bad line detection accuracy. In addition, the first number is not limited either, and may be specifically set according to actual use requirements. For example, the first number is an odd number of values of 1, 3, 5, or 7. An example is that a pixel line is taken as a pixel column A, the first number is 1 as an example, the pixel column A comprises an in-line pixel point a1, an in-line pixel point a2, an in-line pixel point a3, an in-line pixel point a4 and an in-line pixel point a5 which are arranged at intervals, when the in-line pixel point a1 is a first current pixel point, a first associated pixel point of the in-line pixel point a1 serving as the first current pixel point is an in-line pixel point a2 which is separated from the in-line pixel point a1 by 1 pixel point, and when the in-line pixel point a2 is the first current pixel point, the first associated pixel point of the in-line pixel point a2 serving as the first current pixel point is an in-line pixel point a1 or an in-line pixel point a3 which is separated from the in-line pixel point a 2by 1 pixel point, 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 serving as the first current pixel point is the first current pixel point a1 or the in-line pixel point a4 is the first current pixel point a4 which is the first associated pixel point a1 or the first in-line pixel point a4 is the first current pixel point a 4.
The specific formula for obtaining the pixel difference between each first current pixel point and the corresponding first associated pixel point is as follows:
diff1(i,j)=Img(i,j)-Img(i-a,j)
diff2(i,j)=Img(i,j)-Img(i+a,j)
wherein α represents a first number, (i, j) represents a first current pixel coordinate, (i- α, j) and (i+α, j) each represent an in-line pixel coordinate of a first number of pixels spaced from the first current pixel on a pixel line, and diff1 (i, j) and diff2 (i, j) each represent a pixel difference between the first current pixel and a corresponding first associated pixel.
In an embodiment, the first associated pixel of the first current pixel may be 1. When the number of the first associated pixels of the first current pixel is 1, the first associated pixels of the first current pixel may be the previous or the subsequent in-line pixels spaced apart from the first current pixel by a first number of pixels. For example, taking a pixel line as a pixel column a as an example, when the first associated pixel points of the first current pixel points are 1, for each first current pixel point in the pixel column a, an in-line pixel point separated from the first current pixel point by a first number of pixel points may be an in-line pixel point of a previous row or an in-line pixel point of a subsequent row. For another example, taking a pixel line as a pixel row B, when the first associated pixel points of the first current pixel points are 1, for each first current pixel point in the pixel row B, an in-line pixel point separated from the first current pixel point by a first number of pixel points may be an in-line pixel point of a previous column or an in-line pixel point of a subsequent column. It will be appreciated that, in other embodiments, the number of the first associated pixels of the first current pixel may be 2, which is not limited herein. When the number of the first associated pixels of the first current pixel is 2, for each first current pixel in the pixel line, the first associated pixel of the first current pixel and the first current pixel are separated by a first number of pixels, and the in-line pixel of the first current pixel is the in-line pixel before the in-line pixel and the in-line pixel after the in-line pixel.
It should be noted that, for the above formula, when the first associated pixel of the first current pixel is 1, the pixel difference between the first current pixel and the corresponding first associated pixel is calculated according to the specific situation by using the formula corresponding to diff1 (i, j) or diff2 (i, j), and when the first associated pixel of the first current pixel is 2, the pixel difference between the first current pixel and 1 of the first associated pixels is calculated according to the formula corresponding to diff1 (i, j), and the pixel difference between the first current pixel and the other 1 of the first associated pixels is calculated according to the formula corresponding to diff2 (i, j). For example, the pixel line is taken as a pixel column A, the first associated pixel point of the first current pixel point is 1, The first number is 1 for example, for the first current pixel point a 1 in the pixel column a, the in-line pixel point spaced 1 pixel point apart from the first current pixel point a 1 may be the in-line pixel point a 2 of the previous line or the in-line pixel point a 3 of the next line, so that when the in-line pixel point spaced 1 pixel point apart from the first current pixel point a 1 is the in-line pixel point a 2 of the previous line, the pixel difference between the first current pixel point a 1 and the in-line pixel point a 2 is calculated using the formula corresponding to diff1 (i, j), and when the in-line pixel point spaced 1 pixel point apart from the first current pixel point a 1 is the in-line pixel point a 3 of the next line, the pixel difference between the first current pixel point a 1 and the in-line pixel point a 3 is calculated using the formula corresponding to diff2 (i, j).
In an embodiment, for each pixel line, at least a part of in-line pixel points on the pixel line are respectively used as second current pixel points, and a pixel difference value between each second current pixel point and a corresponding second associated pixel point is obtained to obtain a second pixel value difference condition of the pixel line, wherein the second associated pixel points of the second current pixel points are off-line pixel points separated from the second current pixel points by a second number of pixel points. That is, for each pixel line, at least part of in-line pixel points on the pixel line are respectively used as second current pixel points, pixel difference values between each second current pixel point and out-of-line pixel points separated from the second current pixel points by a second number of pixel points are obtained, and then second pixel value difference conditions of the pixel lines are determined through the pixel difference values between each second current pixel point and the corresponding second associated pixel points.
The number of the pixel points in the line, which is used as the second current pixel point on the pixel line, is not limited, and the pixel points can be specifically set according to actual use requirements. For example, all in-line pixels included in the pixel line are respectively taken as the second current pixels, or two-thirds of in-line pixels included in the pixel line are respectively taken as the second current pixels. The method comprises the steps of taking each in-line pixel point on a pixel line as a second current pixel point, obtaining a pixel difference value before each second current pixel point and a corresponding second associated pixel point to obtain a second pixel value difference condition of the pixel line, analyzing each in-line pixel point on the pixel line by taking each in-line pixel point on the pixel line as the second current pixel point, analyzing each pixel line more comprehensively, enabling the obtained second pixel value difference condition to be more accurate, enabling bad lines in a to-be-processed image to be more accurate, and improving the bad line detection accuracy. In addition, the second number is not limited either, and may be specifically set according to actual use requirements. For example, the second number is 1 or 2, etc. The image to be processed comprises pixel columns A, B, C and D which are arranged at intervals, wherein when at least part of the pixel points in the pixel columns A are second current pixel points, the second associated pixel points of the second current pixel points in the pixel columns A are off-line pixel points which are 1 pixel point away from the second current pixel points, namely the second associated pixel points of the second current pixel points in the pixel columns A are pixel points on the pixel columns B, the second associated pixel points of the second current pixel points in the pixel columns B are pixel points which are 1 pixel point away from the second current pixel points in the pixel columns, namely the second associated pixel points in the pixel columns B are pixel points on the pixel columns A or the pixel columns C, and the second associated pixel points of the second current pixel points in the pixel columns B are pixel points on the pixel columns C which are the pixel points on the second current pixel points in the pixel columns D which are the pixel points on the second current pixel points in the pixel columns B, namely the second associated pixel points in the pixel columns D which are the pixel points on the pixel columns which are the second current pixel points in the pixel columns C.
The specific formula for obtaining the pixel difference between each second current pixel point and the corresponding second associated pixel point is as follows:
diff3(i,j)=Img(i,j)-Img(i,j-d)
diff4(i,j)=Img(i,j)-Img(i,j+d)
wherein d represents a second number, (i, j) represents a second current pixel point coordinate, (i, j-d) and (i, j+d) each represent an off-line pixel point coordinate on the pixel line separated from the second current pixel point by a second number of pixel points, and diff3 (i, j) and diff4 (i, j) each represent a pixel difference value between the second current pixel point and a corresponding second associated pixel point.
In an embodiment, the number of second associated pixels of the second current pixel may be 1. When the number of the second associated pixels of the second current pixel is 1, the second associated pixels of the second current pixel and the second current pixel are separated by a second number of pixels, which may be the previous off-line pixels or the subsequent off-line pixels. For example, taking a pixel line as a pixel column as an example, when the second associated pixels of the second current pixel point are 1, for each second current pixel point in the pixel column, the off-line pixels separated from the second current pixel point by the second number of pixel points may be off-line pixels of the previous column or off-line pixels of the subsequent column. For example, when the pixel line is taken as the pixel line and the number of the second associated pixels of the second current pixel point is 1, for each second current pixel point in the pixel line, the off-line pixel point separated from the second current pixel point by the second number of pixel points may be the off-line pixel point of the previous line or the off-line pixel point of the subsequent line. It will be appreciated that, in other embodiments, the number of second associated pixels of the second current pixel may be 2, which is not specifically limited herein. When the number of second associated pixels of the second current pixel is 2, for each second current pixel in the pixel line, the second associated pixels of the second current pixel and the second current pixel are separated by a second number of off-line pixels of the second current pixel as the previous off-line pixels and the following off-line pixels.
It should be noted that, for the above formula, when the number of second associated pixels of the second current pixel is 1, the pixel difference between the second current pixel and the corresponding second associated pixel is calculated according to the specific situation by using the formula corresponding to diff3 (i, j) or diff4 (i, j), and when the number of second associated pixels of the second current pixel is 2, the pixel difference between the second current pixel and 1 of the second associated pixels is calculated by using the formula corresponding to diff3 (i, j), and the pixel difference between the second current pixel and the other 1 of the second associated pixels is calculated by using the formula corresponding to diff4 (i, j). For example, taking a pixel line as a pixel column a, a second associated pixel point of a second current pixel point as 1 and a second number as 1 as an example, for the second current pixel point a 1 in the pixel column a, an off-line pixel point spaced 1 pixel point from the second current pixel point a 1 may be an off-line pixel point on a pixel column B that is a previous pixel point, or an off-line pixel point on a pixel column C that is a subsequent pixel point, so when an off-line pixel point spaced 1 pixel point from the second current pixel point a 1 is an off-line pixel point on a previous pixel column that is a pixel column B, a pixel difference value between the second current pixel point a 1 and the off-line pixel point is calculated using a formula corresponding to diff3 (i, j), and when an off-line pixel point spaced 1 pixel point from the second current pixel point a 1 is an off-line pixel point on a pixel column C that is a subsequent pixel column C, a pixel point is calculated using a formula corresponding to diff3 (i, j) to a pixel point of the second current pixel point a 4.
In addition, in the above embodiment, the second associated pixel point of the second current pixel point is connected with the second current pixel point to form a line segment in the first preset direction, and an included 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 each second current pixel point on the pixel line B, when the off-line pixel point separated from the second current pixel point B by 1 pixel point is the off-line pixel point on the pixel column a which is the previous pixel column thereof, the second associated pixel point of the second current pixel point B is the pixel point on the pixel line a which is on the same line as the second current pixel point B, and when the off-line pixel point separated from the second current pixel point B by 1 pixel point is the off-line pixel point on the pixel column C which is the subsequent pixel column thereof, the second associated pixel point of the second current pixel point B is the pixel point on the pixel line C which is on the same line as the second current pixel point B. It will be appreciated that, in other embodiments, the first preset direction may also have other degrees of included angle with the pixel line, which is not limited herein.
Noise points may exist in the image to be processed, so that the determined difference condition of the second pixel values of the pixel lines in the image to be processed is not accurate enough. Therefore, in an embodiment, before determining the difference of the second pixel values of the pixel lines in the image to be processed, the image to be processed is subjected to the mean filtering processing in the second preset direction to filter noise points in the image to be processed. The second preset direction is the extending 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 an extending direction of the pixel column, that is, a vertical direction of the image to be processed, and at this time, average filtering processing is performed on the image to be processed in the vertical direction. For another example, when the pixel line is a pixel line of the image to be processed, the second preset direction is an extending direction of the pixel line, that is, a horizontal direction of the image to be processed, and at this time, average filtering processing is performed on the image to be processed in the horizontal direction.
Specifically, the average filtering processing is performed on the image to be processed according to the window sizes of the preset number of rows and the preset number of columns. It should be noted that, for the edge data in the image to be processed, the average filtering process may be performed after edge trimming by adopting a mirror image edge trimming or a copy edge trimming method. The preset number of rows and the preset number of columns are not limited, and the preset number of rows and the preset number of columns can be specifically set according to actual use requirements. For example, when the pixel line is a pixel column, the preset line number is 3 and the preset column number is 1. For another example, when the pixel line is a pixel row, the preset line number is 1, and the preset column number is 3.
And S13, selecting pixel lines with pixel value distribution conditions meeting the bad line condition as bad lines in the image to be processed.
In this embodiment, a pixel line whose pixel value distribution condition satisfies a bad line condition is selected as a bad line in an image to be processed. When the pixel value distribution condition of the pixel line meets the bad line condition, the pixel value distribution condition of the pixel line can be regarded as meeting the distribution characteristic of the bad line, so that the pixel line with the pixel value distribution condition meeting the bad line condition is regarded as the bad line.
Specifically, as shown in fig. 2 and 3, fig. 2 is a global schematic diagram of an embodiment of the bad line provided by the present application, and fig. 3 is a local enlarged schematic diagram of an embodiment of the bad line provided by the present application, where the pixel value distribution condition of the pixel line 1 is a first pixel value difference condition, when the first pixel value difference condition of the pixel line 1 meets the bad line condition, it can be regarded that the pixel value distribution condition of the pixel line 1 meets the distribution characteristic of the bad line, so that the pixel line 1 is the bad line, and because the pixel value distribution condition of the pixel line 1 meets the distribution characteristic of the bad line between bright and dark phases, the pixel line 1 is the bad line with the bright and dark phase distribution characteristic. The pixel value distribution condition of the pixel line 2 is the second pixel value difference condition, when the second pixel value difference condition of the pixel line 2 meets the bad line condition, the pixel value distribution condition of the pixel line 2 can be regarded as the distribution characteristic of the bad line, so that the pixel line 2 is the bad line, and the pixel line 2 is the penetrating bad line because the pixel value distribution condition of the pixel line 2 meets the distribution characteristic of the penetrating bad line. It should be noted that, when the pixel value distribution condition of each pixel point in the image to be processed includes the first pixel value difference condition and the second pixel value difference condition, the bad line detection method of the image provided by the application can detect the bad line and the penetrating bad line with bright-dark alternate distribution characteristics at the same time.
In the above embodiment, whether each pixel line is a bad line in the image to be processed is determined by determining whether the pixel value distribution condition of each pixel line in the image to be processed satisfies the bad line condition. Therefore, the bad line detection method of the image is used for carrying out bad line detection on the image to be processed based on the distribution characteristics of the bad line, can reduce the influence of the abnormality of individual pixel points on the bad line detection effect, improves the accuracy of the bad line detection, is simple to operate, has small influence and small limitation due to the scene information, the brightness and the like of the image, and can be suitable for various different scenes.
In an embodiment, if it is determined that the pixel value distribution condition of each pixel line in the image to be processed includes a first pixel value difference condition, the number of first current pixel points on the pixel line, where the number of first current pixel points on the pixel line satisfies the first difference condition, is greater than a first threshold. Taking an example that an image to be processed comprises a pixel line A, a pixel line B, a pixel line C, a pixel line D and a pixel line E as the example, determining that the pixel value distribution condition of each pixel line in the image to be processed comprises a first pixel value difference condition, and taking the pixel line B and the pixel line D as bad lines in the image to be processed because the number of first current pixel points meeting a first difference condition on the pixel line B and the pixel line D is larger than a first threshold value.
The first threshold is not limited, and may be specifically set according to actual use requirements. In one embodiment, the first threshold is a fixed value, e.g., the first threshold is 50. In order to enhance the adaptivity of the first threshold, thereby improving the bad line detection accuracy of the image to be processed, in other embodiments, the first threshold is determined based on the resolution of the image to be processed, that is, the first threshold is associated with the resolution of the image to be processed, and the first threshold may be adaptively set based on the resolution of the image to be processed. For example, taking a pixel line as a pixel column as an example, if the resolution of the image to be processed is M rows×n columns, the first threshold may be set to a first preset ratio×m, where the first preset ratio is not limited, for example, the first preset ratio is 0.3, 0.4, or 0.5.
In addition, the first difference condition is not limited either, and may be specifically set according to actual use requirements. For each first current pixel point on each pixel line, when the first associated pixel points of the first current pixel points are 1, in an embodiment, the first difference condition is that an absolute value of a pixel difference value between the first current pixel point and the corresponding first associated pixel point is greater than 0. Because the first current pixel point may not be a bad point when the absolute value of the pixel difference value between the first current pixel point and the corresponding first associated pixel point is too small, 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 value between the first current pixel point and the corresponding first associated pixel point is greater than a first preset pixel threshold, where 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 point, thereby accurately judging whether the pixel line to which the first current pixel point belongs is a bad line, and improving the detection accuracy of the bad line.
For each first current pixel point on each pixel line, when 2 first associated pixel points of the first current pixel points exist, in an embodiment, the first difference condition is that the product of a first pixel difference value between the first current pixel point and one of the first associated pixel points and a second pixel difference value between the first current pixel point and the other first associated pixel point is a positive number, the absolute value of the first pixel difference value is greater than a first pixel threshold value, and the absolute value of the second pixel difference value is greater than a second pixel threshold value, and whether the first current pixel point meets the first difference condition is determined through 2 first associated pixel points of the first current pixel point, so that the first current pixel point meeting the first difference condition in the pixel line can be determined more accurately, and bad lines of an image to be processed can be detected more accurately. The specific formula of the first difference condition is as follows:
diff1 (i, j) ×diff2 (i, j) >0 and abs (diff 1 (i, j)) > thr1 and abs (diff 2 (i, j)) > thr2
Wherein diff1 (i, j) represents a first pixel difference value, diff2 (i, j) represents a second pixel difference value, abs () represents an absolute value function, thr1 represents a first pixel threshold value, wherein the first pixel threshold value is not specifically limited, thr2 represents a second pixel threshold value, wherein the second pixel threshold value is not specifically limited, and the second pixel threshold value and the first pixel threshold value may be equal or unequal. It should be noted that, taking the pixel line as the pixel column a and the first number as 1 as an example, the pixel column a includes an in-line pixel point a1, an in-line pixel point a2, an in-line pixel point a3, and an in-line pixel point a4 that are set at intervals from top to bottom, when the in-line pixel point a2 is the first current pixel point, the in-line pixel point a1 and the in-line pixel point a3 are the first associated pixel points of the in-line pixel point a2 as the first current pixel point, the first pixel difference value and the second pixel difference value between the in-line pixel point a2 and the two first associated pixel points as the first current pixel point are both greater than 0, when the in-line pixel point a3 is the first current pixel point, the in-line pixel point a2 and the in-line pixel point a4 are the first associated pixel points of the in-line pixel point a3 as the first current pixel point, and the first associated pixel point a3 as the first current pixel point are alternately distributed on the first pixel point a2 and the second pixel point a is less than the first pixel point a and the second pixel point a is distributed on the line between the first pixel point a2 and the first pixel point a.
For each pixel line, if the length of the first current pixel point that satisfies the first difference condition on the pixel line is shorter than the first threshold, the pixel line may not be a broken line even if the number of the first current pixel points that satisfies the first difference condition on the pixel line is greater than the first threshold, so in order to improve the accuracy of the determined broken line in the image to be processed, in other embodiments, if the pixel value distribution condition includes the first pixel value difference condition, the broken line condition may also include that the number of the target pixel points on the pixel line is greater than the first threshold, the target pixel points are the first current pixel points that satisfy the first difference condition and the preset distribution condition, and the preset distribution condition is that the target pixel points and at least some other target pixel points are continuously distributed to reach the preset length. That is, the bad line condition is that the number of first current pixel points on the pixel line satisfying the first difference condition and the preset distribution condition is greater than a first threshold.
In an embodiment, if it is determined that the pixel value distribution condition of each pixel line in the image to be processed includes a second pixel value difference condition, the number of second current pixel points on the pixel line, where the bad line condition includes that the second difference condition is satisfied, is greater than a second threshold. Taking an example that an image to be processed comprises a pixel line A, a pixel line B, a pixel line C, a pixel line D and a pixel line E as the example, determining that the pixel value distribution condition of each pixel line in the image to be processed comprises a second pixel value difference condition, and taking the pixel line B and the pixel line D as bad lines in the image to be processed because the number of second current pixel points meeting a second difference condition on the pixel line B and the pixel line D is larger than a second threshold value.
The second threshold is not limited, and may be specifically set according to actual use requirements. In one embodiment, the second threshold is a fixed value, e.g., the second threshold is 100. In order to enhance the adaptivity of the second threshold, thereby improving the bad line detection accuracy of the image to be processed, in other embodiments, the second threshold is determined based on the resolution of the image to be processed, that is, the second threshold is associated with the resolution of the image to be processed, and the second threshold may be adaptively set based on the resolution of the image to be processed. For example, taking a pixel line as a pixel column as an example, if the resolution of the image to be processed is M rows×n columns, the first threshold may be set to a second preset ratio×m, where the second preset ratio is not limited, for example, the second preset ratio is 0.3, 0.4, or 0.5.
In addition, the second difference condition is not limited either, and may be specifically set according to actual use requirements. For each second current pixel point on each pixel line, when the second associated pixel point of the second current pixel point is 1, in an embodiment, the second difference condition is that the pixel difference value between the second current pixel point and the corresponding second associated pixel point is greater than a second preset pixel threshold, wherein the size of the second preset pixel threshold is not limited, the brightness of each pixel point in the bad line of the selected image to be processed is brighter than the brightness of each pixel point of the non-bad line in the image to be processed, or the second difference condition is that the pixel difference value between the second current pixel point and the corresponding second associated pixel point is smaller than the opposite number of the second preset pixel threshold, and the brightness of each pixel point in the bad line of the selected image to be processed is darker than the brightness of each pixel point of the non-bad line in the image to be processed.
For each second current pixel point on each pixel line, when there are 2 second associated pixel points of the second current pixel point, in an embodiment, the second difference condition is that a third pixel difference value between the second current pixel point and one of the second associated pixel points is greater than a third pixel threshold value, a fourth pixel difference value between the second current pixel point and the other second associated pixel point is greater than a fourth pixel threshold value, and an absolute value of the third pixel difference value is less than a fifth pixel threshold value, and an absolute value of the fourth pixel difference value is less than a sixth pixel threshold value. In addition, by setting that the absolute value of the third pixel difference value is smaller than the fifth pixel threshold value and the absolute value of the fourth pixel difference value is smaller than the sixth pixel threshold value, the possibility that the edge line of the image to be processed is determined to be the bad line can be reduced, the edge information of the image to be processed is protected, meanwhile, the detection accuracy of the bad line is improved, and the false detection probability is reduced. The specific formula of the second difference condition is as follows:
diff3 (i, j) > thr3 and diff4 (i, j) > thr4 and abs (diff 3 (i, j)) < thr5 and abs (diff 4 (i, j)) < thr6
Wherein diff3 (i, j) represents a third pixel difference value, diff4 (i, j) represents a fourth pixel difference value, abs () represents an absolute value function, thr3 represents a third pixel threshold value, wherein the third pixel threshold value is not specifically defined, thr4 represents a fourth pixel threshold value, wherein the fourth pixel threshold value is not specifically defined, the third pixel threshold value and the fourth pixel threshold value may be equal or unequal, for example, 10 is taken for both the third pixel threshold value and the fourth pixel threshold value, wherein the fifth pixel threshold value is not specifically defined, thr6 represents a sixth pixel threshold value, wherein the sixth pixel threshold value is not specifically defined, the fifth pixel threshold value and the sixth pixel threshold value may be equal or unequal, for example, 30 is taken for both the fifth pixel threshold value and the sixth pixel threshold value.
Or the second difference condition is that the third pixel difference value between the second current pixel point and one of the second associated pixel points is smaller than the opposite number of the third pixel threshold value, the fourth pixel difference value between the second current pixel point and the other of the second associated pixel points is smaller than the opposite number of the fourth pixel threshold value, and the absolute value of the third pixel difference value is smaller than the fifth pixel threshold value, and the absolute value of the fourth pixel difference value is smaller than the sixth pixel threshold value. Wherein the specific formula of the second difference condition is shown as diff3 (i, j) < -thr3 and diff4 (i, j) < -thr4 and abs (diff 3 (i, j)) < thr5 and abs (diff 4 (i, j)) < thr6
Wherein diff3 (i, j) represents a third pixel difference value, diff4 (i, j) represents a fourth pixel difference value, abs () represents an absolute value function, -thr3 represents an opposite number of the third pixel threshold value, wherein the third pixel threshold value is not specifically defined, -thr4 represents an opposite number of the fourth pixel threshold value, wherein the fourth pixel threshold value is not specifically defined, the third pixel threshold value and the fourth pixel threshold value may be equal or unequal, e.g., 10 is taken for both the third pixel threshold value and the fourth pixel threshold value, wherein the fifth pixel threshold value is not specifically defined, thr5 represents a sixth pixel threshold value, wherein the sixth pixel threshold value is not specifically defined, and the fifth pixel threshold value and the sixth pixel threshold value may be equal or unequal, e.g., 30 is taken for both the fifth pixel threshold value and the sixth pixel threshold value.
In order to improve the image quality of the image to be processed and reduce the influence on visual experience due to the existence of bad lines in the image to be processed, in one embodiment, after the pixel lines meeting the bad line condition in the pixel value distribution condition are selected to serve as the bad lines in the image to be processed, the bad lines are replaced by non-bad lines positioned at the preset positions of the bad lines, so that the bad lines in the image to be processed are eliminated, and the restoration of the image to be processed is completed. The preset position is not limited, and can be specifically set according to actual use requirements.
For example, the non-defective line located at the preset position of the defective line is a non-defective line spaced apart from the defective line by a third number of pixel lines, and the third number is not limited, for example, the third number is 1 or 2. The third number is exemplified by 1, the image to be processed includes N pixel lines, wherein the 2 nd pixel line of the image to be processed is a bad line, and since the 1 st pixel line and the 3 rd pixel line of the image to be processed are both non-bad lines, the 2 nd pixel line of the image to be processed may be replaced with the 1 st pixel line or the 3 rd pixel line of the image to be processed, or the 2 nd pixel line of the image to be processed may also be replaced with the average value of the 1 st pixel line and the 3 rd pixel line of the image to be processed. The third number is 1, and the image to be processed comprises N pixel lines, wherein the 2 nd pixel line of the image to be processed is a bad line 1, the 3 rd pixel line of the image to be processed is a bad line 2, and the 3 rd pixel line of the image to be processed is replaced by the 4 th pixel line of the image to be processed because the non-bad line separated by 1 pixel line from the bad line 2 is only the 4 th pixel line.
If the pixel line spaced from the defective line by the third number of pixel lines is still defective, a non-defective line spaced from the defective line by a fourth number of pixel lines is selected to replace the defective line, the fourth number being greater than the third number, e.g., the fourth number being 2 or 3.
Referring to fig. 4, fig. 4 is a schematic structural diagram of an embodiment of a broken line detection apparatus for an image according to the present application. The bad line detection device 40 of the image comprises a memory 41 and a processor 42 coupled to each other, and the processor 42 is configured to execute program instructions stored in the memory 41, so as to implement the steps of the bad line detection method embodiment of any one of the images. In a specific implementation scenario, the image bad line detection device 40 may include, but is not limited to, a microcomputer, a server, and the image bad line detection device 40 may also include a mobile device such as a notebook computer, a tablet computer, etc., which is not limited herein.
Specifically, the processor 42 is configured to control itself and the memory 41 to implement the steps of the bad line detection method embodiment of any one of the images described above. The processor 42 may also be referred to as a CPU (Central Processing Unit ). The processor 42 may be an integrated circuit chip having signal processing capabilities. The Processor 42 may also be a general purpose Processor, a digital signal Processor (DIGITAL SIGNAL Processor, DSP), an Application SPECIFIC INTEGRATED Circuit (ASIC), a Field-Programmable gate array (Field-Programmable GATE ARRAY, FPGA) or other Programmable logic device, a discrete gate or transistor logic device, a discrete hardware component. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. In addition, the processor 42 may be commonly implemented by an integrated circuit chip.
Referring to fig. 5, fig. 5 is a schematic structural diagram of an embodiment of a computer readable storage medium according to the present application. The computer readable storage medium 50 of the embodiment of the present application stores program instructions 51, which when executed implement the method provided by any embodiment of the bad line detection method of the image of the present application and any non-conflicting combination. Wherein the program instructions 51 may form a program file stored in the above-mentioned computer readable storage medium 50 in the form of a software product for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the application. The computer readable storage medium 50 includes various media capable of storing program codes, such as a usb (universal serial bus), a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk or an optical disk, or a terminal device, such as a computer, a server, a mobile phone, a tablet.
If the technical scheme of the application relates to personal information, the product applying the technical scheme of the application clearly informs the personal information processing rule before processing the personal information and obtains the autonomous agreement of the individual. If the technical scheme of the application relates to sensitive personal information, the product applying the technical scheme of the application obtains individual consent before processing the sensitive personal information, and simultaneously meets the requirement of 'explicit consent'. For example, a clear and obvious mark is set at a personal information acquisition device such as a camera to inform that the personal information acquisition range is entered, personal information is acquired, if the personal voluntarily enters the acquisition range, the personal information is considered as consent to acquire the personal information, or if a clear mark/information is used on a personal information processing device to inform that the personal information processing rule is used, personal authorization is obtained through popup information or a mode of requesting the personal information to upload the personal information by the personal, wherein the personal information processing rule can comprise information such as a personal information processor, a personal information processing purpose, a processing mode, a processed personal information type and the like.
The foregoing description is only of embodiments of the present application, and is not intended to limit the scope of the application, and all equivalent structures or equivalent processes using the descriptions and the drawings of the present application or directly or indirectly applied to other related technical fields are included in the scope of the present application.