Image Optimization Method, Apparatus, Device, and Storage Medium
By updating the high-saturation color correction matrix during image optimization, the color casting problem during high-saturation color conversion is solved, and a more natural and efficient color optimization effect is achieved.
Patent Information
- Application Number
- CN202210103415.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-27
- Publication Date
- 2025-06-20
- Estimated Expiration
- 2042-01-27
AI Technical Summary
During the process of image color optimization, high saturation colors cannot be completely converted, resulting in color castration and reducing the color performance of the image.
By obtaining the original color data of the pixel points of the image to be optimized, the standard color correction matrix and the high saturation color correction matrix are used for calculations, and the high saturation color correction matrix is updated to adjust the color parameters beyond the range of the gamut to return to the inside, avoid excessively reducing saturation, thereby improving the color cast phenomenon and improving the natural color.
It effectively avoids distortion of high saturation colors and improves the overall color performance of the image, especially the natural feeling of high saturation colors.
Smart Images

Figure CN114418896B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the technical field of image calibration, and particularly relates to an image optimization method, device, equipment and storage medium. Background Art
[0002] With the continuous development of digital image processing technology, people's requirements for image quality are also getting higher and higher. As a very important link in digital image processing technology, color optimization can improve the color accuracy and / or color performance of images, making the images have better visual effects.
[0003] Currently, when optimizing the color of an image, the color of the image is usually converted from the first color gamut space to the second color gamut space (for example, from the Adobe RGB color gamut space to the sRGB color gamut space). When the gamut range of the first color gamut space is larger than that of the second color gamut space, the high-saturation colors outside the gamut range of the second color gamut space cannot be fully converted, and certain deletion or adjustment needs to be performed on the high-saturation colors, resulting in color deviation of the high-saturation colors and reducing the color performance of the image. Summary of the Invention
[0004] In view of this, the embodiments of this application provide an image optimization method, device, equipment and storage medium to solve the problem that when optimizing the color of an image currently, it is easy to perform certain deletion or adjustment on high-saturation colors, resulting in color deviation of the high-saturation colors and reducing the color accuracy of the image.
[0005] The first aspect of the embodiments of this application provides an image optimization method, including:
[0006] Obtain the original color data of n pixel points of the image to be optimized;
[0007] Perform an operation on the original color data of the i-th pixel point through a standard color correction matrix to obtain the first color data of the i-th pixel point;
[0008] Perform an operation on the original color data of the i-th pixel point through a high-saturation color correction matrix to obtain the second color data of the i-th pixel point;
[0009] Update the high-saturation color correction matrix according to the first color data of the i-th pixel point and the second color data of the i-th pixel point;
[0010] Optimize the original color data of the i-th pixel point of the image to be optimized according to the standard color correction matrix and the updated high-saturation color correction matrix;
[0011] Wherein, n and i are positive integers, and i = 1, 2,..., n.
[0012] In the first aspect of the embodiments of the present application, an image optimization method is provided. By inputting the original color data of the i-th pixel point into a standard color correction matrix for calculation, the first color data of the i-th pixel point is obtained; and by respectively inputting the original color data of the i-th pixel point into a high-saturation color correction matrix for calculation, the second color data of the i-th pixel point is obtained; the high-saturation color correction matrix can be updated according to the first color data and the second color data of the i-th pixel point. When optimizing high-saturation colors, the parameters of the original color data outside the gamut range can be adjusted back within the gamut range, while avoiding excessive reduction of saturation, thereby avoiding high-saturation color distortion when improving color cast and improving the naturalness of high-saturation colors; cooperating with the standard color correction matrix to optimize non-high-saturation colors, improving the color performance of non-high-saturation colors, and further enhancing the overall color performance of the image.
[0013] In the second aspect of the embodiments of the present application, an image optimization device is provided, including:
[0014] An acquisition module, configured to acquire the original color data of n pixel points of the image to be optimized;
[0015] A first calculation module, configured to calculate the original color data of the i-th pixel point through a standard color correction matrix to obtain the first color data of the i-th pixel point;
[0016] A second calculation module, configured to calculate the original color data of the i-th pixel point through a high-saturation color correction matrix to obtain the second color data of the i-th pixel point;
[0017] An update module, configured to update the high-saturation color correction matrix according to the first color data of the i-th pixel point and the second color data of the i-th pixel point;
[0018] An optimization module, configured to optimize the original color data of the i-th pixel point of the image to be optimized according to the standard color correction matrix and the updated high-saturation color correction matrix;
[0019] Wherein, n and i are positive integers, and i = 1, 2,..., n.
[0020] In the third aspect of the embodiments of the present application, a terminal device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the image optimization method provided in the first aspect of the embodiments of the present application are implemented.
[0021] The fourth aspect of the embodiments of the present application provides a computer-readable storage medium storing a computer program, which when executed by a processor implements the steps of the image optimization method provided in the first aspect of the embodiments of the present application.
[0022] It can be understood that the beneficial effects of the above second aspect to the fourth aspect can be referred to the relevant descriptions in the above first aspect, and will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0024] Figure 1 It is the first flowchart of the image optimization method provided by the embodiments of the present application;
[0025] Figure 2 It is the second flowchart of the image optimization method provided by the embodiments of the present application;
[0026] Figure 3 It is the third flowchart of the image optimization method provided by the embodiments of the present application;
[0027] Figure 4 It is a schematic diagram of the corresponding relationship between the saturation, preset saturation and weight coefficient provided by the embodiments of the present application;
[0028] Figure 5 It is a schematic diagram of the structure of the image optimization device provided by the embodiments of the present application;
[0029] Figure 6 It is a schematic diagram of the structure of the terminal device provided by the embodiments of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0030] In the following description, specific details such as specific system structures and technologies are presented for the purpose of illustration rather than limitation, so as to thoroughly understand the embodiments of the present application. However, those skilled in the art should clearly understand that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid unnecessary details from interfering with the description of the present application.
[0031] It should be understood that when used in the specification of this application and the appended claims, the term "comprising" indicates the presence of the described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or their combinations.
[0032] It should also be understood that the term "and / or" used in the specification of this application and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0033] As used in the specification of this application and the appended claims, the term "if" may be construed, depending on the context, as "when", "once", "in response to determining", or "in response to detecting". Similarly, the phrase "if determined" or "if [the described condition or event] is detected" may be construed, depending on the context, as meaning "once determined", "in response to determining", "once [the described condition or event] is detected", or "in response to detecting [the described condition or event]".
[0034] In addition, in the description of the specification of this application and the appended claims, the terms "first", "second", "third", etc. are only used for distinguishing descriptions and cannot be construed as indicating or implying relative importance.
[0035] The reference to "one embodiment" or "some embodiments" or the like described in the specification of this application means that a specific feature, structure or characteristic described in connection with that embodiment is included in one or more embodiments of this application. Thus, statements such as "in one embodiment", "in some embodiments", "in other some embodiments", "in still other embodiments", etc. that appear in different places in this specification do not necessarily all refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "comprising", "including", "having" and their variants all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0036] In applications, currently when optimizing the color of an image, the color of the image is converted from a first color gamut space to a second color gamut space (for example, from the Adobe RGB color gamut space to the sRGB color gamut space). When the color gamut range of the first color gamut space is larger than that of the second color gamut space, the high-saturation colors outside the color gamut range of the second color gamut space cannot be fully converted, and it is necessary to perform a certain deletion or adjustment on the high-saturation colors, resulting in color deviation of the high-saturation colors and reducing the color performance of the image.
[0037] In applications, to solve the problem of color deviation in high-saturation colors, the parameters of the standard color correction matrix are usually adjusted to obtain a high-saturation color correction matrix, so that when performing color optimization, the saturation of high-saturation colors can be reduced to reduce or avoid color deviation in high-saturation colors. However, when the saturation is reduced too much, it is easy to cause color distortion in high-saturation colors, still reducing the color performance of the image.
[0038] In view of the above technical problems, an embodiment of the present application provides an image optimization method. By inputting the original color data of the i-th pixel point into the standard color correction matrix for calculation, the first color data of the i-th pixel point is obtained; and by inputting the original color data of the i-th pixel point into the high-saturation color correction matrix for calculation respectively, the second color data of the i-th pixel point is obtained; the high-saturation color correction matrix can be updated according to the first color data and the second color data of the i-th pixel point, so that when the high-saturation color correction matrix optimizes high-saturation colors, the parameters of the original color data outside the gamut range can be adjusted back within the gamut range, and at the same time, excessive reduction of saturation is avoided, thereby avoiding color distortion of high-saturation colors when improving the color deviation phenomenon and improving the naturalness of high-saturation colors; cooperating with the standard color correction matrix to optimize non-high-saturation colors, improving the color performance of non-high-saturation colors, and further enhancing the overall color performance of the image.
[0039] The image optimization method provided by the embodiment of the present application can be applied to a terminal device with image processing capabilities, which can be a mobile phone, a tablet computer, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc. The embodiment of the present application does not impose any restrictions on the specific type of the terminal device.
[0040] As Figure 1 shown, the image processing method provided by the embodiment of the present application includes the following steps S101 to step S105:
[0041] Step S101, obtaining the original color data of n pixel points of the image to be optimized.
[0042] In an application, the terminal device can obtain the number of pixel points n of the image to be optimized by scanning the image to be optimized. After obtaining the number of pixel points n, the terminal device can also calculate the theoretical number of pixel points of the image to be optimized according to the size and resolution of the image to be optimized, and compare it with the above-mentioned number of pixel points n. If they are not equal, the image to be optimized is scanned again until the obtained number of pixel points n is equal to the theoretical number of pixel points.
[0043] In an application, after obtaining the number of pixel points n of the image to be optimized, the original color data of n pixel points can be further obtained; or when obtaining the number of pixel points n of the image to be optimized, the original color data of n pixel points can be obtained simultaneously. Among them, the original color data is used to reflect the color of the pixel point, and the data type of the original color data is determined according to the color gamut space adopted by the image to be optimized. For example, assuming that the color gamut space adopted by the image to be optimized is sRGB (Standard Red Green Blue, a common color standard), the corresponding original color data includes three parameters: red value, green value, and blue value; assuming that the color gamut space adopted by the image to be optimized is HSV (Hue-Saturation-Value, a hue-saturation-brightness color gamut space), the corresponding original color data includes three parameters: hue, saturation, and brightness.
[0044] In one embodiment, before step S101, it further includes:
[0045] Receiving a source image, the color gamut space of the source image is the first color gamut space;
[0046] Adjusting the color gamut space of the source image to the second color gamut space to obtain an image to be optimized, and the color gamut range of the second color gamut space is smaller than the color gamut range of the first color gamut space.
[0047] In an application, after receiving the source image, the terminal device can convert the color gamut space of the source image to improve the color accuracy or color performance of the source image. After the terminal device completes the conversion of the color gamut space, it can obtain the first color gamut space of the source image and the second color gamut space of the converted image, and compare the color gamut range of the first color gamut space with the color gamut range of the second color gamut space. When the color gamut range of the second color gamut space is smaller than the color gamut range of the first color gamut space (the terminal device can pre-store the color gamut range of each color gamut space), there may be a problem that the conversion of high-saturation colors in the converted image is incomplete. The converted image can be marked as an image to be optimized, so that the terminal device can quickly and accurately screen the images to be optimized that need to be adjusted after the source image converts the color gamut space. Among them, when the first color gamut space is AdobeRGB, the second color gamut space can be sRGB. The specific types of the first color gamut space and the second color gamut space in the embodiments of the present application are not limited in any way.
[0048] Step S102: Operate on the original color data of the i-th pixel point through a standard color correction matrix (CCM) to obtain the first color data of the i-th pixel point.
[0049] In applications, when the standard CCM is used to process the original color data of n pixel points, the color performance of each pixel point can be improved by operating on the original color data of each pixel point. Among them, operating on the original color data of the i-th pixel point through the standard CCM to obtain the first color data of the i-th pixel point can reflect the color optimization situation of the i-th pixel point.
[0050] Among them, the standard CCM uses the same parameters for each pixel point, and the specific parameters of the standard CCM can be set according to actual needs. Among them, assuming that the color gamut space of the image to be optimized is sRGB, the data type of the original color data of the i-th pixel point can specifically be linear RGB data, including three parameters: red value, green value, and blue value.
[0051] Step S103: Operate on the original color data of the i-th pixel point through a high-saturation color correction matrix to obtain the second color data of the i-th pixel point.
[0052] In applications, when the high-saturation CCM is used to optimize the color of pixel points whose original color data exceeds the color gamut range of the second color gamut space, the parameters of the original color data outside the color gamut range can be adjusted back within the color gamut range by operating on the original color data, and the color cast phenomenon of the corresponding pixel points can be reduced or avoided by reducing the saturation of the corresponding pixel points.
[0053] In applications, operating on the original color data of the i-th pixel point through the high-saturation CCM to obtain the second color data of the i-th pixel point, based on the second color data of the i-th pixel point, the color optimization situation of the i-th pixel point can be reflected.
[0054] In applications, the parameters of the standard color correction matrix can be adjusted according to the original color data of the i-th pixel point to obtain a high-saturation color correction matrix.
[0055] Step S104: Update the high-saturation color correction matrix according to the first color data and the second color data of the i-th pixel point.
[0056] In an application, the first color data of the i-th pixel can be compared with the second color data of the i-th pixel. When the difference between the first color data and the second color data of the i-th pixel is large, it indicates that the high-saturation CCM has overly reduced the saturation of the i-th pixel. Therefore, the parameters of the high-saturation CCM can be adjusted to update the high-saturation CCM, so as to narrow the difference between the first color data and the second color data of the i-th pixel.
[0057] In an application, when the difference between the first color data and the second color data of the i-th pixel is small, it indicates that the updated high-saturation CCM not only adjusts the parameters of the original color data outside the gamut range back within the gamut range, but also does not overly reduce the saturation of the i-th pixel.
[0058] Step S105: Optimize the original color data of the i-th pixel of the image to be optimized according to the standard color correction matrix and the updated high-saturation color correction matrix;
[0059] Where n and i are positive integers, and i = 1, 2,..., n.
[0060] In an application, the standard CCM and the updated high-saturation CCM can be used simultaneously to optimize the original color data of the i-th pixel. Specifically, when the original color data of the i-th pixel is within the gamut range of the second gamut space, the i-th pixel can be color-optimized through the standard CCM to improve the color performance of the i-th pixel; and when the original color data of the i-th pixel is outside the gamut range of the second gamut space, the i-th pixel can be color-optimized through the updated high-saturation CCM, or through a combined matrix of the high-saturation CCM and the standard CCM, to adjust the parameters of the original color data of the i-th pixel outside the gamut range back within the gamut range, while avoiding overly reducing the saturation of the i-th pixel.
[0061] In an application, by inputting the original color data of the i-th pixel into the standard color correction matrix for calculation, the first color data of the i-th pixel is obtained; and by inputting the original color data of the i-th pixel into the high-saturation color correction matrix for calculation respectively, the second color data of the i-th pixel is obtained; the high-saturation color correction matrix can be updated according to the first color data and the second color data of the i-th pixel, so that when the high-saturation color correction matrix optimizes high-saturation colors, it can adjust the parameters of the original color data outside the gamut range back within the gamut range, while avoiding overly reducing the saturation, thereby avoiding high-saturation color distortion when improving color cast phenomena and improving the naturalness of high-saturation colors; cooperating with the standard color correction matrix to optimize non-high-saturation colors and improve the color performance of non-high-saturation colors, thereby enhancing the overall color performance of the image.
[0062] Such asFigure 2 As shown, in one embodiment, based on Figure 1 the corresponding embodiment, the following steps S201 to S209 are included:
[0063] Step S201, obtain the original color data of n pixel points of the image to be optimized;
[0064] Step S202, perform an operation on the original color data of the i-th pixel point through a standard color correction matrix to obtain the first color data of the i-th pixel point;
[0065] Step S203, perform an operation on the original color data of the i-th pixel point through a high-saturation color correction matrix to obtain the second color data of the i-th pixel point.
[0066] In application, steps S201 to S203 are the same as the image optimization method provided by the above steps S101 to S103, and will not be elaborated here.
[0067] In application, the above step S104 includes steps S204 to S208. The following will detail the update method of the high-saturation color correction matrix through steps S204 to S208.
[0068] Step S204, obtain the saturation of the i-th pixel point according to the first color data of the i-th pixel point.
[0069] In application, when the second color gamut space of the image to be optimized is HSV, the saturation can be directly obtained according to the first color data of the i-th pixel point. When the second color gamut space of the image to be optimized is not HSV, the second color gamut space of the image to be optimized can be converted to HSV. Correspondingly, the first color data of the i-th pixel point is converted into hue data, saturation data, and lightness data; alternatively, according to the corresponding relationship between the second color gamut space and HSV, the first color data of the i-th pixel point can be directly converted into hue data, saturation data, and lightness data to obtain the saturation data of the i-th pixel point.
[0070] In one embodiment, after step S204, it further includes:
[0071] Judge whether the saturation of the i-th pixel point is greater than the preset saturation;
[0072] When the saturation of the i-th pixel point is less than or equal to the preset saturation, stop the optimization of the i-th pixel point and perform the optimization of the (i + 1)-th pixel point;
[0073] Among them, n is greater than or equal to 2, and i = 1, 2,..., n - 1.
[0074] In an application, by determining whether the saturation of the i-th pixel is greater than a preset saturation, it can be determined whether the saturation of the i-th pixel is too high. When the saturation of the i-th pixel is less than or equal to the preset saturation, it indicates that the saturation of the i-th pixel is not too high and there will be no color cast phenomenon. Then, the i-th pixel does not need to be optimized, and the optimization of the (i + 1)-th pixel can be started. The optimization method of the (i + 1)-th pixel is the same as that of the i-th pixel. When the saturation of the i-th pixel is greater than or equal to the preset saturation, it indicates that the saturation of the i-th pixel is too high, and there will be a color cast phenomenon or it is prone to distortion after reducing the saturation. Therefore, the i-th pixel needs to be optimized, and step S205 is entered. Among them, the preset saturation can be set according to actual needs. Specifically, it can be equal to the maximum saturation of the second color gamut space. The embodiments of the present application do not impose any restrictions on the specific size of the preset saturation.
[0075] Step S205: When the saturation of the i-th pixel is greater than the preset saturation, calculate the difference between the first color data of the i-th pixel and the second color data of the i-th pixel to obtain the (k + 1)-th color difference; where k = 1, 2,..., m; k and m are positive integers, and k + 1 represents the number of times of color difference calculation for n pixels.
[0076] In an application, by calculating the difference between the first color data of the i-th pixel and the second color data of the i-th pixel, the (k + 1)-th color difference of the current calculation result can be obtained, which can be used to quantify the reduction of the saturation of the i-th pixel by the high-saturation CCM, that is, whether the color performance is natural after image optimization. Specifically, the larger the (k + 1)-th color difference, the more the saturation of the i-th pixel is reduced by the high-saturation CCM, and the less natural the color performance is; the smaller the (k + 1)-th color difference, the less the saturation of the i-th pixel is reduced by the high-saturation CCM, and the more natural the color performance is.
[0077] Step S206: Determine whether the (k + 1)-th color difference or the k-th color difference is greater than a preset threshold.
[0078] In an application, the k-th color difference represents the difference between the first color data of the high-saturation pixel and the second color data of the high-saturation pixel in the previous calculation. The above high-saturation pixel can be the i-th pixel or a previously optimized pixel with a serial number before the i-th pixel. By determining whether the (k + 1)-th color difference or the k-th color difference is greater than the preset threshold, it can be determined whether the larger value of the (k + 1)-th color difference and the k-th color difference is greater than the preset threshold. Among them, the preset threshold represents the standard value of saturation reduction, and the specific size of the preset threshold can be set according to actual needs.
[0079] It should be noted that when the color difference operation is performed on n pixel points for the first time, the first color difference can be obtained. At this time, there is only the first color difference. Then, in step S206, it can be determined whether the first color difference is greater than a preset threshold. If so, step S207 is entered; if not, step S208 is entered.
[0080] Step S207: When the (k + 1)-th color difference or the k-th color difference is greater than the preset threshold, update the high-saturation color correction matrix, and return to perform an operation on the original color data of the i-th pixel point through the high-saturation color correction matrix to obtain the second color data of the i-th pixel point until both the (k + 1)-th color difference and the k-th color difference are less than the preset threshold.
[0081] In application, when the (k + 1)-th color difference is greater than the preset threshold, it indicates that after the current high-saturation CCM optimizes the i-th pixel point, the saturation of the i-th pixel point decreases too much; when the k-th color difference is greater than the preset threshold, it indicates that after the previously updated high-saturation CCM optimizes the i-th pixel point, the saturation of the i-th pixel point decreases too much; when both the (k + 1)-th color difference and the k-th color difference are less than the preset threshold, it indicates that after the high-saturation CCMs updated in the most recent two times optimize the high-saturation pixel points, the saturation does not decrease too much and reaches the optimization expectation. Therefore, by updating the high-saturation CCM when the (k + 1)-th color difference or the k-th color difference is greater than the preset threshold and returning to step S203, the high-saturation CCM can be repeatedly updated until the high-saturation CCMs updated in the most recent two times reach the optimization expectation.
[0082] It can be understood that the smaller the preset threshold is set, the less the saturation of the i-th pixel point is reduced by the high-saturation CCM, and thus the less color distortion is caused, and the better the image optimization effect is. In addition, the update of the high-saturation CCM can be controlled when any one of the color differences calculated in the most recent q times is greater than the preset threshold. In this embodiment, q = 2, q is a positive integer and can be set according to actual needs. The larger the value of q, the better the optimization stability of the updated high-saturation CCM. The specific size of q in the embodiments of the present application is not limited in any way.
[0083] In one embodiment, step S207 includes:
[0084] When the (k + 1)-th color difference or the k-th color difference is greater than the preset threshold, adjust the gain coefficient of the high-saturation color correction matrix to update the high-saturation color correction matrix.
[0085] In application, the calculation formula for adjusting the gain coefficient of the high-saturation color correction matrix is as follows:
[0086] HighSatCCM tmp_new = Step * HighSatCCM tmp +(1 - Step) * StdCCM;
[0087] Among them, HighSatCCM tmp_new represents the updated high-saturation CCM, and HighSatCCM tmp represents the current high-saturation CCM. Step represents the gain coefficient of the high-saturation CCM, and StdCCM represents the standard CCM.
[0088] In applications, the high-saturation color correction matrix can be updated by adjusting the gain coefficient of the high-saturation color correction matrix. The gain coefficient adjustment method can be linear optimization and non-linear optimization. Specifically, for linear optimization, a preset descent value can be set, and by subtracting the gain coefficient from the preset descent value, one adjustment of the gain coefficient can be completed; non-linear optimization can be specifically implemented through algorithms such as the gradient descent method or the Gaussian method, etc. The embodiments of the present application do not impose any restrictions on the gain coefficient adjustment method.
[0089] Step S208: When both the (k + 1)-th color difference and the k-th color difference are less than the preset threshold, output the updated high-saturation color correction matrix.
[0090] In applications, when either the (k + 1)-th color difference or the k-th color difference is less than the preset threshold, it indicates that the color differences calculated in the last two times are both less than the preset threshold, that is, the image optimization of the high-saturation CCM for the i-th pixel has achieved the optimization expectation in the last two times. It can be determined that the optimization of the high-saturation CCM is completed, and step S209 can be entered to optimize the original color data of the i-th pixel through the updated high-saturation CCM and the standard CCM.
[0091] Step S209: Optimize the original color data of the i-th pixel of the image to be optimized according to the standard color correction matrix and the updated high-saturation color correction matrix.
[0092] In applications, the image optimization method provided in step S209 is the same as that in the above step S105, and will not be elaborated here.
[0093] In an application, by obtaining the saturation of the i-th pixel, it is possible to determine whether the saturation of the i-th pixel is too high, so as to achieve the screening of high-saturation pixels; when the saturation of the i-th pixel is greater than the preset saturation, by calculating the difference between the first color data of the i-th pixel and the second color data of the i-th pixel, the (k + 1)-th color difference can be obtained, which can quantify the reduction of saturation by the high-saturation CCM, that is, whether the color performance after image optimization is natural; and when the (k + 1)-th color difference or the k-th color difference is greater than the preset threshold, the high-saturation CCM is repeatedly updated until the performance of the high-saturation CCM is trained to the optimization expectation, so that the high-saturation CCM can be fully trained for the saturation of the i-th pixel before the high-saturation CCM is used for image optimization of the i-th pixel. Thus, after the training is completed, it is possible to better improve the color cast phenomenon while avoiding high-saturation color distortion and improve the naturalness of high-saturation colors.
[0094] As Figure 3 shown, in one embodiment, based on Figure 2 the corresponding embodiment, the following steps S301 to S311 are included:
[0095] Step S301, obtain the original color data of n pixels of the image to be optimized;
[0096] Step S302, perform an operation on the original color data of the i-th pixel through a standard color correction matrix to obtain the first color data of the i-th pixel;
[0097] Step S303, perform an operation on the original color data of the i-th pixel through a high-saturation color correction matrix to obtain the second color data of the i-th pixel.
[0098] Step S304, obtain the saturation of the i-th pixel according to the first color data of the i-th pixel.
[0099] Step S305, when the saturation of the i-th pixel is greater than the preset saturation, calculate the difference between the first color data of the i-th pixel and the second color data of the i-th pixel to obtain the (k + 1)-th color difference; where k = 1, 2,..., m; k and m are positive integers, and k + 1 represents the number of times of color difference calculation for n pixels;
[0100] Step S306, determine whether the (k + 1)-th color difference or the k-th color difference is greater than the preset threshold;
[0101] Step S307, when the (k + 1)-th color difference or the k-th color difference is greater than the preset threshold, update the high-saturation color correction matrix, and return to perform an operation on the original color data of the i-th pixel through the high-saturation color correction matrix to obtain the second color data of the i-th pixel until both the (k + 1)-th color difference and the k-th color difference are less than the preset threshold;
[0102] Step S308: When both the (k + 1)-th color difference and the k-th color difference are less than a preset threshold, output the updated high-saturation color correction matrix.
[0103] In application, steps S301 to S308 are the same as the image optimization method provided by the above steps S201 to S208, and will not be elaborated here.
[0104] Step S309: Determine the weight coefficients of the standard color correction matrix and the updated high-saturation color correction matrix according to the saturation of the i-th pixel.
[0105] In application, the terminal device can store a correspondence table of saturation, preset saturation, and weight coefficients. According to the saturation of the i-th pixel, the corresponding weight coefficient can be obtained by looking up the table in the above correspondence table. The specific correspondence of saturation, preset saturation, and weight coefficients can be: when the saturation is less than or equal to the preset saturation, the weight coefficient is 1; when the saturation is greater than the preset saturation, the weight coefficient gradually decreases, which can be a linear decrease or a non-linear decrease, until the maximum saturation is reached, the weight coefficient is 0.
[0106] As Figure 4 shown, an exemplary correspondence diagram of saturation, preset saturation, and weight coefficients is shown, where S represents saturation, T represents preset saturation, and HighSatCCM wt represents the weight coefficient.
[0107] Step S310: Establish an adaptive color correction matrix according to the weight coefficient, the standard color correction matrix, and the updated high-saturation color correction matrix.
[0108] In one embodiment, the calculation formula for establishing the adaptive color correction matrix is:
[0109] CCM = (1 - HighSatCCM wt ) * HighSatCCM + HighSatCCM wt * StdCCM;
[0110] where CCM represents the adaptive color correction matrix, and HighSatCCM represents the updated high-saturation CCM.
[0111] In application, when step S308 outputs the updated high-saturation CCM, the updated high-saturation CCM can be recorded as HighSatCCM to distinguish it from the HighSatCCM tmp_new generated during the update process.
[0112] Step S311: Optimize the original color data of the i-th pixel of the image to be optimized according to the adaptive color correction matrix.
[0113] In applications, by using the adaptive color correction matrix to optimize the i-th pixel of the image, when the saturation of the i-th pixel is less than or equal to the preset saturation, the standard CCM can be used to optimize the color of the i-th pixel to improve the color performance of the i-th pixel; when the saturation of the i-th pixel is greater than the preset saturation, a combined matrix of the updated high-saturation CCM and the standard CCM is used to optimize the color of the i-th pixel, and the parameters of the original color data of the i-th pixel outside the gamut range are adjusted back within the gamut range, while avoiding excessive reduction of the saturation of the i-th pixel. The color correction matrix adopted can be flexibly selected according to the saturation of the i-th pixel and the parameters of the correction matrix can be adjusted, without the need for repeated manual parameter adjustment, realizing adaptive and high-efficiency optimization at different saturations and improving the color performance of the image.
[0114] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The order of execution of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
[0115] As Figure 5 shown, the embodiments of the present application also provide an image optimization device for executing the steps in the above image optimization method embodiments. The image optimization device can be a virtual appliance in a terminal device, run by the processor of the terminal device, or the terminal device itself.
[0116] As Figure 5 shown, the image optimization device 10 provided by the embodiments of the present application includes:
[0117] An acquisition module 11, configured to acquire the original color data of n pixels of the image to be optimized;
[0118] A first operation module 12, configured to perform an operation on the original color data of the i-th pixel through a standard color correction matrix to obtain the first color data of the i-th pixel;
[0119] A second operation module 13, configured to perform an operation on the original color data of the i-th pixel through a high-saturation color correction matrix to obtain the second color data of the i-th pixel;
[0120] An update module 14, configured to update the high-saturation color correction matrix according to the first color data of the i-th pixel and the second color data of the i-th pixel;
[0121] Optimization module 15 is configured to optimize the original color data of the i-th pixel of the image to be optimized according to the standard color correction matrix and the updated high-saturation color correction matrix;
[0122] where n and i are positive integers, and i = 1, 2,..., n.
[0123] In applications, each module in the image optimization device can be a software program module, can also be implemented by different logic circuits integrated in a processor, or can also be implemented by multiple distributed processors.
[0124] It should be noted that for the information interaction, execution process, etc. between the above modules, since they are based on the same concept as the method embodiments of the present application, their specific functions and the technical effects brought about can be specifically referred to in the method embodiment part, and will not be elaborated here.
[0125] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the above division of each functional module is used as an example for illustration. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. Each functional module in the embodiment can be integrated in a processing module, can also exist physically separately for each module, or two or more modules can be integrated in one module. The above integrated modules can be implemented in the form of hardware or in the form of software functional modules. In addition, the specific names of each functional module are only for the convenience of mutual distinction and do not limit the protection scope of the present application. The specific working process of the modules in the above system can refer to the corresponding process in the foregoing method embodiments and will not be elaborated here.
[0126] As Figure 6 shown, an embodiment of the present application further provides a terminal device 100, including a memory 101, a processor 102, and a computer program 103 stored in the memory 101 and executable on the processor. When the processor 102 executes the computer program 103, the steps in the above method embodiments of each image optimization method are implemented.
[0127] In an application, the processor may be a Central Processing Unit (CPU), and the processor may also be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate Arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.
[0128] In an application, the memory may be an internal storage unit of the terminal device in some embodiments, such as the hard disk or memory of the terminal device. The memory may also be an external storage device of the terminal device in other embodiments, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, Flash Card, etc. equipped on the terminal device. Further, the memory may also include both the internal storage unit and the external storage device of the terminal device. The memory is used to store an operating system, application programs, a BootLoader, data, and other programs, such as the program code of a computer program. The memory may also be used to temporarily store data that has been output or is to be output.
[0129] It can be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the terminal device 100. In other embodiments of the present application, the terminal device 100 may include more or fewer components than those illustrated, or combine certain components, or different components. For example, it may also include input / output devices, network access devices, etc. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0130] The embodiments of the present application also provide a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned various embodiments of the image optimization method can be implemented.
[0131] When the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, to implement all or part of the processes in the above-described embodiment methods of this application, a computer program can be used to instruct relevant hardware to complete. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of the above-described method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file, or some intermediate form, etc. The computer-readable medium can at least include: any entity or device capable of carrying the computer program code to the photographing terminal device, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electrical carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk, or an optical disc, etc.
[0132] In the above embodiments, the descriptions of the various embodiments have their own emphases. For parts not detailed or recorded in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0133] Those of ordinary skill in the art can realize that the modules and algorithm steps of the examples described in combination with the embodiments disclosed in this article can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.
[0134] In the embodiments provided in this application, it should be understood that the disclosed terminal devices and methods can be implemented in other ways. For example, the terminal device embodiments described above are merely illustrative. For example, the division of the modules is only a logical function division. In actual implementation, there can be other division methods. For example, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces, indirect couplings or communication connections of devices or modules, and can be in electrical, mechanical, or other forms.
[0135] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. An image optimization method, characterized in that, Including: Obtain the original color data of n pixel points of the image to be optimized; Perform an operation on the original color data of the i-th pixel point through a standard color correction matrix to obtain the first color data of the i-th pixel point; Perform an operation on the original color data of the i-th pixel point through a high-saturation color correction matrix to obtain the second color data of the i-th pixel point; Update the high-saturation color correction matrix according to the first color data of the i-th pixel point and the second color data of the i-th pixel point; The step of updating the high-saturation color correction matrix according to the first color data of the i-th pixel point and the second color data of the i-th pixel point includes: comparing the first color data and the second color data of the i-th pixel point, and when the difference between the first color data and the second color data of the i-th pixel point is greater than a preset threshold, updating the high-saturation color correction matrix until the difference is less than the preset threshold, and then outputting the updated high-saturation color correction matrix; Optimize the original color data of the i-th pixel point of the image to be optimized according to the standard color correction matrix and the updated high-saturation color correction matrix; Wherein, n and i are positive integers, and i = 1, 2,..., n.
2. The image optimization method according to claim 1, characterized in that, The step of updating the high-saturation color correction matrix according to the first color data of the i-th pixel point and the second color data of the i-th pixel point includes: Obtain the saturation of the i-th pixel point according to the first color data of the i-th pixel point; When the saturation of the i-th pixel point is greater than a preset saturation, calculate the difference between the first color data and the second color data of the i-th pixel point to obtain the (k + 1)-th color difference; where k = 1, 2,..., m; k and m are positive integers, and k + 1 represents the number of times of color difference calculation for the n pixel points; Judge whether the (k + 1)-th color difference or the k-th color difference is greater than a preset threshold; When the (k + 1)-th color difference or the k-th color difference is greater than the preset threshold, update the high-saturation color correction matrix, and return to the step of performing an operation on the original color data of the i-th pixel point through the high-saturation color correction matrix to obtain the second color data of the i-th pixel point until both the (k + 1)-th color difference and the k-th color difference are less than the preset threshold; When both the (k + 1)-th color difference and the k-th color difference are less than the preset threshold, output the updated high-saturation color correction matrix.
3. The image optimization method according to claim 2, characterized in that, After obtaining the saturation of the i-th pixel point according to the first color data of the i-th pixel point, it further includes: Judge whether the saturation of the i-th pixel point is greater than a preset saturation; When the saturation of the i-th pixel point is less than or equal to the preset saturation, stop optimizing the i-th pixel point and perform the optimization of the (i + 1)-th pixel point; Wherein, n is greater than or equal to 2, and i = 1, 2,..., n - 1.
4. The image optimization method according to claim 2, characterized in that, The step of updating the high-saturation color correction matrix when the (k + 1)-th color difference or the k-th color difference is greater than a preset threshold includes: When the (k + 1)-th color difference or the k-th color difference is greater than a preset threshold, adjust the gain coefficient of the high-saturation color correction matrix to update the high-saturation color correction matrix.
5. The image optimization method according to claim 4, characterized in that, The step of adjusting the gain coefficient of the high-saturation color correction matrix to update the high-saturation color correction matrix when the (k + 1)-th color difference or the k-th color difference is greater than a preset threshold includes: When the (k + 1)-th color difference or the k-th color difference is greater than a preset threshold, adjust the gain coefficient of the high-saturation color correction matrix by gradient descent to update the high-saturation color correction matrix.
6. The image optimization method according to claim 1, characterized in that, Before obtaining the color data of n pixel points of the image to be optimized, it further includes: Receiving a source image, the color gamut space of the source image being the first color gamut space; Adjust the color gamut space of the source image to the second color gamut space to obtain an image to be optimized, and the color gamut range of the second color gamut space is smaller than the color gamut range of the first color gamut space.
7. The image optimization method according to any one of claims 1 to 6, characterized in that, The step of optimizing the original color data of the i-th pixel point of the image to be optimized according to the standard color correction matrix and the updated high-saturation color correction matrix includes: Determine the weight coefficients of the standard color correction matrix and the updated high-saturation color correction matrix according to the saturation of the i-th pixel point; Establish an adaptive color correction matrix according to the weight coefficients, the standard color correction matrix and the updated high-saturation color correction matrix; Optimize the original color data of the i-th pixel point of the image to be optimized according to the adaptive color correction matrix.
8. An image optimization device, characterized in that, It includes: An acquisition module for acquiring the original color data of n pixel points of an image to be optimized; A first operation module for operating on the original color data of the i-th pixel point through a standard color correction matrix to obtain the first color data of the i-th pixel point; A second operation module for operating on the original color data of the i-th pixel point through a high-saturation color correction matrix to obtain the second color data of the i-th pixel point; An update module for updating the high-saturation color correction matrix according to the first color data and the second color data of the i-th pixel point; The step of updating the high-saturation color correction matrix according to the first color data and the second color data of the i-th pixel point includes: comparing the first color data and the second color data of the i-th pixel point, and when the difference between the first color data and the second color data of the i-th pixel point is greater than a preset threshold, update the high-saturation color correction matrix until the difference is less than the preset threshold, and then output the updated high-saturation color correction matrix; An optimization module for optimizing the original color data of the i-th pixel point of the image to be optimized according to the standard color correction matrix and the updated high-saturation color correction matrix; Wherein, n and i are positive integers, and i = 1, 2,..., n.
9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the image optimization method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, the steps of the image optimization method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Image display method and device and computer storage medium
CN111192333A
Color correction matrix adjusting method and device, terminal equipment and medium
CN112073703A