Bayer Image Decoding Method for Correcting Green Channels Based on Edge Perception

The edge-aware green channel correction method for Bayer image decoding addresses mosaic artifacts in low-resolution images by modifying green pixel values and interpolating red and blue pixels, improving image smoothness and uniformity.

CN116823658BActive Publication Date: 2025-07-15ZHEJIANG DALI TECH
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202310786523.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-29
Publication Date
2025-07-15
Estimated Expiration
2043-06-29

AI Technical Summary

Technical Problem

The prior art is prone to serious mosaic phenomena after decoding Bayer images in low resolution scenarios, resulting in mutations in image connections.

Method used

The green channel is corrected based on edge perception, and the adjacent pixel values in the pixel matrix are obtained for interpolation and correction, and the red and blue channels are processed in combination with a linear interpolation algorithm to optimize the image decoding process.

Benefits of technology

Improves image smoothness and demosaic effect, especially in low resolution scenarios to significantly improve image quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116823658B_ABST
    Figure CN116823658B_ABST
Patent Text Reader

Abstract

The present invention relates to a Bayer image decoding method for correcting a green channel based on edge perception, belonging to the technical field of image processing, and solves the problem that the mosaic phenomenon is serious after decoding Bayer images in low-resolution scenarios. The Bayer image decoding method includes: obtaining a pixel matrix centered on each target pixel set based on each target pixel set in the original Bayer image; determining the color result of the target pixel according to the encoding format of the original Bayer image and the pixel positions of each target pixel in the target pixel set in the original Bayer image; decoding the target pixel according to the color result of the target pixel and the pixel matrix; if the color result of the target pixel is green, based on the edge perception algorithm, correcting the original green pixel value of the target pixel, and taking the corrected green pixel value as the green pixel output value corresponding to the target pixel. The effect of demosaicking Bayer images in low-resolution scenarios is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular, to a Bayer image decoding method for correcting a green channel based on edge perception. Background Art

[0002] Color images are generally represented by three color components: red (R), green (G), and blue (B), and each color component is called a color channel. Nowadays, RGB digital cameras are the most common for recording color images, and most digital cameras use an imaging structure with a single sensor. The image sensor in a single-sensor color digital camera is usually a charge-coupled device or a complementary metal-oxide-semiconductor chip, which can only sense the intensity of light rather than color. Therefore, a filter is placed in front of the sensor to only allow light of a certain wavelength to pass through. When exposing and imaging, each pixel position of the sensor only collects one color. The image obtained by this direct sampling is called a Bayer image, and the process of reconstructing the information of the other two color components that are not directly sampled at each pixel position is called image demosaicing.

[0003] When decoding a Bayer image, a mosaic phenomenon will always occur. However, as the resolution of image sensors increases year by year, the impact of the mosaic phenomenon generated by decoding on human vision is getting smaller and smaller. However, in some special fields and in scenarios with low resolution, using the Bayer image decoding method in the prior art will cause the decoded image to easily have connection mutations, resulting in a serious mosaic phenomenon.

[0004] Therefore, there is an urgent need for a technical solution to further improve the demosaicing effect of Bayer image decoding. Summary of the Invention

[0005] In view of the above analysis, an embodiment of the present invention aims to provide a Bayer image decoding method for correcting a green channel based on edge perception, so as to solve the problem of the serious mosaic phenomenon after decoding a Bayer image in the prior art in a low-resolution scenario.

[0006] An embodiment of the present invention provides a Bayer image decoding method for correcting a green channel based on edge perception, and the Bayer image decoding method includes:

[0007] Collect an original Bayer image, and based on each target pixel set in the original Bayer image, obtain a pixel matrix centered on each target pixel set; the size of the pixel matrix is N*N, where N≥5;

[0008] Determine the color result of the target pixel according to the encoding format of the original Bayer image and the pixel position of each target pixel in the original Bayer image where it belongs in the target pixel set;

[0009] Decode the target pixel according to the color result of the target pixel and the pixel matrix; if the color result of the target pixel is green, based on the edge perception algorithm, correct the original green pixel value of the target pixel, and use the corrected green pixel value as the green pixel output value corresponding to the target pixel.

[0010] Based on a further improvement of the above method, the correction of the original green pixel value of the target pixel includes:

[0011] Obtain four pixels adjacent to the target pixel in the pixel matrix;

[0012] Based on the edge perception algorithm, obtain the interpolated green pixel value of each adjacent pixel according to the original green pixel values corresponding to the four green pixels adjacent to each adjacent pixel;

[0013] Based on the edge perception algorithm, correct the original green pixel value of the target pixel according to the interpolated green pixel values of the four pixels adjacent to the target pixel, and obtain the corrected green pixel value of the target pixel.

[0014] Based on a further improvement of the above method, the obtaining of the interpolated green pixel value of each adjacent pixel according to the original green pixel values corresponding to the four green pixels adjacent to each adjacent pixel includes:

[0015] Determine the green direction of each adjacent pixel according to the original green pixel values corresponding to the four green pixels adjacent to each adjacent pixel;

[0016] Take the average value of the original green pixel values of the two green pixels located in the green direction of each adjacent pixel as the interpolated green pixel value of each adjacent pixel.

[0017] Based on a further improvement of the above method, the correction of the original green pixel value of the target pixel according to the interpolated green pixel values of the four pixels adjacent to the target pixel includes:

[0018] Determine the green direction of the target pixel according to the interpolated green pixel values of the four pixels adjacent to the target pixel;

