Color correction method and device, equipment and storage medium

By correcting the basic color correction matrix of the image data, the target color correction matrix is ​​generated, which solves the problem that the color correction matrix cannot meet user needs, and realizes flexible correction of image color and saturation, improving user experience.

CN120198332APending Publication Date: 2025-06-24SHANGHAI INTEGRATED CIRCUIT RESEARCH & DEVELOPMENT CENTER CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311785773.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-22
Publication Date
2025-06-24

AI Technical Summary

Technical Problem

After using the color correction matrix to correct the color once, the display effect of the image cannot meet the user's needs, resulting in a poor user experience.

Method used

By receiving the image data to be corrected, the corresponding basic color correction matrix is ​​determined and a corresponding grayscale matrix is ​​generated. Based on the preset saturation adjustment model, the basic color correction matrix is ​​corrected according to the saturation adjustment coefficient and grayscale matrix input by the user to obtain the target color correction matrix to correct the image data.

Benefits of technology

Through the use of the target color correction matrix, not only can the image color be corrected, but the image saturation can also be adjusted, so that the corrected image meets the needs of different users or different scenarios of the same user, improving the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120198332A_ABST
    Figure CN120198332A_ABST
Patent Text Reader

Abstract

The invention provides a color correction method and device, equipment and a storage medium. The method comprises the following steps: receiving image data to be corrected, and determining a basic color correction matrix corresponding to the image data; generating a corresponding gray matrix according to the basic color correction matrix; and based on a preset saturation adjustment model, according to a saturation adjustment coefficient input by a user and the gray matrix, correcting the basic color correction matrix to obtain a target color correction matrix, and correcting the image data according to the target color correction matrix. According to the method, the target color correction matrix is subjected to saturation correction on the basis of the basic color correction matrix, so that the image is corrected on the basis of the target color correction matrix, the image color can be corrected, the image saturation can be adjusted, the corrected image meets the requirements of a user, and the user experience is improved. And the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technologies, and in particular, to a color correction method, apparatus, device, and storage medium. Background Art

[0002] The human eye's recognition of colors is based on three different light-sensing units in the human eye for the spectrum. Different light-sensing units have different response curves to light in different wavelength bands, and the perception of colors is obtained through the synthesis of the brain. The response of a sensor to the spectrum usually has deviations from that of the human eye in each RGB component, and it is necessary to correct it, not only for the cross effect but also for the response intensity of each color component.

[0003] In some related technologies, colors can be corrected once through a color correction matrix (CCM).

[0004] However, since users have different preferences for the color correction effect, only correcting colors according to the color correction matrix cannot meet the user's needs for the display effect of the corrected image, and the user experience is poor. Summary of the Invention

[0005] This application provides a color correction method, apparatus, device, and storage medium to solve the problem that the display effect of the corrected image cannot meet the user's needs and the user experience is poor when using the color correction matrix to correct colors once.

[0006] In a first aspect, this application provides a color correction method, including:

[0007] Receiving image data to be corrected and determining a basic color correction matrix corresponding to the image data;

[0008] Generating a corresponding grayscale matrix according to the basic color correction matrix;

[0009] Based on a preset saturation adjustment model, correcting the basic color correction matrix according to the saturation adjustment coefficient input by the user and the grayscale matrix to obtain a target color correction matrix, so as to correct the image data according to the target color correction matrix.

[0010] In some possible implementation manners, generating a corresponding grayscale matrix according to the basic color correction matrix includes:

[0011] Based on the weighted average method, converting the color components included in the basic color correction matrix into corresponding grayscale components, and the grayscale components include conversion variables;

[0012] Establish a target loss function, determine the value of the conversion variable when the loss value calculated by the target loss function is minimized, and determine the value of the grayscale component according to the value of the conversion variable, so as to generate a grayscale matrix according to the value of the grayscale component.

[0013] In some possible implementation manners, establishing a target loss function includes:

[0014] Convert the basic color correction matrix from the first color space to the second color space to obtain the luminance component corresponding to each color component included in the basic color correction matrix;

[0015] Determine the difference between each luminance component and the corresponding grayscale component, and perform an addition operation on multiple differences to obtain the target loss function.

[0016] In some possible implementation manners, based on a preset saturation adjustment model, according to the saturation adjustment coefficient input by the user and the grayscale matrix, correct the basic color correction matrix to obtain a target color correction matrix, including:

[0017] Based on the preset saturation adjustment model, determine the difference between the basic color correction matrix and the grayscale matrix, and perform a multiplication operation on the difference and the basic color correction matrix to obtain a multiplication result;

[0018] Use the sum of the multiplication result and the grayscale matrix as the target color correction matrix.

[0019] In some possible implementation manners, determining the basic color correction matrix corresponding to the image data includes:

[0020] Extract the color information of multiple color blocks included in the image data, and convert the color information of multiple color blocks from the first color space to the third color space;

[0021] Determine the basic color correction matrix according to the color information of multiple color blocks based on the third color space and the color information of the standard color blocks.

[0022] In some possible implementation manners, after receiving the image data to be corrected, it further includes:

[0023] If the image data has been subjected to gamma correction processing, perform inverse gamma correction processing on the image data.

[0024] In a second aspect, the present application provides a color correction device, including:

[0025] A receiving module, configured to receive the image data to be corrected;

[0026] A processing module, configured to determine the basic color correction matrix corresponding to the image data;

[0027] The processing module is further configured to generate a corresponding grayscale matrix according to the basic color correction matrix;

[0028] The processing module is further configured to, based on a preset saturation adjustment model, correct the basic color correction matrix according to the saturation adjustment coefficient input by the user and the grayscale matrix to obtain a target color correction matrix, so as to correct the image data according to the target color correction matrix.

[0029] In a third aspect, the present application provides a color correction device, including: a processor and a memory. Codes are stored in the memory, and the processor runs the codes stored in the memory to execute the method according to any one of the first aspect.

[0030] In a fourth aspect, the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the method according to any one of the first aspect.

[0031] In a fifth aspect, the present application provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements the method according to any one of the first aspect.

[0032] The present application provides a color correction method, device, device and storage medium. The method includes: after receiving the image data to be corrected, determining the corresponding basic color correction matrix of the image data, and further generating a corresponding grayscale matrix according to the basic color correction matrix. Based on a preset saturation adjustment model, the basic color correction matrix is corrected according to the saturation adjustment coefficient input by the user and the grayscale matrix to obtain a target color correction matrix. Since the target color correction matrix is obtained by correcting the saturation on the basis of the basic color correction matrix, when the image is corrected based on the target color correction matrix, while correcting the image color, the saturation of the image is also corrected, so that the display effect of the corrected image meets the needs of different users or the same user in different scenarios, improving the user experience. Description of the Drawings

[0033] The drawings here are incorporated into the specification and form a part of this specification, showing the embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.

[0034] Figure 1 It is a schematic structural diagram of a shooting device provided by an embodiment of the present application;

[0035] Figure 2 It is a flowchart of a color correction method provided by an embodiment of the present application;

[0036] Figure 3 It is a flowchart of a method for generating a grayscale matrix provided by an embodiment of the present application;

[0037] Figure 4 Schematic diagram of the geometric relationship between the color components of a basic color correction matrix and the gray components of a gray matrix provided by an embodiment of the present application;

[0038] Figure 5 Flowchart of a method for obtaining a basic color correction matrix provided by an embodiment of the present application;

[0039] Figure 6 Flowchart of a method for saturation correction provided by an embodiment of the present application;

[0040] Figure 7 Schematic diagram of a color correction device provided by an embodiment of the present application;

[0041] Figure 8 Schematic diagram of a color correction device provided by an embodiment of the present application.

[0042] Through the above-mentioned drawings, specific embodiments of the present application have been shown, and more detailed descriptions will be given later. These drawings and textual descriptions are not intended to limit the scope of the concept of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. Detailed implementation manners

[0043] Here, exemplary embodiments will be described in detail, and their examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0044] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with relevant laws, regulations, and standards of relevant countries and regions, and corresponding operation entrances are provided for users to select authorization or rejection.

[0045] Due to the influence of different sensors on the spectrum, there are usually deviations in the RGB components from the human eye's response to the spectrum. To restore the true color of the image, it is necessary to correct the image.

[0046] In some related technologies, the color of the image can be corrected once through a color correction matrix, but the display effect of the corrected image cannot meet the user's needs, resulting in a poor user experience.

[0047] Since the user's color preference is not fixed, in addition to correcting the image color, it is usually necessary to correct the saturation of the color correction matrix again. Specifically, saturation correction affects the vividness of colors. In view of the actual usage requirements, during the saturation correction process, the impact on the overall brightness of the image should be minimized, and the same degree of correction should be applied to each color component to facilitate quantitative adjustment.

[0048] Based on the above requirements, this application provides a color correction method. After obtaining the image data and determining the basic color correction matrix corresponding to the image data, a grayscale matrix corresponding to the basic color correction matrix can be generated. Based on a preset saturation adjustment model, according to the saturation adjustment coefficient input by the user and the grayscale matrix, the saturation of the basic color correction matrix is corrected to obtain the target color correction matrix. Correcting the image data according to the target color correction matrix can not only correct the image color, but also correct the saturation of the image, improving the flexibility of image correction, meeting the user's needs, and enhancing the user experience.

