Curve generation method for image correction and image color correction method

By generating nonlinear correction curves for the R, G, and B channels adapted to the lens, the problems of color deviation and brightness nonlinearity in images captured by the camera lens are solved, achieving fast and accurate color correction and improving the accuracy of image color.

CN116993608BActive Publication Date: 2026-04-14ZHUHAI JIELI TECH
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHUHAI JIELI TECH
Filing Date
2023-07-25
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

Due to differences in the quality of camera lenses produced by different manufacturers and the differences in sensor technology in optical imaging systems, images captured by camera lenses suffer from color deviation and brightness nonlinearity, making it difficult for existing technologies to perform color correction quickly and accurately.

Method used

By acquiring the RGB pixel values ​​of the calibration image, calculating the color temperature coordinates, and generating nonlinear correction curves for the R, G, and B channels, these curves are used to perform nonlinear correction and white balance correction on the target image, generating a correction curve adapted to the lens.

Benefits of technology

It enables fast and accurate correction of color deviation in images captured by the lens, improves the accuracy of color correction, and makes the corrected image color closer to the true color of the object, avoiding complex calculations and additional equipment costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116993608B_ABST
    Figure CN116993608B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of image processing, and particularly relates to a curve generation method for image correction, an image color correction method and device, electronic equipment, readable storage medium and chip. The curve generation method for image correction comprises: obtaining a calibration picture obtained by a calibration image shot by a to-be-corrected lens, wherein the calibration image comprises a plurality of color blocks different in color, R, G and B three channel pixel values of each color block are equal, and the calibration picture comprises a plurality of pixel blocks corresponding to the color blocks; calculating color temperature coordinates of the calibration picture in a color temperature coordinate system according to R, G and B three channel pixel values of the pixel blocks of the calibration picture; and determining mapping values of each pixel value in 0-255 of R, G and B three channels respectively according to R, G and B three channel pixel values of the plurality of pixel blocks of the calibration picture and the color temperature coordinates, so as to obtain non-linear correction curves of R, G and B three channels. Through the above manner, the present application realizes improving the accuracy of color correction on the image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and specifically to a curve generation method for image correction, an image color correction method, a curve generation device for image correction, an image color correction device, an electronic device, a computer-readable storage medium, and a chip. Background Technology

[0002] With the rapid development of technologies such as smartphones, surveillance cameras, and autonomous driving, the demand for high-quality images and videos is becoming increasingly prominent. Due to the differences in how camera lenses and the human eye perceive color, the colors in images captured by a camera lens differ from the colors seen by the human eye for the same object. Furthermore, for the same object, the colors in images captured by a camera lens will change under different light sources, resulting in color casts. To ensure that the colors in images captured by a camera lens match those seen by the human eye, white balance processing is typically required.

[0003] However, due to differences in the quality of camera lenses produced by different manufacturers, the materials used in camera lenses in electronic devices exhibit significant dispersion, meaning they possess considerable nonlinearity. Furthermore, in optical imaging systems, variations in sensor manufacturing processes and image correction coefficient errors within the camera lens can lead to chromatic aberration and nonlinearity in brightness in images captured by the lens. Consequently, when performing white balance correction on such images, the resulting color correction accuracy is low.

[0004] Therefore, for camera lenses that do not meet the requirements for nonlinearity, how to perform nonlinear correction on the images they capture in a simple and quick way, while avoiding color cast and improving the accuracy of color correction, is a problem that needs to be solved. Summary of the Invention

[0005] Based on the above situation, the main objective of this invention is to provide a curve generation method for image correction and an image color correction method, so as to achieve simple and fast color correction of target images, avoid color cast problems, and improve the accuracy of color correction.

[0006] To achieve the above objectives, the technical solution used in this invention to generate the image color correction curve is as follows:

[0007] Step S100: Obtain a calibration image obtained by capturing a calibration image of the lens to be calibrated. The calibration image includes multiple color blocks of different colors. The R, G, and B channel pixel values ​​of each color block are equal. The calibration image includes multiple pixel blocks corresponding to the color blocks.

[0008] Step S200: Calculate the color temperature coordinates of the calibration image in the color temperature coordinate system based on the R, G, and B channel pixel values ​​of the pixel blocks of the calibration image. The horizontal coordinate x of the color temperature coordinate is determined by the ratio of the R channel pixel value to the G channel pixel value, and the vertical coordinate y is determined by the ratio of the B channel pixel value to the G channel pixel value.

[0009] Step S300: Determine the mapping value of each pixel value in the G channel from 0 to 255 based on the G channel pixel values ​​of multiple pixel blocks of the calibration image to obtain the nonlinear correction curve of the G channel; determine the mapping value of each pixel value in the R channel and B channel from 0 to 255 based on the color temperature coordinates and the R channel and B channel pixel values ​​of multiple pixel blocks of the calibration image to obtain the nonlinear correction curves of the R channel and B channel respectively. The nonlinear correction curves of the R, G, and B channels are used to perform nonlinear correction before white balance correction on the target image obtained by the lens to be corrected.

[0010] Preferably, step S100 includes: acquiring the original RAW data obtained by the lens to be calibrated capturing the calibration image; performing black level correction processing on the original RAW data to obtain calibrated RAW data; and processing the calibrated RAW data to obtain the calibration image.

[0011] Preferably, the calibration image includes t color blocks, where t is a positive integer and t≥2. Step S300 includes: obtaining the R, G, and B channel pixel values ​​of k pixel blocks from the calibration image, wherein k is configured such that all pixel values ​​in the same channel of the obtained R, G, and B channel pixel values ​​of all pixel blocks are different, and k is a positive integer and k≤t; determining the mapping value of the G channel pixel value of each pixel block in the k pixel blocks as the G channel pixel value of the color block corresponding to that pixel block in the calibration image, and the mapping value of the R channel pixel value of each pixel block as the calibration value of the color block in the calibration image. The product of the R-channel pixel value of the color block corresponding to the pixel block in the calibration image and the horizontal coordinate x is used. The mapping value of the B-channel pixel value of each pixel block is the product of the B-channel pixel value of the color block corresponding to the pixel block in the calibration image and the vertical coordinate y. Among the k pixel blocks, the minimum value of the G-channel pixel value is g1, and the maximum value is g2; the minimum value of the R-channel pixel value is r1, and the maximum value is r2; the minimum value of the B-channel pixel value is b1, and the maximum value is b2. Furthermore, g1, g2, r1, r2, b1, and b2 are all natural numbers. If g1 is greater than 0... If g2 is less than 255, then the mapping value of the G channel pixel values ​​from 0 to (g1-1) is determined to be 0; if g2 is less than 255, then the mapping value of the G channel pixel values ​​from (g2+1) to 255 is determined to be 255; if the G channel pixel values ​​of the k pixel blocks are not continuous, then the mapping value of the G channel pixel values ​​between g1 and g2 that have not been determined is determined by the first interpolation formula; if r1 is greater than 0, then the mapping value of the R channel pixel values ​​from 0 to (r1-1) is determined to be 0; if r2 is less than 255, then the mapping value of the R channel pixel values ​​from (r2+1) to 255 is determined to be 255 and the horizontal... The product of coordinates x; if the R-channel pixel values ​​of the k pixel blocks are not continuous, the mapping value of the R-channel pixel values ​​between r1 and r2 that have not been mapped is determined by the second interpolation formula; if b1 is greater than 0, the mapping value of the R-channel pixel values ​​from 0 to (b1-1) is determined to be 0; if b2 is less than 255, the mapping value of the B-channel pixel values ​​from (b2+1) to 255 is determined to be the product of 255 and the vertical coordinate y; if the B-channel pixel values ​​of the k pixel blocks are not continuous, the mapping value of the B-channel pixel values ​​between b1 and b2 that have not been mapped is determined by the third interpolation formula.

[0012] Preferably, the first interpolation formula is: y G =y0+(x G -x0)*(y1-y0) / (x1-x0), where x G Let x0 and x1 be the G-channel pixel values ​​to be mapped, respectively, and let x0 and x1 be the G-channel pixel values ​​in the k pixel blocks and x1, respectively. G The G-channel pixel value of the nearest pixel block, x0≤xG ≤x1, the y G The y0 and y1 are respectively the x G The mapping values ​​of x0 and x1.

[0013] Preferably, the second interpolation formula is: y R =x*x R Where x is the x-coordinate, x R The y channel pixel value is the mapping value to be determined. R For the x R The mapping value; the third interpolation formula is: y B =y*x B Where y is the ordinate y, and x is the coordinate x. B For the B-channel pixel value of the mapping value to be determined, the y B For the x B The mapping value.

[0014] Preferably, the calibration image includes at least 256 color blocks, the pixel values ​​of the 256 color blocks include all pixel values ​​from 0 to 255, and the obtained k pixel blocks include the pixel blocks corresponding to the color blocks with pixel values ​​of 0 and 255 in the calibration image, wherein k ≥ 2.

[0015] Preferably, before step S100, the method further includes: acquiring multiple color chart images, wherein each color chart image is obtained by photographing the same color chart under illumination by a corresponding color temperature light source through the lens to be calibrated; for each color chart image, determining at least two corresponding target color patches from the color chart image based on the positions of at least two target color patches on the color chart, wherein the difference between any two of the R channel pixel values, G channel pixel values, and B channel pixel values ​​of each target color patch is less than a preset value; calculating the color temperature difference of the at least two target color patches in each color chart image; if the color temperature difference between any two target color patches in each color chart image is greater than a preset color temperature difference threshold, then determining that the nonlinearity of the lens to be calibrated does not meet the requirements, and executing step S100.

[0016] The technical solution used for image color correction in this invention is as follows:

[0017] Step S400: Acquire the target image captured by the target lens;

[0018] Step S500: The target image is nonlinearly corrected using the R, G, and B three-channel nonlinear correction curves corresponding to the target lens, wherein the R, G, and B three-channel nonlinear correction curves are generated by the method described above for generating image correction curves.

[0019] Step S600: Perform white balance correction on the target image after nonlinear correction.

[0020] Preferably, step S600 includes:

[0021] Step S601: Obtain the R, G, and B channel pixel values ​​of the current pixel in the nonlinearly corrected target image, and calculate the color temperature coordinates of the current pixel, wherein the x-coordinate of the color temperature coordinates of the current pixel is... P The ratio of the R channel pixel value to the G channel pixel value of this pixel is represented by the y-axis. P This is the ratio of the B channel pixel value to the G channel pixel value of that pixel.