[0019] Take the average value of the interpolated green pixel values of the two adjacent pixels located in the green direction of the target pixel and the original green pixel value of the target pixel as the corrected green pixel value of the target pixel.

[0020] Based on a further improvement of the above method, the decoding of the target pixel according to the color result of the target pixel and the pixel matrix further includes:

[0021] If the color result of the target pixel is blue or red, obtain the original green pixel values corresponding to the four green pixels adjacent to the target pixel in the pixel matrix;

[0022] Based on the linear interpolation algorithm, calculate the green pixel output value corresponding to the target pixel through the following formula:

[0023]

[0024] where (i, j) represents the pixel position to which the target pixel belongs, g(i - 1, j), g(i + 1, j), g(i, j - 1), and g(i, j + 1) respectively represent the original green pixel values corresponding to the four green pixels adjacent to the target pixel, and Gr,b(i, j) represents the green pixel output value corresponding to the target pixel.

[0025] Based on a further improvement of the above method, the decoding of the target pixel according to the color result of the target pixel and the pixel matrix further includes:

[0026] If the color result of the target pixel is green, obtain the two blue pixels and two red pixels adjacent to the target pixel in the pixel matrix;

[0027] Based on the linear interpolation algorithm, calculate the red pixel output value and the blue pixel output value corresponding to the target pixel through the following formula:

[0028]

[0029]

[0030] where Rg represents the red pixel output value corresponding to the target pixel, r1 and r2 respectively represent the original red pixel values corresponding to the two red pixels adjacent to the target pixel; Bg represents the blue pixel output value corresponding to the target pixel, and b1 and b2 respectively represent the original blue pixel values corresponding to the two blue pixels adjacent to the target pixel.

[0031] Based on a further improvement of the above method, the decoding of the target pixel according to the color result of the target pixel and the pixel matrix further includes:

[0032] If the color result of the target pixel is blue, obtain the original blue pixel value corresponding to the target pixel in the pixel matrix and use it as the blue pixel output value corresponding to the target pixel;

[0033] At the same time, obtain the original red pixel values corresponding to the four nearest neighbor red pixels of the target pixel in the pixel matrix, and based on the linear interpolation algorithm, calculate the red pixel output value corresponding to the target pixel through the following formula:

[0034]

[0035] Among them, Rb represents the red pixel output value corresponding to the target pixel, and r1', r2', r3' and r4' respectively represent the original red pixel values corresponding to the four red pixels closest to the target pixel.

[0036] Based on a further improvement of the above method, the decoding of the target pixel according to the color result of the target pixel and the pixel matrix further includes:

[0037] If the color result of the target pixel is red, obtain the original red pixel value corresponding to the target pixel in the pixel matrix and use it as the red pixel output value corresponding to the target pixel;

[0038] At the same time, obtain the original blue pixel values corresponding to the four blue pixels closest to the target pixel in the pixel matrix, and based on the linear interpolation algorithm, calculate the blue pixel output value corresponding to the target pixel through the following formula:

[0039]

[0040] Among them, Br represents the blue pixel output value corresponding to the target pixel, and b1', b2', b3' and b4' respectively represent the original blue pixel values corresponding to the four blue pixels closest to the target pixel.

[0041] Based on a further improvement of the above method, the determination of the color result of the target pixel according to the coding format of the original Bayer image and the pixel positions of each target pixel in the target pixel set in the original Bayer image includes:

[0042] If the coding format of the original Bayer image is the GBRG coding format, the determination of the color result of the target pixel through the pixel position to which the target pixel belongs includes:

[0043] If both i and j are even or both are odd, the color result of the target pixel is green;

[0044] If i is even and j is odd, the color result of the target pixel is blue;

[0045] If i is odd and j is even, the color result of the target pixel is red;

[0046] Among them, (i, j) represents the pixel position to which the target pixel belongs, i is the serial number of the target pixel in the width direction, and j is the serial number of the target pixel in the height direction.

[0047] Based on further improvements to the above method, determining the color result of a target pixel according to the encoding format of the original Bayer image and the pixel positions of each target pixel in the target pixel set in the original Bayer image includes:

[0048] If the encoding format of the original Bayer image is the RGGB encoding format, determining the color result of the target pixel by the pixel position where the target pixel belongs includes:

[0049] If i is odd and j is odd, the color result of the target pixel is red;

[0050] If i is even and j is even, the color result of the target pixel is blue;

[0051] If i is odd and j is even, the color result of the target pixel is green;

[0052] If i is even and j is odd, the color result of the target pixel is green;

[0053] Wherein, (i, j) represents the pixel position where the target pixel belongs, i is the serial number of the target pixel in the width direction, and j is the serial number of the target pixel in the height direction.

[0054] Compared with the prior art, the present invention can at least achieve one of the following beneficial effects:

[0055] 1. When the color result of the target pixel is green, the present invention corrects the original green pixel value of the target pixel based on the quadratic edge perception algorithm, and uses the corrected green pixel value as the green pixel output value corresponding to the target pixel, improving the smoothness of the decoded image and the effect of demosaicing.

[0056] 2. The present invention determines the interpolated green pixel values of the four pixels adjacent to the target pixel through the edge perception algorithm, and then corrects the original green pixel value of the target pixel through the edge perception algorithm to obtain the corrected green pixel value of the target pixel, further improving the effect of demosaicing.

[0057] 3. When calculating the red pixel output value and the blue pixel output value corresponding to the target pixel, the present invention uses the linear interpolation algorithm to make the red pixel output value and the blue pixel output value more uniform, further improving the effect of demosaicing.

