Self-adaptive color correction method and system

Through the adaptive color correction method, the 24 color card images are used to calibrate and calculate the white balance and color correction matrix parameters, solving the problem of unsatisfactory image correction under different light sources, realizing automatic correction, and improving the accuracy and convenience of correction , improves the visual effect of the image.

CN119130870APending Publication Date: 2024-12-13HEFEI JUNDA HI TECH INFORMATION TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411306512.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-19
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

The prior art image color correction and white balance correction effects under different light sources are not ideal, requires a lot of calibration work, is difficult to ensure accuracy, and is unable to achieve automation.

Method used

Adaptive color correction method is adopted to obtain 24 color card images taken by the camera under different light sources for calibration, calculate the white balance parameters and color correction matrix parameters, and realize automated white balance and color correction.

Benefits of technology

It improves parameter calibration efficiency, reduces workload, realizes effective balance correction and color correction in different scenarios, improves the accuracy and applicability of correction, reduces user manual operations, and improves the visual effect of the image.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119130870A_ABST
    Figure CN119130870A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image processing, solves the technical problem that color correction and white balance correction of images under different light sources are not ideal in the prior art, and particularly relates to a self-adaptive color correction method and system. The method comprises the following steps: obtaining a plurality of calibration images obtained by shooting 24 color cards by a camera under different light sources in a color temperature box, and carrying out color calibration on the calibration images to obtain calibration parameters under different light sources; acquiring an image shot by a camera in any scene, and performing demosaicing processing to generate an image IMG; calculating a white balance parameter of the image IMG; and calculating color correction matrix parameters of the image IMG according to the calibration parameters. According to the method, the parameter calibration efficiency can be improved, the workload is reduced, effective balance correction and color correction in different scenes are realized, and automatic balance correction and color correction are realized, so that the manual operation of a user is reduced, and the use convenience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to an adaptive color correction method and system. Background Art

[0002] The human eye has the ability to compensate for different light sources in the scene, that is, it can distinguish white under any light source. This ability is called color constancy. Cameras do not have this feature, and images taken under different light sources will have color casts, which requires white balance to solve this problem. The deviation between the spectral response of the camera sensor and the human eye causes a deviation between the photos taken and what the human eye sees. The color needs to be further corrected through the color correction matrix to restore the actual scene as much as possible.

[0003] Existing color correction and white balance correction technologies mainly pre-process the image and then use some preset parameters or algorithms for correction. For example, color correction can be performed by using some preset color correction parameters and white balance parameters under standard light sources, and then using a certain algorithm to calculate the color correction parameters and white balance parameters under the current light source.

[0004] There are some problems with the existing technologies. First, these technologies often require the preset of some fixed parameters, which requires a lot of calibration work under different light sources, which is not only labor-intensive but also difficult to ensure the accuracy of the calibration. Secondly, these existing technologies can often only calibrate specific light sources, and for unknown light sources, the calibration effect may not be ideal. In addition, most of the existing automatic color correction methods and devices require manual intervention and cannot achieve true automation. Summary of the invention

[0005] In view of the deficiencies of the prior art, the present invention provides an adaptive color correction method and system, which solves the technical problem of the prior art in that color correction and white balance correction of images under different light sources are not ideal.

[0006] To solve the above technical problems, the present invention provides the following technical solution: an adaptive color correction method, the method comprising the following steps:

[0007] S1, obtaining a plurality of calibration images obtained by shooting 24 color cards under different light sources in a color temperature box by a camera, and performing color calibration on the calibration images to obtain calibration parameters under different light sources;

[0008] S2, obtaining an image taken by a camera in any scene, and performing a demosaicing process to generate an image IMG;

[0009] S3, calculating the white balance parameters of the image IMG;

[0010] S4, calculating the color correction matrix parameters of the image IMG according to the calibration parameters;