[0049] Figure 1 The figure is a schematic structural diagram of a shooting device provided by an embodiment of this application. The shooting device includes, but is not limited to, cameras, mobile phones, computers, etc. As Figure 1 shown, the shooting device may include multiple components such as a lens, a sensor, an image processor, and a display. The lens focuses light onto the sensor, the sensor converts the optical signal into an electrical signal, and the image processor processes the electrical signal to achieve color correction of the image. After the processing is completed, the corrected image can be displayed through the display.

[0050] Next, specific embodiments will be used to detail the technical solution of this application and how the technical solution of this application solves the above technical problems. These specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of this application will be described below with reference to the accompanying drawings.

[0051] Figure 2 The figure is a flowchart of a color correction method provided by an embodiment of this application. The method of this embodiment can be executed by a color correction device and can be implemented in a manner combining hardware, software, or both. As Figure 2 shown, the method may include:

[0052] S201: Receive the image data to be corrected and determine the basic color correction matrix corresponding to the image data.

[0053] In some embodiments, after receiving the image data to be corrected, it can be determined whether the image data has been gamma-corrected. If the image data has been gamma-corrected, inverse gamma correction processing is performed on the image data.

[0054] In one implementation scenario, since gamma correction processing can improve the brightness of the image, a brightness threshold can be preset. If the brightness of the current image data is less than the brightness threshold, it can be determined that the image data has not been gamma-corrected.

[0055] In another implementation scenario, if the brightness of the current image data is higher than the brightness threshold, it can be determined that the image data has been gamma-corrected. At this time, to obtain the original image data, inverse gamma correction processing can be performed on the image data to obtain the corresponding basic color correction matrix according to the original image data, improving the accuracy of the basic color correction matrix and further facilitating the improvement of the accuracy of color correction.

[0056] In some embodiments, when determining the basic color correction matrix corresponding to the image data, the color information of multiple color blocks included in the image data can be extracted, and the color information of the multiple color blocks is converted from the first color space to the third color space; the basic color correction matrix is determined according to the color information of the multiple color blocks based on the third color space and the color information of the standard color blocks.

[0057] In one implementation scenario, the first color space can be RGB, RYYB, RGBY, RYBW, RGBW, RGBYW color space and its variants, etc. The type of the first color space is not limited in this application. Among them, R represents the red channel, G represents the green channel, B represents the blue channel, Y represents the yellow channel, W represents the white channel, etc.

[0058] The third color space is the L*a*b color space. For the L*a*b color space, the color is represented by three values of L, a, and b, where L represents the brightness, a represents the red-green chromaticity of the color, and b represents the yellow-blue chromaticity of the color.

[0059] In some embodiments, when determining the basic color correction matrix according to the color information of multiple color blocks and the color information of the standard color blocks, multiple iterations can be performed to minimize the difference between the color information of the multiple color blocks and the color information of the standard color blocks, thereby determining the corresponding basic color correction matrix.

[0060] Among them, the color information of the standard color blocks can be the color information corresponding to the 24-color card image.

[0061] The dimension of the basic color correction matrix is related to the number of channels included in the first color space. For example, when the first color space is the RGB color space, since this color space includes three channels of R, G, and B, the basic color correction matrix can be set as a 3×3 matrix. At this time, the basic color correction matrix includes three color components, namely the red component, the green component, and the blue component.

[0062] For example, when the first color space is the RYYB color space, within this space, the repetition period of pixel arrangement is four colors. However, since the number of color channels included in the RYYB color space is 3, namely R, Y, and B, the basic color correction matrix is also set as a 3×3 matrix.

[0063] For example, when the first color space is the RGBYW color space, since this color space includes 5 color channels, the basic color correction matrix is set as a 5×5 matrix.

[0064] S202: Generate a corresponding grayscale matrix according to the basic color correction matrix.

[0065] The grayscale matrix is used to represent the current brightness. Since the grayscale matrix is used to correct the basic color correction matrix, the dimension of the grayscale matrix is the same as that of the basic color correction matrix. If the basic color correction matrix is a 3×3 matrix, the grayscale matrix is also a 3×3 matrix, including three grayscale components, and each color component has a corresponding grayscale component.

[0066] In some embodiments, the color components of the basic color correction matrix can be converted into corresponding grayscale components. During the conversion process, conversion variables for conversion are involved. By determining the values of the conversion variables and further determining the grayscale components, the grayscale matrix can be obtained.

[0067] S203: Based on a preset saturation adjustment model, correct the basic color correction matrix according to the saturation adjustment coefficient input by the user and the grayscale matrix to obtain a target color correction matrix, so as to correct the image data according to the target color correction matrix.

[0068] In some embodiments, the saturation adjustment model is used to represent the relationship between the target color correction matrix, the basic color correction matrix, and the grayscale matrix. A representation method of a saturation adjustment model can be referred to as follows:

[0069] Target color correction matrix = saturation adjustment coefficient * (basic color correction matrix - grayscale matrix) + grayscale matrix

[0070] Based on the above representation, when correcting the basic color correction matrix according to the saturation adjustment coefficient and the grayscale matrix to obtain the target color correction matrix, the difference between the basic color correction matrix and the grayscale matrix can be determined based on a preset saturation adjustment model, and the product operation is performed on the difference and the basic color correction matrix to obtain a product result; the sum of the product result and the grayscale matrix is used as the target color correction matrix.

[0071] In another implementation scenario, the representation of the above saturation adjustment model can also be deformed. One deformed representation is as follows:

[0072] Target color correction matrix = saturation adjustment coefficient * basic color correction matrix + (1 - saturation adjustment coefficient) * grayscale matrix

[0073] Based on the above representation, it can be known that the product operation can be first performed on the saturation adjustment coefficient and the basic color correction matrix to obtain a first product result. Let the difference between 1 and the saturation adjustment coefficient be multiplied by the grayscale matrix to obtain a second product result. The sum of the first product result and the second product result is used as the target color correction matrix.

[0074] In some embodiments, the image data is corrected using the target color correction matrix, and the corrected image data is displayed accordingly.

[0075] The embodiments of the present application provide a color correction method. After receiving the image data to be corrected, the corresponding basic color correction matrix of the image data can be determined. A corresponding grayscale matrix is generated according to the basic color correction matrix. Based on a preset saturation adjustment model, according to the saturation adjustment coefficient input by the user and the grayscale matrix, the basic color correction matrix is corrected to obtain the target color correction matrix, and the image data is color-corrected according to the target color correction matrix. Since the target color correction matrix of the present application performs saturation correction on the basis of the basic color correction matrix, correcting the image based on the target color correction matrix can not only correct the image color, but also adjust the image saturation, so that the corrected image meets the user's needs and improves the user experience.

[0076] In one or more embodiments of the present application, generating a corresponding grayscale matrix according to the basic color correction matrix includes Figure 3 the steps shown as Figure 3 This is a flowchart of a method for generating a grayscale matrix provided by the embodiments of the present application, specifically as follows:

[0077] S301: Based on the weighted average method, the color components included in the basic color correction matrix are converted into corresponding grayscale components, and the grayscale components include conversion variables.

[0078] For convenience of description, in the embodiments of the present application, the first color space is taken as the RGB color space for illustration. At this time, the basic color correction matrix can be defined as follows:

[0079]

[0080] Among them, ccm 3×3 represents the basic color correction matrix, and X, Y, and Z respectively represent the three row vectors of the basic color correction matrix ccm 3×3 i.e., color components. X is the red component, Y represents the green component, and Z represents the blue component. And it is preset that X + Y + Z = (1, 1, 1). Among them, X = [RR RG RB], Y = [GR GG GB], Z = [BR BG BB], and RR, RG, RB, GR, GG, GB, BR, BG, BB are data for correcting the image. The specific data can be determined through the color information of multiple color blocks included in the image data and the color information of the standard color blocks as shown above, which will not be elaborated here.

[0081] Define the grayscale matrix as follows:

[0082]

[0083] Among them, grey_ccm 3×3 represents the grayscale matrix, and grey_r, grey_g, and grey_b respectively represent the three grayscale components of the grayscale vector. grey_r, grey_g, and grey_b are collinear and grey_r + grey_g + grey_b = (1, 1, 1). Among them, grey_r = [u u u], grey_g = [v v v], grey_b = [w w w].

[0084] For example, a specific grayscale matrix is as follows:

[0085]

[0086] Among them, grey_ccm 3×3 is the grayscale matrix, and grey_r, grey_g, and grey_b respectively represent the three grayscale components of the grayscale matrix, and grey_r = [0.192 0.192 0.192], grey_g = [0.946 0.946 0.946], grey_b = [-0.138 -0.138 -0.138].

[0087] Based on the weighted average method, a calculation method for converting the three color components of the color correction matrix to grayscale components is as follows:

[0088]

[0089] Among them, α, β, and γ are three conversion variables, and grey_x represents the grayscale component, where x can be r, g, or b. This matrix is the transpose of the color component corresponding matrix.

[0090] For example, when converting the red component to the grayscale component, that is, when x is r, it is as follows:

[0091]

[0092] Among them, grey_r is the grayscale component corresponding to the red component X, and α, β, and γ are three conversion variables. That is the transpose of the red component X = [RR RG RB].

[0093] The method for obtaining the grayscale component grey_g corresponding to the green component and the grayscale component grey_b corresponding to the blue component can refer to the process of obtaining the grayscale component grey_r corresponding to the red component above, and will not be elaborated here.