[0022] Step S602: Determine the minimum distance between the color temperature coordinates of the current pixel and the z color temperature coordinates in the preset color temperature curve, where z is a positive integer;

[0023] Step S603: If the minimum distance is less than a preset distance threshold, then the first initial value is compared with the x-coordinate of the color temperature coordinate of the current pixel. P Add them together to obtain a first sum, and then add the second initial value to the y-coordinate of the color temperature coordinate of the current pixel. P Add the first initial value to obtain the second sum, and add the third initial value to 1 to obtain the third sum, wherein the first initial value, the second initial value, and the third initial value are all 0;

[0024] Step S604: Take the first sum, the second sum, and the third sum as the first initial value, the second initial value, and the third initial value, respectively, and repeat steps S601 to S603 until all pixels of the nonlinearly corrected target image are traversed.

[0025] Step S605: Calculate the R-channel gain and B-channel gain of the nonlinearly corrected target image, wherein the R-channel gain is the ratio of the last obtained third sum to the last obtained first sum, and the B-channel gain is the ratio of the last obtained third sum to the last obtained second sum.

[0026] Step S606: Multiply the R and G channel pixel values ​​of each pixel in the nonlinearly corrected target image by the R channel gain and the B channel gain, respectively.

[0027] The present invention also provides a curve generation apparatus for image correction, the apparatus comprising:

[0028] The first acquisition module is used to acquire a calibration image obtained by capturing a calibration image of the lens to be calibrated. The calibration image includes multiple color blocks of different colors, and the R, G, and B channel pixel values ​​of each color block are equal. The calibration image includes multiple pixel blocks corresponding to the color blocks.

[0029] The calculation module is used to calculate the color temperature coordinates of the calibration image in the color temperature coordinate system based on the R, G, and B channel pixel values ​​of the pixel blocks of the calibration image. The horizontal coordinate x of the color temperature coordinate is determined by the ratio of the R channel pixel value to the G channel pixel value, and the vertical coordinate y is determined by the ratio of the B channel pixel value to the G channel pixel value.

[0030] The determining module is used to determine the mapping value of each pixel value in the G channel from 0 to 255 based on the G channel pixel values ​​of multiple pixel blocks of the calibration image, so as to obtain the non-linear correction curve of the G channel; based on the color temperature coordinates and the R channel pixel values ​​and B channel pixel values ​​of multiple pixel blocks of the calibration image, the module determines the mapping value of each pixel value in the R channel and B channel from 0 to 255 respectively, so as to obtain the non-linear correction curves of the R channel and B channel respectively. The non-linear correction curves of the R, G, and B channels are used to perform non-linear correction before white balance correction is performed on the target image obtained by the lens to be corrected.

[0031] The present invention also provides an image color correction device, the device comprising:

[0032] The second acquisition module is used to acquire the target image captured by the target lens;

[0033] The first correction module is used to perform nonlinear correction on the target image using the R, G, and B three-channel nonlinear correction curves corresponding to the target lens, wherein the R, G, and B three-channel nonlinear correction curves are generated by the method described above for generating image correction curves.

[0034] The second correction module is used to perform white balance correction on the target image after nonlinear correction.

[0035] The present invention also provides an electronic device, including a processor and a memory:

[0036] The memory stores executable instructions;

[0037] The processor is used to execute the executable instructions to implement the related operations of the above-described method for generating an image correction curve; or, the electronic device further includes a lens for capturing a target image, and the processor is used to execute the executable instructions to implement the related operations of the above-described image color correction method.

[0038] The present invention also provides a computer-readable storage medium storing executable instructions that cause an electronic device to perform operations corresponding to the above-described method for generating image correction curves and / or image color correction methods.

[0039] The present invention also provides a chip suitable for electronic devices, wherein the chip stores an instruction set, which, when executed, implements operations corresponding to the above-described method for generating image correction curves and / or image color correction methods.

[0040] In this embodiment of the invention, after obtaining a calibration image by capturing a calibration image through the lens to be calibrated, the color temperature coordinates are determined based on the calibration image. Then, the R, G, and B three-channel nonlinear correction curves are determined using the color temperature coordinates and the pixel blocks of the calibration image. Since the R, G, and B three-channel nonlinear correction curves are determined based on the calibration image obtained by capturing the calibration image through the lens to be calibrated, meaning the determined R, G, and B three-channel nonlinear correction curves are compatible with the lens to be calibrated, when performing nonlinear correction on the target image captured by the lens to be calibrated using the determined R, G, and B three-channel nonlinear correction curves, the obtained nonlinearly corrected image is linear in brightness. Therefore, when performing white balance processing on the nonlinearly corrected image, the influence of color cast caused by errors in white balance calibration can be reduced, i.e., the error generated during white balance color correction is reduced, thereby improving the accuracy of color correction of the target image captured by the lens to be calibrated, and ensuring that the color of the obtained color-corrected image is closer to the true color of the object.

[0041] Other beneficial effects of the present invention will be explained in detail through the introduction of specific technical features and technical solutions in specific embodiments. Those skilled in the art should be able to understand the beneficial technical effects brought about by these technical features and technical solutions through the introduction of these technical features and technical solutions. Attached Figure Description

[0042] Preferred embodiments of the curve generation method for image correction, the image color correction method, and the electronic device of the present invention will now be described with reference to the accompanying drawings. In the drawings:

[0043] Figure 1 This is a flowchart illustrating a curve generation method for image correction according to a preferred embodiment of the present invention.

[0044] Figure 2 for Figure 1 A flowchart illustrating the sub-steps of step S100;

[0045] Figure 3 for Figure 1 A flowchart illustrating the sub-steps of step S300;

[0046] Figure 4 The above are schematic diagrams of the calibration image and calibration picture provided by the present invention, wherein Figure (a) is a schematic diagram of the calibration image and Figure (b) is a schematic diagram of the calibration picture;

[0047] Figure 5 This is a flowchart illustrating a curve generation method for image correction according to another preferred embodiment of the present invention.

[0048] Figure 6 This is a flowchart illustrating an image color correction method according to a preferred embodiment of the present invention;

[0049] Figure 7 for Figure 6 A flowchart illustrating the sub-steps of step S600;

[0050] Figure 8 This is a schematic diagram of a curve generation apparatus for image correction according to a preferred embodiment of the present invention.

[0051] Figure 9 This is a schematic diagram of an image color correction device according to a preferred embodiment of the present invention;

[0052] Figure 10 This is a schematic diagram of an electronic device according to a preferred embodiment of the present invention. Detailed Implementation

[0053] The present invention is described below based on embodiments, but the present invention is not limited to these embodiments. In the following detailed description of the present invention, some specific details are described in detail, but well-known methods, processes, procedures, and elements are not described in detail in order to avoid obscuring the essence of the present invention.

[0054] Furthermore, those skilled in the art should understand that the accompanying drawings provided herein are for illustrative purposes only and are not necessarily drawn to scale.

[0055] Unless the context explicitly requires it, the words "comprising," "including," and similar terms throughout the specification and claims should be interpreted as encompassing rather than being exclusive or exhaustive; that is, meaning "including but not limited to."

[0056] In the description of this invention, it should be understood that the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. Furthermore, in the description of this invention, unless otherwise stated, "a plurality of" means two or more.

[0057] Color features are the most widely used visual features in image retrieval, primarily because color is often closely related to the physical elements or scene depicted in an image. In images generated by cameras, surveillance cameras, and other devices used in our daily lives, colors change depending on the time of day and lighting. Furthermore, with the rapid development of the modular lens market, users have increasingly higher demands for lens quality parameters. While the lens is a core component of a camera, the quality of modular lenses produced by different manufacturers varies significantly, resulting in substantial material dispersion. In optical imaging systems, sensor manufacturing processes, correction coefficient errors, grayscale errors, or other issues can cause chromatic aberration in the captured images and non-linearity in brightness. This leads to errors in white balance calibration, resulting in significant color correction errors and color casts. Therefore, color correction is necessary to ensure that imaging devices accurately reflect the true colors of objects.

[0058] Traditional color correction can be broadly categorized into two types: device-based color correction and image-based color correction. Device-based color correction involves automatically detecting the ambient color temperature using a third-party color temperature detector and then applying this value for color correction. However, this method increases the cost of the third-party detector and complicates the image acquisition system. Image-based color correction uses more complex white balance algorithms for color correction. However, this method requires complex algorithms, leading to high computational demands, demanding high-performance equipment, and potentially slowing down device operation. Furthermore, this method can only address color cast issues, not completely eliminate them.

[0059] Based on the above considerations, the inventors of this application, after in-depth research, propose a curve generation method and an image color correction method for image correction. By generating an image correction curve corresponding to the module lens, and then using this image correction curve to perform mapping processing on the image captured by the module lens, nonlinear correction is achieved, ensuring that the brightness of the nonlinearly corrected image is linear. Finally, white balance correction completes the image color correction. Nonlinear image correction can be achieved by mapping the image using a defined image correction curve, eliminating the need for third-party equipment and thus avoiding additional costs. Furthermore, the simple mapping process ensures that the nonlinear image correction does not reduce the device's operating speed or increase performance requirements.

[0060] Figure 1This diagram illustrates a flowchart of a curve generation method for image correction provided by an embodiment of the present invention. The method is executed by a computing device, which may be a computing device including one or more processors. The processor may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention; no limitation is made herein. The one or more processors included in the computing 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; no limitation is made herein. Figure 1 As shown, the method includes the following steps:

[0061] Step S100: Obtain a calibration image from the calibration image captured by the lens to be calibrated. The calibration image includes multiple color blocks of different colors, and the R, G, and B channel pixel values ​​of each color block are equal. The calibration image includes multiple pixel blocks corresponding to the color blocks.

[0062] The lens to be corrected can be a module lens whose nonlinearity does not meet the requirements. The RGB color model is an industry color standard that uses variations in the red (R), green (G), and blue (B) color channels and their superposition to obtain a wide variety of colors. RGB represents the colors of the red, green, and blue channels. This standard encompasses almost all colors perceptible to human vision and is one of the most widely used color systems. In other words, different RGB values ​​can represent different colors.