[0011] S5. Perform white balance correction and color correction on the image IMG using white balance parameters and color correction matrix parameters to obtain a corrected image IMG`.

[0012] Furthermore, in step S1 , the calibration parameters include chromaticity parameters U, V, color correction matrix parameters CCM and color temperature parameters T.

[0013] Furthermore, in step S1, the specific process includes the following steps:

[0014] S11, obtain multiple images of 24 color cards taken by the camera under different light sources including low, medium and high color temperatures in the color temperature box, and obtain a calibration image Img=[Img 1 , Img 2 ,…,Img num ], num≥3, and use a color temperature meter to measure the color temperature parameters of the light source and record it as T=[T 1 , T 2 ,…,T mun ];

[0015] S12, automatically detect and identify the 24 color blocks of the calibration image Img, and calculate the R, G, and B mean values ​​of each color block, where:

[0016] R=[R 1 , R 2 , …, R m ]

[0017] G=[G 1 , G 2 , …, G m ]

[0018] B=[B 1 , B 2 , …, B m ]

[0019] Wherein, m=24;

[0020] S13, calculate the mean values ​​Rmean, Gmean, Bmean of R, G, B of color blocks 20-23, and convert them into chromaticity in the CIE UCS system to obtain chromaticity parameters u, v, where:

[0021] Rmean=(R 20 +R 21 +R 22 +R 23 ) / 4

[0022] Gmean=(G20 +G 21 +G 22 +G 23 ) / 4

[0023] Bmean=(B 20 +B 21 +B 22 +B 23 ) / 4

[0024] The conversion formula of chromaticity parameters u and v is:

[0025]

[0026]

[0027] In the formula, X, Y, and Z represent the image data converted from RGB space to XYZ space respectively;

[0028] S14, determining a color correction matrix M' according to the relationship between the color information R', G', B' of the color blocks of the standard color card 24 and the mean values ​​of R, G, B;

[0029] S15, repeating steps S12-S14, calibrating the chromaticity parameters and the color correction matrix under different color temperature parameters to obtain calibration parameters, namely:

[0030] U=[u 1 ,u 2 ,…,u num ]

[0031] V=[v 1 , v 2 , …, v num ]

[0032] CCM=[M` 1 , M` 2 ,…,M` num ]

[0033] Where U and V represent the chromaticity parameters under different color temperature parameters T; CCM represents the color correction matrix under different color temperature parameters T.

[0034] Further, in step S14, the relationship between the color information R', G', B' of the color block of the standard color card 24 and the mean values ​​of R, G, B is:

[0035]

[0036] Among them, i and j are the row and column where the color block is located, i = 1, 2, 3, 4, j = 1, 2, 3, 4, 5, 6;

[0037] The color correction matrix M' is calculated using the least squares method, and we get:

[0038]

[0039] in,

[0040] m 00 +m 01 +m 02 =1

[0041] m 10 +m 11 +m 12 =1

[0042] m 20 +m 21 +m 22 =1