[0094] In some embodiments, additional constraint conditions can be added to make the sum of the grayscale components corresponding to the three color components equal to 1, specifically as follows:

[0095] 1 = grey_r + grey_g + grey_b

[0096] = (α * r_r + β * r_g + γ * r_b) + (α * g_r + β * g_g + γ * g_b) + (α * b_r + β * b_g + γ * b_b)

[0097] = α(r_r + g_r + b_r) + β(r_g + g_g + b_g) + γ(r_b + g_b + b_b)

[0098] = α + β + γ

[0099] Among them, α, β, and γ are three conversion variables, grey_r is the grayscale component corresponding to the red component and grey_r = α * r_r + β * r_g + γ * r_b, grey_g is the grayscale component corresponding to the green component and grey_g = α * g_r + β * g_g + γ * g_b, grey_b is the grayscale component corresponding to the blue component and grey_b = α * b_r + β * b_g + γ * b_b, where r_r, r_g, r_b are the data included in the red component, g_r, g_g, g_b are the data included in the green component, and b_r, b_g, b_b are the data included in the blue component.

[0100] S302: Establish a target loss function, determine the value of the conversion variable when the loss value calculated by the target loss function is minimized, and determine the value of the grayscale component according to the value of the conversion variable, so as to generate a grayscale matrix according to the value of the grayscale component.

[0101] In some embodiments, when establishing the target loss function, the basic color correction matrix can be converted from the first color space to the second color space to obtain the luminance component corresponding to each color component included in the basic color correction matrix; determine the difference between each luminance component and the corresponding grayscale component, and perform an addition operation on multiple differences to obtain the target loss function.

[0102] In one implementation scenario, the first color space is the RGB color space, and the second color space is the YUV color space.

[0103] In the YUV color space, Y represents the brightness, that is, the grayscale value, and U and V represent the chrominance, which is used to describe the influence on color and saturation and specify the color of the pixel.

[0104] A conversion method for converting the basic color correction matrix from the RGB color space to the YUV color space is as follows:

[0105]

[0106] Among them, represents the transpose of the basic color correction matrix based on the RGB color space, X represents the red component, Y represents the green component, Z represents the blue component, represents the basic color correction matrix based on the YUV color space, Y is the luminance component, and U and V are the chrominance components,

[0107] This matrix is a conversion coefficient for converting the RGB color space to the YUV color space.

[0108] Since Y is the luminance component, after converting the basic color correction matrix from the first color space to the second color space to obtain the matrix, the luminance component corresponding to each color component can be obtained.

[0109] Specifically, the luminance component Y_r corresponding to the red component = 0.299RR + 0.587RG + 0.114RB, the luminance component Y_g corresponding to the green component = 0.299GR + 0.587GG + 0.114GB, and the luminance component Y_b corresponding to the blue component = 0.299BR + 0.587BG + 0.114BB. Among them, RR, RG, RB, GR, GG, GB, BR, BG, and BB are the data included in the basic color correction matrix.

[0110] In some embodiments, since the influence on brightness should be minimized during the saturation adjustment process, in order to reduce the impact on the image brightness and keep the three color components maintaining their original brightness information as much as possible, a target loss function is specifically as follows:

[0111] L = min(ΔR + ΔG + ΔB)

[0112] Where L represents the loss value, ΔR = Y_r - grey_r, ΔG = Y_g - grey_g, ΔB = Y_b - grey_b, Y represents the brightness in the YUV color space, Y_r is the brightness component corresponding to the red component, Y_g is the brightness component corresponding to the green component, Y_b is the brightness component corresponding to the blue component, grey represents the grey component of the grey matrix. Specifically, grey_r is the grey component corresponding to the red component, grey_g is the grey component corresponding to the green component, and grey_b is the grey component corresponding to the blue component.

[0113] Based on the above target loss function, since Y_r, Y_g, and Y_b are fixed values, the size of the loss value L is related to the grey components grey_r, grey_g, and grey_b. As mentioned above, the grey components grey_r, grey_g, and grey_b are all related to the three conversion variables α, β, and γ, and α + β + γ = 1. Therefore, the conversion variables α, β, and γ can be iterated to minimize the loss value L. At this time, the values of the grey components grey_r, grey_g, and grey_b are also determined accordingly, and the grey matrix can be obtained.

[0114] In some embodiments, after the grey matrix is determined, based on a preset saturation adjustment model, according to the saturation adjustment coefficient input by the user and the grey matrix, the basic color correction matrix can be corrected to obtain the target color correction matrix. Correcting the image data according to the target color correction matrix can not only correct the color, but also, with less impact on the image brightness, achieve saturation correction, improve the flexibility of color correction, meet the user's needs, and enhance the user experience.