[0058] In the present invention, the above technical solutions can also be combined with each other to achieve more preferred combined solutions. Other features and advantages of the present invention will be described in the subsequent specification, and some advantages will be obvious from the specification or can be understood by implementing the present invention. The objectives and other advantages of the present invention can be achieved and obtained from the content specifically pointed out in the specification and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] The drawings are only for the purpose of showing specific embodiments and are not considered as a limitation of the present invention. Throughout the drawings, the same reference signs denote the same components.

[0060] Figure 1 It is a schematic flowchart of a Bayer image decoding method for correcting a green channel based on edge perception provided by an embodiment of the present invention;

[0061] Figure 2 It is a schematic structural diagram of a pixel matrix with a size of 5*5 provided by an embodiment of the present invention;

[0062] Figure 3 It is a schematic structural diagram of a pixel matrix with a size of 6*6 provided by an embodiment of the present invention;

[0063] Figure 4 It is a schematic structural diagram of a Bayer image with a GBRG coding format provided by an embodiment of the present invention;

[0064] Figure 5 It is a schematic structural diagram of a Bayer image with an RGGB coding format provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0065] The following will specifically describe the preferred embodiments of the present invention with reference to the drawings. The drawings form a part of this application and are used together with the embodiments of the present invention to explain the principles of the present invention, rather than to limit the scope of the present invention.

[0066] A specific embodiment of the present invention discloses a Bayer image decoding method for correcting a green channel based on edge perception. As Figure 1 shown, the Bayer image decoding method includes:

[0067] Step S1: Collect the original Bayer image, and based on each target pixel set in the original Bayer image, obtain a pixel matrix centered on each target pixel set; the size of the pixel matrix is N*N, where N≥5;

[0068] Step S2: Determine the color results of the target pixels according to the encoding format of the original Bayer image and the pixel positions of the respective target pixels in the original Bayer image within the target pixel set;

[0069] Step S3: Decode the target pixels according to the color results of the target pixels and the pixel matrix; if the color result of the target pixel is green, based on the edge perception algorithm, correct the original green pixel value of the target pixel, and use the corrected green pixel value as the green pixel output value corresponding to the target pixel.

[0070] Specifically, with the progress of the information age and the rapid development of artificial intelligence, the processing of acquired images and related information extraction have widespread applications in various aspects. The rapid development and wide application of very large scale integrated circuits and large scale programmable logic devices have further promoted the development of image processing. Using FPGA (Field Programmable Gate Array) as the hardware platform for development can effectively improve the speed of image processing and meet the requirements of real-time and high efficiency.

[0071] It should be noted that the Bayer image decoding method based on edge perception for correcting the green channel provided by the embodiments of the present invention utilizes the FPGA hardware platform to achieve the decoding of Bayer images in low-resolution scenarios, effectively improving the real-time and high efficiency during image processing.

[0072] Specifically, as Figure 1 shown, in Step S1, the original Bayer image can be acquired by a color camera. Preferably, the image is acquired by a CMOS (Complementary Metal Oxide Semiconductor) camera. Currently, the color formats of the output images supported by CMOS (Complementary Metal Oxide Semiconductor) cameras include RGB, YCbCr, YUV, and RAW. The image captured by the CMOS sensor, after being filtered, obtains an unprocessed image, which is called the RAW format. The image in RAW format has not been processed, so no information loss will occur.

[0073] Specifically, after the color camera acquires the original Bayer image, the Bayer image is input into the FPGA hardware platform through the CLM bus.

[0074] Specifically, in step S1, based on each target pixel set in the original Bayer image, a pixel matrix centered on each target pixel set is obtained, where the size of the pixel matrix is N*N and N≥5. It should be noted that when N = 5, the target pixel set is a single pixel at the center of the pixel matrix, that is, the target pixel set includes 1 target pixel; when N = 6, the target pixel set includes 4 pixels at the center, that is, the target pixel set includes 4 target pixels; when N = 7, the target pixel set includes 9 pixels at the center, that is, the target pixel set includes 9 target pixels.

[0075] It can be understood that the value of N should not be too large. When N is too large, there will be more distorted pixel values at the image edge. Therefore, in the embodiments of the present invention, N≤9. Within the range of 5≤N≤9, not only can the distorted pixel values at the image edge be kept within an acceptable range, but also the processing speed of the image is more appropriate.

[0076] Specifically, when N = 5, the target pixel set is 1 pixel at the center of the pixel matrix. Through the Bayer image decoding method for correcting the green channel based on edge perception provided by the embodiments of the present invention, the green pixel output value, red pixel output value, and blue pixel output value corresponding to each pixel can be calculated each time. By continuously obtaining the 5*5 pixel matrix centered on the target pixel, the green pixel output value, red pixel output value, and blue pixel output value corresponding to each pixel in the original Bayer image are calculated. It can be understood that the green pixel output value is the final output green pixel value of the pixel, the blue pixel output value is the final output blue pixel value of the pixel, and the red pixel output value is the final output red pixel value of the pixel.

[0077] It can be understood that as Figure 2 shown, when N = 5, the central pixel is pixel X. Each time, only the green pixel output value, red pixel output value, and blue pixel output value corresponding to one target pixel X can be calculated. When obtaining the pixel matrix from the original Bayer image, it is preferably set that the moving step size is 1 pixel. It can move from the left boundary of the image to the right boundary, and then from the upper boundary to the lower boundary until all target pixels are calculated; or it can move from the upper boundary of the image to the lower boundary, and then from the left boundary to the right boundary until all target pixels are calculated. The specific calculation order of the target pixels is not specifically limited here.

