Method for solving false color problem in Bayer image interpolation algorithm

CN116416126BActive Publication Date: 2026-09-18HEFEI JUNZHENG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111639129.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-29
Publication Date
2026-09-18
Estimated Expiration
2041-12-29

AI Technical Summary

Technical Problem

[0004]1.基于插值过程的校正方法太依赖于G通道,对R和B通道关注太少,不能很好的解决伪彩色问题;

Benefits of technology

[0162] 1. Effectively reduces false color phenomenon, resulting in more accurate interpolation results and a more perfect visual effect;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116416126B_ABST
    Figure CN116416126B_ABST
Patent Text Reader

Abstract

The application provides a method for solving false color problem in Bayer image interpolation algorithm, comprising: S1, calculating horizontal color difference and vertical color difference; S1.1, linear interpolation; S1.2, calculating horizontal color difference and vertical color difference; S2, calculating interpolation weight; S2.1, calculating color difference gradient; S2.2, calculating interpolation weight; S3, estimating color difference value; S4, G channel interpolation; S5, R channel and B channel interpolation; S5.1, calculating average gradient of eight directions; S5.2, calculating interpolation weight of eight directions; S5.3, estimating B channel interpolation result of R pixel position; S5.4, estimating R channel interpolation result of B pixel position; S5.5, estimating R channel interpolation result of G pixel position; S5.6, estimating B channel interpolation result of G pixel position; S6, correcting interpolation result; S6.1, estimating image color difference value; S6.2, estimating saturation; S6.3, calculating fusion weight; S6.4, calculating correction value. The method effectively reduces false color phenomenon, the interpolation result is more accurate, the visual effect is more perfect, the original Bayer image is used, complex operation is not needed, and the hardware is easy to realize.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to a method for solving the pseudo-color problem in the Bayer image interpolation algorithm. Background Technology

[0002] In Bayer images, the sampling frequencies of the R and B channels are only half that of the G channel. Therefore, the R and B channels are prone to generating incorrect interpolation information, leading to false color in the interpolation results. Methods to address false color mainly fall into two categories: correction of the interpolation process and correction of the interpolation results. Correction of the interpolation process typically involves first interpolating the G channel, and then using the G channel to guide the interpolation of the R and B channels. This method focuses primarily on the interpolation of the G channel; the more accurate the interpolation result of the G channel, the more accurate the interpolation results of the R and B channels will be. Correction of the interpolation results involves first interpolating the complete RGB image, and then performing color correction on the moiré areas prone to false color.

[0003] However, the main drawback of the existing technology is:

[0004] 1. Correction methods based on interpolation rely too much on the G channel and pay too little attention to the R and B channels, thus failing to effectively solve the false color problem;

[0005] 2. Correction based on interpolation results depends on the detection of moiré regions, but moiré region detection itself is a difficult problem. In addition, this method will fail for non-moiré regions.

[0006] 3. Insufficient resolution: Neither algorithm fully utilizes the original Bayer image information. The extensive smoothing operations during interpolation inevitably reduce the image resolution.

[0007] 4. High complexity: Correction methods based on the interpolation process generally require complex interpolation algorithms (such as guided upsampling, neural networks, etc.) to achieve good correction results, while correction based on the results requires relatively complex methods for judging moiré patterns.

[0008] In addition, commonly used technical terms in the prior art include:

[0009] 1. Bayer Image: Most color cameras use Bayer sensors to acquire image information. A color filter array (CFA) is covered on the sensor surface. The most common CFA format is Bayer format. The raw data acquired by the sensor in Bayer format is called a Bayer image. Figure 1 The image shown is a typical Bayer diagram.

[0010] 2. Bayer image interpolation: The process of restoring a Bayer image to a complete RGB image.

[0011] 3. Resolution: The ability to distinguish details of the photographed object. The higher the resolution, the richer the image details and the higher the clarity.