[0043] In the formula, m 00 、m 01 、m 02 ;m 10 、m 11 、m 12 ;m 20 、m 21 、m 22 They are the 9 values ​​after normalization constraints in the color correction matrix M`.

[0044] Furthermore, in step S3, the specific process includes the following steps:

[0045] S31, using the gray world method to calculate the initial white balance parameters Rgain0, Ggain0, Bgain0 of the image IMG, and performing white balance correction to obtain a corrected image I;

[0046] S32, let the red channel gain parameter of the corrected image I=[r, g, b] be rg, and the blue channel gain parameter be bg, and convert the corrected image I from the RGB space to the YCbCr space to obtain an image I_YCbCr=[Y 0 , Cb 0 ,Cr 0 ], the conversion formula is:

[0047]

[0048] Wherein, i represents the row where the pixel is located, i=1, 2, ..., p; j represents the column where the pixel is located, j=1, 2, ..., q;

[0049] S33, filter all gray pixels in the image I_YCbCr and calculate the chromaticity mean Cb 0 and Cr 0 ;

[0050] S34, create an objective function f(rg, bg) with gain parameters rg and bg as optimization solution parameters, that is:

[0051]

[0052] Where Cb(rg, bg) and Cr(rg, bg) represent the chromaticity mean Cb under the gain parameters rg and bg assignments respectively. 0 and Cr 0 ; f(·) represents the color difference of gray pixels;

[0053] S35, using the Lagarias simplex search method to iteratively calculate and solve the minimum value of the objective function f(rg, bg) to obtain the gain parameters rg and bg corresponding to the minimum gray pixel color difference;

[0054] S36, calculating the white balance parameters of the image IMG according to the gain parameters rg and bg, that is:

[0055] Rgain=Rgain0*rg

[0056] Ggain=Ggain0*1

[0057] Bgain=Bgain0*bg

[0058] Where Rgain0, Ggain0, and Bgain0 are the initial white balance parameters of the image IMG.

[0059] Furthermore, in step S33, gray pixels are screened to satisfy the following formula:

[0060]

[0061] Chroma mean Cb 0 and Cr 0 The calculation formula is:

[0062]

[0063]

[0064] In the formula, Mask ij Represents the gray pixels obtained after screening; α is the constraint condition for screening gray pixels, and the default value is 10.

[0065] Furthermore, in step S4, the specific process includes the following steps:

[0066] S41, the gray value (R X , G X , B X) is converted to chromaticity parameters (u X , v X ), and calculate the chromaticity parameters (u X , v X ) and the minimum distance d between the chromaticity parameters (U, V) num ;

[0067]

[0068] d=min(d 1 , d 2 , …, d num )

[0069] In the formula, u num 、v num represents the chromaticity parameters calibrated under different color temperatures, corresponding to the color temperature parameters [T 1 , T 2 ,…,T mun ];

[0070] S42, let the minimum distance d num The corresponding chromaticity parameter u num 、v num Denoted as u c 、v c , is the color temperature parameter T of group c c The chromaticity parameter under the temperature measurement parameter T c-1 and T c+1 Calculate the correlated color temperature T of the test light source ij ;

[0071]

[0072] in,

[0073]

[0074]

[0075] Where, d c-1 ,d c+1 Respectively represent the color temperature parameters T of the c-1 and c+1 groups c The minimum distance under c+1 、u c-1 and v c+1 、v c-1 Respectively represent the color temperature parameters T of the c-1 and c+1 groups c The chromaticity parameters below;

[0076] S43, repeat steps S41-S42 to traverse all pixels in the image IMG, and obtain the correlated color temperature T of all pixels. all =[T11 , T 12 , T 13 ,…,T ij ];

[0077] S44, Correlated color temperature T all The average value is calculated as the current color temperature parameter T in this scene. Z ;

[0078] S45, using the interpolation approximation formula to calculate the current color temperature parameter T Z The color correction matrix parameters M are as follows:

[0079] M=ω*M` a +(1-ω)*M` b

[0080] in,

[0081]

[0082] Where, T a , T b Indicates that it contains the current color temperature parameter T Z The upper and lower limits of the minimum color temperature range; M` a , M` b Respectively represent the color temperature parameter T a , T b The color correction matrix below.

[0083] Furthermore, in step S5, the correction formula is:

[0084]

[0085] Where Rgain, Ggain, and Bgain are the white balance parameters of the image IMG; M is the color correction matrix parameter; IMG_R ij 、IMG_G ij 、IMG_B ij Respectively represent the grayscale values ​​of the R, G, and B channels of the image IMG; IMG_R` ij 、IMG_G` ij 、IMG_B` ij Respectively represent the grayscale values ​​of the R, G, and B channels of the image IMG`.

[0086] By means of the above technical solution, the present invention provides an adaptive color correction method and system, which has at least the following beneficial effects:

[0087] 1. The adaptive color correction method proposed in the present invention can improve the efficiency of parameter calibration, reduce workload, and realize effective balance correction and color correction in different scenes, and realize automatic balance correction and color correction to reduce the user's manual operation and improve the convenience of use.

[0088] 2. The present invention can quickly complete parameter calibration, improve calibration efficiency, and perform adaptive color correction and white balance correction according to the actual environment and equipment, thereby improving the accuracy and applicability of the correction, thereby improving the visual effect of the image and making the image closer to the visual perception of the human eye. BRIEF DESCRIPTION OF THE DRAWINGS

[0089] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0090] Figure 1 is a flow chart of the adaptive color correction method of the present invention;

[0091] Figure 2 It is a principle block diagram of the adaptive color correction system of the present invention. DETAILED DESCRIPTION

[0092] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific implementation methods, so that the implementation process of how the present application uses technical means to solve technical problems and achieve technical effects can be fully understood and implemented accordingly.

[0093] This embodiment addresses the technical deficiencies of how to quickly calibrate parameters under different light sources and devices; how to effectively perform white balance correction and color correction for unknown light sources; and how to achieve automatic color correction and white balance correction. Please refer to Figure 1-Figure 2 This embodiment proposes an adaptive color correction method and system, which can improve the parameter calibration efficiency, reduce the workload, realize effective balance correction and color correction in different scenes, and realize automatic balance correction and color correction, so as to reduce the manual operation of the user and improve the convenience of use. The adaptive color correction method includes the following steps:

[0094] S1, obtaining a plurality of calibration images obtained by shooting 24 color cards under different light sources in a color temperature box by a camera, and color calibrating the calibration images to obtain calibration parameters under different light sources; the calibration parameters include chromaticity parameters U, V, color correction matrix parameters CCM and color temperature parameters T; in step S1, the specific process includes the following steps:

[0095] S11, obtain multiple images of 24 color cards taken by the camera under different light sources including low, medium and high color temperatures in the color temperature box, and obtain a calibration image Img=[Img 1 , Img 2 ,…,Img num ], num≥3, and use a color temperature meter to measure the color temperature parameters of the light source and record it as T=[T 1 , T 2 ,…,T mun ];

[0096] S12, automatically detect and identify the 24 color blocks of the calibration image Img, and calculate the R, G, and B mean values ​​of each color block, where:

[0097] R=[R 1 , R 2 , …, R m ]

[0098] G=[G 1 , G 2 , …, G m ]

[0099] B=[B 1 , B 2 , …, B m ]

[0100] Wherein, m=24;

[0101] S13, calculate the mean values ​​Rmean, Gmean, Bmean of R, G, B of the color blocks 20-23, and convert them into the chromaticity in the CIE UCS (Uniform Chromaticity Scale) system to obtain chromaticity parameters u and v, where:

[0102] Rmean=(R 20 +R 21 +R 22 +R 23 ) / 4

[0103] Gmean=(G 20 +G 21 +G 22 +G 23 ) / 4

[0104] Bmean=(B 20 +B 21 +B 22 +B 23 ) / 4

[0105] The conversion formula of chromaticity parameters u and v is:

[0106]

[0107]

[0108] In the formula, X, Y, and Z represent the image data converted from RGB space to XYZ space respectively. The conversion formula is:

[0109]

[0110] The above conversion formula is a conventional conversion formula in the prior art, and therefore is only disclosed and will not be described in detail.

[0111] S14, determine the color correction matrix M' according to the relationship between the color information R', G', B' of the color block of the standard color card 24 and the mean values ​​of R, G, B, that is:

[0112]

[0113] Among them, i and j are the row and column where the color block is located, i = 1, 2, 3, 4, j = 1, 2, 3, 4, 5, 6;

[0114] The color correction matrix M' is calculated using the least squares method, and we get:

[0115]

[0116] in,

[0117] m 00 +m 01 +m 02 =1

[0118] m 10 +m 11 +m 12 =1

[0119] m 20 +m 21 +m 22 =1

[0120] In the formula, m 00 、m 01 、m 02 ;m 10 、m 11 、m 12 ;m 20 、m 21 、m 22 They are the 9 values ​​after normalization constraints in the color correction matrix M`.