[0078] It can be understood that as Figure 3As shown, when N = 6, the target pixel set is the central pixels X1, X2, X3, and X4. The green pixel output values, red pixel output values, and blue pixel output values corresponding to the target pixels X1, X2, X3, and X4 can be calculated successively. It can be understood that when obtaining the pixel matrix from the original Bayer image, it is preferably set that the moving step is 2 pixels, and it can move from the left boundary of the image to the right boundary, and then from the upper boundary to the lower boundary until all the target pixels are calculated; it can also move from the upper boundary of the image to the lower boundary, and then from the left boundary to the right boundary until all the target pixels are calculated. Here, the calculation order of the target pixels is not specifically limited.

[0079] It can be understood that when N = 7, the target pixel set includes 9 pixels at the center of the pixel matrix. When obtaining the pixel matrix from the original Bayer image, it is preferably set that the moving step is 3 pixels, and it can move from the left boundary of the image to the right boundary, and then from the upper boundary to the lower boundary until all the target pixels are calculated; it can also move from the upper boundary of the image to the lower boundary, and then from the left boundary to the right boundary until all the target pixels are calculated. Here, the calculation order of the target pixels is not specifically limited.

[0080] Specifically, as Figure 1 shown, in step S2, according to the encoding format of the original Bayer image and the pixel positions of each target pixel in the target pixel set in the original Bayer image, the color result of the target pixel is determined. The Bayer (i.e., RAW format) array simulates the sensitivity of the human eye to colors and converts the gray information into color information in the arrangement of 1 red, 2 greens, and 1 blue.

[0081] It should be noted that the encoding format of the original Bayer image is any one of the GBRG encoding format, RGGB encoding format, and GRBG encoding format. The pixel position where the target pixel belongs is (i, j), where i is the serial number of the target pixel in the width direction and j is the serial number of the target pixel in the height direction. For example, the size of the original Bayer image is 1280 * 1280, that is, the width of the image is 1280 pixels and the height is 1280 pixels. The value ranges of i and j are [1, 1280].

[0082] Preferably, the determining the color result of the target pixel according to the encoding format of the original Bayer image and the pixel positions of each target pixel in the target pixel set in the original Bayer image includes:

[0083] If the encoding format of the original Bayer image is the GBRG encoding format, determining the color result of the target pixel through the pixel position where the target pixel belongs includes:

[0084] If both i and j are even or both are odd, the color result of the target pixel is green;

[0085] If i is even and j is odd, the color result of the target pixel is blue;

[0086] If i is odd and j is even, the color result of the target pixel is red;

[0087] Among them, (i, j) represents the pixel position to which the target pixel belongs, i is the serial number of the target pixel in the width direction, and j is the serial number of the target pixel in the height direction.

[0088] Specifically, as Figure 4 shown, if the encoding format of the original Bayer image is the GBRG encoding format, the color result of the pixel is determined by judging the parity of the pixel position (i, j). If both i and j are even or both are odd, the color result of the target pixel is green; if i is even and j is odd, the color result of the target pixel is blue; if i is odd and j is even, the color result of the target pixel is red.

[0089] Preferably, the determining the color result of the target pixel according to the encoding format of the original Bayer image and the pixel positions of each target pixel in the target pixel set in the original Bayer image includes:

[0090] If the encoding format of the original Bayer image is the RGGB encoding format, determining the color result of the target pixel by the pixel position to which the target pixel belongs includes:

[0091] If i is odd and j is odd, the color result of the target pixel is red;

[0092] If i is even and j is even, the color result of the target pixel is blue;

[0093] If i is odd and j is even, the color result of the target pixel is green;

[0094] If i is even and j is odd, the color result of the target pixel is green;

[0095] Among them, (i, j) represents the pixel position to which the target pixel belongs, i is the serial number of the target pixel in the width direction, and j is the serial number of the target pixel in the height direction.

[0096] Specifically, as Figure 5As shown, if the encoding format of the original Bayer image is the RGGB encoding format, then if i is odd and j is odd, the color result of the target pixel is red; if i is even and j is even, the color result of the target pixel is blue; if i is odd and j is even, the color result of the target pixel is green; if i is even and j is odd, the color result of the target pixel is green, that is, if one of i and j is odd and the other is even, the color result of the target pixel is green.

[0097] If the encoding format of the original Bayer image is the RGGB encoding format, the color result of the target pixel can also be obtained according to the same principle, which will not be elaborated here.

[0098] It should be noted that in the Bayer image decoding method for correcting the green channel based on edge perception provided by the embodiments of the present invention, there are 4 adjacent pixels for any one pixel, which are used to represent the pixel on the left, the pixel on the right, the pixel above, and the pixel below of the pixel.

[0099] Specifically, as Figure 1 shown, in step S3, the target pixel is decoded according to the color result of the target pixel and the pixel matrix.

[0100] It should be noted that the color result of the target pixel includes that the color result of the target pixel is green, blue, and red. For example, when the size of the pixel matrix is 5*5, the target pixel set is the central pixel, the color result of 1 target pixel in the target pixel set is determined, and the target pixel is decoded according to the color result of the target pixel and the pixel matrix.

[0101] Specifically, as Figure 1 shown, in step S3, if the color result of the target pixel is green, based on the edge perception algorithm, the original green pixel value of the target pixel is corrected, and the corrected green pixel value is used as the output value of the green pixel corresponding to the target pixel.

[0102] Preferably, the correction of the original green pixel value of the target pixel includes:

[0103] Obtain four pixels adjacent to the target pixel in the pixel matrix;