[0012] 4. Nyquist Frequency: According to the sampling theorem, mixing will occur when the sampling frequency is less than twice the highest frequency of the sampled signal. In practical applications, the sampling frequency is known, and half of the sampling frequency is called the Nyquist frequency.

[0013] 5. Moiré patterns: In Bayer image interpolation, due to the influence of sampling frequency and interpolation algorithm, phenomena such as checkerboard patterns and false colors may appear in high-frequency regions, which are called moiré patterns.

[0014] 6. False Color: When interpolating Bayer images, if the color information is interpolated incorrectly, abnormal colors (False Color) may appear, which is called false color. Summary of the Invention

[0015] To address the aforementioned issues, the main objective of this application is to simultaneously consider the correction of the interpolation process and the correction of the interpolation results, adopting a more reasonable solution that effectively reduces the false color phenomenon, resulting in more accurate interpolation results and a more perfect visual effect.

[0016] Specifically, the present invention provides a method for solving the pseudo-color problem in the Bayer image interpolation algorithm, the method comprising the following steps:

[0017] S1, Calculate horizontal and vertical color differences: Calculate linear interpolation in the horizontal and vertical directions; and calculate the horizontal and vertical color differences based on the obtained linear interpolation. Arrange all horizontal color difference values ​​together according to pixel position to form a horizontal color difference map. The vertical color difference map is constructed by arranging all the vertical color difference values ​​together according to their pixel positions.

[0018] S2, Calculate the interpolation weights:

[0019] S2.1, Calculate the color difference gradient:

[0020] The formulas for calculating the color difference gradient in the horizontal and vertical directions at position coordinates (i, j) are as follows:

[0021]

[0022]

[0023] The average gradients in the four directions are:

[0024]

[0025]

[0026]

[0027]

[0028] S2.2, Calculate the interpolation weights:

[0029] The sum of the color difference gradients in the four directions is:

[0030]

[0031] in, This represents the sum of color difference gradients;

[0032] when When the value is 0, the interpolation weights are the same in all four directions:

[0033] W left (i, j = W) right (i, j) = W top (i, j) = W down (i, j) = 0.25

[0034] otherwise:

[0035]

[0036]

[0037]

[0038]

[0039] W in the formula left (i, j), W right (i, j), W itop (i, j), W down (i, j) represent the weight values ​​of the four directions (left, right, up, down) at coordinate (i, j);

[0040] S3. Estimate color difference value:

[0041] This represents the estimated color difference between R and G at position (i, j); the estimated color difference between B and G is obtained.

[0042] S4. Obtain G-channel interpolation

[0043] S5. Obtain the interpolation values ​​for the R and B channels:

[0044] When the interpolation directions of the R, B, and G channels are the same, the consistency of the three RGB channels can be guaranteed to the greatest extent. Therefore, the G channel, which has already been interpolated, is used to complete the directional interpolation of the R and B channels.

[0045] S5.1, Calculate the average gradient in 8 directions.

[0046] Using the results from S4, calculate the gradient values ​​in the four directions: horizontal, vertical, diagonal, and anti-diagonal.

[0047]

[0048]

[0049]

[0050]

[0051] in, This represents the interpolation result of channel G obtained in the previous step S4. These represent the gradient values ​​in the four directions: horizontal, vertical, diagonal, and anti-diagonal.

[0052] The average gradient values ​​in all eight directions can be calculated using the gradient values ​​in these four directions:

[0053]

[0054]

[0055]

[0056]

[0057]

[0058]

[0059]

[0060]

[0061] S5.2, Calculate the interpolation weights in 8 directions:

[0062] The interpolation weights in the eight directions were calculated using the same weighting method as in G-channel interpolation.

[0063] The total chromatic difference gradient in the eight directions is:

[0064]

[0065] when When it is 0:

[0066]

[0067] otherwise:

[0068]

[0069] S5.3, Estimating the B channel interpolation result at pixel R:

[0070] For the R position in the Bayer image, the B channel interpolation is performed using the following formula:

