Image demosaicing method and device
Through the method of multi-directional interpolation and edge correction, the problem of poor effect of existing demosaicing methods is solved, and the demosaicing effect of the image is improved, especially in the oblique direction and edges, and the accurate restoration of color information is achieved.
Patent Information
- Application Number
- CN202410644593.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-23
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-05-23
AI Technical Summary
Existing demosaicing methods are ineffective, resulting in images that cannot accurately restore the color information of real visual scenes. In particular, there are aliasing and false color phenomena in oblique interpolation and image edges.
Multi-set direction interpolation is used to calculate the missing green component of the pixel, and correction is made at the edge. The green channel value of the pixel to be interpolated is determined through the first and second interpolation formulas. Finally, the red and blue channel values are reconstructed based on the green channel value. , converted into a complete RGB image.
It improves the aliasing and false color phenomena caused by interpolation in the diagonal direction of the image during the demosaicing process, improves the accuracy of the image edge and the overall demosaicing effect, and ensures that the image can accurately restore the color information of the real visual scene.
Smart Images

Figure CN118233764B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of imaging devices, and in particular to a method and device for de-mosaicing an image. Background Art
[0002] After placing a color filter array (CFA) on a single image sensor, each pixel in the acquired image has only one channel color value. This image is called a mosaic image. In the common RGB images currently, each pixel actually has three channel color values. De-mosaicing refers to filling in the missing color values of other channels for each pixel in the mosaic image.
[0003] In the prior art, the demosaicing method is to find the color values of other channels that are missing from the pixel point, and then fill the color values of other channels that are missing from the pixel point.
[0004] However, the existing method has a poor de-mosaicing effect, resulting in the image being unable to accurately restore the color information of the real visual scene. Summary of the invention
[0005] The present application provides an image de-mosaicing method and device, which are used to solve the problem of poor de-mosaicing effect in the prior art.
[0006] In a first aspect, an embodiment of the present application provides a method for de-mosaicing an image, comprising:
[0007] Obtaining a pixel point to be interpolated in a mosaic image, wherein the color channel value of each pixel point in the mosaic image is one of a green channel value, a red channel value, and a blue channel value, and the color channel value of the pixel point to be interpolated is a red channel value or a blue channel value;
[0008] Determine a green channel value of the pixel to be interpolated based on the color channel value of the pixel to be interpolated, the color channel values of pixels in multiple set directions of the pixel to be interpolated, and a first interpolation formula;
[0009] Based on the color channel value of the pixel to be interpolated, the color channel value of the pixel in a preset direction of the pixel to be interpolated and a second interpolation formula, the green channel value of the pixel to be corrected is corrected, and the pixel to be corrected is the pixel to be interpolated at the edge of the mosaic image;
[0010] Determine a red channel value and a blue channel value of each pixel in the mosaic image based on a green channel value of each pixel;
[0011] The mosaic image is converted into a demosaiced image based on the green channel value, the red channel value and the blue channel value of each pixel.
[0012] In a second aspect, an embodiment of the present application provides an image demosaicing device, comprising:
[0013] An interpolation pixel determination module is used to obtain a pixel to be interpolated in a mosaic image, wherein the color channel value of each pixel in the mosaic image is one of a green channel value, a red channel value, and a blue channel value, and the color channel value of the pixel to be interpolated is a red channel value or a blue channel value;
[0014] A first interpolation module is used to determine the green channel value of the pixel to be interpolated based on the color channel value of the pixel to be interpolated, the color channel values of the pixels in multiple set directions of the pixel to be interpolated, and a first interpolation formula;
[0015] An interpolation correction module, used to correct the green channel value of the pixel to be corrected based on the color channel value of the pixel to be interpolated, the color channel value of the pixel in a preset direction of the pixel to be interpolated, and a second interpolation formula, wherein the pixel to be corrected is the pixel to be interpolated at the edge of the mosaic image;
[0016] A channel value determination module, used to determine a red channel value and a blue channel value of each pixel point in the mosaic image based on a green channel value of each pixel point;
[0017] The demosaicing module is used to convert the mosaic image into a demosaicing image based on the green channel value, the red channel value and the blue channel value of each pixel.
[0018] The image de-mosaicing method and device provided in the embodiments of the present application calculate the green component of the missing pixel points based on the interpolation in multiple set directions, which can improve the aliasing and pseudo-color phenomena that occur in the interpolation in the oblique direction of the image during the de-mosaicing process, and then perform edge correction to correct the green component of the pixel points at the edge, which can improve the pseudo-color phenomenon at the edge of the image and improve the image de-mosaicing effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings herein are incorporated in and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the description, are used to explain the principles of the present application;
[0020] Figure 1 A schematic diagram of a mosaic image provided in an embodiment of the present application;
[0021] Figure 2 A schematic diagram of mosaic image generation provided in an embodiment of the present application;
[0022] Figure 3 A schematic diagram of a process flow of an image demosaicing method provided in an embodiment of the present application;
[0023] Figure 4 A schematic diagram of the pixels to be interpolated provided by the computing power of this application;
[0024] Figure 5 A schematic diagram of six setting directions of pixels to be interpolated provided in an embodiment of the present application;
[0025] Figure 6 A mask schematic diagram provided for an embodiment of the present application;
[0026] Figure 7 A schematic diagram of color difference gradient calculation provided in an embodiment of the present application;
[0027] Figure 8 A schematic diagram of green channel value correction provided in an embodiment of the present application;
[0028] Fig. 9 It is a comparison diagram of the ideal interpolation filter and the five-coefficient approximate function curve family;
[0029] Fig.10 A schematic diagram of interpolation of red channel values of pixels provided in an embodiment of the present application;
[0030] Fig.11 A schematic diagram of a de-mosaicing process provided by another embodiment of the present application;
[0031] Fig.12 A schematic diagram of a de-mosaic processing module provided in an embodiment of the present application;
[0032] Fig.13 A schematic diagram of the processing flow of the green channel 8-direction interpolation module provided in an embodiment of the present application;
[0033] Fig.14 A schematic diagram of the processing flow of the edge correction module provided in an embodiment of the present application;
[0034] Fig.15 A schematic diagram of the processing flow of the red and blue channel interpolation module provided in an embodiment of the present application;
[0035] Fig.16 A schematic diagram of the processing flow of the high and low frequency division correction module provided in an embodiment of the present application;
[0036] Fig.17 A schematic diagram of the structure of a de-mosaicing device for an image provided in an embodiment of the present application;
[0037] Fig.18 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0038] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0040] At present, the imaging elements of cameras are mainly charge coupled devices (CCD) and CMOS. In order to reduce cost and complexity, the manufacturing of CMOS or CCD is to place a color filter array (CFA) on the image sensor. CFA can filter light of different frequency bands, so the data output by the imaging element is in RAW format. The characteristic of RAW format is that each pixel only provides one of the three color channel values of RGB. De-mosaicing refers to completing the other two color channel values missing from the pixel point, so that the pixel point has the three color channel values of RGB and restores the complete RGB format. There is also a mosaic algorithm in the related art. The interpolation direction of the mosaic algorithm is determined only based on the green component to be reconstructed, that is, the pixel point that does not capture the green channel value, so that only half of the pixels in the image need to be judged, and the frequency division operation is added at the end to further improve the generated reconstructed image. The disadvantage of this algorithm is that it is interpolated only based on the horizontal and vertical directions, resulting in low accuracy in the judgment of the oblique edge area, and secondly, there is a pseudo-color phenomenon in the high-frequency areas of the image edge.
[0041] In view of the above problems, the present application provides a de-mosaicing solution, which can improve the jagged and pseudo-color phenomena that occur in the interpolation of the image in the oblique direction during the de-mosaicing process based on the multi-directional interpolation calculation of the missing green component of the pixel point, and then perform edge correction to correct the missing green component of the pixel point at the edge, thereby improving the pseudo-color phenomenon at the edge of the image. After the correction is completed, the green component of each pixel point in the image can be obtained, and then based on the green component, the color components of the red or blue channels missing from the pixel point can be further reconstructed, and finally a complete RGB format image is obtained, thereby improving the image de-mosaicing effect.
[0042] Figure 1 A schematic diagram of a mosaic image provided in an embodiment of the present application, such as Figure 1 As shown in the figure, taking a small square in the image as a pixel, G is used to indicate that the pixel has only green channel value, R is used to indicate that the pixel has only red channel value, and B is used to indicate that the pixel has only blue channel value. In an RGB format image, each pixel has three color channel values: R, G, and B. So it is necessary to fill Figure 1 The other two color channel values missing for each pixel in the image are used to restore the complete RGB image.
[0043] in, Figure 1 This mosaic image is caused by the CFA filtering light of different frequency bands. Specifically, Figure 2 A schematic diagram of generating a mosaic image provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, a CFA is laid on top of the image sensor. The CFA can be configured in a ratio of 1 red light filter, 1 blue light filter, and 2 green light filters. In this way, only light of a specific color can pass through the filter. Figure 2 In the filter, R represents red, G represents green, and B represents blue. Red light can pass through the red filter, while green and blue light are blocked, making Figure 1 A small square with only red channel values appears in the image; green light can pass through the green filter, while red and blue light are blocked, making Figure 1 A small square with only the green channel value appears in the image; blue light can pass through the blue filter, while red and green light are blocked, making Figure 1 Small square blocks with only blue channel values appear in the image.
[0044] The de-mosaicing solution provided by the present application is described in detail below through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0045] Figure 3 The flowchart of the image demosaicing method provided in the embodiment of the present application is a schematic diagram. The method can be applied to process mosaic images captured by CCD or CMOS, and because it can improve the aliasing and pseudo-color phenomena that occur in the interpolation of the image in the oblique direction during the demosaicing process, as well as the pseudo-color phenomenon at the edge of the image, the demosaicing method provided in the embodiment has a better demosaicing effect in backlit shooting scenes and scenes with light and dark boundaries. Figure 3 As shown, the method specifically comprises the following steps:
[0046] Step S310: Obtain pixels to be interpolated in the mosaic image.
[0047] The color channel value of each pixel in the mosaic image is one of a green channel value, a red channel value, and a blue channel value, and the color channel value of the pixel to be interpolated is a red channel value or a blue channel value.
[0048] In this embodiment, the characteristics of mosaic images have been mentioned above, that is, each pixel has only one color channel value (see the above Figure 1 ), for the sake of ease of expression, this article uses red pixels to describe pixels with only red channel values, blue pixels to describe pixels with only blue channel values, and green pixels to describe pixels with only green channel values. Among them, depending on the configuration ratio of the filters in the CFA, the number of red pixels, blue pixels, and green pixels in the mosaic image is also different. For example, if the ratio of filters in the CFA is: 1 red light filter, 1 blue light filter, and 2 green light filters, then the ratio of the number of red pixels, blue pixels, and green pixels in the corresponding mosaic image is 1:1:2, that is Figure 1 In every four small squares, there appear two small squares having only green channel values, one small square having only red channel values, and one small square having only blue channel values.
[0049] Among them, CFA is mainly formed by several Bayer filters. Figure 1 Every four adjacent small square blocks (i.e. four pixels) form a unit, which is formed by the Bayer filter laid on the image sensor.
[0050] Among them, CFA is mainly composed of several Bayer filters. The ratio of filters in the Bayer filter is 1 red light filter, 1 blue light filter and 2 green light filters. This is because the human eye is more sensitive to green, and the transmittance of green light is better than that of the other two colors.
[0051] In this embodiment, because the Bayer filter is widely used in cameras, the ratio of the number of red pixels, blue pixels, and green pixels in the mosaic image is 1:1:2. Based on this quantitative ratio, this solution uses red pixels and blue pixels as pixels to be interpolated to fill the missing green components of red pixels and blue pixels. This is equivalent to only 1 / 2 of the pixels in the entire mosaic image needing interpolation to fill their missing green components, thereby reducing the number of interpolations and improving interpolation efficiency. If it is assumed that blue pixels and green pixels are used as pixels to be interpolated to fill the missing red components of blue pixels and green pixels, this is equivalent to 3 / 4 of the pixels needing to be interpolated, and the amount of data is large, which is not conducive to interpolation processing.
[0052] Step S320: Determine the green channel value of the pixel to be interpolated based on the color channel value of the pixel to be interpolated, the color channel values of the pixels in multiple set directions of the pixel to be interpolated, and the first interpolation formula.
[0053] In this embodiment, it has been mentioned above that the pixel points to be interpolated are red pixel points and blue pixel points. If the pixel point to be interpolated is a red pixel point, the color channel value of the pixel point to be interpolated refers to the red channel value. If the pixel point to be interpolated is a blue pixel point, the color channel value of the pixel point to be interpolated refers to the blue channel value.
[0054] in, Figure 4 A schematic diagram of the pixels to be interpolated provided by the computing power of this application, such as Figure 4 As shown, if the pixel to be interpolated is a red pixel (using Figure 4 ), there are other pixels in all directions around it, such as green pixel G1 and green pixel G-1, green pixel G2 and green pixel G-2, red pixel R-2 and red pixel R2, etc., which are respectively in different directions of the pixel to be interpolated.
[0055] Among them, the color channel values of these pixels can be used as input parameters of the first interpolation formula, and the first interpolation formula obtains a calculation result based on the input parameters. The calculation result can be directly used as the green channel value of the pixel to be interpolated, but the interpolation effect is not ideal. For this reason, the calculation result can be further processed to improve the interpolation effect, which will be described in detail later in this article.
[0056] Step S330: based on the color channel value of the pixel to be interpolated, the color channel value of the pixel in the preset direction of the pixel to be interpolated and the second interpolation formula, correct the green channel value of the pixel to be corrected.
[0057] The pixel points to be corrected are the pixel points to be interpolated at the edge of the mosaic image.
[0058] Among them, the above expression is continued to be used, that is, the color channel value of the pixel to be interpolated refers to the red channel value or the blue channel value (at this time, the pixel to be interpolated has not yet completed the interpolation filling, and only has one color channel value, that is, it does not currently have a green channel value).
[0059] Among them, continue to use the above Figure 4 As described in , the pixel to be interpolated has corresponding pixel points in different directions, so the preset direction can be pre-configured according to the actual situation. For example, there is a green pixel point G-2 above the pixel to be interpolated and a green pixel point G2 below the pixel to be interpolated as the pixel points in the preset direction of the pixel to be interpolated.
[0060] In this embodiment, the color channel value of the pixel point in the preset direction of the pixel point to be interpolated is used as the input of the second interpolation formula. The second interpolation formula calculates a color value based on the input color channel value, and the color value can be directly used as the green channel value of the pixel point to be corrected. Similarly, the calculated color value can be further processed, and the processing result is used as the green channel value of the pixel point to be corrected.
[0061] In this embodiment, the pixel points to be corrected refer to the pixel points to be interpolated at the edge of the mosaic image. It can be determined which pixel points to be interpolated are at the edge of the mosaic image by an edge detection algorithm. Exemplarily, the edge detection algorithm may include: Laplace operator, Sobel operator, etc.
[0062] The edge of the image may refer to a discontinuity in the distribution of characteristics (such as pixel grayscale and texture) in the mosaic image, or a set of pixels whose characteristics around the image have a step change or a ridge-like change.
[0063] In this embodiment, the green channel value of the pixel to be interpolated can be determined through the above-mentioned step S320, but due to the above-mentioned characteristics of the image edge, the green channel value of the pixel to be interpolated at the edge is re-corrected through step S330, so as to avoid the appearance of pseudo color at the edge in the subsequently output de-mosaiced image.
[0064] Step S340: based on the green channel value of each pixel in the mosaic image, determine the red channel value and the blue channel value of each pixel.
[0065] In this embodiment, after the green channel value of the pixel to be interpolated is determined by the interpolation method described above, all pixels in the entire mosaic image have green channel values. Among them, the pixel to be interpolated has a red channel value or a blue channel value from the beginning, which is equivalent to the pixel to be interpolated already having two color channel values (green + red or green + blue), and the original green pixel (i.e., the pixel not interpolated) still has only a green channel value. In this case, the red channel value or the blue channel value of the original green pixel can be determined by taking the color difference value, as follows:
[0066] R0-G0=q(R1-G1+R -1 -G -1 )
[0067] In the above formula, R0 represents the red channel value of the green pixel, G0 represents the green channel value of the green pixel, R1 represents the red channel value of the first pixel, and R -1The red channel value of the second pixel, G1 represents the green channel value of the first pixel, G -1 It represents the green channel value of the second pixel. q is the set value. Depending on the set value, the calculated value of R0 is also different.
[0068] Similarly, the blue channel value of the original green pixel can also be determined by the above method.
[0069] Step S350: based on the green channel value, the red channel value and the blue channel value of each pixel, convert the mosaic image into a demosaiced image.
[0070] In this embodiment, when each pixel has red, green, and blue color channel values, the final interpolated RGB three-channel data is obtained, which can be converted into an RGB format image as a demosaiced image. The demosaiced image obtained by this solution can accurately restore the color information of the real visual scene.
[0071] The embodiment of the present application fills the missing color channel values of the pixel to be interpolated by utilizing the color channel values of other pixels in multiple directions of the pixel to be interpolated, and after filling, continues to correct the color channel values filled by the pixel to be interpolated at the edge, which can effectively improve the pseudo-color phenomenon and the jagged phenomenon and improve the de-mosaicing effect.
[0072] The following describes in detail the multiple setting directions of the interpolation pixels through some embodiments.
[0073] Figure 5 The following is a schematic diagram of six setting directions of the pixel points to be interpolated provided in the embodiment of the present application, such as Figure 5 As shown, taking the red pixel R0 as the pixel to be interpolated as an example, it includes directions (a), (b), (c), (d), (e), and (f). Among them, Figure 5 (a) represents the left and right sides of the pixel to be interpolated; (b) represents the top and bottom of the pixel to be interpolated; (c) represents the left and top of the pixel to be interpolated; (d) represents the left and bottom of the pixel to be interpolated; (e) represents the right and top of the pixel to be interpolated; (f) represents the right and bottom of the pixel to be interpolated.
[0074] In this embodiment, it has been mentioned above that a color filter array CFA is laid on the image sensor. The color filter array CFA is formed by an array of multiple filters (the filter ratio is 2 green filters, 1 red filter and 1 blue filter). Correspondingly, in this way, the row and column of each pixel in the mosaic image can be determined, for example, R i,jIt represents the red pixel, which is in the i-th row and j-th column in the mosaic image. By configuring the corresponding row and column for each pixel, the position of each pixel in the mosaic image can be located, and then based on the position of each pixel in the mosaic image, the other pixels of each pixel in the set direction can be further determined.
[0075] Among them, the mask matrices of the three color channels of RGB can be obtained according to the color filter array CFA, and each mask matrix represents the position of the pixel under each channel. Figure 6 The mask diagram provided in the embodiment of the present application is as follows: Figure 6 As shown, Figure 6 In (1), the small positive squares with a value of "1" represent red pixels, and the small positive squares with a value of "0" represent other pixels (including green pixels and blue pixels). Figure 6 The small positive square with a value of "1" in (2) represents a blue pixel. Figure 6 The small positive square with the value of "1" in (3) represents the green pixel. After the mask is used, the position of the red pixel, the position of the blue pixel, and the position of the green pixel can be determined.
[0076] In this embodiment, the Figure 5 N other pixels are selected in each set direction of the pixel point R0 to be interpolated, and then the color channel values of the N other pixels in the 6 set directions are respectively input into the first interpolation formula, so that the first interpolation formula can output the corresponding calculation results in the 6 set directions. Exemplarily, an optimal calculation result can be selected from the calculation results corresponding to the 6 set directions as the green channel value of the pixel point R0 to be interpolated. In addition, in some other implementations used to support this scheme, the average of the corresponding calculation results in the 6 set directions can also be taken as the green channel value of the pixel point R0 to be interpolated. Wherein, N is a positive integer.
[0077] The embodiment of the present application selects the color channel values of the pixel points in 6 set directions of the pixel points to be interpolated as the input of the first interpolation formula, so that 6 calculation results can be calculated. In this way, it can be determined in which directions of the image the color difference value gradient changes greatly, so as to select the appropriate calculation result as the green channel value of the pixel points to be interpolated, thereby further improving the interpolation effect.
[0078] Further, continue to refer to the above Figure 5 , the following number of color channel values of pixels can be selected in each set direction as input parameters of the first interpolation formula:
[0079] Figure 5The middle direction (a) is: the color channel values of at least two pixels to the left of the pixel to be interpolated and the color channel values of at least two pixels to the right;
[0080] Figure 5 Middle direction (b): color channel values of at least two pixels above the pixel to be interpolated and color channel values of at least two pixels below the pixel to be interpolated;
[0081] Figure 5 Middle direction (c): color channel values of at least two pixels to the left of the pixel to be interpolated and color channel values of at least two pixels above it;
[0082] Figure 5 Middle direction (d): color channel values of at least two pixels to the left of the pixel to be interpolated and color channel values of at least two pixels below the pixel to be interpolated;
[0083] Figure 5 Middle direction (e): color channel values of at least two pixels to the right of the pixel to be interpolated and color channel values of at least two pixels above it;
[0084] Figure 5 Middle direction (f): color channel values of at least two pixels to the right of the pixel to be interpolated and color channel values of at least two pixels below it.
[0085] Refer to the above Figure 5 For direction (a), two pixel points R-2 (red pixel point) and G-1 (green pixel point) on the left side of the pixel point R0 to be interpolated and two pixel points R2 (red pixel point) and G1 (green pixel point) on the right side of R0 can be selected as inputs of the first interpolation formula, and the first result can be calculated by the first interpolation formula.
[0086] For direction (b), two pixel points R-2 (red pixel point) and G-1 (green pixel point) above the pixel point R0 to be interpolated and two pixel points R2 (red pixel point) and G1 (green pixel point) below R0 can be selected as inputs of the first interpolation formula, and the second result can be calculated by the first interpolation formula.
[0087] For direction (c), two pixel points R2 (red pixel point) and G1 (green pixel point) above the pixel point R0 to be interpolated and two pixel points R-2 (red pixel point) and G-1 (green pixel point) on the left side of R0 can be selected as inputs of the first interpolation formula, and the third result can be calculated by the first interpolation formula.
[0088] For direction (d), two pixel points R-2 (red pixel point) and G-1 (green pixel point) to the left of the pixel point R0 to be interpolated and two pixel points R2 (red pixel point) and G1 (green pixel point) below R0 can be selected as inputs of the first interpolation formula, and the fourth result can be calculated by the first interpolation formula.
[0089] For direction (e), two pixel points R-2 (red pixel point) and G-1 (green pixel point) above the pixel point R0 to be interpolated and two pixel points R2 (red pixel point) and G1 (green pixel point) on the right side of R0 can be selected as inputs of the first interpolation formula, and the fifth result can be calculated by the first interpolation formula.
[0090] For direction (f), two pixel points R-2 (red pixel point) and G-1 (green pixel point) below the pixel point R0 to be interpolated and two pixel points R2 (red pixel point) and G1 (green pixel point) on the right side of R0 can be selected as inputs of the first interpolation formula, and the sixth result can be calculated by the first interpolation formula.
[0091] The above six directions correspond to one calculation result respectively, and there are six calculation results in total. Based on these six calculation results, the color channel value of the pixel to be interpolated is obtained.
[0092] It should be noted here that when there are no other pixels on the left, above, below or right of a pixel to be interpolated, for example Figure 5 There are no other pixels above the red pixel R-2 in the middle (b) direction. At this time, the color channel values of the pixels below R-2 (i.e., the green pixel G-1 and the red pixel R0) can be used to obtain the color channel values of the missing pixels above the red pixel R-2 through a mapping relationship.
[0093] Furthermore, in some embodiments, the first interpolation formula is:
[0094]
[0095] In the above formula, is the color channel value of the pixel to be interpolated, is the color channel value of the first pixel to the left, right, above, or below the pixel to be interpolated. is the color channel value of the second pixel to the left, right, above, or below the pixel to be interpolated. is the candidate value of the green channel under the set direction, and q1, q2, q3, q4, and q5 are the set values.
[0096] In this embodiment, q1, q2, q3, q4, and q5 can be configured according to actual conditions. For example, the values of q1, q2, and q3 can be 0.5, and the values of q4 and q5 can be 0.25.
[0097] In the embodiment of the present application, four pixel points are collected in each set direction of the pixel point to be interpolated. , The color channel value of the pixel to be interpolated and the color channel values of the four pixels are used as input parameters, and the green channel candidate values under each set direction are calculated by the first interpolation formula. In this way, the differences in each set direction can be compared, and the optimal green channel value can be selected from these green channel candidate values as the green channel value of the pixel to be interpolated, thereby improving the interpolation effect and avoiding pseudo color and aliasing phenomena in the demosaicing process.
[0098] The above has introduced how to obtain the candidate green channel values under various set directions. The following will illustrate how to determine the green channel value of the pixel to be interpolated based on these candidate green channel values through some embodiments. Exemplarily, there are two ways:
[0099] Method (1) selects a target candidate value from the green channel candidate values under all set directions as the green channel value of the pixel to be interpolated.
[0100] Method (2) configures different weight coefficients for the green channel candidate values in each set direction, and then weights the green channel candidate values in each set direction and sums them up to serve as the green channel value of the pixel to be interpolated.
[0101] Among them, for method (1), it can be implemented through the following steps:
[0102] Step (i): based on the green channel candidate value and the color channel value of the pixel to be interpolated in each set direction, obtaining the color difference value of the pixel to be interpolated in each set direction;
[0103] Step (ii): based on the color difference value of the pixel to be interpolated in each set direction, obtaining the color difference gradient in each set direction;
[0104] Step (iii) based on the color difference gradient in each set direction, select a target candidate value from all green channel candidate values.
[0105] In this embodiment, Figure 7 The color difference gradient calculation schematic diagram provided in the embodiment of the present application is as follows: Figure 7 As shown, Figure 7(A) in the figure represents the original mosaic image, which has a pixel B (i.e., a blue pixel) and a pixel R (i.e., a red pixel) to be interpolated. After obtaining the candidate values of the green channel of the pixel to be interpolated in the above manner, refer to Figure 7 In (B), Figure 7 (A) minus Figure 7 In (B), the color difference value of the pixel to be interpolated is obtained. The specific calculation formula is as follows:
[0106]
[0107] In the above formula, represents the color difference value, i and j represent the row and column where the pixel is located, and H is the set direction, with a value of [1, 6].
[0108] It should be noted that each set direction has a green channel candidate value, which is equivalent to that in each set direction, the pixel point to be interpolated has a corresponding color difference value.
[0109] Furthermore, after the color difference value is calculated, the color difference values of two adjacent pixels to be interpolated can be subtracted to obtain the color difference gradient. The specific formula is as follows:
[0110]
[0111] In the above formula, represents the color difference gradient, i and j represent the row and column where the pixel is located, and H is the set direction, with a value of [1, 6].
[0112] In this embodiment, after calculating the color difference gradient of the pixel to be interpolated in each set direction, the color difference gradient sum in the 5x5 neighborhood of the pixel to be interpolated in each set direction can be calculated. Exemplarily, the following weights can be configured for each color difference gradient in the 5x5 neighborhood:
[0113]
[0114] Through the above weights, the color difference gradient sum in the 5x5 neighborhood of the pixel to be interpolated in each set direction is calculated (that is, each set direction has a color difference gradient sum, and 6 set directions have a total of 6 color difference gradient sums), and then these 6 color difference gradient sums are compared, and the optimal color difference gradient sum corresponding to the target set direction is selected, and the green channel candidate value corresponding to the target set direction is obtained as the green channel value of the pixel to be interpolated.
[0115] Exemplarily, the color difference gradient sum with the smallest value among the six color difference gradient sums can be selected as the above-mentioned optimal color difference gradient sum.
[0116] The embodiment of the present application performs interpolation calculation through the color channel values of the pixel points in 6 set directions of the pixel points to be interpolated and the above-mentioned first interpolation formula to obtain 6 green channel candidate values, and selects the optimal target candidate value from the 6 green channel candidate values based on the color difference gradient and as the green channel value of the pixel point to be interpolated, which can effectively improve the aliasing phenomenon and pseudo color phenomenon that occur in the oblique direction interpolation, and further improve the de-mosaic effect of the image.
[0117] After obtaining the green channel value of the pixel to be interpolated, it is necessary to further correct the green channel value of the pixel to be interpolated at the edge. The correction process is described in detail below through some embodiments.
[0118] In this embodiment, some pixels to be interpolated in the mosaic image may be located in the edge area. To facilitate distinction, the pixels to be interpolated located in the edge area are described as pixels to be corrected.
[0119] Among them, in order to avoid the occurrence of pseudo-color phenomenon in these pixels to be corrected, on the basis of the most original mosaic image (that is, the mosaic image before interpolation), the color channel values of other pixels in the preset direction of each pixel to be interpolated (including pixels to be interpolated in the edge area and pixels to be interpolated not in the edge area) can be obtained, and then input into the second interpolation formula to calculate a value. If this pixel to be interpolated is the above-mentioned pixel to be corrected, the value is taken as the green channel value of the pixel to be corrected.
[0120] For example, Figure 8 A schematic diagram of green channel value correction provided in an embodiment of the present application is shown in FIG. Figure 8 As shown, Figure 8 is the original mosaic image, assuming Figure 8 The red pixel point R0 in the figure is a pixel point to be interpolated in the edge area, and the green channel value L1 of the red pixel point R0 is obtained through the above interpolation step. This embodiment continues to use the color channel values of other pixels in the preset direction of the red pixel point R0 and the second interpolation formula to calculate a value L2, and then corrects the green channel value L1 determined by the above interpolation step to the value L2.
[0121] The preset direction may refer to the pixel point to be interpolated (for example Figure 8 The horizontal and vertical directions of the red pixel R0 in the image are the left and right sides, the top and the bottom of the pixel to be interpolated. Figure 8, two pixels on the left and right sides of the pixel to be interpolated (i.e., including green pixel G1, green pixel G-1, red pixel R1, and red pixel R-1) can be taken as the pixels in the horizontal direction of the pixel to be interpolated. In addition, two pixels above and below the pixel to be interpolated (i.e., including green pixel G-2, green pixel G2, red pixel R2, and red pixel R-2) can also be taken as the pixels in the vertical direction of the pixel to be interpolated.
[0122] Further, in some implementations, the second interpolation formula is:
[0123]
[0124] In the above formula, is the color channel value of the pixel to be interpolated, are the color channel values of the pixels on the left and right of the pixel to be interpolated or the color channel values of the pixels above and below the pixel to be interpolated, respectively. It is the green channel value of the pixel to be corrected. qx1, qx2, qx3, qx4, qx5 are the set values
[0125] In this embodiment, from the perspective of Fourier spectrum analysis and optimization algorithm design, an approximate function of an ideal interpolation filter with five coefficients can be derived:
[0126]
[0127] in, The different values of determine the approximation degree between the approximate function and the ideal interpolation filter, thus affecting the calculation result of the second interpolation formula. The five coefficients refer to the five weight coefficients qx1, qx2, qx3, qx4, and qx5 mentioned above. Different values of are related to five coefficients. For example, Fig. 9 This is a comparison diagram of the ideal interpolation filter and the five-coefficient approximate function curve family. Fig. 9 As shown, by adjusting The value of can make the corresponding approximate function curve and the ideal interpolation filter curve ( Fig. 9 The curve rect in the image is as close as possible. Based on this inference, an approximate function that is closer to the ideal interpolation filter is applied at the edge of the image. The value of is chosen so that the curve of the corresponding approximate function is consistent with the curve of the ideal interpolation filter ( Fig. 9 After fitting the curve rect in the figure as closely as possible, the five corresponding coefficients are: −0.083, 0.25, 0.666, 0.25, −0.083, that is, qx1 and qx5 take the values of −0.083, qx2 and qx4 take the values of 0.25, and qx3 takes the value of 0.666.
[0128] Specifically, if two pixels above and below the pixel to be interpolated are taken (i.e., including Figure 8 The green pixel point G-2, the green pixel point G2, the red pixel point R2, the red pixel point R-2) are used as the pixel points in the vertical direction of the pixel point to be interpolated, and the second interpolation formula is as follows:
[0129]
[0130] If two pixels on the left and right sides of the pixel to be interpolated (i.e., green pixel G1, green pixel G-1, red pixel R1, and red pixel R-1) are taken as the pixels in the horizontal direction of the pixel to be interpolated, the second interpolation formula is as follows:
[0131]
[0132] Among them, you can choose according to the actual situation. or As the corrected green channel value of the above pixel to be corrected.
[0133] The embodiment of the present application selects a second interpolation formula that is more in line with the high-frequency area (i.e., the edge area) to correct the green channel value of the pixel point to be interpolated in the edge area, which can effectively improve the pseudo-color problem at the edge of the image and further improve the de-mosaicing effect.
[0134] After the interpolation and correction of the green channel values of all pixels are completed as described above, an embodiment is described below in detail how to determine the red channel value and the blue channel value of each pixel based on the green channel value of each pixel after interpolation and correction.
[0135] In this embodiment, when a pixel has two color channel values, the color difference value of the pixel can be obtained by subtracting them, and then based on the principle that the color difference values of adjacent pixels are equal, the missing color channel values of other pixels can be obtained. Specifically, the following methods can be used:
[0136] Method A: Obtain a first color difference value of a pixel on the left side of the pixel and a second color difference value of a pixel on the right side of the pixel; determine a red channel value and a blue channel value of the pixel based on the first color difference value, the second color difference value and the green channel value of the pixel.
[0137] The first color difference value is the difference between the two color channel values of the left pixel point, and the second color difference value is the difference between the two color channel values of the right pixel point.
[0138] Method B: Obtain the third color difference value of the pixel above the pixel and the fourth color difference value of the pixel below the pixel; determine the red channel value and the blue channel value of the pixel based on the third color difference value, the fourth color difference value and the green channel value of the pixel.
[0139] The third color difference value is the difference between the two color channel values of the upper pixel point, and the fourth color difference value is the difference between the two color channel values of the lower pixel point.
[0140] For example, Fig.10 A schematic diagram of interpolation of the red channel value of a pixel point provided in an embodiment of the present application is shown in FIG. Fig.10 As shown, according to the position of the pixel point, it can be divided into the following two cases:
[0141] Case (1): The pixel is Fig.10 Position in ①
[0142] Case (2): The pixel is in Fig.10 Position ② or position ③
[0143] Among them, the R value (i.e., the red channel value) or B value (the red channel value) at position ② is subjected to horizontal bilinear interpolation; the R value or B value at position ③ is subjected to vertical bilinear interpolation. The interpolation formula can be expressed as:
[0144]
[0145] In the above formula, is the R value at position ②, is the G value at position ②, is the R value of the pixel on the left side of position ②, is the R value of the pixel on the right side of position ②, is the G value of the pixel on the left side of position ②, is the G value of the pixel on the right side of position ②. Similarly, the B value at position ② can be obtained.
[0146] For the red channel, for position ①, the red channel value of the current pixel can be interpolated based on the color difference gradient and obtained in the above interpolation step. The calculation formula is:
[0147]
[0148] In the above formula, is the red channel value of the pixel at the i-th row and j-th column, is the blue channel value of the pixel at the i-th row and j-th column. , are the color difference gradient and in the vertical direction of the pixel point and the color difference gradient and in the horizontal direction respectively.
[0149] The embodiment of the present application further determines the red channel value or blue channel value of the pixel point by using the color difference gradient and used in the aforementioned interpolation step, so that there is no need to re-interpolate the red channel value and the blue channel value, which can reduce the computational complexity and improve the image demosaicing efficiency. At the same time, based on the green channel value of the pixel point obtained in the aforementioned interpolation step, determining the red channel value or blue channel value of the pixel point can also further improve the demosaicing effect.
[0150] The de-mosaicing process of this solution is described in detail below through a complete embodiment.
[0151] Fig.11 A schematic diagram of a de-mosaicing process is provided for another embodiment of the present application, such as Fig.11 As shown, it includes the following steps:
[0152] S1101: Acquire a two-dimensional bayer image;
[0153] S1102: Obtain RGB three-channel data;
[0154] S1103: interpolating the G channel along 6 directions;
[0155] S1104: Selecting an optimal interpolation direction according to the color difference gradient;
[0156] S1105: interpolating the G channel horizontally and vertically according to the high frequency filter;
[0157] S1106: extracting edge mask from the G channel using Laplacian operator;
[0158] S1107: Correcting the edge area according to the edge mask;
[0159] S1108: interpolating the color difference components of the red and blue channels;
[0160] S1109: Update the high frequency component of the green channel to be interpolated;
[0161] S1110: Update the high-frequency components of the red and blue channels to be interpolated.
[0162] Correspondingly, Fig.12 A schematic diagram of a de-mosaic processing module provided in an embodiment of the present application, such as Fig.12 As shown, it is divided into four sub-modules:
[0163] 1) Green channel 8-direction interpolation module: used to process the green channel, and reconstruct the green channel interpolation position along 8 directions: up, down, left, right, upper left, lower left, upper right and lower right according to the designed basic interpolation filter. Then, the optimal interpolation direction is selected according to the color difference gradient to obtain the reconstructed green channel. Among them, interpolation is performed based on 8 directions and the corresponding basic interpolation filter is designed (i.e., corresponding to the first interpolation formula), which ultimately improves the aliasing phenomenon and pseudo-color phenomenon that occurs in the oblique direction interpolation.
[0164] 2) Edge correction module: According to the designed high-frequency interpolation filter (corresponding to the second interpolation formula), the green channel interpolation position is reconstructed in the horizontal and vertical directions; then the Laplace operator is used to process the reconstructed green channel to obtain the edge mask, and the edge area of the green channel is corrected according to the mask. This can improve the pseudo-color phenomenon in the edge area.
[0165] 3) Red and blue channel interpolation module: interpolate the color difference values of the red and blue channels according to the classifier obtained by the green channel.
[0166] 4) High- and low-frequency division correction module: The high-frequency component of the reconstructed pixel is corrected with the high-frequency component of the current pixel.
[0167] Specifically, Fig.13 A schematic diagram of the processing flow of the green channel 8-direction interpolation module provided in the embodiment of the present application is shown in FIG. Fig.13 As shown, it includes the following steps:
[0168] S1301: Acquire a two-dimensional bayer image;
[0169] S1302: Obtain RGB three-channel mask and extract three-channel value data;
[0170] S1303: interpolating the position to be interpolated of the G channel along the 8 direction;
[0171] S1304: Calculate the color difference value of the position to be interpolated in the G channel;
[0172] S1305: Calculate the color difference gradients in 8 directions;
[0173] S1306: Calculate the color difference gradient of the 5x5 neighborhood and obtain a classifier;
[0174] S1307: Obtain the pixel value of the position to be interpolated according to the classifier.
[0175] Among them, the basic interpolation filter FIR=[−0.25, 0.5, 0.5, 0.5, −0.25], and the first interpolation formula applied is:
[0176]
[0177] The relevant parameters of the first interpolation formula refer to the above Figure 5 In addition, the classifier may specifically refer to a Figure 5 The green channel candidate values are calculated in the six directions.
[0178] Specifically, Fig.14 A schematic diagram of the processing flow of the edge correction module provided in the embodiment of the present application is shown in FIG. Fig.14 As shown, it includes the following steps:
[0179] S1401: Obtain G channel data;
[0180] S1402: Obtain a high frequency interpolation filter;
[0181] S1403: interpolating the G channel horizontally and vertically according to the high-frequency interpolation filter;
[0182] S1404: extracting edge mask from the G channel using Laplacian operator;
[0183] S1405: Correct the edge area according to the edge mask.
[0184] The specific process is:
[0185] 1) Apply a high-frequency interpolation filter to interpolate the original G channel's interpolation position in the horizontal and vertical directions.
[0186] 2) Use the Laplace operator to process the G channel data output from the previous level to obtain the edge image, and extract the edge mask according to the set threshold, which is set to 1 / 4 of the maximum grayscale level.
[0187] 3) Based on the edge mask matrix obtained in 2), and the horizontal and vertical classifiers obtained by the green channel 8-direction interpolation module (see above Figure 5 In (a) and (b) above, the edge area of the G channel data output from the previous level is corrected. So far, the edge-corrected G channel data can be obtained. Among them, the high-frequency interpolation filter is FIR_hf = [−0.083, 0.25, 0.666, 0.25, −0.083].
[0188] Fig.15 A schematic diagram of the processing flow of the red and blue channel interpolation module provided in the embodiment of the present application is shown in FIG. Fig.15 As shown, it includes the following steps:
[0189] S1501: Process R and B channel data separately;
[0190] S1502: For positions ② and ③ to be interpolated, bilinear interpolation is performed based on the color difference value;
[0191] S1503: For the position to be interpolated ①, interpolation is performed according to the above classifier.
[0192] The specific process is:
[0193] 1) Perform channel processing on RGB three-channel data and RGB three-channel mask matrix.
[0194] 2) As mentioned above Fig.10 As shown, for the red channel, the R value at position ② is bilinearly interpolated horizontally, and the R value at position ③ is bilinearly interpolated vertically; the same operation can be performed on the blue channel. The interpolation formula can be expressed as:
[0195]
[0196] 3) According to the red and blue channel data calculated in step 1), for the red channel, for position ①, the current pixel point can be interpolated according to the classifier obtained in the previous green channel value interpolation step. The calculation formula is:
[0197]
[0198] Similarly, the same operation can be performed on the blue channel, and finally the interpolated R and B color channel values can be obtained.
[0199] Fig.16 A schematic diagram of the processing flow of the high and low frequency division correction module provided in the embodiment of the present application is shown in FIG. Fig.16 As shown, it includes the following steps:
[0200] S1601: RGB three-channel data;
[0201] S1602: Image frequency division;
[0202] S1603: Update the high frequency component of the green channel to be interpolated;
[0203] S1604: Update the high-frequency components of the red and blue channels to be interpolated.
[0204] This high-low frequency division correction module mainly corrects the image after interpolation by the above modules, and replaces the high-frequency component of the reconstructed pixel with the high-frequency component of the current pixel. The specific processing flow is as follows:
[0205] 1) Perform channel processing on the RGB three-channel data and RGB three-channel mask matrix after the previous level of interpolation;
[0206] 2) Perform frequency division on the image, update the green pixel value, and replace the high-frequency component at the interpolation position of the G channel with the high-frequency component of the original R or B pixel.
[0207] 3) The high frequency component of the R (B) pixel located at the G pixel position is replaced by the original G pixel high frequency component.
[0208] 4) Replace the high-frequency component of the B (R) pixel at the R (B) pixel position with the original R (B) pixel high-frequency component. At this point, the final interpolated RGB three-channel data is obtained and converted into an (H, W, C) format image. Among them, H is the height, W is the width, and C is the number of color channels.
[0209] The following are device embodiments of the present application, which can be used to execute the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
[0210] Fig.17 A schematic diagram of the structure of the image de-mosaicing device provided in the embodiment of the present application is shown in FIG. Fig.17 As shown, the de-mosaicing device 1700 includes: an interpolation pixel point determination module 1710 , a first interpolation module 1720 , an interpolation correction module 1730 , a channel value determination module 1740 , and a de-mosaicing module 1750 .
[0211] The interpolation pixel point determination module 1710 is used to obtain the pixel points to be interpolated in the mosaic image.
[0212] The first interpolation module 1720 is used to determine the green channel value of the pixel to be interpolated based on the color channel value of the pixel to be interpolated, the color channel values of the pixel in multiple set directions of the pixel to be interpolated, and the first interpolation formula. The interpolation correction module 1730 is used to correct the green channel value of the pixel to be corrected based on the color channel value of the pixel to be interpolated, the color channel value of the pixel in the preset direction of the pixel to be interpolated, and the second interpolation formula. The channel value determination module 1740 is used to determine the red channel value and the blue channel value of each pixel in the mosaic image based on the green channel value of each pixel. The de-mosaicing module 1750 is used to convert the mosaic image into a de-mosaiced image based on the green channel value, the red channel value, and the blue channel value of each pixel.
[0213] The color channel value of each pixel in the mosaic image is one of the green channel value, the red channel value, and the blue channel value, and the color channel value of the pixel to be interpolated is the red channel value or the blue channel value. The pixel to be corrected is the pixel to be interpolated at the edge of the mosaic image.
[0214] Optionally, the set directions include: the left and right sides of the pixel to be interpolated; the left and above the pixel to be interpolated; the left and below the pixel to be interpolated; the right and above the pixel to be interpolated; the right and below the pixel to be interpolated; and above and below the pixel to be interpolated.
[0215] Optionally, the first interpolation module can be specifically used to: obtain a green channel candidate value in each set direction based on the color channel value of the pixel to be interpolated, the color channel value of the pixel in each set direction of the pixel to be interpolated, and the first interpolation formula; select a target candidate value from all green channel candidate values as the green channel value of the pixel to be interpolated.
[0216] Optionally, the first interpolation module can be specifically used to: obtain the color difference value of the pixel to be interpolated in each set direction based on the green channel candidate value in each set direction and the color channel value of the pixel to be interpolated; and obtain the color difference gradient in each set direction based on the color difference value of the pixel to be interpolated in each set direction; finally, based on the color difference gradient in each set direction, select the target candidate value from all green channel candidate values.
[0217] Optionally, the color channel values of the pixel points in multiple set directions of the pixel point to be interpolated include: the color channel values of at least two pixels to the left of the pixel point to be interpolated and the color channel values of at least two pixels to the right of the pixel point to be interpolated; the color channel values of at least two pixels above the pixel point to be interpolated and the color channel values of at least two pixels below; the color channel values of at least two pixels to the left of the pixel point to be interpolated and the color channel values of at least two pixels above; the color channel values of at least two pixels to the left of the pixel point to be interpolated and the color channel values of at least two pixels below; the color channel values of at least two pixels to the right of the pixel point to be interpolated and the color channel values of at least two pixels above; the color channel values of at least two pixels to the right of the pixel point to be interpolated and the color channel values of at least two pixels below.
[0218] Optionally, the first interpolation formula is:
[0219]
[0220] In the above formula, is the color channel value of the pixel to be interpolated, , is the color channel value of the first pixel to the left, right, above, or below the pixel to be interpolated. , is the color channel value of the second pixel to the left, right, above, or below the pixel to be interpolated. is the candidate value of the green channel under the set direction, and q1, q2, q3, q4, and q5 are the set values.
[0221] Optionally, the preset directions of the pixel to be interpolated include: the left side and the right side of the pixel to be corrected, and the top and the bottom of the pixel to be interpolated.
[0222] Optionally, the second interpolation formula is:
[0223]
[0224] In the above formula, is the color channel value of the pixel to be interpolated, , , , are the color channel values of the pixels to the left, right, above, and below the pixel to be interpolated, respectively. is the green channel value of the pixel to be corrected, and qx1, qx2, qx3, qx4, and qx5 are the set values.
[0225] Optionally, the channel value determination module can be specifically used to: obtain a first color difference value of a pixel on the left side of the pixel point and a second color difference value of a pixel on the right side of the pixel point, the first color difference value being the difference between two color channel values of the pixel on the left side, and the second color difference value being the difference between two color channel values of the pixel on the right side; and then determine a red channel value and a blue channel value of the pixel point based on the first color difference value, the second color difference value and the green channel value of the pixel point;
[0226] Or, obtain the third color difference value of the pixel above the pixel and the fourth color difference value of the pixel below the pixel, where the third color difference value is the difference between the two color channel values of the upper pixel, and the fourth color difference value is the difference between the two color channel values of the lower pixel; then determine the red channel value and the blue channel value of the pixel based on the third color difference value, the fourth color difference value and the green channel value of the pixel.
[0227] The device provided in the embodiment of the present application can be used to execute the method in the above embodiment. Its implementation principle and technical effect are similar and will not be repeated here.
[0228] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software called by processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware. For example, the interpolation pixel point determination module can be a separately established processing element, or it can be integrated in one of the components of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by one of the processing elements of the above device. The implementation of other modules is similar. In addition, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each of the above modules can be completed by the hardware integrated logic circuit in the processor element or the instructions in the form of software.
[0229] Fig.18 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.18 As shown, the electronic device 1800 includes: at least one processor 1801, a memory 1802, a bus 1803 and a communication interface 1804. Among them: the processor, the communication interface and the memory communicate with each other through the bus. The communication interface is used to communicate with other devices. The communication interface includes a communication interface for data transmission and a display interface or an operation interface for human-computer interaction.
[0230] The processor is used to execute the computer-executable instructions stored in the memory, and specifically can execute the relevant steps in the method described in the above embodiment.
[0231] The processor may be a central processing unit, or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement an embodiment of the present invention. The one or more processors included in the review device may be processors of the same type, such as one or more CPUs; or they may be processors of different types, such as one or more CPUs and one or more ASICs. The memory is used to store computer execution instructions. The memory may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk memory.
[0232] This embodiment also provides a readable storage medium, in which computer instructions are stored. When at least one processor of an electronic device executes the computer instructions, the electronic device executes the methods provided in the above-mentioned various implementation modes.
[0233] This embodiment also provides a program product, which includes computer instructions stored in a readable storage medium. At least one processor of the electronic device can read the computer instructions from the readable storage medium, and at least one processor executes the computer instructions so that the electronic device implements the methods provided in the above various embodiments.
[0234] In this application, "at least one" means one or more, and "more" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship; in the formula, the character " / " indicates that the previous and next associated objects are in a "division" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.
[0235] It is to be understood that the various numerical numbers involved in the embodiments of the present application are only for the convenience of description and are not intended to limit the scope of the embodiments of the present application. In the embodiments of the present application, the size of the sequence number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0236] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for demosaicing an image, characterized in that: include: Obtaining a pixel point to be interpolated in a mosaic image, wherein the color channel value of each pixel point in the mosaic image is one of a green channel value, a red channel value, and a blue channel value, and the color channel value of the pixel point to be interpolated is a red channel value or a blue channel value; Determine a green channel value of the pixel to be interpolated based on the color channel value of the pixel to be interpolated, the color channel values of pixels in multiple set directions of the pixel to be interpolated, and a first interpolation formula; Based on the color channel value of the pixel to be interpolated, the color channel value of the pixel in a preset direction of the pixel to be interpolated and a second interpolation formula, the green channel value of the pixel to be corrected is corrected, and the pixel to be corrected is the pixel to be interpolated at the edge of the mosaic image; Determine a red channel value and a blue channel value of each pixel in the mosaic image based on a green channel value of each pixel; Based on the green channel value, the red channel value and the blue channel value of each pixel, the mosaic image is converted into a demosaiced image; The first interpolation formula is: In the above formula, is the color channel value of the pixel to be interpolated, , is the color channel value of the first pixel on the left, right, above, or below the pixel to be interpolated, , is the color channel value of the second pixel point on the left, right, above or below the pixel point to be interpolated, is the candidate value of the green channel under the set direction, q1, q2, q3, q4, q5 are the set values; The second interpolation formula is: In the above formula, is the color channel value of the pixel to be interpolated, , , , are the color channel values of the pixels to the left, right, above, and below the pixel to be interpolated, respectively. is the green channel value of the pixel to be corrected, and qx1, qx2, qx3, qx4, and qx5 are the set values.
2. The method according to claim 1, characterized in that The setting direction includes: The left and right sides of the pixel to be interpolated; The left side and the top side of the pixel to be interpolated; The left side and the bottom side of the pixel to be interpolated; The right side and the top of the pixel to be interpolated; The right side and the bottom side of the pixel to be interpolated; Above and below the pixel to be interpolated.
3. The method according to claim 1, characterized in that The step of determining the green channel value of the pixel to be interpolated based on the color channel value of the pixel to be interpolated, the color channel values of the pixels in multiple set directions of the pixel to be interpolated, and a first interpolation formula includes: Based on the color channel value of the pixel to be interpolated, the color channel value of the pixel in each set direction of the pixel to be interpolated, and the first interpolation formula, obtaining a green channel candidate value in each set direction; A target candidate value is selected from all green channel candidate values as the green channel value of the pixel to be interpolated.
4. The method according to claim 3, characterized in that The step of selecting a target candidate value from all green channel candidate values includes: Based on the green channel candidate value in each set direction and the color channel value of the pixel to be interpolated, obtaining the color difference value of the pixel to be interpolated in each set direction; Based on the color difference value of the pixel to be interpolated in each set direction, obtaining the color difference gradient in each set direction; Based on the color difference gradient in each set direction, a target candidate value is selected from all green channel candidate values.
5. The method according to claim 1 or 2, characterized in that: The color channel values of the pixel points in multiple set directions of the pixel points to be interpolated include: The color channel values of at least two pixels on the left side and the color channel values of at least two pixels on the right side of the pixel to be interpolated; The color channel values of at least two pixels above the pixel to be interpolated and the color channel values of at least two pixels below the pixel to be interpolated; The color channel values of at least two pixels to the left of the pixel to be interpolated and the color channel values of at least two pixels above the pixel to be interpolated; The color channel values of at least two pixels to the left of the pixel to be interpolated and the color channel values of at least two pixels below the pixel to be interpolated; The color channel values of at least two pixels to the right of the pixel to be interpolated and the color channel values of at least two pixels above the pixel to be interpolated; The color channel values of at least two pixels on the right side of the pixel to be interpolated and the color channel values of at least two pixels below the pixel to be interpolated.
6. The method according to claim 1, characterized in that The preset direction of the pixel to be interpolated includes: The left and right sides of the pixel to be corrected; Above and below the pixel to be interpolated.
7. The method according to claim 1, characterized in that The step of determining the red channel value and the blue channel value of each pixel point based on the green channel value of each pixel point in the mosaic image comprises: Obtain a first color difference value of a pixel on the left side of the pixel and a second color difference value of a pixel on the right side of the pixel, wherein the first color difference value is a difference between two color channel values of the pixel on the left side, and the second color difference value is a difference between two color channel values of the pixel on the right side; Determine a red channel value and a blue channel value of the pixel based on the first color difference value, the second color difference value and the green channel value of the pixel; or, Obtain a third color difference value of a pixel above the pixel and a fourth color difference value of a pixel below the pixel, wherein the third color difference value is a difference between two color channel values of the pixel above, and the fourth color difference value is a difference between two color channel values of the pixel below; Based on the third color difference value, the fourth color difference value and the green channel value of the pixel point, a red channel value and a blue channel value of the pixel point are determined.
8. An image demosaicing device, characterized in that: include: An interpolation pixel determination module is used to obtain a pixel to be interpolated in a mosaic image, wherein the color channel value of each pixel in the mosaic image is one of a green channel value, a red channel value, and a blue channel value, and the color channel value of the pixel to be interpolated is a red channel value or a blue channel value; A first interpolation module is used to determine the green channel value of the pixel to be interpolated based on the color channel value of the pixel to be interpolated, the color channel values of the pixels in multiple set directions of the pixel to be interpolated, and a first interpolation formula; An interpolation correction module, used to correct the green channel value of the pixel to be corrected based on the color channel value of the pixel to be interpolated, the color channel value of the pixel in a preset direction of the pixel to be interpolated, and a second interpolation formula, wherein the pixel to be corrected is the pixel to be interpolated at the edge of the mosaic image; A channel value determination module, used to determine a red channel value and a blue channel value of each pixel point in the mosaic image based on a green channel value of each pixel point; A demosaicing module, used for converting the mosaic image into a demosaiced image based on a green channel value, a red channel value and a blue channel value of each pixel; Wherein, the first interpolation formula is: In the above formula, is the color channel value of the pixel to be interpolated, , is the color channel value of the first pixel on the left, right, above, or below the pixel to be interpolated, , is the color channel value of the second pixel point on the left, right, above or below the pixel point to be interpolated, is the candidate value of the green channel under the set direction, q1, q2, q3, q4, q5 are the set values; The second interpolation formula is: In the above formula, is the color channel value of the pixel to be interpolated, , , , are the color channel values of the pixels to the left, right, above, and below the pixel to be interpolated, respectively. is the green channel value of the pixel to be corrected, and qx1, qx2, qx3, qx4, and qx5 are the set values.
Citation Information
Patent Citations
Method for image interpolation
CN101360247A
Demosaicing method for CFA (color filter array) images based on edge-direction interpolation
CN102254301A
Demosaicking method and device
CN102630019A
Bayer-pattern CFA image demosaicking method based on non-local mean
CN102663719A
Edge-related and color-combined demosaicing and amplifying method
CN103347190A