[0115] It should be noted that in the embodiments of this application, the RGB color space is used as the first color space to elaborate on the process of generating the grey matrix based on the basic color correction matrix. When the first color space is other color spaces except the RGB color space, the above process can be referred to. Its basic process and principle are basically the same as the process of generating the grey matrix in the RGB color space. This application will not elaborate on the generation process of the grey matrix for other color spaces.

[0116] In summary, when generating the grayscale matrix corresponding to the basic color correction matrix, the color components are converted into grayscale components, and at this time, the grayscale components include conversion variables. Further, by determining the values of the conversion variables and the values of the grayscale components when the loss value calculated by the target loss function is minimized, the grayscale matrix can be obtained. Since the target loss function is established based on the image brightness, determining the grayscale matrix with the minimum loss value effectively avoids affecting the overall brightness of the image.

[0117] In one or more embodiments of the present application, before performing color correction, it is also necessary to determine a preset saturation adjustment model.

[0118] Still taking the RGB color space as the first color space as an example in the embodiments of the present application for illustration. When determining the preset saturation adjustment model, it is also necessary to first determine the basic color correction matrix and the grayscale matrix, and further determine the geometric relationship between the color components X, Y, Z of the basic color correction matrix and the grayscale components grey_r, grey_g, grey_b of the grayscale matrix, which can be referred to Figure 4 as shown Figure 4 which is a schematic diagram of the geometric relationship between the color components of a basic color correction matrix and the grayscale components of a grayscale matrix provided by the embodiments of the present application.

[0119] Referring to Figure 4 as shown, since the angle changes during the transformation from the red component X to the grayscale component grey_b, it is not easy to solve. Similarly, the angle also changes during the transformation from the green component Y to the grayscale component grey_r and from the blue component Z to the grayscale component grey_g, and it is not easy to solve. Therefore, based on the geometric relationship, the following conversions can be performed:

[0120] X = X’ + grey_b;

[0121] Y = Y’ + grey_r;

[0122] Z = Z’ + grey_g;

[0123] where X, Y, Z are the three color components included in the basic color correction matrix, grey_r, grey_g, grey_b are the three grayscale components included in the grayscale matrix, X’ is the difference between the color component X and the grayscale component grey_b, Y’ is the difference between the color component Y and the grayscale component grey_r, and Z’ is the difference between the color component Z and the grayscale component grey_g.

[0124] Since X + Y + Z = (1, 1, 1) = X’ + Y’ + Z’ + grey_b + grey_r + grey_g, and grey_r + grey_g + grey_b = (1, 1, 1), then X’ + Y’ + Z’ = 0.

[0125] Among them, the gray components grey_r, grey_g, and grey_b are fixed, while X’, Y’, and Z’ only scale and their directions remain unchanged. Therefore, the adjustment object is converted from X, Y, and Z to X’, Y’, and Z’, that is, by multiplying X’, Y’, and Z’ simultaneously with a scaling factor sat, the effect of adjusting saturation can be achieved, specifically as follows:

[0126] X = sat * (X - grey_b) + grey_b;

[0127] Y = sat * (Y - grey_r) + grey_r;

[0128] Z = sat * (Z - grey_g) + grey_g;

[0129] Among them, X, Y, and Z are the three color components included in the basic color correction matrix, grey_r, grey_g, and grey_b are the three gray components included in the gray matrix, and sat represents the scaling factor.

[0130] Based on the above formula, generalizing the vector to a matrix gives the saturation adjustment model, specifically as follows:

[0131] new_matr_ccm = sat * (matr_ccm – grey_ccm) + grey_ccm

[0132] = sat * matr_ccm + (1 - sat) * grey_ccm

[0133] Among them, new_matr_ccm represents the target color correction matrix, matr_ccm represents the basic color correction matrix, grey_ccm represents the gray matrix, and the scaling factor sat is the saturation adjustment coefficient adjustable by the user.

[0134] After the saturation adjustment model is determined, during the process of color correction, the target color correction matrix can be directly determined according to the saturation adjustment model without re-deriving the saturation adjustment model.

[0135] For other color spaces except the RGB color space, the principle of determining the saturation adjustment model is basically the same as that of the RGB color space, and this application will not elaborate here.

[0136] In summary, based on the above-determined saturation adjustment model, it can not only reduce the impact on the image brightness, correct each color component to the same extent, facilitate quantitative adjustment and analysis, but also achieve the quantitative adjustment of saturation.

[0137] The color correction of this application may include two processes: preliminary color correction and saturation correction. Among them, the preliminary color correction is the process of obtaining the basic color correction matrix, and the saturation correction is the process of performing saturation correction on the basic color correction matrix to obtain the target color correction matrix.

[0138] Based on the above embodiments, a specific embodiment is provided below to describe the process of obtaining the basic color correction matrix.