[0071]

[0072] in This represents the interpolation result for channel B. This represents the estimated color difference between B and G, calculated as follows:

[0073]

[0074] The color difference calculation method for each direction is as follows:

[0075]

[0076]

[0077]

[0078]

[0079]

[0080]

[0081]

[0082]

[0083] S5.4, Estimating the R-channel interpolation result at pixel B:

[0084] Based on symmetry, the B-pixel position in the Bayer image is calculated entirely using the B-channel interpolation method for the R-pixel position in S5.3;

[0085] S5.5, Estimated R-channel interpolation result at pixel G:

[0086] For pixel positions Gr in a Bayer image where the left and right adjacent pixels are R, the following formula is used to perform interpolation of the R and B channels:

[0087]

[0088] in:

[0089]

[0090]

[0091]

[0092]

[0093]

[0094]

[0095]

[0096]

[0097]

[0098] in, R(i,j), G(i,j), and B(i,j) represent the interpolation results obtained in the previous steps, respectively, and represent the data that already exists in the original Bayer image.

[0099] For the position Gb of pixel G in the Bayer image whose left and right adjacent pixels are B, simply add the following to the above calculation formula: By exchanging R(i,j) with R(i,j), we can obtain the interpolation formula for this case;

[0100] S5.6, Estimating the B-channel interpolation result at pixel G:

[0101] Utilizing symmetry, we only need to replace R(i,j) in the calculation formula of step S5.5 with... Replacing it with B(i,j) yields the interpolation formula for the B channel at pixel G.

[0102] S6. Interpolation result correction:

[0103] When the image saturation is very low, there is no need to perform image interpolation. Based on this principle, the interpolation results of the image are corrected, and the specific method is as follows:

[0104] S6.1, Estimate image color difference values:

[0105] If we take the horizontal color difference window in step S1 as 9*9, we can calculate the average color difference in the left and right directions:

[0106]

[0107]

[0108] in, These represent the average color difference in the left and right directions, respectively. Using the same method, the average color difference in the vertical direction is obtained. The mean of the minimum color difference in the four directions is taken as the color difference estimate:

[0109]

[0110] S6.2, Estimating saturation:

[0111]

[0112] in, This indicates the estimated saturation level. This represents the interpolated pixel value of the G channel;

[0113] S6.3, Calculate the fusion weights:

[0114]

[0115] Where W(i,j) represents the calculated fusion weight, and S1 and S2 represent the fusion thresholds set by the user;

[0116] S6.4, Calculate the correction value:

[0117]

[0118]

[0119]

[0120] in, These represent the corrected interpolation results. I(i,j) represents the interpolation results of S4 and S5, and I(i,j) represents the pixel value at the corresponding position in the original Bayer image.

[0121] Step S1 further includes:

[0122] S1.1, Linear interpolation:

[0123] For pixels R or B in the Bayer image, the linear interpolation results in the horizontal and vertical directions are calculated using the following formulas:

[0124]

[0125]

[0126] in, G(i,j-1), G(i,j+1), G(i-1,j), and G(i+1,j) represent the linear interpolation results of the G channel in the horizontal and vertical directions, respectively; G(i,j-1), G(i,j+1), G(i-1,j), and G(i+1,j) represent the actual pixel values ​​of the G channel at the corresponding positions, respectively.

[0127] At pixel G of the Bayer image, the calculation formula is similar to the one above, but for each pixel position, only the interpolation result in one of the horizontal or vertical directions can be calculated:

[0128] If the left and right adjacent positions of pixel G are pixels R, then:

[0129]

[0130] Conversely, if pixel G is adjacent to pixel B on either side, then:

[0131]

[0132] S1.2, Calculate the color difference in the horizontal and vertical directions:

[0133] Subtracting R from G and B from G at the effective positions after linear interpolation yields the color difference image RG and the color difference image BG.

[0134] The color difference at pixel R is:

[0135]