[0121] S15, repeating steps S12-S14, calibrating the chromaticity parameters and the color correction matrix under different color temperature parameters to obtain calibration parameters, namely:

[0122] U=[u 1 ,u 2 ,…,u num ]

[0123] V=[v 1 , v 2 , …, v num ]

[0124] CCM=[M` 1 , M` 2 ,…,M` num ]

[0125] Where U and V represent the chromaticity parameters under different color temperature parameters T; CCM represents the color correction matrix under different color temperature parameters T.

[0126] In this embodiment, the calibration parameters finally obtained are saved in the color calibration module for subsequent operations. For a certain camera, the S11-S16 process in the color calibration module only needs to be performed once.

[0127] S2. Obtain an image taken by a camera in any scene, and perform a demosaicing process to generate an image IMG. In this embodiment, since the image taken by the camera is generally a bayer data image, the bayer data image is interpolated into an RGB image through a demosaicing process, and the interpolation algorithm can use bilinear interpolation, high-quality linear interpolation, adaptive interpolation, etc.

[0128] S3, calculating the white balance parameters of the image IMG; in step S3, the specific process includes the following steps:

[0129] S31, using the gray world method to calculate the initial white balance parameters Rgain0, Ggain0, Bgain0 of the image IMG, and performing white balance correction to obtain a corrected image I;

[0130] S32, let the red channel gain parameter of the corrected image I=[r, g, b] be rg, and the blue channel gain parameter be bg, and convert the corrected image I from the RGB space to the YCbCr space to obtain an image I_YCbCr=[Y 0 , Cb 0 ,Cr 0 ], the conversion formula is:

[0131]

[0132] Wherein, i represents the row where the pixel is located, i=1, 2, ..., p; j represents the column where the pixel is located, j=1, 2, ..., q;

[0133] S33, filter all gray pixels in the image I_YCbCr and calculate the chromaticity mean Cb 0 and Cr 0 , where the gray pixels are selected to satisfy the following formula:

[0134]

[0135] Chroma mean Cb 0 and Cr 0 The calculation formula is:

[0136]

[0137]

[0138] In the formula, Mask ij Represents the gray pixels obtained after screening; α is the constraint condition for screening gray pixels, and the default value is 10;

[0139] S34, create an objective function f(rg, bg) with gain parameters rg and bg as optimization solution parameters, that is:

[0140]

[0141] Where Cb(rg, bg) and Cr(rg, bg) represent the chromaticity mean Cb under the gain parameters rg and bg assignments respectively. 0 and Cr 0 ; f(·) represents the color difference of gray pixels;

[0142] S35, using the Lagarias simplex search method to iteratively calculate and solve the minimum value of the objective function f(rg, bg) to obtain the gain parameters rg and bg corresponding to the minimum gray pixel color difference;

[0143] S36, calculating the white balance parameters of the image IMG according to the gain parameters rg and bg, that is:

[0144] Rgain=Rgain0*rg

[0145] Ggain=Ggain0*1

[0146] Bgain=Bgain0*bg

[0147] Where Rgain0, Ggain0, and Bgain0 are the initial white balance parameters of the image IMG.

[0148] S4, calculating the color correction matrix parameters of the image IMG according to the calibration parameters; in step S4, the specific process includes the following steps:

[0149] S41, the gray value (RX, G X , B X ) is converted to chromaticity parameters (u X , vX), and calculate the chromaticity parameters (u X , v X ) and the minimum distance d between the chromaticity parameters (U, V) num ;

[0150]

[0151] d=min(d 1 , d 2 , …, d num )

[0152] In the formula, u num 、v num represents the chromaticity parameters calibrated under different color temperatures, corresponding to the color temperature parameters [T 1 , T 2 ,…,T mun ], as shown in step S15.

[0153] S42, let the minimum distance d num The corresponding chromaticity parameter u num 、v num Denoted as u c 、v c , is the color temperature parameter T of group c c The chromaticity parameter under the temperature measurement parameter T c-1 and T c+1 Calculate the correlated color temperature T of the test light source ij ;

[0154]

[0155] in,

[0156]

[0157]

[0158] Where, d c-1 ,d c+1 Respectively represent the color temperature parameters T of the c-1 and c+1 groups c The minimum distance under c+1 、u c-1 and v c+1 、v c-1Respectively represent the color temperature parameters T of the c-1 and c+1 groups c The chromaticity parameters below;

[0159] S43, repeat steps S41-S42 to traverse all pixels in the image IMG, and obtain the correlated color temperature T of all pixels. all =[T 11 , T 12 , T 13 ,…,T ij ];

[0160] S44, Correlated color temperature T all The average value is calculated as the current color temperature parameter T in this scene. Z ;

[0161] S45, using the interpolation approximation formula to calculate the current color temperature parameter T Z The color correction matrix parameters M are as follows:

[0162] M=ω*M` a +(1-ω)*M` b

[0163] in,

[0164]

[0165] Where, T a , T b Indicates that it contains the current color temperature parameter T Z In this embodiment, since the color temperature parameter T=[T 1 , T 2 ,…,T mun ] is increased sequentially, so it can be based on the current color temperature parameter T Z Determine the two adjacent color temperature parameters T a , T b The value of M` a , M` b Respectively represent the color temperature parameter T a , T b The color correction matrix below is shown as CCM in step S15.

[0166] S5. Use white balance parameters and color correction matrix parameters to perform white balance correction and color correction on the image IMG to obtain a corrected image IMG`. The correction formula is:

[0167]

[0168] Where Rgain, Ggain, and Bgain are the white balance parameters of the image IMG; M is the color correction matrix parameter; IMG_Rij 、IMG_G ij 、IMG_B ij Respectively represent the grayscale values ​​of the R, G, and B channels of the image IMG; IMG-R` ij 、IMG_G` ij 、IMG-B` ij Respectively represent the grayscale values ​​of the R, G, and B channels of the image IMG`.

[0169] Please refer to Figure 2 This embodiment also proposes an adaptive color correction system, which is composed of a camera and a PC. The camera includes a transmission module for outputting the original Bayer data image taken by the camera and transmitting it to the PC. The PC includes a color calibration module, a demosaicing module, an adaptive white balance module, an adaptive color correction module and an output module, wherein:

[0170] The color calibration module is used to automatically calibrate the calibration parameters under different light sources and store the calibration parameters; the de-mosaicing module is used for image de-mosaicing, interpolating the Bayer data map into an RGB map, and the interpolation algorithm can be any of bilinear interpolation, high-quality linear interpolation, and adaptive interpolation; the adaptive white balance module is used to calculate the white balance parameters of images of different scenes; the adaptive color correction module calculates the color correction matrix parameters of images of different scenes according to the calibration parameters in the color calibration module; the output module outputs an image close to the visual perception of the human eye according to the white balance parameters and the color correction matrix parameters. In this embodiment, the specific process is as follows:

[0171] Parameter calibration: Automatically identify 24 color blocks of the calibration image to quickly calibrate and store parameters;

[0172] Adaptive white balance correction: Adaptive white balance correction is performed by minimizing the color difference of gray pixels in the image to correct the color imbalance caused by light source changes;

[0173] Color temperature estimation and adaptive correction of color correction matrix: The color temperature is estimated through the pre-calibrated parameters, and the color correction matrix is ​​automatically corrected using the interpolation formula to further improve the visual effect of the image;

[0174] Automated color correction and white balance correction: Utilize the combination of camera and PC to realize automatic color correction and white balance correction without manual operation by the user.

[0175] This embodiment can quickly complete parameter calibration, improve calibration efficiency, and perform adaptive color correction and white balance correction according to the actual environment and equipment, thereby improving the accuracy and applicability of the correction. At the same time, the automatic operation reduces user operations and improves the convenience of use, thereby improving the visual effect of the image and making the image closer to the visual experience of the human eye.

[0176] Those skilled in the art can understand that all or part of the steps in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a program, so the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0177] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the above embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0178] The above implementation methods have been described in detail. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. An adaptive color correction method, characterized in that: The method comprises the following steps: S1, obtaining a plurality of calibration images obtained by shooting 24 color cards under different light sources in a color temperature box by a camera, and performing color calibration on the calibration images to obtain calibration parameters under different light sources; S2, obtaining an image taken by a camera in any scene, and performing a demosaicing process to generate an image IMG; S3, calculating the white balance parameters of the image IMG; S4, calculating the color correction matrix parameters of the image IMG according to the calibration parameters; S5. Perform white balance correction and color correction on the image IMG using white balance parameters and color correction matrix parameters to obtain a corrected image IMG`.

2. The adaptive color correction method according to claim 1, characterized in that: In step S1 , the calibration parameters include chromaticity parameters U, V, color correction matrix parameter CCM and color temperature parameter T.

3. The adaptive color correction method according to claim 1, characterized in that: In step S1, the specific process includes the following steps: S11, obtain multiple images of 24 color cards taken by the camera under different light sources including low, medium and high color temperatures in the color temperature box, and obtain calibration images Img=Img1,Img2,…,Img after de-mosaicing num ],num≥3, and use a color temperature meter to measure the color temperature parameters of the light source and record them as T=[T1,T2,…,T mun ]; S12, automatically detect and identify the 24 color blocks of the calibration image Img, and calculate the R, G, and B mean values ​​of each color block, where: R=[R1,R2,…,R m ] G=[G1,G2,…,G m ] B=[B1,B2,…,B m ] Wherein, m=24; S13, calculate the mean values ​​Rmean, Gmean, Bmean of R, G, B of color blocks 20-23, and convert them into chromaticity in the CIE UCS system to obtain chromaticity parameters u, v, where: Rmean=(R 20 +R 21 +R 22 +R 23 ) / 4 Gmean=(G 20 +G 21 +G 22 +G 23 ) / 4 Bmean=(B 20 +B 21 +B 22 +B 23 ) / 4 The conversion formula of chromaticity parameters u and v is: In the formula, X, Y, and Z represent the image data converted from RGB space to XYZ space respectively; S14, determining a color correction matrix M' according to the relationship between the color information R', G', B' of the color blocks of the standard color card 24 and the mean values ​​of R, G, B; S15, repeating steps S12-S14, calibrating the chromaticity parameters and the color correction matrix under different color temperature parameters to obtain calibration parameters, namely: U=[u1,u2,…,u num ] V=[v1,v2,…,v num ] CCM=[M`1,M`2,…,M` num ] Where U and V represent the chromaticity parameters under different color temperature parameters T; CCM represents the color correction matrix under different color temperature parameters T.