[0139] Figure 5 It is a flowchart of a method for obtaining a basic color correction matrix provided by an embodiment of this application. Refer to Figure 5 As shown, the method is as follows:

[0140] S501: Obtain the image data to be corrected.

[0141] S502: Determine whether the image has undergone gamma processing. If yes, execute steps S503 - S506; if no, execute steps S504 - S506.

[0142] S503: Perform inverse gamma correction processing.

[0143] S504: Extract the color information of each color block.

[0144] S505: Convert the color information of each color block from the RGB color space to the L*a*b color space.

[0145] S506: Determine the color correction matrix based on the color information of the standard color block and the color information of each color block.

[0146] In summary, the color information of each color block of the image data to be corrected is unified to the L*a*b color space, and the basic color correction matrix is obtained through global search based on the color information of the standard color block. The specific process and implementation principle can refer to the above embodiments and will not be elaborated here.

[0147] Figure 6 It is a flowchart of a method for saturation correction provided by an embodiment of this application. Refer to Figure 6 As shown, the method is as follows:

[0148] S601: Obtain the color vector of the basic color correction matrix and the saturation correction coefficient.

[0149] S602: Convert the color vector from the RGB color space to the YUV color space.

[0150] S603: Perform iterative search based on the target loss function to determine the value of the conversion variable.

[0151] S604: Obtain the gray components included in the gray matrix.

[0152] S605: Based on the saturation adjustment model, correct the basic color correction matrix according to the grayscale matrix to obtain the target color correction matrix.

[0153] In summary, by determining the grayscale matrix corresponding to the basic color correction matrix, further based on the saturation adjustment model, the basic color correction matrix is corrected using the grayscale matrix, so as to achieve the correction of saturation. The specific process and implementation principle can be referred to the above embodiments and will not be elaborated here.

[0154] Figure 7 It is a schematic diagram of a color correction device provided by an embodiment of the present application. As Figure 7 shown, an embodiment of the present application provides a color correction device 700, which may include a receiving module 701 and a processing module 702.

[0155] The receiving module 701 is configured to receive the image data to be corrected;

[0156] The processing module 702 is configured to determine the basic color correction matrix corresponding to the image data;

[0157] The processing module 702 is further configured to generate a corresponding grayscale matrix according to the basic color correction matrix;

[0158] The processing module 702 is further configured to, based on a preset saturation adjustment model, correct the basic color correction matrix according to the saturation adjustment coefficient input by the user and the grayscale matrix to obtain the target color correction matrix, so as to correct the image data according to the target color correction matrix.

[0159] In a possible implementation manner, when the processing module 702 generates a corresponding grayscale matrix according to the basic color correction matrix, it is specifically configured to:

[0160] Based on the weighted average method, convert the color components included in the basic color correction matrix into corresponding grayscale components, and the grayscale components include conversion variables;

[0161] Establish a target loss function, determine the value of the conversion variable when the loss value calculated by the target loss function is the smallest, and determine the value of the grayscale component according to the value of the conversion variable, so as to generate a grayscale matrix according to the value of the grayscale component.

[0162] In a possible implementation manner, when the processing module 702 establishes the target loss function, it is specifically configured to:

[0163] Convert the basic color correction matrix from the first color space to the second color space to obtain the luminance component corresponding to each color component included in the basic color correction matrix;

[0164] Determine the difference between each luminance component and the corresponding grayscale component, and perform an addition operation on multiple differences to obtain a target loss function.

[0165] In a possible implementation manner, when the processing module 702 modifies the basic color correction matrix based on a preset saturation adjustment model, according to the saturation adjustment coefficient input by the user and the grayscale matrix, to obtain a target color correction matrix, it is specifically used for:

[0166] Based on the preset saturation adjustment model, determine the difference between the basic color correction matrix and the grayscale matrix, and perform a multiplication operation on the difference and the basic color correction matrix to obtain a multiplication result;

[0167] Use the sum of the multiplication result and the grayscale matrix as the target color correction matrix.

[0168] In a possible implementation manner, when the processing module 702 determines the basic color correction matrix corresponding to the image data, it is specifically used for:

[0169] Extract the color information of multiple color blocks included in the image data, and convert the color information of the multiple color blocks from the first color space to the third color space;

[0170] Determine the basic color correction matrix according to the color information of multiple color blocks based on the third color space and the color information of the standard color blocks.

[0171] In a possible implementation manner, after receiving the image data to be corrected, the processing module 702 is further used for:

[0172] If the image data has been subjected to gamma correction processing, perform inverse gamma correction processing on the image data.

[0173] The device in this embodiment can be used to execute the method embodiment shown above. Its implementation principle and technical effect are similar, and will not be elaborated here.