[0136]

[0137] The color difference at pixel B is:

[0138]

[0139]

[0140] If the left and right adjacent positions of pixel G are pixels R, then the color difference at pixel G is:

[0141]

[0142]

[0143] If pixel G is adjacent to pixel B on either side, then the color difference at pixel G is:

[0144]

[0145]

[0146] in, These represent the color difference values ​​between G and R in the horizontal direction, the color difference values ​​between G and R in the vertical direction, the color difference values ​​between G and B in the horizontal direction, and the color difference values ​​between G and B in the vertical direction, respectively.

[0147] The horizontal color difference map is constructed by arranging all the horizontal color difference values ​​together according to their pixel positions. The vertical color difference map is constructed by arranging all the vertical color difference values ​​together according to their pixel positions.

[0148] In step S3, the color difference estimation method is as follows:

[0149]

[0150] in, This represents the estimated color difference between R and G at position (i,j); This represents the vertical and horizontal chromatic aberration images RG and W obtained in step 1. top W down W left W γight Let f represent the weighted images in each of the up, down, left, and right directions; let f represent the chromatic aberration smoothing weight vector in each direction. T Let f be the transpose vector;

[0151] The same method can be used to obtain the estimated color difference values ​​between B and G.

[0152]

[0153] in, This represents the estimated color difference between B and G at position (i,j); and Let BG represent the vertical chromatic aberration image and the horizontal chromatic aberration image obtained in step 1, respectively.

[0154] The weight f can be either Gaussian weight or mean weight.

[0155] The f = [1,1,1] / 3.

[0156] Step S4, G-channel interpolation, further includes:

[0157] For the R position in the Bayer image, the G channel is interpolated using the following formula:

[0158]

[0159] For position B in the Bayer image, the G channel is interpolated using the following formula:

[0160]

[0161] Therefore, after studying the existing technology, a Bayer image interpolation algorithm is proposed to solve the pseudo-color problem. This application has the following advantages:

[0162] 1. Effectively reduces false color phenomenon, resulting in more accurate interpolation results and a more perfect visual effect;

[0163] 2. Improves image resolution, recovers high-frequency information to a greater extent, increases image clarity, and effectively reduces moiré patterns and false color phenomena;

[0164] 3. It effectively reduces complexity, makes full use of the original Bayer image, and can complete the interpolation task without complex calculations, making it easy to implement in hardware. Attached Figure Description

[0165] The accompanying drawings, which are provided to further illustrate the invention and form part of this application, are not intended to limit the scope of the invention.

[0166] Figure 1 This is a schematic diagram of a Bayer image commonly used in existing technologies.

[0167] Figure 2 This is a flowchart illustrating the method of the present invention. Detailed Implementation

[0168] To better understand the technical content and advantages of the present invention, the present invention will now be described in further detail with reference to the accompanying drawings.

[0169] like Figure 2 As shown, this application relates to a method for solving the pseudo-color problem in the Bayer image interpolation algorithm, the method comprising:

[0170] S1, Calculate the horizontal and vertical color differences:

[0171] S1.1, Linear interpolation;

[0172] S1.2, Calculate the color difference in the horizontal direction and the color difference in the vertical direction;

[0173] S2. Calculate the interpolation weights:

[0174] S2.1, Calculate the color difference gradient;

[0175] S2.2, Calculate the interpolation weights;

[0176] S3. Estimate the color difference value;

[0177] S4.G channel interpolation;

[0178] S5.R and B channel interpolation:

[0179] S5.1, Calculate the average gradient in 8 directions;

[0180] S5.2, Calculate the interpolation weights in 8 directions;

[0181] S5.3, Estimate the B channel interpolation result at the R pixel position;

[0182] S5.4, Estimating the R-channel interpolation result at pixel B;

[0183] S5.5, Estimated R-channel interpolation result at pixel G position;

[0184] S5.6, Estimate the B channel interpolation result at the position of pixel G;