[0104] Based on the edge perception algorithm, according to the original green pixel values corresponding to the four green pixels adjacent to each adjacent pixel, obtain the interpolated green pixel value of each adjacent pixel;

[0105] Based on the edge perception algorithm, the original green pixel value of the target pixel is corrected according to the interpolated green pixel values of the four pixels adjacent to the target pixel, and the corrected green pixel value of the target pixel is obtained.

[0106] Specifically, as Figure 4 shown, if the color result of the target pixel is green, in the 5*5 pixel matrix, the center of the pixel matrix is the green pixel GX, and the target pixel is the green pixel GX. Obtain the four pixels B1, B2, R1, and R2 adjacent to the target pixel GX. To calculate the interpolated green pixel values of the four adjacent pixels B1, B2, R1, and R2, it is necessary to obtain the original green pixel values corresponding to the four green pixels adjacent to each adjacent pixel respectively. For example, to calculate the interpolated green pixel value of pixel B1, it is necessary to obtain the original green pixel values corresponding to the four green pixels G1, G2, G3, and GX adjacent to pixel B1; to calculate the interpolated green pixel value of pixel B2, it is necessary to obtain the original green pixel values corresponding to the four green pixels G4, G5, G6, and GX adjacent to pixel B2; to calculate the interpolated green pixel value of pixel R1, it is necessary to obtain the original green pixel values corresponding to the four green pixels G2, G5, G8, and GX adjacent to pixel R1; to calculate the interpolated green pixel value of pixel R2, it is necessary to obtain the original green pixel values corresponding to the four green pixels G3, G6, G7, and GX adjacent to pixel R2.

[0107] Specifically, when calculating the interpolated green pixel value of pixel B1, after obtaining the original green pixel values corresponding to the four green pixels G1, G2, G3, and GX adjacent to pixel B1, based on the edge perception algorithm, determine the interpolated green pixel value of pixel B1.

[0108] Preferably, the step of obtaining the interpolated green pixel value of each adjacent pixel according to the original green pixel values corresponding to the four green pixels adjacent to each adjacent pixel includes:

[0109] Determine the green direction of each adjacent pixel according to the original green pixel values corresponding to the four green pixels adjacent to each adjacent pixel;

[0110] Take the average value of the original green pixel values corresponding to the two green pixels located in the green direction of each adjacent pixel as the interpolated green pixel value of each adjacent pixel.

[0111] Specifically, when calculating the interpolated green pixel value of the adjacent pixel B1, the original green pixel values of the four green pixels G1, G2, G3, and GX adjacent to pixel B1 are G(G1), G(G2), G(G3), and G(GX) respectively. Determine whether the green direction of the adjacent pixel B1 is the horizontal direction or the vertical direction:

[0112] If |G(G1) - G(GX)| ≤ |G(G2) - G(G3)|, the green direction of the adjacent pixel B1 is the vertical direction. It should be noted that if the green direction of the adjacent pixel is the vertical direction, the interpolated green pixel value of the adjacent pixel is the average of the original green pixel values corresponding to the two green pixels in the vertical direction. That is, when the green direction of the adjacent pixel B1 is the vertical direction, the interpolated green pixel value of the adjacent pixel B1 is the average of the original green pixel values corresponding to the two green pixels G1 and GX in the vertical direction, i.e., G(B1) = {G(G1) + G(GX)} / 2.

[0113] If |G(G1) - G(GX)| > |G(G2) - G(G3)|, the green direction of the adjacent pixel B1 is the horizontal direction. It should be noted that if the green direction of the adjacent pixel is the horizontal direction, the interpolated green pixel value of the adjacent pixel is the average of the original green pixel values corresponding to the two green pixels in the horizontal direction. That is, when the green direction of the adjacent pixel B1 is the horizontal direction, the interpolated green pixel value of the adjacent pixel B1 is the average of the original green pixel values corresponding to the two green pixels G2 and G3 in the horizontal direction, i.e., G(B1) = {G(G2) + G(G3)} / 2.

[0114] Specifically, based on the edge perception algorithm, the original green pixel value of the target pixel is corrected according to the interpolated green pixel values of the four pixels adjacent to the target pixel, and the corrected green pixel value of the target pixel is obtained.

[0115] Specifically, after obtaining the interpolated green pixel values G(B1), G(B2), G(R1), and G(R2) of the four pixels B1, B2, R1, and R2 adjacent to the target pixel GX, the green pixel value of the target pixel GX is corrected.

[0116] Preferably, the correction of the original green pixel value of the target pixel according to the interpolated green pixel values of the four pixels adjacent to the target pixel includes:

[0117] Determine the green direction of the target pixel according to the interpolated green pixel values of the four pixels adjacent to the target pixel;

[0118] Take the average of the interpolated green pixel values of the two adjacent pixels in the green direction of the target pixel and the original green pixel value of the target pixel as the corrected green pixel value of the target pixel.

[0119] Specifically, determine the green direction of the target pixel GX according to the interpolated green pixel values G(B1), G(B2), G(R1), and G(R2) of the four pixels B1, B2, R1, and R2 adjacent to the target pixel GX:

[0120] If |G(B1) - G(B2)| ≤ |G(R1) - G(R2)|, the green direction of the target pixel GX is the vertical direction. It should be noted that if the green direction of the target pixel is the vertical direction, the corrected green pixel value of the target pixel is the average of the interpolated green pixel values of two adjacent pixels in the vertical direction and the original green pixel value of the target pixel, that is, the corrected green pixel value G'(GX) of the target pixel GX = {G(B1) + G(B2) + G(GX)} / 3.