[0174] Figure 8 This is a schematic diagram of a color correction device provided by an embodiment of the present application. As Figure 8 shown, a color correction device 800 provided by an embodiment of the present application includes a processor 801 and a memory 802. Among them, the processor 801 and the memory 802 are connected through a bus 803.

[0175] In a specific implementation process, code is stored in the memory 802, and the processor 801 runs the code stored in the memory 802 to execute the method of the above method embodiment.

[0176] The specific implementation process of the processor 801 can refer to the above method embodiment. Its implementation principle and technical effect are similar, and will not be elaborated in this embodiment.

[0177] In the above Figure 8 illustrated embodiment, it should be understood that the processor 801 may be a central processing unit (CPU for short), or other general-purpose processors, digital signal processors (DSP for short), application specific integrated circuits (ASIC for short), etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in combination with the invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules in the processor.

[0178] The memory 802 may include high-speed RAM memory and may also include non-volatile storage NVM, such as at least one disk memory.

[0179] The bus 803 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, the bus in the drawings of this application is not limited to only one bus or one type of bus.

[0180] The embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the method of the above method embodiment.

[0181] The above computer-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a disk or an optical disc. The readable storage medium can be any available medium accessible by a general-purpose or special-purpose computer.

[0182] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an Application Specific Integrated Circuit (ASIC). Of course, the processor and the readable storage medium can also exist as discrete components in a device.

[0183] An embodiment of the present application provides a computer program product, including a computer program which, when executed by a processor, implements the method provided in any of the embodiments of the present application described above.

[0184] Those skilled in the art will readily conceive of other implementations of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any variations, uses, or adaptations of the present application, which follow the general principles of the present application and include common general knowledge or conventional technical means in the technical field not disclosed in the present application. The specification and the embodiments are only regarded as exemplary, and the true scope and spirit of the present application are pointed out by the following claims.

[0185] It should be understood that the present application is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present application is only limited by the appended claims.

Claims

1. A color correction method, characterized in that, Including: Receiving image data to be corrected and determining a basic color correction matrix corresponding to the image data; Generating a corresponding grayscale matrix according to the basic color correction matrix; Based on a preset saturation adjustment model, correcting the basic color correction matrix according to a saturation adjustment coefficient input by a user and the grayscale matrix to obtain a target color correction matrix, so as to correct the image data according to the target color correction matrix.

2. The method according to claim 1, characterized in that, The generating a corresponding grayscale matrix according to the basic color correction matrix includes: Based on a weighted average method, converting color components included in the basic color correction matrix into corresponding grayscale components, where the grayscale components include conversion variables; Establishing a target loss function, determining a value of the conversion variable when a loss value calculated by the target loss function is minimized, and determining a value of the grayscale component according to the value of the conversion variable, so as to generate a grayscale matrix according to the value of the grayscale component.

3. The method according to claim 2, wherein The establishing a target loss function includes: Converting the basic color correction matrix from a first color space to a second color space to obtain a luminance component corresponding to each color component included in the basic color correction matrix; Determining a difference between each luminance component and the corresponding grayscale component, and performing an addition operation on multiple differences to obtain a target loss function.

4. The method according to claim 1, wherein The correcting the basic color correction matrix according to a saturation adjustment coefficient input by a user and the grayscale matrix based on a preset saturation adjustment model to obtain a target color correction matrix includes: Based on a preset saturation adjustment model, determining a difference between the basic color correction matrix and the grayscale matrix, and performing a multiplication operation on the difference and the basic color correction matrix to obtain a multiplication result; Taking a sum of the multiplication result and the grayscale matrix as the target color correction matrix.

5. The method according to any one of claims 1-4, characterized in that The determining a basic color correction matrix corresponding to the image data includes: Extracting color information of multiple color blocks included in the image data, and converting the color information of the multiple color blocks from a first color space to a third color space; Determining a basic color correction matrix according to the color information of the multiple color blocks based on the third color space and the color information of standard color blocks.

6. The method according to claim 1, wherein After receiving the image data to be corrected, further including: If the image data has been subjected to gamma correction processing, performing inverse gamma correction processing on the image data.

7. A color correction device, characterized in that, Including: A receiving module, configured to receive image data to be corrected; A processing module, configured to determine a basic color correction matrix corresponding to the image data; The processing module is further configured to generate a corresponding grayscale matrix according to the basic color correction matrix; The processing module is further configured to correct the basic color correction matrix according to a saturation adjustment coefficient input by a user and the grayscale matrix based on a preset saturation adjustment model to obtain a target color correction matrix, so as to correct the image data according to the target color correction matrix.

8. A color correction device, comprising: A processor and a memory, where code is stored in the memory, and the processor runs the code stored in the memory to execute the method according to any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1-6 when executed by a processor.

10. A computer program product, comprising a computer program, which implements the method according to any one of claims 1-6 when executed by a processor.