Method and system for removing regional cross grains and medium
By obtaining the grayscale matrix of the row area of the image, performing linear fitting and interpolation processing, and calculating the gain and bias matrices, the problem of large computational complexity in removing regional horizontal stripes in the existing technology is solved, and an efficient image correction effect is achieved. And applicable to FPGA hardware.
Patent Information
- Application Number
- CN202410920142.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-10
- Publication Date
- 2024-09-27
AI Technical Summary
The existing technology requires a large amount of calculation when removing regional horizontal stripes in images and is not conducive to hardware implementation. It is also limited to the structural characteristics of CMOS image sensors and is difficult to effectively apply in general image processing.
By obtaining the grayscale matrix of the row area of the image, using linear fitting to calculate the gain matrix and bias matrix, performing interpolation processing to obtain the second gain matrix and the second bias matrix, and calculating the correction value of the mean grayscale value of each row of pixels , to achieve the removal of regional horizontal stripes.
This method reduces the calculation amount of hardware resources, optimizes the gain coefficient and offset coefficient, ensures the accuracy of the correction results, and ensures the smoothness of grayscale changes in the row area, and is suitable for FPGA implementation.
Smart Images

Figure CN118710554A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a method, system and medium for removing regional horizontal stripes. Background Art
[0002] Usually, the images captured by actual cameras will have uneven regional grayscale values in the vertical direction due to the inherent defects of the image sensor, such as inconsistent response of sensor pixel units to imaging targets caused by uneven dark current and pixel defects, and errors in pixel unit size caused by process problems. This problem is specifically manifested as dark grayscale in the upper and lower areas of the image and bright grayscale in the middle area.
[0003] In the prior art, the horizontal streak correction algorithm is an algorithm introduced for the grayscale value difference between each row in the vertical direction of the image. The horizontal streak correction algorithm performs linear fitting on a row of the image as a unit, so as to achieve the purpose of eliminating the difference by making the average grayscale value between rows the same. The horizontal streak correction implemented based on the above horizontal streak correction algorithm has a large amount of calculation and is not conducive to hardware implementation.
[0004] Chinese patent CN 112967206 B discloses an adaptive infrared image and video vertical stripe removal method based on image segmentation. The patent obtains pre-processed image frame data, filters the image data, segments the images before and after filtering, and uses the one-dimensional noise feature distribution of each image block in the column direction to perform adaptive image edge evaluation to obtain the vertical stripe noise superposition amount, and corrects the median value in columns as the final vertical stripe noise superposition amount of the column, and then uses the final vertical stripe noise superposition amount to remove vertical stripes on the original image in columns. The method implemented by the patent has the problem of large amount of calculation and not using hardware implementation, and the technical means of the patent are different from this solution.
[0005] Chinese patent CN 112291446 B discloses a method for correcting the non-uniformity of a large-array CMOS image sensor. According to the structural characteristics of the CMOS image sensor, the patent performs curve fitting on the k groups of grayscale mean matrices after grouping, and then optimizes the correction model. This method can effectively solve the non-uniformity problem of the CMOS image sensor, while reducing parameter storage and facilitating the implementation of the hardware system. However, the implementation of the method described in the patent depends on the structural characteristics of the CMOS image sensor and has limitations; secondly, the patent performs multiple optimizations based on the pixel grayscale value to obtain the correction parameters, which is different from the technical means of this solution. Summary of the invention
[0006] The present invention provides a method, system and medium for removing regional horizontal streaks, which can solve at least one of the above technical problems.
[0007] To achieve the above object, the present invention proposes the following technical solutions: A method for removing regional horizontal striae, comprising: Obtain the grayscale value of each pixel of L original images, and calculate the row area grayscale matrix of each image to match the grayscale value distribution characteristics in any original image; Based on the row region grayscale matrix, a first gain matrix and a first bias matrix are calculated respectively by linear fitting to obtain the relationship between any row region grayscale value and the row region grayscale maximum value; The first gain matrix and the first bias matrix are interpolated respectively to obtain the second gain matrix and the second bias matrix, so that the grayscale mean of any row of pixels in each image obtains the corresponding second gain coefficient and second bias coefficient; Based on the second gain matrix and the second bias matrix, a correction value of the grayscale mean of pixels in any row of each image is calculated to obtain each corrected image.
[0008] Furthermore, the row area grayscale matrix of each image is calculated, including: based on the grayscale value of each pixel point in any image and the number of rows n, setting the number of rows h of the row area, calculating the grayscale mean of any row area, and obtaining the row area grayscale matrix of the image.
[0009] Further, setting the number of rows h of the row region includes: setting the number of rows h of the row region based on the number of rows n of the original image, and if the number of rows of any row region is the same, then the number of row regions of any original image is .
[0010] Further, setting the number of rows h of the row region includes: setting the number of rows h of the row region based on the number of rows n of the original image, and except for the number of rows of the last row region, the numbers of rows of other row regions are the same, then the number of row regions of any original image is .
[0011] Furthermore, based on the row area grayscale matrix, linear fitting is used to calculate the first gain matrix and the first bias matrix, including: if L=1, setting the first bias matrix to a zero matrix; using any row area grayscale in the row area grayscale matrix as the horizontal coordinate, and the maximum value of the row area grayscale in the row area grayscale matrix as the vertical coordinate, and using the least squares method to calculate the first gain matrix.
[0012] Furthermore, based on the row area grayscale matrix, linear fitting is used to calculate the first gain matrix and the first bias matrix, including: if L>1, in the L row area grayscale matrices, the maximum value of the row area grayscale of the same row area is used as the vertical coordinate, and the L row area grayscales of the same row area are used as the horizontal coordinate, and the least squares method is used to calculate the gain coefficient and bias coefficient corresponding to each row area respectively, so as to obtain the first gain matrix and the first bias matrix.
[0013] Furthermore, the first gain matrix and the first bias matrix are interpolated and processed respectively, including: respectively expanding the first gain matrix and the first bias matrix, and using linear interpolation for the expanded first gain matrix and the first gain matrix to respectively calculate the second gain coefficient and the second bias coefficient of any row to obtain the second gain matrix and the second bias matrix.
[0014] Further, the first gain matrix and the first bias matrix are respectively expanded, including: in the first gain matrix, adding a first row, assigning a first gain coefficient corresponding to the first row area, adding a last row, and assigning a first gain coefficient corresponding to the last row area; in the first bias matrix, adding a first row, assigning a first bias coefficient corresponding to the first row area, adding a last row, and assigning a first bias coefficient corresponding to the last row area.
[0015] Based on the same inventive concept, the present invention also proposes a system for removing regional horizontal stripes, comprising: An acquisition module obtains the grayscale value of each pixel of L original images; The matrix module sets the number of rows h of the row area based on the gray value of each pixel point and the number of rows n in any image, calculates the gray mean of any row area, and obtains the row area gray matrix of the image to match the gray value distribution characteristics in any original image; linear fitting is used to calculate the first gain matrix and the first bias matrix respectively to obtain the relationship between the gray value of any row area and the maximum gray value of the row area; An interpolation module interpolates the first gain matrix and the first bias matrix respectively to obtain a second gain matrix and a second bias matrix, so that the grayscale mean of any row of pixels in each image obtains its corresponding second gain coefficient and second bias coefficient; The correction module calculates the correction value of the grayscale mean of any row of pixels in each image based on the second gain matrix and the second bias matrix to obtain each corrected image.
[0016] On the other hand, the present invention further provides a computer-readable storage medium, comprising a computer program, which, when executed by a processor, implements the method for removing regional horizontal stripes as described above.
[0017] The beneficial effects of the present invention are as follows: The present application provides a method for removing regional horizontal stripes. To facilitate FPGA implementation, the present application calculates the corresponding gain coefficient and bias coefficient in units of row areas to reduce the number of intermediate coefficients and the hardware resources required for calculation, and optimizes the gain coefficient and bias coefficient to ensure the accuracy of the correction result.
[0018] In this application, on the basis of least squares linear fitting, the gain coefficient and bias coefficient are interpolated again. On the one hand, in the linear fitting data, the mean of each pixel in the row area cannot be guaranteed to be the same, and there may be a sudden change in grayscale at the junction of the areas. Therefore, it is necessary to use interpolation processing based on the row area to ensure the smoothness of the grayscale change.
[0019] In addition, the present invention also considers that the upper boundary and the lower boundary of any image are only in one row area, and the linear fitting of the row area of the upper boundary or the lower boundary has limited accuracy of the correction result. In order to make the row area of the upper boundary or the lower boundary interpolation processing can be used to improve the accuracy of the correction result. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is a schematic flow chart of the method for removing regional horizontal stripes in the present invention; Figure 2 is a schematic diagram of an original image in Example 1 of the present invention; Figure 3 is a schematic diagram of the first bias coefficient and the first gain coefficient in Example 1 of the present invention; Figure 4 It is a schematic diagram of the interpolation processing in Example 1 of the present invention. DETAILED DESCRIPTION
[0021] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments.
[0022] like Figure 1 As shown, the present invention provides a method for removing regional horizontal stripes, comprising: Get the gray value of each pixel of L original images, and calculate the row area gray matrix of each image to match the gray value distribution characteristics in any original image.
[0023] Among them, calculating the row area grayscale matrix of each image includes: based on the grayscale value of each pixel point in any image and the number of rows n, setting the number of rows h of the row area, calculating the grayscale mean of any row area, and obtaining the row area grayscale matrix of the image.
[0024] The number of rows h of the row region is set, including: based on the number of rows n of the original image, the number of rows h of the row region is set, and if the number of rows of any row region is the same, the number of row regions of any original image is .
[0025] Alternatively, based on the number of rows n of the original image, the number of rows h of the row region is set. Except for the number of rows in the last row region, the number of rows in other row regions is the same. Then the number of row regions of any original image is .
[0026] Based on the row region grayscale matrix, linear fitting is adopted to respectively calculate the first gain matrix and the first bias matrix to obtain the relationship between any row region grayscale value and the row region grayscale maximum value.
[0027] Specifically, it includes: if L=1, setting the first bias matrix to be a zero matrix; taking any row area grayscale in the row area grayscale matrix as the horizontal coordinate and the maximum value of the row area grayscale in the row area grayscale matrix as the vertical coordinate, and using the least squares method to calculate the first gain matrix.
[0028] It also includes: if L>1, in the L row area grayscale matrices, the maximum value of the row area grayscale of the same row area is used as the vertical coordinate, and the L row area grayscales of the same row area are used as the horizontal coordinate, and the least squares method is used to calculate the gain coefficient and bias coefficient corresponding to each row area respectively, so as to obtain the first gain matrix and the first bias matrix.
[0029] The first gain matrix and the first bias matrix are interpolated and processed respectively to obtain the second gain matrix and the second bias matrix, so that the grayscale mean of any row of pixels in each image obtains the corresponding second gain coefficient and second bias coefficient.
[0030] Specifically, the method includes: respectively expanding the first gain matrix and the first bias matrix, and using linear interpolation to respectively calculate the second gain coefficient and the second bias coefficient of any row of the expanded first gain matrix and the first gain matrix, so as to obtain the second gain matrix and the second bias matrix.
[0031] Among them, the first gain matrix and the first bias matrix are expanded respectively, including: in the first gain matrix, adding a first row, assigning a first gain coefficient corresponding to the first row area, adding a last row, and assigning a first gain coefficient corresponding to the last row area; in the first bias matrix, adding a first row, assigning a first bias coefficient corresponding to the first row area, adding a last row, and assigning a first bias coefficient corresponding to the last row area.
[0032] Based on the second gain matrix and the second bias matrix, a correction value of the grayscale mean of pixels in any row of each image is calculated to obtain each corrected image. Example 1
[0033] Combined with the following Figure 2 The specific example shown is used to illustrate the above method steps: S1 collects L original images with different saturation levels under uniform light conditions, and each original image corresponds to a saturation level. Each original image collected has n rows and m columns, and the number of pixels in the image is n×m. Wherein L≥1, L is a positive integer. In this embodiment, L>1 is used to illustrate the method, as follows.
[0034] S2 calculates the row area grayscale matrix of each image. Specifically, it includes: based on the grayscale value of each pixel point in any image and the number of rows n, setting the number of rows h of the row area, calculating the grayscale mean of any row area, and obtaining the row area grayscale matrix of the image to match the grayscale value distribution characteristics in the image. In this embodiment, the grayscale values in the original image are distributed with regional characteristics, specifically including dark grayscale in the upper and lower areas and bright grayscale in the middle area.
[0035] S201 calculates the gray value A of each pixel in each original image respectively ij , where i represents the row coordinate of the pixel, and j represents the column coordinate of the pixel. The grayscale matrix of any image is obtained as follows:
[0036] The superscript L represents the sequence number of the current image, and L is a positive integer. Represents the grayscale value of the pixel (i, j) in the Lth image.
[0037] In order to explain the calculation process, the following steps take the data calculation process of one image as an example. In actual operation, multiple images can be processed simultaneously.
[0038] S202: Based on the grayscale matrix of the image obtained in S201 and the number of rows n of the image, set the number of rows h of the image row area, and calculate the grayscale mean value of the xth row area. , where m is the number of columns (total width) of any original image, and the row area grayscale matrix of the image is obtained as or ; In the formula, the subscript Express Round down.
[0039] Description of row area settings: Method 1: Based on the number of rows n of the original image, set the number of rows h of the row area. If the number of rows in any row area is the same, the number of row areas in any original image is Among them, the number of rows in any row area is the same, and there are two situations: (1) The number of rows in the row region h can be divided by the number of rows in the original image. In this case, the number of row regions in the original image is an integer; (2) The number of rows in the row region, h, cannot be divided by the number of rows in the original image. In this case, the last row region is discarded, and the number of rows in the discarded row region is less than h.
[0040] In this case, the row region grayscale matrix of the image is .
[0041] Method 2: For the above situation where the value cannot be divided evenly, in addition to discarding the row area that is less than h rows, the grayscale value of the pixel points in the remaining rows and the number of rows can also be used to calculate the grayscale mean of the current row area. , the calculation method is: Assume that the number of remaining rows in the row region that does not satisfy h rows is h r , the corresponding row area grayscale mean is .
[0042] Then the number of row regions in the image is ; The row area grayscale matrix of the image is .
[0043] In the above case where the row regions that are less than h rows are retained, the number of rows in the other row regions is the same except for the number of rows in the last row region.
[0044] Here, 32 is taken as an example, and it can also be 16, 64, etc., which are multiples of 2 to adapt to the current common even-numbered row images. In this embodiment, only multiples of 2 are used as an optimal method for explanation, but it is not limited to setting the row number h to an odd number, or other arbitrary numbers, but 2≤h≤(n-2), so as to ensure that the image can have at least two row areas, and there are at least two rows in any row area.
[0045] Taking the case where the number of rows in the row area h can be divided by the number of rows in the original image as an example, let h = 32, then the grayscale mean of the row area is calculated , then the row area gray matrix of the image is , similarly, it can also be expressed as .
[0046] S3 calculates the first gain matrix and the first bias matrix respectively based on the row region grayscale matrix by linear fitting to obtain the relationship between any row region grayscale value and the row region grayscale maximum value.
[0047] Specifically including: if L>1, in the L row area grayscale matrices, the maximum value of the row area grayscale of the same row area is used as the vertical coordinate, and the L row area grayscales of the same row area are used as the horizontal coordinate, and the least squares method is used to calculate the gain coefficient and bias coefficient corresponding to each row area respectively, so as to obtain the first gain matrix and the first bias matrix.
[0048] like Figure 3As shown, according to step S2, the row region grayscale matrix corresponding to L original images is obtained, that is, there are L row region grayscale matrices, and the row region grayscale matrix of any image is or .
[0049] In this embodiment, the row area gray matrix is used as Take as an example to illustrate the calculation process of the first bias matrix and the first gain matrix, as follows: According to step S2, the row area grayscale matrix corresponding to the first image is obtained as follows: ; The row area grayscale matrix corresponding to the first image is ;......;The row area grayscale matrix corresponding to the Lth image is .
[0050] In this embodiment, the linear fitting equation of the least squares method is: In the formula, is the first correction value of any row area.
[0051] If we take the first row area as an example, that is, the grayscale of the L row areas of the first row area in L images The horizontal axis is the maximum grayscale value of the first row area. is the vertical coordinate, that is , using the least squares method, calculate the first gain coefficient K0 and the first bias coefficient O0 of the first row area.
[0052] The first gain coefficient and the first bias coefficient are calculated in sequence for the x row regions of the L row region grayscale matrix to obtain the first gain coefficient K corresponding to any row region. x and the first bias coefficient O x , and then obtain the first gain matrix and the first bias matrix.
[0053] The mathematical expression of the first gain matrix is: ; The mathematical expression of the first bias matrix is: .
[0054] If the L images above are set with method 1 for h, the row area grayscale matrix of any image is . Then the mathematical expression of the corresponding first gain matrix is: ; The mathematical expression of the first bias matrix is: .
[0055] After the above calculations, since the grayscale mean values of pixels in each row in the row area may be different, the least squares method and the above fitting equation are used. After linear fitting, a sudden change in grayscale may occur at the junction of any two adjacent row areas. Therefore, it is necessary to use interpolation processing based on the row area to ensure the smoothness of the grayscale change.
[0056] In addition, the present invention also takes into account that the upper boundary and the lower boundary of any image are only in one row area, and the least square method and the above fitting equation are used for the row area of the upper boundary or the lower boundary, and the accuracy of the correction result achieved after linear fitting is limited. In order to make the row area of the upper boundary or the lower boundary use interpolation processing to improve the accuracy of the correction result, the following steps are performed.
[0057] S4 interpolates and processes the first gain matrix and the first bias matrix respectively to obtain the second gain matrix and the second bias matrix, so that the grayscale mean of any row of pixels in each image obtains the corresponding second gain coefficient and second bias coefficient.
[0058] Specifically, the method includes: respectively expanding the first gain matrix and the first bias matrix, and using linear interpolation to respectively calculate the second gain coefficient and the second bias coefficient of any row of the expanded first gain matrix and the first gain matrix, so as to obtain the second gain matrix and the second bias matrix.
[0059] Among them, the first gain matrix and the first bias matrix are expanded respectively, including: in the first gain matrix, adding a first row, assigning a first gain coefficient corresponding to the first row area, adding a last row, and assigning a first gain coefficient corresponding to the last row area; in the first bias matrix, adding a first row, assigning a first bias coefficient corresponding to the first row area, adding a last row, and assigning a first bias coefficient corresponding to the last row area.
[0060] like Figure 4 As shown, based on the first gain matrix and the first bias matrix obtained by calculation in S3, an extended description thereof is as follows: Taking the first gain matrix , the first bias matrix For example, the expanded first gain matrix is , the expanded first bias matrix is .in, , , , .
[0061] For the expanded first gain matrix and the first gain matrix, linear interpolation is used to calculate the second gain coefficient and the second bias coefficient of any row respectively.
[0062] The first gain coefficient K of the x-th row area is knownx-1 and the first bias coefficient O x-1 , the first gain coefficient K of the x+1th row area x and the first bias coefficient O x .
[0063] If the y i The row is between the xth row area and the x+1th row area, that is, the yth row area. i row is any row in the xth row region (or the x+1th row region), then the yth i The second gain factor of the line , the second bias coefficient The calculation formula is as follows:
[0064]
[0065] According to the above calculation formula, linear interpolation is performed on the first gain coefficient and the first bias coefficient corresponding to any two adjacent row areas in turn, and the second gain coefficient and the second bias coefficient of any row are calculated to obtain the second gain matrix , the second bias matrix .
[0066] Through the above interpolation calculation, the second gain coefficient and the second bias coefficient corresponding to the grayscale mean value of any row of the original image can be obtained, that is, the second gain matrix and the second bias matrix can be obtained.
[0067] S5 calculates the correction value of the grayscale mean of any row of pixels in each image based on the second gain matrix and the second bias matrix to obtain each corrected image.
[0068] Based on the grayscale value of each pixel in any image obtained by S2, each second gain coefficient of the second gain matrix and each second bias coefficient of the second bias matrix are obtained based on S4, and linear fitting is used to obtain the corrected value of the grayscale mean of each row of pixels in the original image, thereby obtaining L corrected images.
[0069] In S201, the gray value A of each pixel in each original image is calculated. ij , where i represents the row coordinate of the pixel, and j represents the column coordinate of the pixel. The grayscale matrix of any image is obtained as follows:
[0070] The superscript L represents the sequence number of the current image, and L is a positive integer. Represents the grayscale value of the pixel (i, j) in the Lth image.
[0071] Based on the grayscale matrix of any of the above images and the number of columns m of any original image, calculate the grayscale mean of the i-th row , and then obtain the row grayscale mean matrix of any image .
[0072] The second gain coefficient corresponding to any row in the second gain matrix obtained in S4 , the second bias coefficient corresponding to any row in the second bias matrix , using linear mapping, obtain the correction value of the grayscale mean of any row of pixels in any image .
[0073] In this embodiment, the linear mapping relationship is: .
[0074] Then the row grayscale mean matrix of any corrected image is . Example 2
[0075] The difference between this embodiment and embodiment 1 is that in this embodiment, only one original image is obtained. The specific calculation process is as follows: S1 collects L original images under uniform light conditions. Each original image collected has n rows and m columns, and the number of pixels in the image is n×m. Wherein, L≥1, L is a positive integer. In this embodiment, L=1 is used to illustrate the method, as follows.
[0076] S2 is the same as the method and process described in Example 1 and the setting of the row area, which will not be described in detail here. After calculation in S2, the row area grayscale matrix of the image is obtained as follows: or .
[0077] S3 calculates the first gain matrix and the first bias matrix based on the row region grayscale matrix by linear fitting, which specifically includes: if L=1, setting the first bias matrix as a zero matrix; taking any row region grayscale in the row region grayscale matrix as the horizontal coordinate, taking the maximum value of the row region grayscale in the row region grayscale matrix as the vertical coordinate, and using the least square method to calculate the first gain matrix.
[0078] In this embodiment, the row area gray matrix is used as Take the example to illustrate the calculation process of the first gain matrix, which is as follows: Since only one image is collected in this embodiment, the first bias matrix is set to be a zero matrix, that is, the first bias coefficient O=0.
[0079] In this embodiment, the linear fitting equation of the least squares method is: ,Right now .
[0080] Take any row of the grayscale matrix in the grayscale matrix of the row The horizontal axis is the maximum grayscale value of the row area. is the vertical axis, that is, , using the least squares method, calculate the first gain coefficient K0 of the first row area.
[0081] For the above The corresponding first gain coefficients are calculated in turn in each row area, and then the first gain matrix is obtained. .
[0082] S4 interpolates the first gain matrix and the first offset matrix respectively to obtain a second gain matrix and a second offset matrix.
[0083] The interpolation process in this embodiment is the same as that in Embodiment 1, except that the bias matrix in this embodiment is a zero matrix, and is still a zero matrix after extended interpolation.
[0084] The first gain matrix after expansion is ,in, , .
[0085] For the expanded first gain matrix, linear interpolation is used to calculate the second gain coefficient of any row, thereby obtaining the second gain matrix.
[0086] If the y i The row is between the xth row area and the x+1th row area, that is, the yth row area. i row is any row in the xth row region (or the x+1th row region), then the yth i The second gain factor of the line The calculation formula is as follows:
[0087] According to the above calculation formula, linear interpolation is performed on the first gain coefficients corresponding to any two adjacent row areas in turn, and the second gain coefficient of any row is calculated to obtain the second gain matrix .
[0088] S5 calculates the correction value of the grayscale mean of any row of pixels in each image based on the second gain matrix and the second bias matrix to obtain each corrected image.
[0089] In this embodiment, the second offset matrix is a zero matrix, and other calculation processes are the same as those in Embodiment 1.
[0090] In this embodiment, the row grayscale mean matrix of the image is ; The second gain matrix obtained based on S4 , using linear mapping, obtain the correction value of the grayscale mean of any row of pixels in the image .
[0091] In this embodiment, the linear mapping relationship is: . Then the row grayscale mean matrix of any rectified image is .
[0092] Based on the same inventive concept, the present invention also proposes a system for removing regional horizontal stripes, which is used to execute the above method.
[0093] An acquisition module obtains the grayscale value of each pixel of L original images; The matrix module sets the number of rows h of the row area based on the gray value of each pixel point and the number of rows n in any image, calculates the gray mean of any row area, and obtains the row area gray matrix of the image to match the gray value distribution characteristics in any original image; linear fitting is used to calculate the first gain matrix and the first bias matrix respectively to obtain the relationship between the gray value of any row area and the maximum gray value of the row area; An interpolation module interpolates the first gain matrix and the first bias matrix respectively to obtain a second gain matrix and a second bias matrix, so that the grayscale mean of any row of pixels in each image obtains its corresponding second gain coefficient and second bias coefficient; The correction module calculates the correction value of the grayscale mean of any row of pixels in each image based on the second gain matrix and the second bias matrix to obtain each corrected image.
[0094] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method described above is implemented.
[0095] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0096] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for removing regional horizontal striae, It is characterized in that include: Obtain the grayscale value of each pixel of L original images, and calculate the row area grayscale matrix of each image to match the grayscale value distribution characteristics in any original image; Based on the row region grayscale matrix, a first gain matrix and a first bias matrix are calculated respectively by linear fitting to obtain the relationship between any row region grayscale value and the row region grayscale maximum value; The first gain matrix and the first bias matrix are interpolated respectively to obtain the second gain matrix and the second bias matrix, so that the grayscale mean of any row of pixels in each image obtains the corresponding second gain coefficient and second bias coefficient; Based on the second gain matrix and the second bias matrix, a correction value of the grayscale mean of pixels in any row of each image is calculated to obtain each corrected image.
2. The method for removing regional horizontal stripes according to claim 1, It is characterized in that Calculating the row area grayscale matrix of each image includes: setting the number of rows h of the row area based on the grayscale value of each pixel point and the number of rows n in any image, calculating the grayscale mean of any row area, and obtaining the row area grayscale matrix of the image.
3. The method for removing regional horizontal stripes according to claim 2, It is characterized in that Setting the number of rows h of the row region includes: based on the number of rows n of the original image, setting the number of rows h of the row region, if the number of rows of any row region is the same, then the number of row regions of any original image is .
4. The method for removing regional horizontal stripes according to claim 2, It is characterized in that Setting the number of rows in the row region h includes: Based on the number of rows n of the original image, setting the number of rows in the row region h, except for the number of rows in the last row region, the number of rows in other row regions is the same, then the number of row regions in any original image is .
5. The method for removing regional horizontal stripes according to claim 1, It is characterized in that Based on the row region grayscale matrix, linear fitting is used to calculate the first gain matrix and the first bias matrix, including: if L=1, setting the first bias matrix to a zero matrix; using any row region grayscale in the row region grayscale matrix as the horizontal coordinate and the maximum value of the row region grayscale in the row region grayscale matrix as the vertical coordinate, and using the least squares method to calculate the first gain matrix.
6. The method for removing regional horizontal stripes according to claim 1, It is characterized in that Based on the row area grayscale matrix, linear fitting is used to calculate the first gain matrix and the first bias matrix, including: if L>1, in the L row area grayscale matrices, the maximum value of the row area grayscale of the same row area is used as the vertical coordinate, and the L row area grayscales of the same row area are used as the horizontal coordinate, and the least squares method is used to calculate the gain coefficient and bias coefficient corresponding to each row area respectively, so as to obtain the first gain matrix and the first bias matrix.
7. The method for removing regional horizontal stripes according to claim 1, It is characterized in that The first gain matrix and the first bias matrix are interpolated respectively, including: respectively expanding the first gain matrix and the first bias matrix, and using linear interpolation for the expanded first gain matrix and the first gain matrix to respectively calculate the second gain coefficient and the second bias coefficient of any row to obtain the second gain matrix and the second bias matrix.
8. The method for removing regional horizontal stripes according to claim 7, It is characterized in that The first gain matrix and the first bias matrix are respectively expanded, including: in the first gain matrix, adding a first row, assigning a first gain coefficient corresponding to the first row area, adding a last row, and assigning a first gain coefficient corresponding to the last row area; in the first bias matrix, adding a first row, assigning a first bias coefficient corresponding to the first row area, adding a last row, and assigning a first bias coefficient corresponding to the last row area.
9. A system for removing regional horizontal stripes, It is characterized in that include: An acquisition module obtains the grayscale value of each pixel of L original images; The matrix module sets the number of rows h of the row area based on the gray value of each pixel point and the number of rows n in any image, calculates the gray mean of any row area, and obtains the row area gray matrix of the image to match the gray value distribution characteristics in any original image; linear fitting is used to calculate the first gain matrix and the first bias matrix respectively to obtain the relationship between the gray value of any row area and the maximum gray value of the row area; An interpolation module interpolates the first gain matrix and the first bias matrix respectively to obtain a second gain matrix and a second bias matrix, so that the grayscale mean of any row of pixels in each image obtains its corresponding second gain coefficient and second bias coefficient; The correction module calculates the correction value of the grayscale mean of any row of pixels in each image based on the second gain matrix and the second bias matrix to obtain each corrected image.
10. A computer-readable storage medium comprising a computer program, It is characterized in that When the computer program is executed by a processor, a method for removing regional horizontal stripes as described in any one of claims 1 to 8 is implemented.