[0185] S6. Interpolation result correction:

[0186] S6.1, Estimate image color difference values;

[0187] S6.2, Estimate saturation;

[0188] S6.3, Calculate the fusion weights;

[0189] S6.4, Calculate the correction value.

[0190] Specifically, the method is described in the following steps:

[0191] S1. Calculate the horizontal and vertical color differences.

[0192] (1) Linear interpolation. For pixels R or B in the Bayer image, the linear interpolation results in the horizontal and vertical directions are calculated using the following formulas:

[0193]

[0194]

[0195] in, and These represent the linear interpolation results of the G channel in the horizontal and vertical directions, respectively. G(i,j-1), G(i,j+1), G(i-1,j), and G(i+1,j) represent the actual G channel pixel values ​​at the corresponding positions. At the G pixels in the Bayer image, the calculation formula is similar to the above formula, but only the interpolation result in one direction (horizontal or vertical) can be calculated for each pixel position:

[0196] If the left and right adjacent positions of pixel G are pixels R, then:

[0197]

[0198] Conversely, if pixel G is adjacent to pixel B on either side, then:

[0199]

[0200] (2) Calculate the horizontal and vertical color differences. Subtract G from R and B from G at the effective positions after linear interpolation to obtain the color difference images (RG) and (BG).

[0201] The color difference at pixel R is:

[0202]

[0203]

[0204] The color difference at pixel B is:

[0205]

[0206]

[0207] If the left and right adjacent positions of pixel G are pixels R, then the color difference at pixel G is:

[0208]

[0209]

[0210] If pixel G is adjacent to pixel B on either side, then the color difference at pixel G is:

[0211]

[0212]

[0213] in, These represent the color difference values ​​between G and R in the horizontal direction, the color difference values ​​between G and R in the vertical direction, the color difference values ​​between G and B in the horizontal direction, and the color difference values ​​between G and B in the vertical direction, respectively. Arranging all the horizontal color difference values ​​together according to pixel position constitutes the horizontal color difference map. The vertical color difference map is constructed by arranging all the vertical color difference values ​​together according to their pixel positions.

[0214] S2. Calculate interpolation weights

[0215] (1) Calculate the color difference gradient

[0216] The formulas for calculating the color difference gradient in the horizontal and vertical directions are as follows:

[0217]

[0218]

[0219] The average gradients in the four directions are:

[0220]

[0221]

[0222]

[0223]

[0224] (2) Calculate the interpolation weights

[0225] The sum of the color difference gradients in the four directions is:

[0226]

[0227] Among them, D sum This represents the sum of color difference gradients. When D... sum When the value is 0, the interpolation weights are the same in all four directions:

[0228] W left (i, j) = W right (i, j) = W top (i, j) = W down (i, j) = 0.25

[0229] otherwise:

[0230]

[0231]

[0232]

[0233]

[0234] W in the formula left (i, j), W right (i, j), W top (i, j), W down (i, j) represent the weight values ​​for the left, right, up, and down directions at coordinates (i, j).

[0235] S3. Estimate color difference value

[0236] The color difference estimation method is as follows:

[0237]

[0238] in, This represents the estimated color difference between R and G at position (i,j); This represents the vertical chromatic aberration image and the horizontal chromatic aberration image (RG) obtained in step 1; W left W down W left W right Let f represent the weighted images in each of the up, down, left, and right directions; let f represent the chromatic aberration smoothing weight vector in each direction. T Let f be the transpose of f. f can be weighted by Gaussian or mean weights, such as f = [1, 1, 1] / 3.

[0239] The same method can be used to obtain the estimated color difference values ​​between B and G.

[0240]

[0241] in, This represents the estimated color difference between B and G at position (i,j); and These represent the vertical chromatic aberration image and the horizontal chromatic aberration image (BG) obtained in step 1, respectively.

[0242] S4.G channel interpolation

[0243] For the R position in the Bayer image, the G channel is interpolated using the following formula:

[0244]

[0245] For the R position in the Bayer image, the G channel is interpolated using the following formula:

[0246]

[0247] S5.R and B channel interpolation

[0248] When the interpolation directions of the R, B, and G channels are the same, the consistency of the three RGB channels can be guaranteed to the greatest extent, thereby reducing false color phenomena. Therefore, the G channel, which has already been interpolated, is used to complete the directional interpolation of the R and B channels.

[0249] (1) Calculate the average gradient in 8 directions

[0250] Using the results from step S4, the gradient maps in the four directions—horizontal, vertical, diagonal, and anti-diagonal—can be calculated.

[0251]

[0252]

[0253]

[0254]

[0255] in, This represents the interpolation result of channel G obtained in step S4 of the previous step. These represent the gradient values ​​in the four directions: horizontal, vertical, diagonal, and anti-diagonal.

[0256] The average gradient values ​​in all eight directions can be calculated using the gradient values ​​in these four directions:

[0257]

[0258]

[0259]

[0260]

[0261]

[0262]

[0263]

[0264]

[0265] (2) Calculate the interpolation weights in the eight directions.

[0266] The interpolation weights in the eight directions were calculated using the same weighting method as in G-channel interpolation.

[0267] The total chromatic difference gradient in the eight directions is:

[0268]

[0269] when When it is 0:

[0270]

[0271] otherwise:

[0272]

[0273] (3) Estimating the B-channel interpolation result at the R pixel position

[0274] For the R position in the Bayer image, the B channel interpolation is performed using the following formula:

[0275]

[0276] in This represents the interpolation result for channel B. This represents the estimated color difference between B and G, calculated as follows:

[0277]

[0278] The color difference calculation method for each direction is as follows:

[0279]

[0280]

[0281]

[0282]

[0283]

[0284]

[0285]

[0286]

[0287] (4) Estimating the R-channel interpolation result at pixel B position

[0288] Based on symmetry, for the B pixel position in the Bayer image, the B channel interpolation method for the R pixel position in (3) can be used completely.

[0289] (5) Estimating the R-channel interpolation result at the position of pixel G.

[0290] For the G pixel position (Gr) in a Bayer image where the left and right adjacent pixels are R, the following formula is used to perform interpolation of the R and B channels:

[0291]

[0292] in:

[0293]

[0294]

[0295]

[0296]

[0297]

[0298]

[0299]

[0300]

[0301]

[0302] in, R(i,j), G(i,j), and B(i,j) represent the interpolation results obtained in the previous steps, respectively, and represent the data that already exists in the original Bayer image.

[0303] For the position Gb of pixel G in the Bayer image whose left and right adjacent pixels are B, simply add the following to the above calculation formula: By exchanging R(i,j) with R(i,j), we can obtain the interpolation formula for this case.

[0304] (6) Estimating the B-channel interpolation result of the G pixel position

[0305] Utilizing symmetry, we only need to replace R(i,j) in the calculation formula of step S5.5 with... Replacing it with B(i,j) yields the interpolation formula for the B channel at pixel G.

[0306] S6. Interpolation result correction

[0307] When image saturation is low, image interpolation is unnecessary. This avoids both the loss of detail caused by image smoothing and the generation of false colors. Based on this principle, the interpolation results can also be corrected, as follows:

[0308] (1) Estimating image color difference values

[0309] If we take the horizontal color difference window in step 1 as 9*9, we can calculate the average color difference in the left and right directions:

[0310]

[0311]

[0312] in, These represent the average color difference in the left and right directions, respectively. Using the same method to process the color difference diagram in the vertical direction, we can obtain the average color difference in the up and down directions. The mean of the minimum color difference in the four directions is taken as the color difference estimate:

[0313]

[0314] (2) Estimating saturation

[0315]

[0316] in, This indicates the estimated saturation level. This represents the interpolated pixel value of the G channel.

[0317] (3) Calculate the fusion weight

[0318]