[0121] If |G(B1) - G(B2)| > |G(R1) - G(R2)|, the green direction of the target pixel GX is the horizontal direction. It should be noted that if the green direction of the target pixel is the horizontal direction, the corrected green pixel value of the target pixel is the average of the interpolated green pixel values of two adjacent pixels in the horizontal direction and the original green pixel value of the target pixel, that is, the corrected green pixel value G'(GX) of the target pixel GX = {G(R1) + G(R2) + G(GX)} / 3.

[0122] Specifically, as Figure 1 shown, in step S3, the corrected green pixel value is used as the green pixel output value corresponding to the target pixel.

[0123] It should be noted that through step S3, the green pixel output values of all green pixels in the original Bayer image can be obtained.

[0124] Preferably, the decoding of the target pixel according to the color result of the target pixel and the pixel matrix further includes:

[0125] If the color result of the target pixel is blue or red, obtain the original green pixel values corresponding to the four green pixels adjacent to the target pixel in the pixel matrix;

[0126] Based on the linear interpolation algorithm, calculate the green pixel output value corresponding to the target pixel through the following formula:

[0127]

[0128]

[0129] where (i, j) represents the pixel position to which the target pixel belongs, g(i - 1, j), g(i + 1, j), g(i, j - 1) and g(i, j + 1) respectively represent the original green pixel values corresponding to the four green pixels adjacent to the target pixel, and Gr,b(i, j) represents the green pixel output value corresponding to the target pixel.

[0130] Specifically, as Figure 4As shown, pixel B1, pixel B2, pixel R1, or pixel R2 is the central pixel of the pixel matrix respectively. When the target pixel is pixel B1, pixel B2, pixel R1, or pixel R2, that is, the color result of the target pixel is blue or red. For example, when the target pixel is pixel B1, the color result of the target pixel B1 is blue. Obtain the original green pixel values G(G1), G(G2), G(G3), and G(GX) corresponding to the four adjacent green pixels G1, G2, G3, and GX of the target pixel B1. Based on the linear interpolation algorithm, calculate the green pixel output value corresponding to this target pixel through the following formula:

[0131]

[0132] That is, g(i - 1, j) = G(G2), g(i + 1, j) = G(G3), g(i, j - 1) = G(G1), g(i, j + 1) = G(GX);

[0133] Where (i, j) represents the pixel position to which the target pixel belongs, g(i - 1, j), g(i + 1, j), g(i, j - 1), and g(i, j + 1) respectively represent the original green pixel values corresponding to the four adjacent green pixels of this target pixel, and Gr,b(i, j) represents the green pixel output value corresponding to this target pixel.

[0134] It should be noted that when the color result of the target pixel is blue or red, the original green pixel values corresponding to the four adjacent green pixels of this target pixel can be obtained, and based on the linear interpolation algorithm, the green pixel output value corresponding to the target pixel can be calculated.

[0135] It can be understood that when the color result of the target pixel is green, blue, or red, the green pixel output value of the target pixel can be calculated.

[0136] Preferably, as Figure 1 shown, in step S3, the decoding of the target pixel according to the color result of the target pixel and the pixel matrix further includes:

[0137] If the color result of the target pixel is green, obtain two adjacent blue pixels and two adjacent red pixels of this target pixel in the pixel matrix;

[0138] Based on the linear interpolation algorithm, calculate the red pixel output value and the blue pixel output value corresponding to this target pixel through the following formula:

[0139]

[0140]

[0141] Wherein, Rg represents the red pixel output value corresponding to the target pixel, and r1 and r2 respectively represent the original red pixel values corresponding to two adjacent red pixels of the target pixel; Bg represents the blue pixel output value corresponding to the target pixel, and b1 and b2 respectively represent the original blue pixel values corresponding to two adjacent blue pixels of the target pixel.

[0142] Specifically, as Figure 4 shown, the target pixel is GX. To calculate the blue pixel output value and red pixel output value of the target pixel GX, two adjacent blue pixels B1 and B2 and two red pixels R1 and R2 of the target pixel GX are obtained, and the original blue pixel values b1 and b2 of the two blue pixels B1 and B2 are determined, and the original red pixel values r1 and r2 of the two red pixels R1 and R2 are determined.

[0143] Based on the linear interpolation algorithm, the red pixel output value and blue pixel output value corresponding to the target pixel are calculated by the following formula:

[0144]

[0145]

[0146] Preferably, as Figure 1 shown, in step S3, the decoding of the target pixel according to the color result of the target pixel and the pixel matrix further includes:

[0147] If the color result of the target pixel is blue, the original blue pixel value corresponding to the target pixel is obtained in the pixel matrix and used as the blue pixel output value corresponding to the target pixel;

[0148] At the same time, the original red pixel values corresponding to the four nearest red pixels of the target pixel are obtained in the pixel matrix, and based on the linear interpolation algorithm, the red pixel output value corresponding to the target pixel is calculated by the following formula:

[0149]

[0150] Wherein, Rb represents the red pixel output value corresponding to the target pixel, and r1’, r2’, r3’ and r4’ respectively represent the original red pixel values corresponding to the four nearest red pixels of the target pixel.

[0151] Specifically, when the target pixel is B1, the color result of the target pixel B1 is blue, and the original blue pixel value corresponding to the target pixel B1 is used as the blue pixel output value corresponding to the target pixel B1.

[0152] To calculate the red pixel output value of pixel B1, obtain the original red pixel values r1’, r2’, r3’, and r4’ corresponding to the four red pixels R1, R2, R3, and R4 that are the nearest neighbors of the target pixel B1. The red pixel output value corresponding to the target pixel B1