[0063] In this step, the calibration image includes at least two distinct RGB color blocks. That is, the calibration image contains at least two different color blocks. A color block refers to a small area within the calibration image displaying a certain color. Each color block contains only one color, and the color of each color block is represented by its corresponding RGB values. Furthermore, the R-channel pixel values, G-channel pixel values, and B-channel pixel values ​​of each color block are all equal. Since white balance correction is performed on gray blocks with equal R-channel, G-channel, and B-channel pixel values, in this step, the color blocks are gray blocks with equal R, G, and B channel pixel values.

[0064] It should be noted that when capturing the calibration image using the lens to be calibrated, it is preferable to shoot under a single light source or a standard light source. Since lenses typically produce lens shading, resulting in lower brightness at the corners than in the center of the image, it is preferable to place the calibration image in the center to avoid this problem. Simultaneously, the ambient brightness should be moderate so that when the RGB pixel values ​​of the color blocks are all 255, the RGB pixel values ​​of the captured pixel blocks are equal to or closer to 255. The captured calibration image is the same size as the calibration image or scaled up / enlarged proportionally, and includes all content of the calibration image. In the captured calibration image, the color blocks corresponding to the calibration image are called pixel blocks. For example, if region A of the calibration image includes a first color block and region B includes a second color block, then region A of the captured calibration image includes the first pixel block, and region B includes the second pixel block. The RGB pixel values ​​of a pixel block are the same as or different from the RGB pixel values ​​of its corresponding color block. If the obtained RGB pixel values ​​of a pixel block are different from the RGB pixel values ​​of its corresponding color block, it indicates that the lens has a certain degree of nonlinearity, which means that nonlinearity correction is required.

[0065] Step S200: Calculate the color temperature coordinates of the calibration image in the color temperature coordinate system based on the R, G, and B channel pixel values ​​of the pixel blocks of the calibration image. The horizontal coordinate x is determined by the ratio of the R channel pixel value to the G channel pixel value, and the vertical coordinate y is determined by the ratio of the B channel pixel value to the G channel pixel value.

[0066] In this step, the nonlinear correction curve can be determined based on the color temperature of the calibration image captured in step S100. Specifically, one or more pixel blocks can be selected from the calibration image. After determining the RGB pixel values ​​of each pixel block, the average values ​​of the R-channel, G-channel, and B-channel pixel values ​​of the selected pixel blocks are calculated. Then, the ratio of the average R-channel pixel value to the average G-channel pixel value is calculated to obtain the x-coordinate of the color temperature coordinate of the calibration image. Finally, the ratio of the average B-channel pixel value to the average G-channel pixel value is calculated to obtain the y-coordinate of the color temperature coordinate of the calibration image. Alternatively, you can first calculate the ratio of the R channel pixel value to the G channel pixel value for each pixel block to obtain the x-coordinate of the color temperature coordinate of that pixel block, and then calculate the ratio of the B channel pixel value to the G channel pixel value to obtain the y-coordinate of the color temperature coordinate of that pixel block. Finally, calculate the average of the x-coordinates of the color temperature coordinates of the selected pixel blocks to obtain the x-coordinate of the color temperature coordinate of the calibrated image, and then calculate the average of the y-coordinates of the color temperature coordinates of the selected pixel blocks to obtain the y-coordinate of the color temperature coordinate of the calibrated image.

[0067] Images are typically composed of multiple pixels; that is, each pixel block of a calibrated image contains multiple pixels. In some embodiments, to improve the accuracy of the determined color temperature coordinates of the calibrated image, when determining the R, G, and B channel pixel values ​​of each pixel block, the R, G, and B channel pixel values ​​of one or more pixels in the middle region of the pixel block are first obtained, and the average value of the obtained R, G, and B channel pixel values ​​is calculated for each pixel. The average value of the R, G, and B channel pixel values ​​is then used to determine the R, G, and B channel pixel values ​​of the pixel block. Since when capturing images with a lens, Bayer format image data is usually obtained first, and then RGB format image data is obtained using an interpolation algorithm, by selecting one or more pixels in the middle region of a pixel block and determining the average value of the RGB pixel values ​​of the selected pixels as the RGB pixel values ​​of the pixel block, the interpolation error that exists when interpolating Bayer format data to RGB image data between pixel blocks can be eliminated, thereby improving the accuracy of the obtained RGB pixel values ​​of the pixel block.

[0068] It should be noted that since pixel values ​​are natural numbers and range from 0 to 255, when calculating the pixel values ​​of each pixel block, the calculation results can be rounded to obtain integer pixel values ​​using rounding or other methods, and the obtained pixel values ​​must satisfy the range of 0 to 255.

[0069] In some embodiments, in order to further improve the accuracy of the determined color temperature coordinates of the calibration image, some pixel blocks with moderate brightness are usually selected to determine the color temperature coordinates, that is, the pixel blocks corresponding to the color blocks with RGB pixel values ​​around 128 are selected.

[0070] Step S300: Determine the mapping value of each pixel value in the G channel from 0 to 255 based on the G channel pixel values ​​of multiple pixel blocks in the calibration image to obtain the non-linear correction curve of the G channel; determine the mapping value of each pixel value in the R channel and B channel from 0 to 255 based on the color temperature coordinates and the R channel and B channel pixel values ​​of multiple pixel blocks in the calibration image to obtain the non-linear correction curves of the R channel and B channel respectively. The non-linear correction curves of the R, G, and B channels are used to perform non-linear correction before white balance correction of the target image obtained by the lens to be calibrated.

[0071] In this step, for the multiple pixel blocks selected, each pixel block has its own R, G, and B channel pixel values. The mapping value of the R channel pixel value of each pixel block is positively correlated with the coordinate value related to the R channel in the color temperature coordinates, and is also positively correlated with the R channel pixel value of the color block corresponding to that pixel block. The B channel is similar to the R channel, and will not be described in detail here. Since this embodiment requires determining the mapping value of each pixel value from 0 to 255 in the R channel, if the number of pixel blocks selected in this step is less than 256, or if the mapping value of the R channel pixel value of each pixel block in the selected pixel blocks is determined in the above manner, there are still one or more R channel pixel values ​​whose mapping values ​​are not determined. For example, if the mapping value of each pixel value from 3 to 253 has been determined based on the selected pixel blocks, then it is necessary to continue to determine the mapping values ​​corresponding to R channel pixel values ​​of 0, 1, 2, 254 and 255 respectively, and these R channel pixel values ​​are called the R channel pixel values ​​to be determined. The mapping value of each R channel pixel value to be determined is positively correlated with the coordinate value related to the R channel in the color temperature coordinates, and is also positively correlated with the R channel pixel value to be determined. The B channel is similar to the R channel, and will not be described in detail here. For example, the gains of the R channel and the B channel can be determined based on the color temperature coordinates determined in step S200, and then the mapping values ​​of the R channel pixel values ​​and the B channel pixel values ​​can be determined based on the determined R channel gains and B channel gains, so as to obtain the nonlinear correction curves of the R channel and the B channel.

[0072] Since the pixel values ​​of the R, G, and B channels range from 0 to 255, this step requires determining the mapping value corresponding to each pixel value in the R, G, and B channels from 0 to 255 to obtain the nonlinear correction curve for each channel. The nonlinear correction curves of the R, G, and B channels are used to perform nonlinear correction on the target image captured by the lens to be corrected. This can be achieved by mapping the pixel values ​​of each pixel in the target image according to the nonlinear correction curves. For example, if the mapping value corresponding to an R channel pixel value of 16 in the R channel nonlinear correction curve is 14, then the R channel pixel value of the pixel with an R channel pixel value of 16 in the target image will be corrected to 14.

[0073] It should be noted that the R, G, and B three-channel nonlinear correction curves obtained in this embodiment of the invention are only used to perform nonlinear correction on the target image captured by the lens to be corrected in step S100, so that the nonlinearly corrected target image is linear. Therefore, even if the R, G, and B three-channel nonlinear correction curves determined in this embodiment of the invention are determined based on the color temperature when the calibration image is captured in step S100, the R, G, and B three-channel nonlinear correction curves determined in this embodiment of the invention are also applicable to performing nonlinear correction on the target image captured by the lens to be corrected at different color temperatures, so that the corrected target image is linear.

[0074] In this embodiment of the invention, after obtaining a calibration image by capturing a calibration image through the lens to be calibrated, the color temperature coordinates are determined based on the calibration image. Then, the R, G, and B three-channel nonlinear correction curves are determined using the color temperature coordinates and the pixel blocks of the calibration image. Since the R, G, and B three-channel nonlinear correction curves are determined based on the calibration image obtained by capturing the calibration image through the lens to be calibrated, meaning the determined R, G, and B three-channel nonlinear correction curves are compatible with the lens to be calibrated, when performing nonlinear correction on the target image captured by the lens to be calibrated using the determined R, G, and B three-channel nonlinear correction curves, the obtained nonlinearly corrected image is linear in brightness. Therefore, when performing white balance processing on the nonlinearly corrected image, the influence of color cast caused by errors in white balance calibration can be reduced, i.e., the error generated during white balance color correction is reduced, thereby improving the accuracy of color correction of the target image captured by the lens to be calibrated, and ensuring that the color of the obtained color-corrected image is closer to the true color of the object.

[0075] Furthermore, when performing correction using the R, G, and B three-channel nonlinear correction curves provided in this embodiment of the invention, the pixel values ​​of each pixel in the target image are simply mapped according to the nonlinear correction curves. That is, the nonlinear correction is completed by correcting the pixel values ​​of each pixel to their corresponding mapped values. Compared with correction methods that require complex calculations or processing to complete nonlinear correction, nonlinear correction can be completed quickly and easily using the R, G, and B three-channel nonlinear correction curves provided in this invention, thereby improving the efficiency of correction.

[0076] To improve the accuracy of the determined R, G, and B three-channel nonlinear correction curves, this embodiment of the invention provides a method for obtaining calibration images. Figure 2 It shows Figure 1 The flowchart of the sub-steps in step S100 is as follows: Figure 2 As shown, step S100 obtains a calibration image from the calibration image captured by the lens to be calibrated, including:

[0077] Step S101: Obtain the raw RAW data from the calibration image captured by the lens to be calibrated.