4. The adaptive color correction method according to claim 3, characterized in that: In step S14, the relationship between the color information R', G', B' of the color block of the standard color card 24 and the mean values ​​of R, G, B is: Among them, i and j are the row and column where the color block is located, i = 1, 2, 3, 4, j = 1, 2, 3, 4, 5, 6; The color correction matrix M' is calculated using the least squares method, and we get: in, m 00 +m 01 +m 02 =1 m 10 +m 11 +m 12 =1 m 20 +m 21 +m 22 =1 In the formula, m 00 、m 01 、m 02 ;m 10 、m 11 、m 12 ;m 20 、m 21 、m 22 They are the 9 values ​​after normalization constraints in the color correction matrix M`.

5. The adaptive color correction method according to claim 1, characterized in that: In step S3, the specific process includes the following steps: S31, using the gray world method to calculate the initial white balance parameters Rgain0, Ggain0, Bgain0 of the image IMG, and performing white balance correction to obtain a corrected image I; S32, let the red channel gain parameter of the corrected image I = [r, g, b] be rg, and the blue channel gain parameter be bg, and convert the corrected image I from the RGB space to the YCbCr space to obtain an image I_YCbCr = [Y0, Cb0, Cr0], and the conversion formula is: Where i represents the row where the pixel is located, i=1,2,…,p; j represents the column where the pixel is located, j=1,2,…,q; S33, filter all gray pixels in the image I_YCbCr and calculate the chromaticity mean values ​​Cb0 and Cr0; S34, create an objective function f(rg,bg) with gain parameters rg and bg as optimization solution parameters, that is: Where, Cb(rg,bg) and Cr(rg,bg) represent the chromaticity mean values ​​Cb0 and Cr0 under the assignment of gain parameters rg and bg respectively; f(·) represents the color difference of gray pixels; S35, using the Lagarias simplex search method to continuously iterate and calculate the minimum value of the objective function f(rg,bg) to obtain the gain parameters rg and bg corresponding to the minimum gray pixel color difference; S36, calculating the white balance parameters of the image IMG according to the gain parameters rg and bg, that is: Rgain=Rgain0*rg Ggain=Ggain0*1 Bgain=Bgain0*bg Where Rgain0, Ggain0, and Bgain0 are the initial white balance parameters of the image IMG.

6. The adaptive color correction method according to claim 5, characterized in that: In step S33, gray pixels are screened to satisfy the following formula: The calculation formula for the chromaticity mean Cb0 and Cr0 is: In the formula, Mask ij Represents the gray pixels obtained after screening; α is the constraint condition for screening gray pixels, and the default value is 10.

7. The adaptive color correction method according to claim 1, characterized in that: In step S4, the specific process includes the following steps: S41, the gray value (R X ,G X ,B X ) is converted to chromaticity parameters (u X ,v X ), and calculate the chromaticity parameters (u X ,v X ) and the minimum distance d between the chromaticity parameters (U, V) num ; d=min(d1,d2,…,d num ) In the formula, u num 、v num represents the chromaticity parameters calibrated under different color temperatures, corresponding to the color temperature parameters [T1, T2, …, T mun ]; S42, let the minimum distance d num The corresponding chromaticity parameter u num 、v num Denoted as u c 、v c , is the color temperature parameter T of group c c The chromaticity parameter under the temperature measurement parameter T c-1 and T c+1 Calculate the correlated color temperature T of the test light source ij ; in, Where, d c-1 d c+1 Respectively represent the color temperature parameters T of the c-1 and c+1 groups c The minimum distance under c+1 、u c-1 and v c+1 、v c-1 Respectively represent the color temperature parameters T of the c-1 and c+1 groups c The chromaticity parameters below; S43, repeat steps S41-S42 to traverse all pixels in the image IMG, and obtain the correlated color temperature T of all pixels. all =[T 11 ,T 12 ,T 13 ,…,T ij ]; S44, correlated color temperature T all The average value is calculated as the current color temperature parameter T in this scene. Z ; S45, using the interpolation approximation formula to calculate the current color temperature parameter T Z The color correction matrix parameters M are as follows: M=ω*M` a +(1-ω)*M` b in, Where, T a , T b Indicates that it contains the current color temperature parameter T Z The upper and lower limits of the minimum color temperature range; M` a , M` b Respectively represent the color temperature parameter T a , T b The color correction matrix below.

8. The adaptive color correction method according to claim 1, characterized in that: In step S5, the correction formula is: Where Rgain, Ggain, and Bgain are the white balance parameters of the image IMG; M is the color correction matrix parameter; IMG_R ij 、IMG_G ij 、IMG_B ij Respectively represent the grayscale values ​​of the R, G, and B channels of the image IMG; IMG_R` ij 、IMG_G` ij 、IMG_B` ij Respectively represent the grayscale values ​​of the R, G, and B channels of the image IMG`.

9. A system for implementing the adaptive color correction method according to any one of claims 1 to 8, characterized in that: The system consists of a camera and a PC. The camera includes a transmission module for outputting the original bayer data image taken by the camera and transmitting it to the PC. The PC includes a color calibration module, a demosaicing module, an adaptive white balance module, an adaptive color correction module and an output module.

10. The system according to claim 9, characterized in that Said: The color calibration module is used to automatically calibrate the calibration parameters under different light sources and store the calibration parameters; The demosaicing module is used for image demosaicing, interpolating the Bayer data map into an RGB map. The interpolation algorithm can be any of bilinear interpolation, high-quality linear interpolation, and adaptive interpolation. The adaptive white balance module is used to calculate white balance parameters for images of different scenes; The adaptive color correction module calculates the color correction matrix parameters for images of different scenes according to the calibration parameters in the color calibration module; The output module outputs an image close to the visual perception of the human eye based on white balance parameters and color correction matrix parameters.

Citation Information

Cited By

  • Material surface color difference detection method based on image processing

    CN119887639A