[0153] Preferably, as Figure 1 shown, in step S3, the decoding of the target pixel according to the color result of the target pixel and the pixel matrix further includes:

[0154] If the color result of the target pixel is red, obtain the original red pixel value corresponding to the target pixel in the pixel matrix and use it as the red pixel output value corresponding to the target pixel;

[0155] At the same time, obtain the original blue pixel values corresponding to the four blue pixels that are the nearest neighbors of the target pixel in the pixel matrix. Based on the linear interpolation algorithm, calculate the blue pixel output value corresponding to the target pixel through the following formula:

[0156]

[0157] where Br represents the blue pixel output value corresponding to the target pixel, and b1’, b2’, b3’, and b4’ respectively represent the original blue pixel values corresponding to the four blue pixels that are the nearest neighbors of the target pixel.

[0158] Specifically, when the target pixel is pixel R1, the color result of the target pixel R1 is red, and the original red pixel value corresponding to the target pixel R1 is used as the red pixel output value corresponding to the target pixel R1.

[0159] To calculate the blue pixel output value of pixel B1, obtain the original blue pixel values b1’, b2’, b3’, and b4’ corresponding to the four blue pixels B1, B2, B3, and B4 that are the nearest neighbors of the target pixel B1. The blue pixel output value of the target pixel B1

[0160] It should be noted that through step S3, the green pixel output value, red pixel output value, and blue pixel output value corresponding to the target pixel being blue, red, and green can be calculated.

[0161] It can be understood that the number of target pixels included in the target pixel set in the present invention is (N - 4)*(N - 4).

[0162] When the target pixel set includes 1 target pixel, the size of the pixel matrix obtained with this 1 target pixel as the center is 5*5. According to the method provided by the present invention, the green pixel output value, blue pixel output value, and red pixel output value of this 1 target pixel can be calculated. Moving at a step size of 1, a pixel matrix is obtained each time it moves. Calculate the output RGB value of the central pixel of this pixel matrix. Calculate all the target pixel sets in the original Bayer image, and then the green pixel output value, blue pixel output value, and red pixel output value of each target pixel after decoding the original Bayer image can be obtained.

[0163] When the target pixel set includes 4 target pixels, the size of the pixel matrix obtained with these 4 target pixels as the center is 6*6. According to the method provided by the present invention, the green pixel output value, blue pixel output value, and red pixel output value of these 4 target pixels can be calculated. Moving at a step size of 2, a pixel matrix is obtained each time it moves. Calculate the output RGB value of each target pixel in the target pixel set corresponding to this pixel matrix. Calculate all the target pixel sets in the original Bayer image, and then the green pixel output value, blue pixel output value, and red pixel output value of each target pixel after decoding the original Bayer image can be obtained.

[0164] When the target pixel set includes 9 target pixels, the size of the pixel matrix obtained with these 9 target pixels as the center is 7*7. According to the method provided by the present invention, the green pixel output value, blue pixel output value, and red pixel output value of these 9 target pixels can be calculated. Moving at a step size of 3, a pixel matrix is obtained each time it moves. Calculate the output RGB value of each target pixel in the target pixel set corresponding to this pixel matrix. Calculate all the target pixel sets in the original Bayer image, and then the green pixel output value, blue pixel output value, and red pixel output value of each target pixel after decoding the original Bayer image can be obtained.

[0165] Compared with the prior art, when the color result of the target pixel is green, the Bayer image decoding method for correcting the green channel based on edge perception according to the embodiment of the present invention corrects the original green pixel value of the target pixel based on the quadratic edge perception algorithm, and uses the corrected green pixel value as the green pixel output value corresponding to the target pixel, improving the smoothness of the decoded image and the effect of demosaicing; at the same time, the interpolation green pixel values of the four pixels adjacent to the target pixel are determined through the edge perception algorithm, and then the original green pixel value of the target pixel is corrected through the edge perception algorithm to obtain the corrected green pixel value of the target pixel, further improving the demosaicing effect; moreover, when calculating the red pixel output value and the blue pixel output value corresponding to the target pixel, the linear interpolation algorithm is used to make the red pixel output value and the blue pixel output value more uniform, further improving the demosaicing effect.

[0166] Those skilled in the art can understand that all or part of the processes for implementing the methods of the above embodiments can be completed by instructing relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium. Among them, the computer-readable storage medium is a disk, an optical disc, a read-only memory or a random access memory, etc.

[0167] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by those skilled in the art within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.

Claims

1. A Bayer image decoding method for correcting the green channel based on edge perception, characterized in that, The described Bayer image decoding method includes: Collecting the original Bayer image, and obtaining a pixel matrix centered on each target pixel set based on the respective target pixel sets in the original Bayer image; the size of the pixel matrix is N*N, where N≥5; Determining the color result of the target pixel according to the encoding format of the original Bayer image and the pixel positions of the respective target pixels in the original Bayer image where they belong; Decoding the target pixel according to the color result of the target pixel and the pixel matrix; if the color result of the target pixel is green, based on the edge perception algorithm, correcting the original green pixel value of the target pixel, and taking the corrected green pixel value as the green pixel output value corresponding to the target pixel; The correction of the original green pixel value of the target pixel includes: Obtaining four pixels adjacent to the target pixel in the pixel matrix; Based on the edge perception algorithm, obtaining the interpolated green pixel value of each adjacent pixel according to the original green pixel values corresponding to the four green pixels adjacent to each adjacent pixel; Based on the edge perception algorithm, correcting the original green pixel value of the target pixel according to the interpolated green pixel values of the four pixels adjacent to the target pixel, and obtaining the corrected green pixel value of the target pixel; The obtaining of the interpolated green pixel value of each adjacent pixel according to the original green pixel values corresponding to the four green pixels adjacent to each adjacent pixel includes: Determining the green direction of each adjacent pixel according to the original green pixel values corresponding to the four green pixels adjacent to each adjacent pixel; Taking the average value of the original green pixel values corresponding to the two green pixels located in the green direction of each adjacent pixel as the interpolated green pixel value of each adjacent pixel.