[0319] Where W(i,j) represents the calculated fusion weight, and S1 and S2 represent the fusion thresholds set by the user.

[0320] (4) Calculate the correction value

[0321]

[0322]

[0323]

[0324] in, These represent the corrected interpolation results. I(i,j) represents the interpolation results of S4 and S5, and I(i,j) represents the pixel value at the corresponding position in the original Bayer image.

[0325] In summary, the following key steps in this application constitute a reasonable solution to the false color problem:

[0326] The method for calculating the interpolation weights in step S2.2;

[0327] The entire content of step S5 includes the interpolation weight calculation method for 8 directions, and the interpolation method for the R channel and B channel;

[0328] The entirety of step S6 includes methods for estimating saturation and methods for correcting interpolation results.

[0329] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, various modifications and variations can be made to the embodiments of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for solving the pseudo-color problem in a Bayer image interpolation algorithm, characterized in that, The method includes the following steps: S1, Calculate horizontal and vertical color differences: Calculate linear interpolation in the horizontal and vertical directions; and calculate the horizontal and vertical color differences based on the obtained linear interpolation. Arrange all horizontal color difference values ​​together according to pixel position to form a horizontal color difference map. The vertical color difference map is formed by arranging all the vertical color difference values ​​together according to their pixel positions. ; S2, Calculate the interpolation weights: S2.1, Calculate the color difference gradient: The formulas for calculating the color difference gradient in the horizontal and vertical directions at position coordinates (i,j) are as follows: ; ; The average gradient in the four directions is: ; S2.2, Calculate the interpolation weights: The sum of the color difference gradients in the four directions is: ; in, This represents the sum of color difference gradients; when When the value is 0, the interpolation weights are the same in all four directions: ; otherwise: ; in the formula These represent the weight values ​​for the left, right, up, and down directions at coordinates (i,j). S3. Estimate color difference value: This represents the estimated color difference between R and G at position (i,j); the estimated color difference between B and G is obtained. ; S4. Obtain G-channel interpolation Further including: For the R position in the Bayer image, the G channel is interpolated using the following formula: ; For position B in the Bayer image, the G channel is interpolated using the following formula: ; S5. Obtain the interpolation values ​​for the R and B channels: When the interpolation directions of the R, B, and G channels are the same, the consistency of the three RGB channels can be guaranteed to the greatest extent. Therefore, the G channel, which has already been interpolated, is used to complete the directional interpolation of the R and B channels. S5.1, calculate the average gradient in 8 directions; Using the results from S4, calculate the gradient values ​​in the four directions: horizontal, vertical, diagonal, and anti-diagonal. ; in, This represents the interpolation result of channel G obtained in the previous step S4. These represent the gradient values ​​in the four directions: horizontal, vertical, diagonal, and anti-diagonal. The average gradient values ​​in all eight directions can be calculated using the gradient values ​​in these four directions: ; S5.2, Calculate the interpolation weights in 8 directions: The interpolation weights in the eight directions were calculated using the same weighting method as in G-channel interpolation. : The total chromatic difference gradient in the eight directions is: ; when When it is 0: otherwise: ; S5.3, Estimating the B channel interpolation result at pixel R: For the R position in the Bayer image, the B channel interpolation is performed using the following formula: ; in This represents the interpolation result for channel B. This represents the estimated color difference between B and G. The method for calculating this color difference estimate is as follows: ; The color difference calculation method for each direction is as follows: ; S5.4, Estimating the R-channel interpolation result at pixel B: Based on symmetry, the position of pixel B in the Bayer image is calculated entirely using the B-channel interpolation method for the position of pixel R in step S5.