[0078] Typically, when taking a photo, the camera captures a Bayer image of the target object through its lens. This Bayer image undergoes analog-to-digital conversion (ADC) to obtain a digital image signal (RAW data). After a series of processing steps, the RAW data is finally used to generate the image of the target object. The raw RAW data refers to the original image data, specifically the Bayer image data corresponding to the calibrated image, or Bayer format RAW data obtained after analog-to-digital conversion of the Bayer image data.

[0079] Step S102: Perform black level correction on the original RAW data to obtain the corrected RAW data.

[0080] When capturing calibration images, the image data acquired by the sensor often fails to convert very small voltage values ​​due to insufficient accuracy during analog-to-digital (ADC) conversion. Therefore, a fixed offset is added before ADC to ensure the lowest input level is not zero, allowing for successful ADC conversion. For example, a fixed offset of 5 is typically set, resulting in pixel values ​​ranging from 5 to 255. To obtain more accurate calibration images, this step performs black level correction on the raw RAW data, restoring the pixel value range of the raw RAW data obtained in step S101 to the standard pixel value range, i.e., 0 to 255.

[0081] Step S103: Process the corrected RAW data to obtain the calibration image.

[0082] The process of processing the corrected RAW data can include interpolation or other methods to obtain a calibration image.

[0083] In this embodiment of the invention, for lenses with a fixed offset, black level correction is performed on the raw RAW data obtained from the lens to make the pixel value range of the obtained image pixels 0 to 255, that is, within the standard range. Therefore, when determining the calibration image based on the corrected RAW data, the accuracy of the obtained calibration image can be improved, thereby improving the accuracy of the obtained R, G, and B three-channel nonlinear correction curves.

[0084] To improve the accuracy of the determined nonlinear correction curves for the R, G, and B channels, this embodiment of the invention provides a method for determining the mapping value of each pixel value in the range of 0 to 255 for the R, G, and B channels, wherein the calibration image includes t color blocks, where t is a positive integer greater than 1. Figure 3It shows Figure 1 The flowchart of the sub-steps in step S300 is as follows: Figure 3 As shown, step S300 determines the mapping value of each pixel value in the G channel from 0 to 255 based on the G channel pixel values ​​of multiple pixel blocks in the calibration image, to obtain the non-linear correction curve of the G channel; based on the color temperature coordinates and the R channel and B channel pixel values ​​of multiple pixel blocks in the calibration image, the mapping values ​​of each pixel value in the R channel and B channel from 0 to 255 are determined respectively, to obtain the non-linear correction curves of the R channel and B channel respectively, including:

[0085] Step S301: Obtain the R, G, and B channel pixel values ​​of k pixel blocks from the calibration image, where k is configured to ensure that all pixel values ​​in the same channel of the obtained R, G, and B channel pixel values ​​of all pixel blocks are different, k is a positive integer, and k≤t.

[0086] Specifically, in all the pixel blocks acquired, the R, G, and B channel pixel values ​​are all different. In particular, in the acquired k pixel blocks, each pixel block has corresponding R channel pixel values, G channel pixel values, and B channel pixel values, and the k R channel pixel values ​​are all different from each other, the k G channel pixel values ​​are all different from each other, and the k B channel pixel values ​​are all different from each other.

[0087] Step S302: Determine the mapping value of the G channel pixel value of each pixel block in the k pixel blocks as the G channel pixel value of the color block corresponding to that pixel block in the calibration image, the mapping value of the R channel pixel value of each pixel block as the product of the R channel pixel value of the color block corresponding to that pixel block in the calibration image and the horizontal coordinate x, and the mapping value of the B channel pixel value of each pixel block as the product of the B channel pixel value of the color block corresponding to that pixel block in the calibration image and the vertical coordinate y. Among these, the minimum value of the G channel pixel value in the k pixel blocks is g1, the maximum value is g2, the minimum value of the R channel pixel value is r1, the maximum value is r2, the minimum value of the B channel pixel value is b1, and the maximum value is b2, and g1, g2, r1, r2, b1, and b2 are all natural numbers.

[0088] To better illustrate how to determine the mapping values ​​of the R, G, and B channels for each pixel block in k pixel blocks, Figure 4 A schematic diagram of the calibration image and calibration picture is shown. (For example...) Figure 4 As shown, Figure 4 Image (a) is a schematic diagram of the calibration image, which includes a1 to a2. 16 There are 16 color blocks in total, from a1 to a 16 The R, G, and B channel pixel values ​​of the color block increase sequentially, and in this case, t is 16. Correspondingly, Figure 4 (b) is a schematic diagram of the calibration image, which includes color blocks a1 to a2.16 One-to-one correspondence of b1~b 16 There are a total of 16 pixel blocks, among which the pixel blocks with a gray background are the pixel blocks selected from the calibration image in step S301, namely: b2, b5, b7, b9, b 13 b 15 At this point, k is 6. In the diagram, "b2→a2" means that the mapping value of the G channel pixel value of pixel block b2 is determined as the G channel pixel value of color block a2, the mapping value of the R channel pixel value of pixel block b2 is determined as the product of the R channel pixel value of color block a2 and the x-coordinate of the color temperature coordinate determined in step S200, and the mapping value of the B channel pixel value of pixel block b2 is determined as the product of the B channel pixel value of color block a2 and the y-coordinate of the color temperature coordinate determined in step S200. For example, if the pixel values ​​of the R, G, and B channels of color block a2 are all 6, and the pixel values ​​of the R channel, G channel, and B channels of pixel block b2 are 2, 5, and 3 respectively, then the mapping value of the R channel pixel value of 2 is determined to be 6 multiplied by the x-coordinate of the color temperature coordinate determined in step S200, the mapping value of the G channel pixel value of 5 is determined to be 6, and the mapping value of the B channel pixel value of 3 is determined to be 6 multiplied by the y-coordinate of the color temperature coordinate determined in step S200. Pixel blocks b5, b7, b9, b 13 b 15 The method for determining the mapping values ​​of the pixel values ​​in the R, G, and B channels is similar to that for pixel block b2, and will not be repeated here.

[0089] Step S303: If g1 is greater than 0, then the mapping value of the G channel pixel values ​​from 0 to (g1-1) is determined to be 0; if g2 is less than 255, then the mapping value of the G channel pixel values ​​from (g2+1) to 255 is determined to be 255; if the G channel pixel values ​​of k pixel blocks are not continuous, then the mapping value of the G channel pixel values ​​between g1 and g2 that have not been determined is determined by the first interpolation formula.

[0090] If r1 is greater than 0, then the mapping value of the R channel pixel values ​​from 0 to (r1-1) is determined to be 0; if r2 is less than 255, then the mapping value of the R channel pixel values ​​from (r2+1) to 255 is determined to be the product of 255 and the x-coordinate; if the R channel pixel values ​​of k pixel blocks are not continuous, then the mapping value of the R channel pixel values ​​between r1 and r2 that have not been determined is determined by the second interpolation formula.

[0091] If b1 is greater than 0, then the mapping value of the B channel pixel values ​​from 0 to (b1-1) is determined to be 0; if b2 is less than 255, then the mapping value of the B channel pixel values ​​from (b2+1) to 255 is determined to be the product of 255 and the ordinate y; if the B channel pixel values ​​of k pixel blocks are not continuous, then the mapping value of the B channel pixel values ​​between b1 and b2 that have not been determined is determined by the third interpolation formula.

[0092] In step S301, if the minimum value g1 of the G channel pixel value among the selected k pixel blocks is greater than 0, then the mapping value of the G channel pixel values ​​from 0 to (g1-1) is determined to be 0. For example, if g1 is 3, then the mapping values ​​of G channel pixel values ​​of 0, 1, and 2 are all determined to be 0. If the minimum value r1 of the R channel pixel value is greater than 0 and the minimum value b1 of the B channel pixel value is greater than 0, then the method for determining the mapping value of the R channel pixel values ​​from 0 to (r1-1) and the method for determining the mapping value of the B channel pixel values ​​from 0 to (b1-1) are similar to those for the G channel, and will not be repeated here. Figure 4 As shown, if the R, G, and B channel pixel values ​​of color block a2 are all 3, the R, G, and B channel pixel values ​​of pixel block b2 are 4, 3, and 4 respectively, and all of them are the minimum pixel values ​​among the selected 6 pixel blocks, and the R, G, and B channel pixel values ​​of pixel block b1 are 1, 2, and 2 respectively, then "b1→0" means that the mapping value of the R channel pixel value of 1 is determined to be 0, the mapping value of the G channel pixel value of 2 is determined to be 0, and the mapping value of the B channel pixel value of 2 is determined to be 0.

[0093] If the maximum value g2 of the G channel pixel value among the k pixel blocks selected in step S301 is less than 255, then the mapping value of the G channel pixel values ​​from (g2+1) to 255 is determined to be 255. For example, if g2 is 253, then the mapping value of the G channel pixel values ​​254 and 255 is determined to be 255. If the maximum value r2 of the R channel pixel value is less than 255, then the mapping value of the R channel pixel values ​​from (r2+1) to 255 is determined to be the product of 255 and the x-coordinate of the color temperature coordinate determined in step S200. If the maximum value b2 of the B channel pixel value is less than 255, then the mapping value of the B channel pixel values ​​from (b2+1) to 255 is determined to be the product of 255 and the y-coordinate of the color temperature coordinate determined in step S200. Figure 4 As shown, if color block a 15 The R, G, and B channel pixel values ​​are all 254, and the pixel block b 15 The R, G, and B channel pixel values ​​are 251, 252, and 253 respectively, and all are the maximum pixel values ​​among the selected 6 pixel blocks. Pixel block b 16 The R channel pixel value is 200, the G channel pixel value is 254, and the B channel pixel value is 213. 16 →255” means that the mapping value of the G channel pixel value of 254 is determined as 255, the mapping value of the R channel pixel value of 200 is determined as the product of 255 and the x-coordinate of the color temperature coordinate determined in step S200, and the mapping value of the B channel pixel value of 213 is determined as the product of 255 and the y-coordinate of the color temperature coordinate determined in step S200.