2. The Bayer image decoding method according to claim 1, characterized in that, The correction of the original green pixel value of the target pixel according to the interpolated green pixel values of the four pixels adjacent to the target pixel includes: Determining the green direction of the target pixel according to the interpolated green pixel values of the four pixels adjacent to the target pixel; Taking the average value of the interpolated green pixel values of the two adjacent pixels located in the green direction of the target pixel and the original green pixel value of the target pixel as the corrected green pixel value of the target pixel.

3. The Bayer image decoding method according to claim 1, wherein The decoding of the target pixel according to the color result of the target pixel and the pixel matrix further includes: If the color result of the target pixel is blue or red, obtaining the original green pixel values corresponding to the four green pixels adjacent to the target pixel in the pixel matrix; Based on the linear interpolation algorithm, calculating the green pixel output value corresponding to the target pixel through the following formula: where (i, j) represents the pixel position where the target pixel belongs, g(i-1, j), g(i+1, j), g(i, j-1), and g(i, j+1) respectively represent the original green pixel values corresponding to the four green pixels adjacent to the target pixel, and Gr,b(i, j) represents the green pixel output value corresponding to the target pixel.

4. The Bayer image decoding method according to claim 1, wherein The decoding of the target pixel according to the color result of the target pixel and the pixel matrix further includes: If the color result of the target pixel is green, obtain two adjacent blue pixels and two adjacent red pixels of the target pixel in the pixel matrix; Based on the linear interpolation algorithm, calculate the red pixel output value and the blue pixel output value corresponding to the target pixel through the following formula: Wherein, Rg represents the red pixel output value corresponding to the target pixel, and r1 and r2 respectively represent the original red pixel values corresponding to the two adjacent red pixels of the target pixel; Bg represents the blue pixel output value corresponding to the target pixel, and b1 and b2 respectively represent the original blue pixel values corresponding to the two adjacent blue pixels of the target pixel.

5. The Bayer image decoding method according to claim 3, wherein The decoding of the target pixel according to the color result of the target pixel and the pixel matrix further includes: If the color result of the target pixel is blue, obtain the original blue pixel value corresponding to the target pixel in the pixel matrix and use it as the blue pixel output value corresponding to the target pixel; At the same time, obtain the original red pixel values corresponding to the four nearest-neighbor red pixels of the target pixel in the pixel matrix, and calculate the red pixel output value corresponding to the target pixel based on the linear interpolation algorithm through the following formula: Wherein, Rb represents the red pixel output value corresponding to the target pixel, and r1’, r2’, r3’ and r4’ respectively represent the original red pixel values corresponding to the four nearest-neighbor red pixels of the target pixel.

6. The Bayer image decoding method according to claim 3, wherein The decoding of the target pixel according to the color result of the target pixel and the pixel matrix further includes: If the color result of the target pixel is red, obtain the original red pixel value corresponding to the target pixel in the pixel matrix and use it as the red pixel output value corresponding to the target pixel; At the same time, obtain the original blue pixel values corresponding to the four nearest-neighbor blue pixels of the target pixel in the pixel matrix, and calculate the blue pixel output value corresponding to the target pixel based on the linear interpolation algorithm through the following formula: Wherein, Br represents the blue pixel output value corresponding to the target pixel, and b1’, b2’, b3’ and b4’ respectively represent the original blue pixel values corresponding to the four nearest-neighbor blue pixels of the target pixel.

7. The Bayer image decoding method according to claim 1, wherein Determining the color result of the target pixel according to the encoding format of the original Bayer image and the pixel positions of the respective target pixels in the original Bayer image in the target pixel set includes: If the encoding format of the original Bayer image is the GBRG encoding format, determining the color result of the target pixel by the pixel position where the target pixel belongs includes: If both i and j are even or both are odd, the color result of the target pixel is green; If i is even and j is odd, the color result of the target pixel is blue; If i is odd and j is even, the color result of the target pixel is red; Wherein, (i, j) represents the pixel position where the target pixel belongs, i is the serial number of the target pixel in the width direction, and j is the serial number of the target pixel in the height direction.

8. The Bayer image decoding method according to claim 1, characterized in that, Determining the color result of the target pixel according to the encoding format of the original Bayer image and the pixel positions of the respective target pixels in the original Bayer image in the target pixel set includes: If the encoding format of the original Bayer image is the RGGB encoding format, determining the color result of the target pixel based on the pixel position to which the target pixel belongs includes: If i is odd and j is odd, the color result of the target pixel is red; If i is even and j is even, the color result of the target pixel is blue; If i is odd and j is even, the color result of the target pixel is green; If i is even and j is odd, the color result of the target pixel is green; where (i, j) represents the pixel position to which the target pixel belongs, i is the serial number of the target pixel in the width direction, and j is the serial number of the target pixel in the height direction.

Citation Information

Patent Citations

  • Image processing method and system

    CN106412542A

  • Bayer image green channel balance method and apparatus

    CN107018343A

  • Image processing method and device

    CN110430403A

  • Efficient algorithm for color recovery from 8-bit to 24-bit color pixels

    US6091851A