3. S5.5, Estimated R-channel interpolation result at pixel G: For pixel positions Gr in a Bayer image where the left and right adjacent pixels are R, the following formula is used to perform interpolation of the R and B channels: ; in: ; ; in, , , These represent the interpolation results obtained in the previous steps. , , These represent the data that already exists in the original Bayer image; For the position Gb of pixel G in the Bayer image whose left and right adjacent pixels are B, simply add the following to the above calculation formula: and By exchanging the two, the interpolation formula can be obtained; S5.6, Estimating the B channel interpolation result at pixel G: By utilizing symmetry, we only need to change the calculation formula in step S5.

5. Change to , Change to This gives us the interpolation formula for the B channel at pixel G. S6. Interpolation result correction: When the image saturation is very low, there is no need to perform image interpolation. Based on this principle, the interpolation results of the image are corrected, and the specific method is as follows: S6.1, Estimate image color difference values: If we take the horizontal color difference window in step S1 as 9*9, we can calculate the average color difference in the left and right directions: ; in, These represent the average color difference in the left and right directions, respectively. Using the same method, the average color difference in the vertical direction is obtained. Take the mean of the minimum color difference in the four directions as the color difference estimate: ; S6.2, Estimating saturation: ; in, This indicates the estimated saturation level. This represents the interpolated pixel value of the G channel; S6.3, Calculate the fusion weights: ; in, This represents the calculated fusion weights. and This indicates the fusion threshold set by the user. S6.4, Calculate the correction value: ;; in, These represent the corrected interpolation results. This represents the interpolation results of S4 and S5. This represents the pixel value at the corresponding position in the original Bayer image.

2. The method for solving the pseudo-color problem in a Bayer image interpolation algorithm according to claim 1, characterized in that, Step S1 further includes: S1.1, Linear interpolation: For pixels R or B in the Bayer image, the linear interpolation results in the horizontal and vertical directions are calculated using the following formulas: ; ; in, , These represent the linear interpolation results of the G channel in the horizontal and vertical directions, respectively; , , , These represent the actual G-channel pixel values ​​at the corresponding positions; At pixel G of the Bayer image, the calculation formula is similar to the one above, but for each pixel position, only the interpolation result in one of the horizontal or vertical directions can be calculated: If the left and right adjacent positions of pixel G are pixels R, then: , ; Conversely, if pixel G is adjacent to pixel B on either side, then: , ; S1.2, Calculate the color difference in the horizontal and vertical directions: Subtracting R from G and B from G at the effective positions after linear interpolation yields the color difference image RG and the color difference image BG. The color difference at pixel R is: ; ; The color difference at pixel B is: ; ; If the left and right adjacent positions of pixel G are pixels R, then the color difference at pixel G is: ; ; If pixel G is adjacent to pixel B on either side, then the color difference at pixel G is: ; ; in, , , , These represent the color difference values ​​between G and R in the horizontal direction, the color difference values ​​between G and R in the vertical direction, the color difference values ​​between G and B in the horizontal direction, and the color difference values ​​between G and B in the vertical direction, respectively. The horizontal color difference map is constructed by arranging all the horizontal color difference values ​​together according to their pixel positions. The vertical color difference map is formed by arranging all the vertical color difference values ​​together according to their pixel positions. .

3. The method for solving the pseudo-color problem in a Bayer image interpolation algorithm according to claim 1, characterized in that, In S3, the color difference estimation method is as follows: ; in, This represents the estimated color difference between R and G at position (i,j); , This represents the vertical chromatic aberration image and the horizontal chromatic aberration image RG obtained in step S1; These represent the weighted images for each of the up, down, left, and right directions; This represents the color difference smoothing weight vector for each direction. express The transpose of ; The same method can be used to obtain the color difference estimates for B and G. : ; in, This represents the estimated color difference between B and G at position (i,j); and Let BG represent the vertical chromatic aberration image and the horizontal chromatic aberration image obtained in step S1, respectively.

4. The method for solving the pseudo-color problem in a Bayer image interpolation algorithm according to claim 3, characterized in that, Choose Gaussian weights or mean weights.

5. The method for solving the pseudo-color problem in a Bayer image interpolation algorithm according to claim 4, characterized in that, The .