[0094] If the G channel pixel values ​​of k pixel blocks are not continuous, the mapping values ​​of the undetermined G channel pixel values ​​between g1 and g2 are determined using the first interpolation formula. For example, if k is 4, and the G channel pixel values ​​of the four pixel blocks obtained in step S301 are 123, 125, 126, and 129 respectively, then the mapping values ​​of G channel pixel values ​​124, 127, and 128 are determined using the first interpolation formula. The R channel is similar to the B channel and will not be described further here. Figure 4 As shown, the selected 6 pixel blocks b2, b5, b7, b9, b 13 b 15 In this context, the R, G, and B channel pixel values ​​are discontinuous, and the pixel values ​​of these six pixel blocks are increasing. Therefore, "b3→interpolation" means that the mapping value of the G channel pixel value for pixel block b3 is determined by the first interpolation formula, the mapping value of the R channel pixel value is determined by the second interpolation formula, and the mapping value of the B channel pixel value is determined by the third interpolation formula. The mapping values ​​of pixel blocks b4, b6, b8, b... 10 b 11 b 12 b 14 Similar to pixel block b3, it will not be described in detail here.

[0095] If the nonlinearity of the lens does not meet the requirements, the RGB pixel values ​​of the images captured by it will change. For example, if the RGB pixel values ​​of a certain color block in the calibration image are all 128, the RGB pixel values ​​of the corresponding pixel block in the calibration image captured by the lens may be 126. That is, the RGB pixel values ​​of the obtained calibration image will deviate from the actual RGB pixel values. Therefore, in this embodiment of the invention, after selecting k pixel blocks, the mapping values ​​of the R, G, and B three-channel pixel values ​​are determined based on the deviation between the pixel values ​​of the selected k pixel blocks and the pixel values ​​of their corresponding color blocks, and the color temperature coordinates. This ensures that the determined mapping values ​​of the R, G, and B three-channel pixel values ​​are the same as or close to the pixel values ​​of their corresponding color blocks, that is, the determined mapping values ​​are the same as or close to their corresponding actual pixel values, so that pixel value correction is completed when using the nonlinear correction curve for mapping processing.

[0096] By using interpolation formulas to determine the mapping values ​​of pixels with undetermined mapping values ​​among the selected k RGB pixel values, the problem of a single pixel value having multiple mapping values ​​in the same channel is avoided, which would prevent the use of the determined nonlinear correction curve for correction. Furthermore, the mapping value of pixels less than the minimum value among the k RGB pixel values ​​is set to 0; the mapping value of pixels greater than the maximum value among the k G channel pixel values ​​is set to 255; the mapping value of pixels greater than the maximum value among the k R channel pixel values ​​is set to the product of 255 and the x-coordinate; and the mapping value of pixels greater than the maximum value among the k B channel pixel values ​​is set to the product of 255 and the y-coordinate. This improves the accuracy of the determined nonlinear correction curve.

[0097] Meanwhile, by configuring k so that the pixel values ​​of the same channel in the selected k pixel blocks are different from each other, the problem of a single pixel value having multiple mapping values ​​in the same channel can be avoided, thereby improving the accuracy of the determined nonlinear correction curve.

[0098] To improve the accuracy of the mapping value of the determined G channel pixel value, in this embodiment of the invention, the first interpolation formula is: y G =y0+(x G -x0)*(y1-y0) / (x1-x0), where x G Let x0 and x1 be the G-channel pixel values ​​to be mapped, respectively, and let x0 and x1 be the G-channel pixel values ​​and x1 values ​​in k pixel blocks. G The G-channel pixel value of the nearest pixel block, x0≤x G ≤x1, y G y0 and y1 are x G The mapping values ​​of x0 and x1.

[0099] Where k is 4, and the G channel pixel values ​​in the selected 4 pixel blocks are 123, 125, 126, and 129 respectively, then when determining the mapping value for a G channel pixel value of 124 using the first interpolation formula, x G x0 is 123, x1 is 125; when using the first interpolation formula to determine the mapping value of the G channel pixel value as 127, x G x0 is 126, x1 is 129; when using the first interpolation formula to determine the mapping value of the G channel pixel value as 128, x G x0 is 126, x1 is 129. For example... Figure 4 As shown, when using the first interpolation formula to determine the mapping value of the G channel pixel value of pixel block b3, x0 and x1 are the G channel pixel values ​​of pixel blocks b2 and b5, respectively.

[0100] In this embodiment of the invention, by using a first interpolation formula to determine the mapping value of the G channel pixel values ​​between g1 and g2 that have no determined mapping value, it is possible to avoid multiple different mapping values ​​for the same pixel value in the G channel. This ensures a one-to-one mapping when using the G channel nonlinear correction curve for correction, thereby improving the accuracy of nonlinear correction. It should be noted that when calculating the mapping value using the first interpolation formula, if the calculation result is a decimal, it can be rounded using rounding or other methods, ensuring that the determined mapping value falls within the range of 0 to 255.

[0101] To improve the accuracy of the mapping values ​​of the determined R and B channel pixel values, in this embodiment of the invention, the second interpolation formula is y. R =x*x R Where x is the x-coordinate, x... R Let y be the R channel pixel value to be mapped. R For x R The mapping value. The third interpolation formula is y. B =y*x B Where y is the ordinate and x is the coordinate. B Let y be the B-channel pixel value to be mapped. B For x B The mapping value.

[0102] Where x is the abscissa of the color temperature coordinate determined in step S200, and y is the ordinate of the color temperature coordinate determined in step S200.

[0103] In this embodiment of the invention, the second interpolation formula is positively correlated with the x-axis of the color temperature coordinate system, and the third interpolation formula is positively correlated with the y-axis of the color temperature coordinate system. Since the calibration image is captured under a specific light source, by setting both the second and third interpolation formulas to be correlated with the color temperature at which the calibration image was captured, the accuracy of the mapping values ​​determined by the second and third interpolation formulas can be improved. This means improving the accuracy of the mapping values ​​of the determined R and B channel pixel values, thereby improving the accuracy of the nonlinear correction curve. For example, if the R, G, and B pixel values ​​of a certain color block in the calibration image are all 100, and the R channel pixel value and B channel pixel value of the corresponding pixel block in the calibration image are both 50, by setting the gain of the second interpolation formula to the x-axis of the color temperature coordinate system, the mapping value corresponding to the R channel pixel value of 50 determined by the second interpolation formula can be 100, or close to 100, which is equal to or close to the true value of its pixel value, thereby improving the accuracy of the determined nonlinear correction curve. The B channel is similar and will not be described further here.

[0104] To further improve the accuracy of the determined R, G, and B three-channel nonlinear correction curves, in this embodiment of the invention, the calibration image includes at least 256 color blocks, the pixel values ​​of the 256 color blocks include all pixel values ​​from 0 to 255, and the obtained k pixel blocks include the pixel blocks corresponding to the color blocks with pixel values ​​of 0 and 255 in the calibration image, where k ≥ 2.

[0105] Since RGB pixel values ​​range from 0 to 255, in this embodiment of the invention, by setting the pixel values ​​of the pixel blocks in the calibration image to include all pixel values ​​from 0 to 255, when obtaining a calibration image by capturing the calibration image through the lens to be calibrated, the accuracy of the obtained nonlinear calibration curve can be improved by determining the mapping value based on the deviation between the pixel values ​​of the pixel blocks corresponding to each pixel value from 0 to 255 in the calibration image and the pixel values ​​of their corresponding color blocks. By obtaining pixel blocks corresponding to color blocks with pixel values ​​of 0 and 255, it is possible to avoid directly determining a large number of R, G, and B channel mapping values ​​as 0, and to avoid directly determining a large number of R channel mapping values ​​as the product of 255 and the x-coordinate of the color temperature coordinate, and to avoid directly determining a large number of B channel mapping values ​​as the product of 255 and the y-coordinate of the color temperature coordinate, thereby improving the accuracy of the R, G, and B channel nonlinear calibration curve.

[0106] It should be noted that, provided that k meets the value requirements, the larger k is, that is, the more pixel blocks are taken, the higher the accuracy of the final nonlinear correction curve, the better the effect of using the nonlinear curve to perform nonlinear correction on the image, and the closer the brightness of the nonlinearly corrected image is to the linear effect. Thus, after the nonlinearly corrected image is white-balanced, the color is closer to the actual color of the object.

[0107] When the calibration image includes at least 256 color blocks, the calibration image obtained at this time includes at least 256 pixel blocks. In step S301, k pixel blocks are selected, and the R, G, and B pixel values ​​of each pixel block in these k pixel blocks are calculated to determine the mapping value of each pixel value in the R, G, and B channels from 0 to 255. If more pixel blocks are selected, i.e., the larger k is, the greater the computational load when calculating the pixel values ​​of these k pixel blocks, thus the efficiency of determining the mapping value is low. Therefore, preferably, the calibration image includes one color block with each pixel value from 0 to 255, i.e., only 256 color blocks. The 256 color blocks in the calibration image are arranged in ascending order according to the size of the RGB pixel values, forming a row and column of 16. That is, the color block with an RGB pixel value of 0 is located in the first row and first column, and the color block with an RGB pixel value of 255 is located in the 16th row and 16th column. At this point, when selecting k pixel blocks from the calibration image, we can select the pixel block corresponding to the first color block in each row and the pixel block corresponding to the last color block in the last row of the calibration image, i.e., the first pixel block in each row and the last pixel block in the last row of the calibration image. In this case, k is 17. Selecting pixel blocks in this way to determine the nonlinear correction curve does not significantly affect the accuracy of the determined nonlinear correction curve. Because the number of selected pixel blocks is small, the computational load for calculating the pixel values ​​of each pixel block is also reduced, thus improving efficiency.

[0108] To determine whether the nonlinearity of a lens meets the requirements, embodiments of the present invention provide a method for detecting the nonlinearity of a lens. Figure 5 A flowchart of another curve generation method for image correction is shown, wherein, Figure 5 Is Figure 1 Based on the provided embodiment, steps a1 to a5 are added to detect the degree of nonlinearity of the lens to be corrected. For example... Figure 5 As shown, the method includes the following steps:

[0109] Step a1: Acquire multiple color chart images, wherein each color chart image is obtained by taking a picture of the same color chart under the illumination of a light source of the corresponding color temperature through a lens to be calibrated.

