Image color correction method, storage medium, computer program product, and electronic device
By performing luminance segmentation correction and color difference calculation in the CIE Lab color space, the instability caused by luminance errors in camera color calibration is solved, achieving fast and accurate color style matching, which is suitable for multi-camera systems and camera sensor replacement scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ESPRESSIF SYST SHANGHAI
- Filing Date
- 2026-04-30
- Publication Date
- 2026-07-24
AI Technical Summary
In existing technologies, during camera color calibration, brightness errors lead to unstable color fitting, increasing manual calibration costs and making it difficult to quickly and accurately match the expected hue or the color style of the target device.
By acquiring color block image data of the target device and the device to be debugged, luminance segmentation correction is performed in the CIE Lab color space, color difference is calculated, and an optimization algorithm is used to determine the candidate color correction matrix, thereby reducing the impact of luminance error and improving the accuracy and stability of color correction.
It enables the rapid replication of the color style of the target device from the device under test, reduces debugging costs, and improves the stability and repeatability of color correction. It is suitable for color style consistency in multi-camera systems and rapid inheritance after camera sensor replacement.
Smart Images

Figure CN122453676A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image signal processing (ISP), specifically to image color correction methods, storage media, computer program products, and electronic devices used for camera color calibration and color style matching. Background Technology
[0002] Because the color and brightness response characteristics of camera sensors (such as CMOS or CCD chips) differ from human visual perception, camera systems typically include an Image Signal Processing (ISP) workflow to perform color-related correction on the sensor output image, making the output image more consistent with human color perception. The Color Correction Matrix (CCM) is one of the commonly used color correction modules in ISP. Since different light sources vary significantly in color temperature and brightness, CCM is usually used to convert the color data to match the colors expected by the human eye after ISP processing.
[0003] In existing technologies, a typical color correction workflow involves modules such as White Balance Gain (WBG), Color Correction Mechanism (CCM), and Gamma correction. WBG is used to reproduce white or neutral colors, CCM is used to reproduce or correct colors, and Gamma is used to match the display characteristics of the monitor and enhance image contrast. Basic color calibration schemes typically employ a combination of WBG, CCM, and Gamma, and their processing order in the ISP workflow can be summarized as: WBG → other modules → CCM → other modules → Gamma.
[0004] In camera color calibration, the color correction module has a significant impact on image color quality. Efficiently obtaining CCM parameters that match the expected hue or the color style of the target device remains a key technical challenge in camera color calibration. Especially when there are deviations in shooting brightness, brightness errors often interfere with color fitting, leading to decreased stability in CCM solution and increased manual calibration costs. Summary of the Invention
[0005] This application aims to solve at least one of the technical problems existing in the prior art or related art. To this end, this application provides an image color correction method, a computer-readable storage medium, a computer program product, and an electronic device to achieve rapid and accurate matching of the image color effect of the device under test to the expected hue or the color effect of the target device.
[0006] According to a first aspect of this application, an image color correction method is provided, comprising: acquiring a target image containing multiple color blocks captured by a target device, and extracting CIE Lab color data of each color block in the target image; acquiring a source image containing multiple color blocks captured by a device to be debugged, and converting it to the CIE Lab color space; performing segmented correction on the luminance component of the source image in the CIE Lab color space to obtain corrected CIE Lab color data; determining multiple corrected CIE Lab color data corresponding to multiple candidate color correction matrices based on the corrected CIE Lab color data; calculating multiple color differences between the source image and the target image based on the CIE Lab color data of the target image and the multiple corrected CIE Lab color data of the source image; and determining the candidate color correction matrix corresponding to the minimum color difference as the target color correction matrix; wherein the target image and the source image correspond to the same photographed object.
[0007] In some embodiments, the plurality of color blocks includes at least one colored color block and at least two neutral color blocks.
[0008] In some embodiments, determining multiple corrected CIE Lab color data corresponding to multiple candidate color correction matrices based on corrected CIE Lab color data includes: obtaining RGB color data of each color block in the source image corresponding to the corrected CIE Lab color data; applying the multiple candidate color correction matrices to the RGB color data respectively to obtain multiple corrected RGB color data; and converting the multiple corrected RGB color data to the CIE Lab color space respectively to obtain multiple corrected CIE Lab color data.
[0009] In some embodiments, after acquiring a source image containing multiple color blocks collected by the device to be debugged, the method further includes: performing white balance correction on the source image.
[0010] In some embodiments, after acquiring a target image containing multiple color blocks collected by the target device, the method further includes: adjusting the color parameters of the acquired target image to generate a target color main tone style.
[0011] In some embodiments, extracting CIE Lab color data of each color patch in the target image includes: obtaining RGB color data of each color patch in the target image; performing a gamma de-gamma operation on the RGB color data to obtain gamma-de-gamma RGB color data; and converting the gamma-de-gamma RGB color data from the RGB color space to the CIE Lab color space to obtain CIE Lab color data of each color patch in the target image.
[0012] In some embodiments, degamma operation is the inverse operation of gamma operation, and the degamma operation processes RGB color data based on a preset gamma value.
[0013] In some embodiments, when processing the white balance corrected source image, the method further includes performing gamma demapping on each color block of the white balance corrected source image.
[0014] In some embodiments, acquiring a source image containing multiple color blocks from the device under test includes: when acquiring the source image, disabling white balance gain, color correction matrix processing, and / or gamma curve correction processing on the device under test.
[0015] In some embodiments, segmenting the luminance component of the source image in the CIE Lab color space for correction includes: determining luminance correction coefficients for multiple luminance intervals based on the luminance components of multiple neutral color patches in the source image and the luminance components of corresponding neutral color patches in the target image; wherein the luminance correction coefficient is the ratio of the luminance component of the target image to the luminance component of the source image or an interpolation result determined based on the ratio; and segmenting the CIE Lab color data of the source image according to multiple luminance intervals, multiplying the luminance component of the color patch in each luminance interval by the corresponding luminance correction coefficient to obtain corrected CIE Lab color data.
[0016] In some embodiments, calculating multiple color differences between the source image and the target image includes: calculating at least one color difference between corresponding color patches based on the CIE Lab color data of each color patch in the target image and the corrected CIE Lab color data of each color patch in the source image, using a preset color difference calculation formula to obtain multiple color differences; and weighting the at least one color difference according to a preset weight to obtain the total color difference used to characterize the overall color difference between the source image and the target image.
[0017] In some embodiments, determining the candidate color correction matrix corresponding to the minimum color difference as the target color correction matrix includes: using the total color difference between the source image and the target image as a loss function, and using an optimization algorithm to iteratively update the matrix parameters of the candidate color correction matrix to obtain the target color correction matrix that minimizes the loss function; wherein the optimization algorithm is the least squares method or the gradient descent method.
[0018] According to a second aspect of this application, a non-volatile computer-readable storage medium is also provided, on which a computer program is stored, which, when executed by a processor, implements the above-described arbitrary image color correction method.
[0019] According to a third aspect of this application, a computer program product is also provided, the computer program product including computer instructions, which, when executed by a processor, implement any of the above-described image color correction methods.
[0020] According to a fourth aspect of this application, an electronic device is also provided, comprising: a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the computer instructions, when executed by the processor, implement any of the above-described image color correction methods.
[0021] This application uses the color chart data collected by the target device as a reference target, which can enable the device under test to quickly replicate the color style of the target device, rather than just making the output approximate the natural color of the standard color chart, thereby reducing debugging costs and improving style consistency and repeatability.
[0022] Furthermore, this embodiment performs luminance correction on the luminance component in the CIE Lab color space. Compared to uniform luminance correction in the RGB space, this reduces errors introduced by channel coupling and improves the accuracy of luminance compensation. Moreover, through segmented luminance correction and interpolation, it can better approximate the nonlinear photosensitivity characteristics of some sensors, improving the fitting consistency and robustness across different luminance ranges. Attached Figure Description
[0023] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. The drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 This is a schematic diagram of the standard 24-color card used in the embodiments of this application.
[0025] Figure 2 This is a schematic diagram of the CIE Lab color space coordinate system.
[0026] Figure 3 This is a geometric diagram of color difference in the CIE Lab color space.
[0027] Figure 4 This is a flowchart illustrating an image color correction method provided in an embodiment of this application.
[0028] Figure 5 This is a schematic diagram of the process for determining and correcting CIE Lab color data provided in an embodiment of this application.
[0029] Figure 6 This is a schematic diagram of the process for extracting CIE Lab color data of each color block in a target image, provided in an embodiment of this application.
[0030] Figure 7 This is a flowchart illustrating an exemplary image color correction method of this application.
[0031] Figure 8 This is an example diagram illustrating the relationship between gamma curves and degamma operations.
[0032] Figure 9 This is a schematic diagram illustrating the nonlinear characteristics of an exemplary sensor and piecewise interpolation brightness correction.
[0033] Figure 10 This is a structural block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0034] The technical solution of this application will now be clearly and completely described with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are merely some embodiments of this application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0035] Before describing the technical solution of this application, for ease of understanding, a brief explanation of the relevant technologies involved in this application will be given first.
[0036] In the field of image signal processing, the Color Correction Matrix (CCM) module is typically used to perform linear transformations on image color data. It can achieve a linear mapping between two sets of color data using a 3×3 matrix. For example, the meaning of a CCM matrix can be represented as: [R', G', B'] = C × [R, G, B], Where C is a 3×3 matrix.
[0037] In existing color calibration or color adjustment processes, standard color charts are typically used as reference objects for sampling and fitting. See also Figure 1 An exemplary standard color chart can be a standard 24-color chart. This chart consists of 24 square color blocks arranged in 4 rows and 6 columns. The first color block in the upper left corner is labeled "1" (dark brown), and the last color block in the lower right corner is labeled "24" (black). After acquiring the color chart image, each color block can be located and sampled to obtain its color data in a specific color space. This color data is then compared with a reference value to obtain the color difference value. Based on this color difference value, color calibration parameters such as CCM are calculated.
[0038] Color data can be represented in different color spaces. Typical color spaces include the RGB color space, which represents color as a combination of red, green, and blue channels. The RGB color space is a device-dependent representation; its color values and display effects are often affected by the image acquisition device, display device, and encoding method. Besides RGB, other color spaces include CIE XYZ and CIE Lab, defined by the International Commission on Illumination (CIE). CIE XYZ can be used as a device-independent intermediate color space, while the CIE Lab color space uses (L, a, b) to represent color, where L is the luminance component, a is the chromaticity component from red to green, and b is the chromaticity component from yellow to blue. Compared to RGB and XYZ, CIE Lab has a characteristic that more closely approximates perceptual uniformity; that is, the geometric distances in the color space are more consistent with the human eye's perception of color differences. Therefore, it is often used for color difference evaluation and color matching.
[0039] Referring to Table 1, the characteristics of common RGB color spaces and CIE color spaces are summarized as follows:
[0040] Table 1
[0041] See Figure 2 This is a schematic diagram of the CIE Lab color space coordinate system. As can be seen, the CIE Lab color space defines color as a ternary array (L, a, b), where dimension L represents brightness, dimension a represents the color transition factor from red to green, and dimension b represents the color transition factor from yellow to blue. Furthermore, because the CIE Lab color representation method has good perceptual uniformity, the geometric distance in its color space has a strong correspondence with the color difference perceived by the human eye. Based on this, the CIE organization has also defined several color difference calculation methods, including CIE76, CIE94, and CIE2000. The CIE Lab color space is widely used in industries such as printing, photography, paints (including automotive and household products), dyes (including textiles and plastics), printing inks, and paper color specifications.
[0042] See Figure 3 This is a geometric diagram of color difference in the CIE Lab color space. In the CIE Lab color space, the difference between two colors can be quantified as the distance between two points; the longer the line, the greater the difference. For example, if the coordinates of two colors in the CIE Lab color space are...
[0043] for and The CIE1976 color difference standard quantifies the difference between two colors as the Euclidean distance between two points, resulting in the following color difference:
[0044] In some cases, It is approximately 2.3, which corresponds to the just noticeable difference (JND) that the human eye can perceive.
[0045] To further consider the varying sensitivities of the human eye to differences in brightness, chromaticity, and hue, CIE76, CIE94, CIE2000, or other color difference formulas used to characterize color differences can be employed to evaluate these differences. Taking CIE94 as an example, it maintains L... a b Based on the color space, weight parameters related to the application scenario are introduced to decompose the color difference into brightness difference, chromaticity difference, and hue difference, and then perform weighted calculations to obtain the color difference as follows:
[0046] Typically, after acquiring a color chart image, the acquired color data is converted to a specified color space, the color difference between the acquired data and the reference value is calculated, and numerical optimization methods (such as least squares method or gradient descent method) are used to solve for the CCM parameters that minimize the color difference, thereby achieving color calibration or color adjustment.
[0047] The relevant terms used in this application can be defined as follows: The target device is the device used to provide the desired color effect, such as a reference phone, a camera, or the main camera.
[0048] The device to be debugged is the device that needs to be debugged to match the color effect of the target device, such as a new sensor module, a camera, or a replacement model.
[0049] The target image is an image containing multiple color blocks captured by the target device under the same shooting conditions.
[0050] The source image is an image containing multiple color blocks captured by the device to be debugged under the same shooting conditions.
[0051] The candidate color correction matrix is a matrix used to linearly transform the RGB data of the source image, preferably a 3×3 matrix.
[0052] Light is a fundamental condition for imaging. Light sources such as sunlight and incandescent lamps vary significantly in color temperature and brightness at different times, easily leading to different dominant color tones in captured images. Different color temperatures correspond to different spectral distributions, thus affecting the reflected spectrum of the illuminated object. Imaging devices typically lack strict color constancy, so images of the same object taken under different lighting conditions may show significant differences. Furthermore, excessively high or low illumination levels affect the object's brightness and color saturation to varying degrees, thus impacting the representation of color information. Only under appropriate illumination can the object's brightness, hue, and color saturation be accurately conveyed, resulting in a more realistic and objective reproduction of color information.
[0053] Brightness error strongly influences color error, significantly impacting color error evaluation and CCM (Color Scale) solution. On one hand, without effective handling of brightness differences, color difference evaluation may simultaneously include brightness and chromaticity deviations, causing the obtained CCM parameters to be influenced by brightness error, leading to unstable color matching. On the other hand, some solutions rely on technicians repeatedly adjusting the shooting environment's brightness and exposure parameters to reduce brightness error, resulting in low debugging efficiency and insufficient repeatability. In multi-camera systems, independently debugging each camera's parameters can easily lead to inconsistent color styles between cameras. While style alignment of other cameras using the main camera as a target benchmark is more valuable in engineering, existing solutions often struggle to balance efficiency and stability when there are lighting fluctuations or brightness deviations. Furthermore, some applications require "targeting the imaging style of the target device," meaning the image style output by the device being debugged should be consistent with or close to the target device, rather than limited to approximating the objective reference value of a standard color chart.
[0054] Therefore, the purpose of this application embodiment is at least as follows: based on the target image acquired by the target device, extract the CIE Lab color data of each color block of the target image as a reference, and perform segmented correction on the luminance component of the source image in the CIE Lab color space to reduce the influence of luminance error. Then, use the color difference as the loss function to solve the target color correction matrix that reduces the color difference, so that the device under test can generate an image with the same or similar color effect as the target device when capturing images, and improve the stability, repeatability and debugging efficiency of the solution process.
[0055] Figure 4 This is a schematic flowchart of the image color correction method provided in an embodiment of this application. See also... Figure 4 The method includes the following steps S401 to S406.
[0056] Step S401: Acquire a target image containing multiple color blocks captured by the target device, and extract the CIE Lab color data of each color block in the target image; Step S402: Acquire the source image containing multiple color blocks captured by the device to be debugged, and convert it to the CIE Lab color space; Step S403: Perform segmented correction on the luminance component of the source image in the CIE Lab color space to obtain corrected CIE Lab color data; Step S404: Based on the corrected CIE Lab color data, determine multiple corrected CIE Lab color data corresponding to multiple candidate color correction matrices; Step S405: Based on the CIE Lab color data of the target image and multiple corrected CIE Lab color data of the source image, calculate multiple color differences between the source image and the target image; Step S406: Determine the candidate color correction matrix corresponding to the minimum color difference as the target color correction matrix; In this case, the target image and the source image correspond to the same photographed object.
[0057] In this embodiment, the color chart data acquired by the target device is used as a reference target, and the color difference between the source image acquired by the device under test and the target image acquired by the target device is calculated based on CIE Lab color data. Since the CIE Lab color space is relatively independent of the acquisition and display devices, and its spatial distance has a strong correspondence with the color difference perceived by the human eye, it helps to make the color difference evaluation closer to visual perception, thereby making the subsequently determined target color correction matrix more suitable for achieving the matching of the color style of the device under test to the target device.
[0058] Furthermore, this embodiment performs luminance correction on the luminance component in the CIE Lab color space, and preferably only compensates for the luminance component. Compared to uniformly correcting luminance in the RGB space, this reduces errors introduced by channel coupling and improves the accuracy of luminance compensation. Moreover, through segmented luminance correction and interpolation, the nonlinear photosensitivity response characteristics of some sensors can be better approximated, improving the fitting consistency and robustness across different luminance ranges.
[0059] Furthermore, this embodiment generates corrected CIE Lab color data corresponding to multiple candidate color correction matrices and determines the target color correction matrix based on the criterion of minimizing color difference. The process of determining the color correction matrix is transformed into a search or optimization process with color difference as the target. This allows the obtained target color correction matrix to reduce the overall color difference between the source image and the target image in an overall sense. As a result, the device under test can obtain an image color effect close to that of the target device more quickly after applying the target color correction matrix. This is especially suitable for application scenarios such as color style consistency in multi-camera systems and rapid inheritance of the original imaging style after camera sensor replacement.
[0060] In some embodiments, the plurality of color blocks includes at least one colored color block and at least two neutral color blocks.
[0061] It can be understood that color blocks are multiple preset areas set on a color chart, which may include colored color blocks and neutral color blocks. Colored color blocks are color blocks with preset hues and / or preset chromaticities, used to provide different color samples to constrain color mapping during candidate color correction matrix evaluation and color difference calculation, thereby improving the fitting consistency of the target matrix. Neutral color blocks are color blocks on the color chart used to provide neutral references, appearing as gray, white, or black blocks to the human eye. If represented in the RGB domain, their R:G:B values are close to 1:1:1. If represented in the Lab domain, their L component, a, and b components are close to 0. Since neutral color blocks ideally do not introduce significant hue shifts, they can serve as stable references for white balance correction and luminance segmentation correction in this application.
[0062] As an example, one could use Figure 1 The standard 24-color chart is shown. The standard 24-color chart includes 24 color blocks, where the colored color blocks include blocks 1–18, and the neutral color blocks include blocks 19–24. The neutral color blocks preferably cover multiple brightness levels from high to low, to facilitate the formation of multiple segmentation nodes and support interpolation processing during brightness segmentation correction. It should be understood that this application does not limit the type of color chart; the number of color blocks, their arrangement, and color configuration can be set according to actual application requirements, as long as the color chart includes at least one colored color block and at least two neutral color blocks to meet the needs of white balance correction, brightness segmentation correction, and color correction matrix solving. For example, in addition to the standard 24-color chart, the color chart can also be a standard 128-color chart, a high-block-count color chart (e.g., ColorChecker SG), an IT8 series color chart, a DSC Labs test chart, etc.
[0063] Figure 5 This is a schematic diagram of the process for determining corrected CIE Lab color data provided in an embodiment of this application. See also... Figure 5 In some embodiments, determining multiple corrected CIE Lab color data corresponding to multiple candidate color correction matrices based on corrected CIE Lab color data may include the following steps 501 to 503.
[0064] Step S501: Obtain the RGB color data of each color block in the source image corresponding to the corrected CIE Lab color data.
[0065] It should be noted that the corrected CIE Lab color data is used to characterize the target alignment state of the source image in Lab space after luminance segmentation correction; while the candidate color correction matrix usually corresponds to the linear transformation parameters performed on RGB data in ISP. Therefore, when evaluating the candidate color correction matrix, it is preferable to return to the RGB domain and apply matrix operations to the RGB data of the color patches to simulate the processing mechanism of the actual CCM module.
[0066] Step S502: Apply multiple candidate color correction matrices to the RGB color data respectively to obtain multiple corrected RGB color data.
[0067] For example, the candidate color correction matrix is a 3×3 matrix. Matrix multiplication is performed on the RGB vector of each color block to obtain the corrected RGB result corresponding to the candidate matrix, thereby forming one or more sets of corrected RGB data under different candidate matrices.
[0068] Step S503: Convert the multiple rectified RGB color data to the CIE Lab color space to obtain multiple rectified CIE Lab color data.
[0069] This conversion allows subsequent color difference calculations to be performed uniformly within the CIE Lab color space.
[0070] In this embodiment, converting the corrected RGB results to Lab color space and evaluating them in Lab color space helps to make the comparison of the merits of candidate matrices more consistent with the human eye's perception of color difference, thereby improving the stability and accuracy of the target color correction matrix screening or optimization process, reducing debugging uncertainty caused by brightness fluctuations or device differences, and thus improving the efficiency of color style matching.
[0071] In some embodiments, after acquiring a source image containing multiple color blocks collected by the device to be debugged, the method further includes: performing white balance correction on the source image.
[0072] It should be understood that white balance correction is mainly used to eliminate the overall color cast introduced by differences in light source color temperature and sensor channel response. Through this process, this embodiment can avoid erroneously attributing white balance errors to color correction matrix parameters, improve the accuracy of solving the target color correction matrix, and facilitate color style consistency across multiple cameras.
[0073] In some embodiments, after acquiring a target image containing multiple color blocks collected by the target device, the method further includes: adjusting the color parameters of the acquired target image.
[0074] Specifically, the color parameter adjustments can be used to generate a personalized target color dominant tone style. For example, the target image can be imported into image editing software or image processing programs (such as Photoshop or equivalent image processing tools), and preset color processing parameters can be applied to the target image to obtain the adjusted target image. These color processing parameters may include, but are not limited to: hue shift, saturation adjustment, contrast adjustment, curve adjustment, zone color correction, or local color replacement. The color parameter adjustments are preferably performed without changing the spatial relationship of the color blocks to ensure that subsequent extraction and matching of each color block is still possible.
[0075] After the color parameters are adjusted, this embodiment can use the adjusted target image as a reference image for solving the target color correction matrix, and extract the CIE Lab color data of each color block based on the adjusted target image. This allows the subsequent color difference calculation and matrix solving process to use the stylized target Lab data as the optimization target, so that the device to be debugged can output an image close to the personalized main color style during the shooting stage, improving the repeatability and debugging efficiency of color style transfer between different devices or different cameras.
[0076] Figure 6 This is a schematic diagram illustrating the process of extracting CIE Lab color data from each color patch of a target image, as provided in an embodiment of this application. See also... Figure 6 In some embodiments, extracting CIE Lab color data for each color patch in the target image includes the following steps 601 to 603.
[0077] Step 601: Obtain the RGB color data of each color block in the target image.
[0078] Step 602: Perform gamma demapping on the RGB color data to obtain gamma-demapping RGB color data.
[0079] It should be understood that de-gamma operation is the inverse operation of gamma operation, used to restore encoded nonlinear RGB values to approximately linear light intensity response values. De-gamma operation can process RGB color data based on a preset gamma value. The preset gamma value can be determined according to the color coding standard of the target device; for example, when the color coding standard is sRGB, the gamma value can be 2.2; when the color coding standard is P3, the gamma value can be 1.8.
[0080] Step 603: Convert the gamma-de-RGB color data from the RGB color space to the CIE Lab color space to obtain the CIE Lab color data of each color block in the target image.
[0081] For example, you can first convert the gamma-degraded RGB to the CIE XYZ color space, and then convert it from CIE XYZ to the CIE Lab color space to obtain a color space with (L... , a , b The target color block data is represented by ).
[0082] In this embodiment, by introducing gamma de-calculation before RGB to Lab conversion, the influence of gamma nonlinearity on color numerical relationships can be reduced, making the obtained Lab data closer to device-independent representation. This improves the consistency of target data under different devices, different displays, and different encoding standards, thereby enhancing the accuracy and repeatability of the color style matching of the device under test to the target device.
[0083] In other embodiments, gamma removal can be performed on each color patch of the white-balance corrected source image to further avoid misattributing the brightness compression error introduced by gamma to the CCM parameters, thereby improving the stability of the matrix solution. It is important to note that both the source and target images involved in the color difference calculation should be gamma-removed to improve the consistency of their color data comparison.
[0084] In some embodiments, acquiring a source image containing multiple color blocks from the device under test includes: when acquiring the source image, disabling white balance gain, color correction matrix processing, and / or gamma curve correction processing on the device under test.
[0085] For example, in the image signal processing flow of the device to be debugged, modules such as white balance gain (WBG), color correction matrix (CCM), and gamma curve (Gamma) can be set to off or bypassed to keep the image data output by the sensor as original as possible. Then, in this state, a color card containing multiple color blocks is photographed to obtain the source image.
[0086] In this way, this embodiment can avoid the superimposed influence of the existing WBG, CCM, and Gamma parameters of the device under test on the color and brightness relationship of the source image, reduce the interference on subsequent white balance correction, Lab brightness segmentation correction and target CCM solution, thereby making color difference calculation more controllable, matrix optimization easier to converge, improving the accuracy and repeatability of target color correction matrix solution, and shortening the debugging cycle.
[0087] In some embodiments, segmental correction of the luminance component of the source image in the CIE Lab color space may include the following process: First, based on the luminance components of multiple neutral color patches in the source image and the corresponding luminance components of neutral color patches in the target image, luminance correction coefficients for multiple luminance ranges are determined; wherein, the luminance correction coefficient is the ratio of the luminance component of the target image to the luminance component of the source image or an interpolation result determined based on the ratio.
[0088] For example, several grayscale color patches from a color chart (e.g., some neutral color patches from a 24-color chart) can be selected, and their L values in the source and target images can be read respectively. The ratio of the two values is then calculated as the brightness correction coefficient, i.e., correction coefficient = target L / source L. For brightness ranges not directly covered by neutral color patches, interpolation can be performed based on the correction coefficients of adjacent neutral color patches to obtain the correction coefficients for each brightness range, thus forming a segmented brightness mapping relationship.
[0089] Subsequently, the CIE Lab color data of the source image is segmented into multiple brightness ranges. The brightness component of the color block in each brightness range is multiplied by the corresponding brightness correction coefficient to obtain the corrected CIE Lab color data.
[0090] Compared to uniform brightness scaling in the RGB space, this embodiment performs piecewise compensation on the brightness channel L in the Lab space. This more accurately corrects brightness deviations during acquisition and reduces the interference of brightness errors on subsequent color difference calculations and CCM solutions. Simultaneously, the piecewise interpolation method better approximates the nonlinear characteristics of the sensor's photosensitivity response, allowing for targeted correction of errors in different brightness ranges. This improves the stability and convergence of the color correction matrix solution and achieves more consistent color matching even with fluctuations in exposure or illuminance.
[0091] In some embodiments, calculating multiple color differences between the source image and the target image includes: calculating the color difference between corresponding color blocks based on the CIE Lab color data of each color block in the target image and the corrected CIE Lab color data of each color block in the source image using a preset color difference calculation formula to obtain at least one color difference; and weighting the at least one color difference according to a preset weight to obtain the total color difference used to characterize the overall color difference between the source image and the target image.
[0092] It is understood that when only one color patch is selected for evaluation, the at least one color difference is a single color difference value, which can be directly used as the total color difference to characterize the overall color difference between the source image and the target image.
[0093] When multiple color patches are selected for evaluation, the at least one color difference includes multiple color difference values. For example, the color difference can be calculated separately for each pair of color patches with the same number to form a set of color difference values. The color difference calculation can use a preset color difference formula, such as the CIE76 color difference formula, CIE94 color difference formula, or CIE2000 color difference formula, to calculate the (L) value for each pair of color patches with the same number. ,a , b The differences are quantified to obtain a set of color difference values for each color patch. Further, these multiple color difference values can be weighted and averaged according to preset weights to obtain the total color difference characterizing the overall color difference between the source image and the target image. For example, the total color difference can be expressed as the ratio of the weighted sum of the color differences of each color patch and their corresponding weights to the sum of the weights. The preset weights can be configured according to the importance of different color patches, and it is permissible to set the weights of some color patches to 0 so that these color patches do not participate in the calculation of the total color difference. For example, key color patches such as skin tone, sky color, and green can be assigned higher weights, while color patches that are not considered or do not participate in the fitting can be assigned lower weights or have their weights set to 0.
[0094] In this embodiment, the candidate matrix is quantitatively evaluated using the color difference formula in the CIE Lab space. By introducing a weighting mechanism, the matrix solving process can prioritize the matching effect of key colors, thereby improving the controllability of color style matching.
[0095] In some embodiments, determining the candidate color correction matrix corresponding to the minimum color difference as the target color correction matrix includes: using the total color difference between the source image and the target image as a loss function, and employing an optimization algorithm to iteratively update the matrix parameters of the candidate color correction matrix to obtain the target color correction matrix that minimizes the loss function. The iteration termination conditions may include, but are not limited to: the loss function converging to a preset threshold, the decrease in the loss function being less than a preset threshold, or the number of iterations reaching a preset upper limit.
[0096] In some embodiments, the optimization algorithm can be the least squares method or the gradient descent method. As an example, the least squares method is used to solve for or update the matrix parameters to minimize the sum of squared errors between the correction results of the corresponding color patches and the target Lab data, thereby obtaining the target color correction matrix. As another example, the gradient descent method is used to update the matrix parameters in the gradient direction of the loss function to gradually reduce the total color difference and obtain the target color correction matrix. The least squares method or gradient descent method used in this application can reduce computational complexity while meeting accuracy requirements, thereby saving computational resources and improving solution efficiency. It should be understood that the above optimization algorithms are merely examples, and the optimization algorithms that can be used in this application are not limited to these.
[0097] The embodiments of this application use weighted total color difference as the optimization objective, which can minimize the color difference between the source image and the target image in an overall sense, thereby improving the accuracy and consistency of color style matching.
[0098] For a better understanding of the image color correction process in the embodiments of this application, please refer to... Figure 7 The image color correction process provided in this application embodiment is illustrated below with examples. It should be understood that the following steps are merely illustrative, and the execution order, parameter values, and implementation methods of each step can be appropriately adjusted without departing from the technical solution of this application.
[0099] See Figure 7 The flowchart illustrates an exemplary image color correction method of this application, including the following steps 701-711.
[0100] Step 701: Obtain the target image.
[0101] A test environment is set up, and a color calibration chart is captured using the target device to obtain the target image `target_image`. The color calibration chart includes at least colored patches and neutral patches. For example, the color calibration chart can be as follows: Figure 1 The 24-color chart shown has color blocks 1-18 as colored blocks and color blocks 19-24 as neutral blocks.
[0102] During shooting, the brightness of the light source can be adjusted so that the pixel value of the brightest color block in the target image is 0.6 to 0.8 times its saturation value. Taking an 8-bit width as an example, the brightness of the brightest neutral color block (such as color block 19 on a 24-color chart) can be controlled within the range of 153 to 204.
[0103] Optionally, the acquired target image can be subjected to color parameter adjustments or stylization (e.g., adjusting local or overall colors using image editing software), and the processed image can be used as the target image target_image.
[0104] Step 702: Extract RGB data of color blocks from the target image.
[0105] The target image `target_image` is processed by locating and sampling color blocks to obtain the RGB color data of each block. For example, let `RGB_block1` be the RGB value of color block number 1, and `RGB_blockn` be the RGB value of color block number n. Figure 1 As shown, the top left corner of the 24-color chart is color block number 1, and the bottom right corner is color block number 24.
[0106] Step 703: Perform gamma removal processing on the target RGB data.
[0107] Considering that different display or encoding standards may correspond to different gamma characteristics, de-gamma operations can be performed on the RGB data of each color block to improve the comparability and stability of the target data. De-gamma operation is the inverse operation of gamma operation, and the specific gamma value can be determined according to the color encoding standard of the target device. For example, the typical gamma value of the sRGB standard is 2.2, and the typical gamma value of the P3 standard is 1.8.
[0108] See Figure 8 This is an exemplary schematic diagram showing the relationship between gamma curves and degamma operations. Figure 8 In the diagram, the horizontal axis can represent the normalized linear brightness or linear light intensity input value, and the vertical axis can represent the non-linear output value after gamma processing (such as the code value used for storage, transmission, or display). Figure 8 Two curves with inverse mapping relationships are shown. The curve labeled "CRTGamma γ=2.2" represents the gamma response of a typical display, while the curve labeled "Video Gamma γ=1 / 2.2=0.45" represents the gamma response of the encoding end corresponding to the aforementioned display gamma response. Figure 8 The mapping relationship shown illustrates that gamma de-processing is used to counteract the brightness compression or expansion effect introduced by gamma nonlinearity, thereby improving the comparability of color data under different devices or different color coding standards, and enhancing the stability and accuracy of subsequent color difference evaluation and color correction matrix solution.
[0109] Step 704: Obtain CIE Lab data of the target image color patch.
[0110] Based on the gamma-free target RGB data, each color patch is converted from RGB to the CIE Lab color space to obtain the Target_lab data for each color patch. The RGB to Lab conversion can be achieved by converting RGB to XYZ and then back to Lab. For example, the relationship between RGB color space and XYZ color space conversion can be represented as:
[0111] In the formula: [T] is a 3×3 matrix:
[0112] The relationship between XYZ color space and Lab color space can be represented as follows:
[0113] in: , , The values are 0.950456, 1.0, and 1.088754 respectively; the function f is a correction function similar to the Gamma function; When t > 0.008856,
[0114] When t≤0.008856,
[0115] Step 705: Obtain the source image.
[0116] When acquiring the source image, the ISP module of the device under test can be configured to disable white balance (WB), color correction matrix (CCM), and gamma curve processing to reduce the influence of existing parameters on the sampled data. Subsequently, the same color calibration chart is photographed using the device under test to obtain the source image src_image.
[0117] Step 706: Extract RGB data of color blocks from the source image.
[0118] The source image src_image is used to locate and sample color blocks to obtain the RGB color data of each color block.
[0119] Step 707: Perform white balance correction.
[0120] Calculate the white balance gain based on the RGB mean of one or more neutral color patches, for example, calculate RG_Gain=G / R and BG_Gain=G / B, and then perform gain compensation on the source image channels to obtain the white balance corrected image wb_image: R''=R'×RG_Gain G''=G'×1 B''=B'×BG_Gain Step 708: Obtain the source Lab data after white balance.
[0121] Convert the RGB data of each color block in wb_image to the CIE Lab color space to obtain the white balance corrected source data Src_lab.
[0122] Step 709: Perform segmented correction on the luminance component in Lab space.
[0123] The luminance correction coefficient is calculated based on the L component of multiple neutral color patches, and segmented compensation is performed for different luminance ranges. For example, when using a 24-color chart, neutral color patches 19 to 22 can be selected as luminance segmentation nodes. For each neutral color patch, its L value in the target image (target_L) and its L value in the source image (src_L) are read, and the ratio is calculated as the luminance correction coefficient for that node, i.e., (k=target_L / src_L). For example, for color patch 22, if the L values of the corresponding color patch in the target image and the source image are 34 and 31 respectively, then the corresponding correction coefficient is (34 / 31=1.097).
[0124] See Table 2, which lists the values of the luminance components (e.g., L in Lab space) of several neutral color blocks (e.g., block19 to block22) in the target image and the source image, and the corresponding ratio target_L / src_L.
[0125]
[0126] Table 2
[0127] Based on Table 2, the L value of the neutral color block in the source image can be used as a segmentation node to divide the brightness range of the source image into multiple brightness intervals. For color blocks in each brightness interval, the L component is compensated using the correction coefficient corresponding to that interval. For brightness intervals between adjacent nodes, interpolation can be performed based on the correction coefficients of adjacent nodes to determine the interval correction coefficient. Subsequently, only the L component of each color block is multiplied by the corresponding correction coefficient, while keeping the a and b components unchanged, thereby obtaining the segmented brightness-corrected correction_lab data.
[0128] See Figure 9 This is an exemplary schematic diagram of the nonlinear photosensitive characteristics of a sensor and piecewise interpolation brightness correction. Figure 9 In the diagram, the horizontal axis represents physical luminance, and the vertical axis represents the sampled values output by the imaging system. Solid curves represent the actual photosensitivity curves, while dashed curves represent photosensitivity curves obtained through piecewise interpolation. In this embodiment of the application, using the aforementioned piecewise correction and interpolation fitting in the CIE Lab color space, targeted correction of luminance errors can be achieved even in the presence of exposure deviations or illuminance fluctuations. This reduces the interference of luminance errors on color difference calculations and the solution of the target color correction matrix, improving the stability and consistency of color matching.
[0129] Step 710: Calculate the color difference and obtain the total color difference.
[0130] The color difference between correction_lab and Target_lab is calculated using a preset color difference formula (such as CIE76, CIE94, or CIE2000). The total color difference can be the weighted average of the color differences of each color patch; for color patches that are not of interest, their weight can be set to 0.
[0131] Step 711: Solve for the optimal CCM matrix.
[0132] Using the total color difference as the loss function, the parameters of the CCM matrix are solved or iteratively updated using optimization methods such as least squares or gradient descent to obtain the target CCM matrix that minimizes the color difference.
[0133] It should be understood that the embodiments of this application obtain a standard image containing multiple color blocks captured by the target camera device, and use the color data of the standard image as a reference target to solve the target color correction matrix (e.g., CCM matrix) for the device to be debugged, so that the output image of the device to be debugged is consistent with or close to the target device in terms of color effect.
[0134] In some application scenarios, the embodiments of this application can be used in, but are not limited to, the following situations: 1. During product development or mass production debugging, quickly obtain color effects that are consistent with or close to those of the target device.
[0135] 2. In scenarios where the camera sensor is replaced (e.g., using a higher-performance sensor or replacing the original sensor after it has been discontinued), the new sensor should inherit the imaging color style of the original device while recalibrating the parameters.
[0136] 3. In a multi-camera system, the color effect of the main camera is used as the target benchmark, and the color style of other cameras is aligned to improve the consistency of multi-camera output.
[0137] 4. In personalized color style scenarios, the images captured by the target device can be post-stylized (for example, by adjusting some color areas through image editing software to form a specific main color tone), and then the stylized image can be used as the target image to solve the color correction parameters, so that the device to be debugged can directly output an image close to the style during the shooting stage, reducing the workload of post-processing each image.
[0138] In summary, compared with some traditional technologies, the embodiments of this application have at least the following technical advantages: First, luminance component L is corrected in the CIE Lab color space. Compared with uniform luminance correction in the RGB space, this reduces the error introduced by channel coupling and improves the accuracy of luminance compensation.
[0139] Secondly, by using segmented brightness correction and interpolation, the nonlinear photosensitive response characteristics of some sensors can be better approximated, improving the fitting consistency and robustness of different brightness ranges.
[0140] Third, by using the color chart data collected by the target device as a reference, the color style of the target device can be quickly replicated, rather than simply making the output approximate the natural color of the standard color chart, thereby reducing debugging costs and improving style consistency and repeatability.
[0141] This application also provides an electronic device, see [link to document]. Figure 10The diagram shows a block diagram of an electronic device according to an embodiment of the present application. The electronic device 10 includes a memory 1001, a processor 1002, and computer instructions 1003 stored in the memory and executable on the processor. When the computer instructions 1003 are executed by the processor 1002, they implement the methods described in the various embodiments of the present application.
[0142] This application also provides a computer program product that includes computer instructions, which, when executed by a processor, implement the methods described in the various embodiments of this application.
[0143] This application also provides a computer-readable storage medium storing computer program instructions thereon, which, when executed by a processor, can implement the methods described in the various embodiments of this application.
[0144] This application also provides a computer program instruction that, when executed by a processor, can implement the methods described in the various embodiments of this application.
[0145] For the implementation principles and beneficial effects of the electronic devices, computer program products, computer-readable storage media, and computer programs described in the above embodiments, please refer to the foregoing description of the image color correction method in the embodiments of this application, and therefore will not be repeated here.
[0146] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic resistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0147] While various embodiments of various aspects of this application have been described for the purposes of this disclosure, they should not be construed as limiting the teachings of this disclosure to these embodiments. Features disclosed in one specific embodiment are not limited to that embodiment, but can be combined with features disclosed in different embodiments. For example, one or more features and / or operations of the method according to this application described in one embodiment can also be applied individually, in combination, or in whole in another embodiment. Those skilled in the art will understand that there are many more possible alternative implementations and variations, and various changes and modifications can be made to the above system without departing from the scope defined by the claims of this application.
Claims
1. An image color correction method, characterized in that, include: Acquire a target image containing multiple color blocks captured by the target device, and extract the CIE Lab color data of each color block in the target image; Acquire a source image containing multiple color patches from the device to be debugged and convert it to the CIE Lab color space; The luminance component of the source image in the CIE Lab color space is segmented and corrected to obtain corrected CIE Lab color data; Based on the corrected CIE Lab color data, multiple corrected CIE Lab color data corresponding to multiple candidate color correction matrices are determined. Based on the CIE Lab color data of the target image and multiple corrected CIE Lab color data of the source image, calculate multiple color differences between the source image and the target image; as well as The candidate color correction matrix corresponding to the minimum color difference is determined as the target color correction matrix; The target image and the source image correspond to the same photographed object.
2. The image color correction method according to claim 1, characterized in that, The plurality of color blocks includes at least one colored color block and at least two neutral color blocks.
3. The image color correction method according to claim 1, characterized in that, The step of determining multiple corrected CIE Lab color data corresponding to multiple candidate color correction matrices based on the corrected CIE Lab color data includes: Obtain the RGB color data of each color patch in the source image corresponding to the corrected CIE Lab color data; Multiple candidate color correction matrices are applied to the RGB color data respectively to obtain multiple corrected RGB color data; and The multiple corrected RGB color data are converted to the CIE Lab color space to obtain the multiple corrected CIE Lab color data.
4. The image color correction method according to claim 1, characterized in that, After acquiring the source image containing multiple color blocks collected by the device to be debugged, the method further includes: performing white balance correction on the source image.
5. The image color correction method according to claim 1, characterized in that, After acquiring the target image containing multiple color blocks from the target device, the process also includes: adjusting the color parameters of the acquired target image to generate the target color main tone style.
6. The image color correction method according to claim 1, characterized in that, The extraction of CIE Lab color data for each color patch in the target image includes: Obtain the RGB color data of each color block in the target image; Perform a degamma operation on the RGB color data to obtain degamma RGB color data; The degamma RGB color data is converted from the RGB color space to the CIE Lab color space to obtain the CIE Lab color data of each color block in the target image.
7. The image color correction method according to claim 6, characterized in that, The degamma operation is the inverse operation of the gamma operation, and the degamma operation processes the RGB color data based on a preset gamma value.
8. The image color correction method according to claim 3, characterized in that, After white balance correction of the source image, the method further includes performing gamma demapping on each color block of the white balance corrected source image.
9. The image color correction method according to claim 1, characterized in that, The process of acquiring a source image containing multiple color blocks from the device under test includes: when acquiring the source image, turning off white balance gain, color correction matrix processing, and / or gamma curve correction processing on the device under test.
10. The image color correction method according to claim 1, characterized in that, The segmented correction of the luminance component of the source image in the CIELab color space includes: Based on the luminance components of multiple neutral color patches in the source image and the corresponding luminance components of neutral color patches in the target image, luminance correction coefficients for multiple luminance ranges are determined; wherein, the luminance correction coefficient is the ratio of the luminance component of the target image to the luminance component of the source image, or an interpolation result determined based on the ratio; and The CIE Lab color data of the source image is segmented according to the multiple brightness ranges. The brightness component of the color block in each brightness range is multiplied by the corresponding brightness correction coefficient to obtain the corrected CIE Lab color data.
11. The image color correction method according to claim 1, characterized in that, The calculation of multiple color differences between the source image and the target image includes: Based on the CIE Lab color data of each color block in the target image and the corrected CIE Lab color data of each color block in the source image, the color difference between the corresponding color blocks is calculated using a preset color difference calculation formula to obtain at least one color difference. The at least one color difference is weighted and averaged according to a preset weight to obtain the total color difference used to characterize the overall color difference between the source image and the target image.
12. The image color correction method according to claim 11, characterized in that, The step of determining the candidate color correction matrix corresponding to the minimum color difference as the target color correction matrix includes: The total color difference between the source image and the target image is used as the loss function, and an optimization algorithm is used to iteratively update the matrix parameters of the candidate color correction matrix to obtain the target color correction matrix that minimizes the loss function. The optimization algorithm is either the least squares method or the gradient descent method.
13. A non-volatile computer-readable storage medium, characterized in that, The device contains a computer program that, when executed by a processor, implements the method of any one of claims 1 to 12.
14. A computer program product, characterized in that, The computer program product includes computer instructions that, when executed by a processor, implement the method as described in any one of claims 1 to 12.
15. An electronic device, characterized in that, The electronic device includes: a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the computer instructions, when executed by the processor, implement the method according to any one of claims 1 to 12.