[0110] The color chart includes various color blocks of different colors, which may be, but are not limited to, a standard 24-color chart, a Pantone color chart, etc. Specifically, the color chart is illuminated using at least two different color temperature light sources, and then the color chart is photographed using the lens to be calibrated in step S100, thereby obtaining color chart images corresponding to each color temperature light source. It should be noted that there is a one-to-one correspondence between the color temperature light source and the color chart image.

[0111] Step a2: For each color chart image, based on the positions of at least two target color chart patches in the color chart, determine at least two corresponding target color patches from the color chart image, wherein the difference between any two of the R channel pixel values, G channel pixel values, and B channel pixel values ​​of each target color chart patch is less than a preset value.

[0112] When the R, G, and B channel pixel values ​​are all 255, the color of the patch is white. When the R, G, and B channel pixel values ​​are all equal and range from 1 to 254, the color of the patch is gray, with only a difference in brightness. If the nonlinearity of the lens to be corrected does not meet the requirements, the R, G, and B channel pixel values ​​of the pixels in the image it captures will deviate from the actual pixel values. This is because a lens with insufficient nonlinearity will affect the color temperature of the image it captures. Therefore, at least one white patch and at least one gray patch in the color chart image can be identified as target color chart patches to detect the nonlinearity of the lens to be corrected. Furthermore, since the target color block in the color chart image corresponding to the determined target color chart color block may be overexposed or underexposed, it can easily lead to errors in the detection of the nonlinearity of the lens to be calibrated. Therefore, by determining the color block that satisfies the difference between any two of the R-channel pixel value, G-channel pixel value and B-channel pixel value is less than a preset value as the target color chart color block, it can be ensured that even if there are no white or gray color blocks on the color chart in step a1, a target color chart color block that meets the requirements can still be selected, thereby enabling the nonlinearity detection of the lens to be calibrated.

[0113] Before photographing the color chart image, you can first determine the position of each target color block on the color chart. Then, the color block in the photographed color chart image that corresponds to that position can be identified as the target color block.

[0114] Step a3: Calculate the color temperature difference between at least two target color patches in each color chart image.

[0115] In this process, after identifying all target color blocks in each color chart image, the color temperature of each target color block is first detected. Then, for each color chart image, the color temperature difference between each pair of target color blocks is calculated, thereby obtaining one or more color temperature differences.

[0116] Step a4: Determine whether there exists at least one color chart image where the color temperature difference between any two target color blocks is greater than a preset color temperature difference threshold. If yes, proceed to step a5; otherwise, proceed to step a6.

[0117] Specifically, for each color temperature difference of each color card image, each color temperature difference is compared with a preset color temperature difference threshold, and it is determined whether there is at least one color temperature difference in at least one color card image that is greater than the preset color temperature difference threshold. If so, proceed to step a5; otherwise, proceed to step a6.

[0118] In this embodiment of the invention, if it is determined whether there is at least one color chart image where the color temperature difference between any two target color blocks is greater than a preset color temperature difference threshold, then proceed to step a5; otherwise, proceed to step a6. In some embodiments, it can also be determined whether there is at least one color chart image where the color temperature difference between any two target color blocks is less than or equal to a preset color temperature difference threshold; if so, proceed to step a6; otherwise, proceed to step a5.

[0119] Step a5: Determine that the nonlinearity of the lens to be corrected does not meet the requirements, and proceed to step S100.

[0120] If in step a4 it is determined that at least one color temperature difference in at least one color chart image is greater than the preset color temperature difference threshold, then it is determined that the nonlinearity of the lens to be corrected does not meet the requirements at the color temperature corresponding to the color chart image, and thus it can be determined that the nonlinearity of the lens to be corrected does not meet the requirements.

[0121] Step a6: Determine whether the nonlinearity of the lens to be corrected meets the requirements.

[0122] If, in all the color chart images obtained in step a1, the color temperature difference in each color chart image is less than or equal to the preset color temperature difference threshold, then the nonlinearity of the lens to be corrected is determined to meet the requirements.

[0123] In this embodiment of the invention, the nonlinearity of the lens to be calibrated is first detected under multiple light source environments to determine whether the nonlinearity of the lens to be calibrated meets the requirements. Step S100 is executed only when the nonlinearity of the lens to be calibrated does not meet the requirements, that is, a nonlinear correction curve is generated. Then, the nonlinear correction curve is used to perform nonlinear correction on the image captured by the lens, thus avoiding nonlinear correction on the image captured by the lens that meets the nonlinearity requirements, thereby reducing the power consumption of the electronic device including the lens to be calibrated.

[0124] Figure 6A flowchart illustrating an image color correction method provided in an embodiment of the present invention is shown. This method is executed by a computing device, which may include one or more processors. The processors may be a central processing unit (CPU), a specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention; no limitation is made herein. The one or more processors included in the computing 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; no limitation is made herein. The embodiments of the present invention are... Figure 1 Based on the provided embodiment, steps S400 to S600 are added, such as... Figure 6 As shown, the method includes the following steps:

[0125] Step S400: Acquire the target image captured by the lens to be calibrated.

[0126] The target image is obtained by photographing the target object in response to an operation that captures the target object. It should be noted that the lens to be calibrated in this step is the same lens as the lens to be calibrated in step S100.

[0127] Step S500: Perform nonlinear correction on the target image based on the nonlinear correction curves of the R, G, and B channels.

[0128] Specifically, based on the R-channel pixel values ​​of the R-channel nonlinear correction curve and their corresponding mapping values, the R-channel pixel values ​​of each pixel in the target image are mapped to complete the nonlinear correction. For example, if the R-channel pixel value is 5 and its corresponding mapping value is 6 in the R-channel nonlinear correction curve, then the pixel values ​​of all pixels in the target image with an R-channel pixel value of 5 are corrected to 6. The nonlinear correction methods for the G and B channels are similar to those for the R channel; the specific implementation methods can be found in the R-channel nonlinear correction method, and will not be elaborated here.

[0129] Step S600: Perform white balance correction on the target image after nonlinear correction.

[0130] Existing white balance correction methods can be used to perform white balance correction on the nonlinearly corrected target image, which will not be elaborated here.

[0131] In this embodiment of the invention, the target image captured by the lens to be calibrated is first nonlinearly calibrated using the R, G, and B three-channel nonlinear calibration curves to achieve linear brightness in the calibrated target image. Then, white balance correction is performed on the nonlinearly calibrated target image to complete color correction, making the color of the white-balanced target image closer to the actual color of the target object.

[0132] To improve the accuracy of color correction of target images, and to make the corrected colors closer to the true colors of the objects, embodiments of the present invention... Figure 6 Based on the provided embodiments, a white balance correction method for images is proposed. Figure 7 The flowchart of the sub-steps of step S600 is shown, as follows: Figure 7 As shown, step S600 performs white balance correction on the nonlinearly corrected target image, including:

[0133] Step S601: Obtain the R, G, and B channel pixel values ​​of the current pixel in the nonlinearly corrected target image, and calculate the color temperature coordinates of the current pixel, where the x-coordinate of the color temperature coordinates of the current pixel is x. P The ratio of the R channel pixel value to the G channel pixel value of this pixel is represented by the y-axis. P This is the ratio of the B channel pixel value to the G channel pixel value for that pixel.

[0134] Specifically, an unselected pixel is selected from the nonlinearly corrected target image as the current pixel, and the color temperature coordinates of this pixel are calculated. The method for calculating the color temperature coordinates can refer to the method for calculating the color temperature coordinates in step S200, and will not be repeated here.

[0135] Step S602: Determine the minimum distance between the color temperature coordinates of the current pixel and the z color temperature coordinates in the preset color temperature curve, where z is a positive integer.

[0136] The preset color temperature curve includes z color temperature coordinates. The distances between the current pixel's color temperature coordinates and each of the z color temperature coordinates are first calculated to obtain z distances. Finally, the minimum distance is determined from these z distances. It's worth noting that the current pixel refers to the pixel being processed, not necessarily the pixel obtained at the current moment.

[0137] The preset color temperature curve can be determined in the following way:

[0138] First, the test images are captured under z standard light sources using the lens to be calibrated in step S100 to obtain z test images. The test images can be a standard color chart or the calibration image from step S100. Each test image includes test pixel blocks corresponding to the test color blocks in the test images. Then, at least one test pixel block is selected from each test image, and the R, G, and B channel pixel values ​​of each selected test pixel block are obtained. Finally, the color temperature coordinates of each test image are calculated using the selected test pixel blocks, thus obtaining z color temperature coordinates.

[0139] Step S603a: Determine whether the minimum distance is less than a preset distance threshold. If yes, proceed to step S603b; otherwise, proceed to step S604a.

[0140] In this embodiment of the invention, if the minimum distance is less than a preset distance threshold, the process proceeds to step S603b; otherwise, it proceeds to step S604a. In some embodiments, the process can also proceed to step S603b if the minimum distance is greater than or equal to the preset distance threshold.

[0141] Step S603b: Combine the first initial value with the x-coordinate of the color temperature coordinate of the current pixel. P Add them together to obtain the first sum. Then, combine the second initial value with the y-coordinate of the color temperature coordinate of the current pixel. P Add the first, second, and third initial values ​​together to obtain the second sum. Add the third initial value to 1 to obtain the third sum. The first, second, and third initial values ​​are all 0.

[0142] The initial values ​​of the first, second, and third initial values ​​are all 0.

[0143] Step S604a: Determine whether to traverse all pixels of the nonlinearly corrected target image. If not, proceed to step S604b; if yes, proceed to step S605.

[0144] In step S601, it is determined whether all pixels of the target image have been selected. If there are still pixels that have not been selected, the process proceeds to step S604b; if all pixels have been selected, the process proceeds to step S605.

[0145] Step S604b: Use the first sum, the second sum, and the third sum as the first initial value, the second initial value, and the third initial value, respectively. Use the next pixel as the current pixel and proceed to step S601.

[0146] Specifically, the first sum, the second sum, and the third sum determined in step S603b are used as the first initial value, the second initial value, and the third initial value, respectively. An unselected pixel is selected as the current pixel, and the process jumps to step S601 and repeats.

[0147] It should be noted that after the execution of step S601 from this step, when the execution reaches step S603b, the first initial value, the second initial value, and the third initial value are determined in the previous step S604b, and are not the initial value 0.

[0148] Step S605: Calculate the R-channel gain and B-channel gain of the target image after nonlinear correction, where the R-channel gain is the ratio of the third sum obtained in the last time to the first sum obtained in the last time, and the B-channel gain is the ratio of the third sum obtained in the last time to the second sum obtained in the last time.

[0149] Among them, the last obtained first sum, the last obtained second sum, and the last obtained third sum refer to the first, second, and third sums finally obtained after traversing all the pixels of the target image.

[0150] Step S606: Multiply the R and G channel pixel values ​​of each pixel in the nonlinearly corrected target image by the R channel gain and the B channel gain, respectively.

[0151] Specifically, the R-channel pixel values ​​of each pixel in the nonlinearly corrected target image are multiplied by the R-channel gain determined in step S605; the B-channel pixel values ​​of each pixel in the nonlinearly corrected target image are multiplied by the B-channel gain determined in step S605, thereby completing the white balance correction.

[0152] In this embodiment of the invention, the color temperature coordinates of each pixel in the nonlinearly corrected target image are calculated, and the minimum distance between the color temperature coordinates of each pixel and the z color temperature coordinates in the preset color temperature curve is determined. Then, it is determined whether each minimum distance is less than a preset distance threshold. If the minimum distance is less than the preset distance threshold, the first initial value is compared with the x-coordinate of the color temperature coordinate of that pixel. P Add them together to obtain the first sum. Then, combine the second initial value with the y-coordinate of the color temperature coordinate of that pixel. P The first and second sums are added together to obtain the second sum. The third initial value is then added to 1 to obtain the third sum. The final third sum is the total number of pixels in the non-linearly corrected target image whose minimum distance from the z color temperature coordinates in the preset color temperature curve is less than a preset distance threshold. The ratio of the final third sum to the final first sum is determined as the R-channel gain, and the ratio of the final third sum to the final second sum is determined as the B-channel gain. Multiplying the R and G channel pixel values ​​of each pixel in the non-linearly corrected target image by the R-channel gain and B-channel gain respectively completes the white balance correction. By determining the R-channel and B-channel gains based on the color temperature coordinates of all pixels, the accuracy of the determined gains is improved, thereby improving the accuracy of white balance correction and making the color of the white balance corrected target image closer to the actual color of the target object.

[0153] Figure 8The diagram shows a schematic of a curve generation device for image correction provided in an embodiment of the present invention. The specific implementation of the curve generation device for image correction is not limited by the specific embodiments of the present invention.

[0154] like Figure 8 As shown, the curve generation device 700 for image correction may include a first acquisition module 701, a calculation module 702, and a determination module 703.

[0155] Wherein: the first acquisition module 701, the calculation module 702 and the determination module 703 are used to implement the relevant steps in the above embodiment of the curve generation method for image correction. For example, the first acquisition module 701 is used to implement step S100, the calculation module 702 is used to implement step S200, and the determination module 703 is used to implement step S300.

[0156] The curve generation apparatus 700 for image correction in this embodiment of the invention also includes other modules for performing the steps of the curve generation method for image correction described above, which will not be described in detail here.

[0157] In this embodiment of the invention, after the lens to be calibrated captures a calibration image to obtain a calibration picture, the first acquisition module 701 acquires the calibration picture, the calculation module 702 determines the color temperature coordinates based on the calibration picture, and then the determination module 703 uses the color temperature coordinates and the pixel blocks of the calibration picture to determine the R, G, and B three-channel nonlinear correction curves respectively. Since the R, G, and B three-channel nonlinear correction curves are determined based on the calibration picture obtained by the lens to be calibrated capturing the calibration image, that is, the determined R, G, and B three-channel nonlinear correction curves are adapted to the lens to be calibrated, when the determined R, G, and B three-channel nonlinear correction curves are used to perform nonlinear correction on the target image captured by the lens to be calibrated, the obtained nonlinearly corrected image is linear in brightness. Therefore, when performing white balance processing on the nonlinearly corrected image, the influence of color cast caused by the error generated during white balance calibration can be reduced, that is, the error generated during white balance color correction is reduced, thereby improving the accuracy of color correction of the target image captured by the lens to be calibrated, and making the color of the obtained color-corrected image closer to the true color of the object.

[0158] Figure 9 The diagram shows a schematic of the image color correction device provided in an embodiment of the present invention. The specific implementation of the image color correction device is not limited by the specific embodiments of the present invention.

[0159] like Figure 9 As shown, the image color correction device 800 may include a second acquisition module 801, a first correction module 802, and a second correction module 803.

[0160] Wherein: the second acquisition module 801, the first correction module 802 and the second correction module 803 are used to implement the relevant steps in the above-described image color correction method embodiment. For example, the second acquisition module 801 is used to implement step S400, the first correction module 802 is used to implement step S500, and the second correction module 803 is used to implement step S600.

[0161] The image color correction apparatus 800 of this embodiment of the invention also includes other modules for performing the steps of the above-described image color correction method embodiments, which will not be described in detail here.

[0162] In this embodiment of the invention, after the target image is acquired by the second acquisition module 801, the first correction module 802 performs nonlinear correction on the target image captured by the lens to be corrected using the R, G, and B three-channel nonlinear correction curves, so that the target image after nonlinear correction exhibits linearity in brightness. Then, the second correction module 803 performs white balance correction on the nonlinearly corrected target image, thereby completing color correction and making the color of the white-balance corrected target image closer to the actual color of the target object.

[0163] Figure 10 The diagram shows a structural schematic of an electronic device provided in an embodiment of the present invention. The specific embodiments of the present invention do not limit the specific implementation of the electronic device.

[0164] like Figure 10 As shown, the electronic device may include a processor 902 and a memory 904.

[0165] Wherein: processor 902 is used to execute program 906, specifically to execute the relevant steps in the above embodiment of the curve generation method for image correction.

[0166] Specifically, program 906 may include program code, which includes computer-executable instructions.

[0167] Processor 902 may be a central processing unit (CPU), a specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention. The electronic device includes one or more processors, which 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.

[0168] Memory 904 is used to store program 906. Memory 904 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.

[0169] In some embodiments, the electronic device further includes a lens for performing relevant steps in the image color correction method embodiment to capture a target image, and a processor for executing a program, specifically performing the relevant steps in the image color correction method embodiment described above.

[0170] Furthermore, the present invention also provides a computer-readable storage medium, such as a chip, an optical disc, etc., for a curve generation method and / or an image color correction method for image correction. The computer-readable storage medium stores an executable program, which, when executed, implements the curve generation method and / or image color correction method for image correction as described in any of the preceding claims.

[0171] The present invention also provides a chip, wherein the chip is suitable for electronic devices, and the chip stores an instruction set, which, when executed, implements the curve generation method and / or image color correction method for image correction as described in any of the preceding claims.

[0172] It should be noted that the computer-readable storage medium described in the embodiments of this disclosure is not limited to the embodiments given above. For example, it can also be an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In the embodiments of this disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0173] It will be understood by those skilled in the art that the above-described preferred solutions can be freely combined and superimposed without conflict. The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings; for example, two consecutively indicated blocks may actually be executed substantially in parallel, or sometimes in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions. The numbering of each step in this document is for ease of explanation and reference only and is not intended to limit the order of execution. The specific execution order is determined by the technology itself, and those skilled in the art can determine various permissible and reasonable orders based on the technology itself.

[0174] It should be noted that the use of step numbers (letters or numbers) to refer to certain specific method steps in this invention is merely for the purpose of convenience and brevity in description, and is by no means intended to restrict the order of these method steps. Those skilled in the art will understand that the order of the relevant method steps should be determined by the technology itself and should not be unduly restricted by the existence of step numbers. Those skilled in the art can determine various permissible and reasonable orderings of steps based on the technology itself.

[0175] Those skilled in the art will understand that, without conflict, the above-mentioned preferred solutions can be freely combined and superimposed.

[0176] It should be understood that the above embodiments are merely exemplary and not restrictive. Various obvious or equivalent modifications or substitutions that can be made by those skilled in the art regarding the above details without departing from the basic principles of the present invention will be included within the scope of the claims of the present invention.

Claims

1. A curve generation method for image correction, characterized in that, The method includes: Step S100: Obtain a calibration image obtained by capturing a calibration image of the lens to be calibrated. The calibration image includes multiple color blocks of different colors. The R, G, and B channel pixel values ​​of each color block are equal. The calibration image includes multiple pixel blocks corresponding to the color blocks. Step S200: Calculate the color temperature coordinates of the calibration image in the color temperature coordinate system based on the R, G, and B channel pixel values ​​of the pixel blocks in the calibration image. The horizontal coordinate x is determined by the ratio of the R channel pixel value to the G channel pixel value, and the vertical coordinate y is determined by the ratio of the B channel pixel value to the G channel pixel value. Specifically, step S200 includes: calculating the ratio of the R channel pixel value to the G channel pixel value for each pixel block to obtain the horizontal coordinate x of the color temperature coordinates of that pixel block; calculating the ratio of the B channel pixel value to the G channel pixel value to obtain the vertical coordinate y of the color temperature coordinates of that pixel block; finally, calculating the average value of the horizontal coordinate x of the selected pixel blocks to obtain the horizontal coordinate x of the color temperature coordinates of the calibration image; and calculating the average value of the vertical coordinate y of the selected pixel blocks to obtain the vertical coordinate y of the color temperature coordinates of the calibration image. Step S300: Determine the mapping value of each pixel value in the G channel from 0 to 255 based on the G channel pixel values ​​of multiple pixel blocks in the calibration image to obtain the nonlinear correction curve of the G channel; determine the mapping value of each pixel value in the R channel and B channel from 0 to 255 based on the color temperature coordinates and the R channel and B channel pixel values ​​of multiple pixel blocks in the calibration image to obtain the nonlinear correction curves of the R channel and B channel respectively. The R, G, and B three-channel nonlinear correction curves are used for nonlinear correction before white balance correction of the target image obtained by the lens to be calibrated; wherein the calibration image includes t color blocks, where t is a positive integer, t≥2, and step S300 includes... The following steps are performed:

1. Obtain the R, G, and B channel pixel values ​​of k pixel blocks from the calibration image. Here, k is configured such that all pixel values ​​in the same channel of the obtained R, G, and B channel pixel values ​​of all pixel blocks are distinct. k is a positive integer, k ≤ t.

2. Determine the mapping value of the G channel pixel value of each of the k pixel blocks to the G channel pixel value of the corresponding color block in the calibration image.

3. Determine the mapping value of the R channel pixel value of each pixel block to the product of the R channel pixel value of the corresponding color block in the calibration image and the horizontal coordinate x.

4. Determine the mapping value of the B channel pixel value of each pixel block to the product of the B channel pixel value of the corresponding color block in the calibration image and the vertical coordinate y.

2. The method according to claim 1, characterized in that, Step S100 includes: Obtain the raw RAW data of the calibration image captured by the lens to be calibrated; The original RAW data is subjected to black level correction to obtain corrected RAW data; The calibrated image is obtained by processing the corrected RAW data.

3. The method according to claim 1, characterized in that, In the k pixel blocks, the minimum value of the G channel pixel is g1 and the maximum value is g2, the minimum value of the R channel pixel is r1 and the maximum value is r2, and the minimum value of the B channel pixel is b1 and the maximum value is b2, and g1, g2, r1, r2, b1, and b2 are all natural numbers; If g1 is greater than 0, then the mapping value of the G channel pixel values ​​from 0 to (g1-1) is determined to be 0; if g2 is less than 255, then the mapping value of the G channel pixel values ​​from (g2+1) to 255 is determined to be 255; if the G channel pixel values ​​of the k pixel blocks are not continuous, then the mapping value of the G channel pixel values ​​between g1 and g2 that have not been determined is determined by the first interpolation formula. If r1 is greater than 0, then the mapping value of the R channel pixel values ​​from 0 to (r1-1) is determined to be 0; if r2 is less than 255, then the mapping value of the R channel pixel values ​​from (r2+1) to 255 is determined to be the product of 255 and the horizontal coordinate x; if the R channel pixel values ​​of the k pixel blocks are not continuous, then the mapping value of the R channel pixel values ​​between r1 and r2 that have not been determined is determined by the second interpolation formula. If b1 is greater than 0, then the mapping value of the R channel pixel values ​​from 0 to (b1-1) is determined to be 0; if b2 is less than 255, then the mapping value of the B channel pixel values ​​from (b2+1) to 255 is determined to be the product of 255 and the ordinate y; if the B channel pixel values ​​of the k pixel blocks are not continuous, then the mapping value of the B channel pixel values ​​between b1 and b2 that have not been determined is determined by the third interpolation formula.

4. The method according to claim 3, characterized in that, The first interpolation formula is: y G =y0+(x G -x0)*(y1-y0) / (x1-x0), where x G Let x0 and x1 be the G-channel pixel values ​​to be mapped, respectively, and let x0 and x1 be the G-channel pixel values ​​in the k pixel blocks and x1, respectively. G The G-channel pixel value of the nearest pixel block, x0≤x G ≤x1, the y G The y0 and y1 are respectively the x G The mapping values ​​of x0 and x1.

5. The method according to claim 3, characterized in that, The second interpolation formula is: y R =x*x R Where x is the x-coordinate, x R The y channel pixel value is the mapping value to be determined. R For the x R The mapping value; The third interpolation formula is: y B =y*x B Where y is the ordinate y, and x is the coordinate x. B For the B-channel pixel value of the mapping value to be determined, the y B For the x B The mapping value.

6. The method according to any one of claims 3 to 5, characterized in that, The calibration image includes at least 256 color blocks, and the pixel values ​​of the 256 color blocks include all pixel values ​​from 0 to 255. The obtained k pixel blocks include the pixel blocks corresponding to the color blocks with pixel values ​​of 0 and 255 in the calibration image, where k ≥ 2.

7. The method according to claim 1, characterized in that, Prior to step S100, the method further includes: Multiple color chart images are acquired, wherein each color chart image is obtained by taking a picture of the same color chart under illumination by a light source of the corresponding color temperature through the lens to be calibrated; For each color chart image, based on the positions of at least two target color chart patches in the color chart, at least two corresponding target color patches are determined from the color chart image, wherein the difference between any two of the R channel pixel value, G channel pixel value and B channel pixel value of each target color chart patch is less than a preset value; Calculate the color temperature difference between the at least two target color patches in each color chart image; If, in each color chart image, the color temperature difference between any two target color blocks is greater than the preset color temperature difference threshold, then it is determined that the nonlinearity of the lens to be corrected does not meet the requirements, and step S100 is executed.

8. An image color correction method, characterized in that, The method includes: Step S400: Acquire the target image captured by the target lens; Step S500: The target image is nonlinearly corrected using the R, G, and B three-channel nonlinear correction curves corresponding to the target lens, wherein the R, G, and B three-channel nonlinear correction curves are generated by the method according to any one of claims 1 to 7. Step S600: Perform white balance correction on the target image after nonlinear correction.

9. The method according to claim 8, characterized in that, Step S600 includes: Step S601: Obtain the R, G, and B channel pixel values ​​of the current pixel in the nonlinearly corrected target image, and calculate the color temperature coordinates of the current pixel, wherein the x-coordinate of the color temperature coordinates of the current pixel is... P The ratio of the R channel pixel value to the G channel pixel value of this pixel is represented by the y-axis. P This is the ratio of the B channel pixel value to the G channel pixel value of that pixel. Step S602: Determine the minimum distance between the color temperature coordinates of the current pixel and the z color temperature coordinates in the preset color temperature curve, where z is a positive integer; Step S603: If the minimum distance is less than a preset distance threshold, then the first initial value is compared with the x-coordinate of the color temperature coordinate of the current pixel. P Add them together to obtain a first sum, and then add the second initial value to the y-coordinate of the color temperature coordinate of the current pixel. P Add the first initial value to obtain the second sum, and add the third initial value to 1 to obtain the third sum, wherein the initial values ​​of the first initial value, the second initial value, and the third initial value are all 0; Step S604: Take the first sum, the second sum, and the third sum as the first initial value, the second initial value, and the third initial value, respectively, and repeat steps S601 to S603 until all pixels of the nonlinearly corrected target image are traversed. Step S605: Calculate the R-channel gain and B-channel gain of the nonlinearly corrected target image, wherein the R-channel gain is the ratio of the last obtained third sum to the last obtained first sum, and the B-channel gain is the ratio of the last obtained third sum to the last obtained second sum. Step S606: Multiply the R and G channel pixel values ​​of each pixel in the nonlinearly corrected target image by the R channel gain and the B channel gain, respectively.

10. A curve generation apparatus for image correction, characterized in that, The device includes: The first acquisition module is used to acquire a calibration image obtained by capturing a calibration image of the lens to be calibrated. The calibration image includes multiple color blocks of different colors, and the R, G, and B channel pixel values ​​of each color block are equal. The calibration image includes multiple pixel blocks corresponding to the color blocks. The calculation module is used to calculate the color temperature coordinates of the calibration image in a color temperature coordinate system based on the R, G, and B channel pixel values ​​of the pixel blocks of the calibration image. The x-coordinate of the color temperature coordinates is determined by the ratio of the R channel pixel value to the G channel pixel value, and the y-coordinate is determined by the ratio of the B channel pixel value to the G channel pixel value. The calculation module is also used to: calculate the ratio of the R channel pixel value to the G channel pixel value for each pixel block to obtain the x-coordinate of the color temperature coordinates for that pixel block; calculate the ratio of the B channel pixel value to the G channel pixel value to obtain the y-coordinate of the color temperature coordinates for that pixel block; finally, calculate the average of the x-coordinates of the selected pixel blocks to obtain the x-coordinate of the color temperature coordinates of the calibration image; and calculate the average of the y-coordinates of the selected pixel blocks to obtain the y-coordinate of the color temperature coordinates of the calibration image. The determining module is configured to determine the mapping value of each pixel value in the G channel (0-255) based on the G channel pixel values ​​of multiple pixel blocks in the calibration image, to obtain the non-linear correction curve of the G channel; and to determine the mapping value of each pixel value in the R channel (0-255) and B channel (0-255) based on the color temperature coordinates and the R channel and B channel pixel values ​​of multiple pixel blocks in the calibration image, respectively, to obtain the non-linear correction curves of the R channel and B channel, wherein the R, G, and B three-channel non-linear correction curves are used for non-linear correction before white balance correction is performed on the target image obtained by the lens to be calibrated; the determining module is further configured to: obtain the R, G, and B three-channel pixel values ​​of k pixel blocks from the calibration image. The calibration image comprises t color blocks, where t is a positive integer, t≥2, and k is configured such that all pixel values ​​in the same channel of the R, G, and B channels of all acquired pixel blocks are different, where k is a positive integer, k≤t; the mapping value of the G channel pixel value of each pixel block in the k pixel blocks is determined to be the G channel pixel value of the color block corresponding to that pixel block in the calibration image, the mapping value of the R channel pixel value of each pixel block is the product of the R channel pixel value of the color block corresponding to that pixel block in the calibration image and the horizontal coordinate x, and the mapping value of the B channel pixel value of each pixel block is the product of the B channel pixel value of the color block corresponding to that pixel block in the calibration image and the vertical coordinate y.

11. An image color correction device, characterized in that, The device includes: The second acquisition module is used to acquire the target image captured by the target lens; The first correction module is used to perform nonlinear correction on the target image using the R, G, and B three-channel nonlinear correction curves corresponding to the target lens, wherein the R, G, and B three-channel nonlinear correction curves are generated by the method according to any one of claims 1 to 7. The second correction module is used to perform white balance correction on the target image after nonlinear correction.

12. An electronic device, characterized in that, Including processor and memory: The memory stores executable instructions; The processor is configured to execute the executable instructions to implement the method as described in any one of claims 1-7; or, the electronic device further includes a lens for capturing a target image; The processor is used to execute the executable instructions to implement the method as described in claim 8 or 9.

13. A computer-readable storage medium storing at least one executable instruction, characterized in that, When the executable instructions are executed by the processor, they can implement the method as described in any one of claims 1 to 9.

14. A chip suitable for electronic devices, characterized in that, The chip stores an instruction set, which, when executed by the processor, implements the method as described in any one of claims 1 to 9.

Citation Information

Patent Citations

  • Printing method and device, ink-jet printer and storage medium

    CN112477438A

  • Image white balance processing method and device, electronic equipment and storage medium

    CN112995633A

  • Image processing device and method and imaging equipment

    CN115834855A