Image color correction method, correction device, and readable storage medium

By constructing a coefficient matrix in the camera device and dynamically adjusting the color correction matrix using the magnification and gain values, the problem of image color quality loss caused by magnification and gain changes is solved, and the image color is improved.

CN115205140BActive Publication Date: 2025-10-21ZHEJIANG DAHUA TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210672443.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-13
Publication Date
2025-10-21
Estimated Expiration
2042-06-13

AI Technical Summary

Technical Problem

In the prior art, changes in magnification and gain of camera equipment lead to loss of image color quality, especially problems of contrast change and color noise change.

Method used

By obtaining the magnification value and gain value of the camera device, a coefficient matrix is ​​constructed, and the current color correction matrix is ​​calculated using the reference color correction matrix. The color correction matrix is ​​dynamically adjusted to improve the image color quality.

Benefits of technology

It effectively solves the contrast and color noise changes caused by magnification and gain changes, and improves the color quality of the image.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115205140B_ABST
    Figure CN115205140B_ABST
Patent Text Reader

Abstract

The application discloses an image color correction method, a color correction device and a readable storage medium. The method comprises the following steps: acquiring a to-be-processed image photographed by a current camera device and related parameters of the camera device, wherein the related parameters comprise a current magnification value and a current gain value; constructing a coefficient matrix based on the current magnification value and the current gain value; multiplying the coefficient matrix and a reference color correction matrix to generate a current color correction matrix; and correcting the to-be-processed image based on the current color correction matrix to generate a color correction image. In this way, the application can improve the color quality of an image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of video surveillance technology, and in particular to an image color correction method, a color correction device, and a readable storage medium. Background Art

[0002] With the advancement of security technology, improving video image quality is becoming increasingly important. Color, as the most crucial component of image quality, has become a crucial factor in user evaluations of videos. The most commonly used method for video color processing is the color correction matrix (CCM). This method corrects for differences in spectral response between sensors and the human eye, making video images more closely resemble the physical world as seen by the human eye. Furthermore, white-balanced images can exhibit color casts, necessitating a solution to correct the color correction matrix. Summary of the Invention

[0003] The present application provides an image color correction method, a color correction device, and a readable storage medium, which can improve the color quality of an image.

[0004] In order to solve the above technical problems, the technical solution adopted in this application is: to provide an image color correction method, the method comprising: obtaining the image to be processed captured by the current camera device and relevant parameters of the camera device, the relevant parameters including the current magnification value and the current gain value; constructing a coefficient matrix based on the current magnification value and the current gain value; multiplying the coefficient matrix with the reference color correction matrix to generate a current color correction matrix; and correcting the image to be processed based on the current color correction matrix to generate a color-corrected image.

[0005] To solve the above technical problems, another technical solution adopted by the present application is to provide a color correction device, which includes a memory and a processor connected to each other, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, it is used to implement the image color correction method in the above technical solution.

[0006] To solve the above technical problems, another technical solution adopted in this application is: providing a computer-readable storage medium, which is used to store a computer program. When the computer program is executed by a processor, it is used to implement the image color correction method in the above technical solution.

[0007] Through the above scheme, the beneficial effect of the present application is: first obtain the image to be processed captured by the current camera device and the relevant parameters of the camera device, which include the current magnification value and the current gain value; then use the current magnification value and the current gain value to calculate the coefficient matrix; then use the reference color correction matrix and the coefficient matrix to calculate the current color correction matrix; then use the current color correction matrix to correct the image to be processed, thereby realizing color correction of the image to be processed; the present application adopts the method of magnification-linked gain to dynamically adjust the color correction matrix, which solves the problem of contrast changes caused by magnification changes and color noise changes caused by gain changes, thereby causing loss of picture color quality, and can improve the color quality of the image. BRIEF DESCRIPTION OF THE DRAWINGS

[0008] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without inventive efforts. Among them:

[0009] Figure 1 This is a flow chart of an embodiment of the image color correction method provided by the present application;

[0010] Figure 2 This is a flow chart of another embodiment of the image color correction method provided by the present application;

[0011] Figure 3 This is a structural diagram of an embodiment of a color correction device provided by the present application;

[0012] Figure 4 It is a structural diagram of an embodiment of a computer-readable storage medium provided by this application. DETAILED DESCRIPTION

[0013] The present application will be further described in detail below in conjunction with the accompanying drawings and examples. It is particularly noted that the following examples are only intended to illustrate the present application and are not intended to limit the scope of the present application. Similarly, the following examples are only some examples of the present application and not all examples. All other examples obtained by those of ordinary skill in the art without creative work are intended to fall within the scope of protection of this application.

[0014] References to "embodiments" in this application mean that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0015] It should be noted that the terms "first", "second" and "third" in this application are only used for descriptive purposes and should not be understood as indicating or suggesting relative importance or implicitly indicating the number of the indicated technical features. Thus, the features defined as "first", "second" and "third" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units that are inherent to these processes, methods, products or devices.

[0016] The color correction matrix is ​​used to correct color reproduction. In actual use, there may be situations where the color correction matrix needs to be adjusted. For example, due to changes in the magnification of the camera device, different gamma values ​​are loaded, causing changes in color reproduction. In this case, the color correction matrix needs to be dynamically adjusted; or due to changes in the gain of the camera device, the picture noise increases. In order to avoid color noise, the color correction matrix also needs to be dynamically adjusted to reduce color noise. In order to achieve dynamic adjustment of the color correction matrix, this application adopts a new solution, which is described in detail below.

[0017] See also Figure 1 , Figure 1 : is a flow chart of an embodiment of an image color correction method provided by the present application, the method comprising:

[0018] S11: Acquire the image to be processed captured by the current camera device and related parameters of the camera device.

[0019] A camera device is used to shoot the target monitoring scene to obtain the image to be processed at the current moment, or the image to be processed sent by other devices is received, or the image to be processed is read from a storage device; and relevant parameters of the current camera device are obtained, which include a current magnification value and a current gain value. The current magnification value is the magnification of the lens in the current camera device, and the current gain value is the gain of the sensor in the current camera device.

[0020] S12: Construct a coefficient matrix based on the current magnification value and the current gain value.

[0021] After obtaining the current magnification value and the current gain value, the current magnification value and the current gain value can be processed to generate a linkage coefficient. The linkage coefficient is then used to construct a coefficient matrix, which can then be used to perform color correction on the processed image. For example, the linkage coefficient includes the coefficient corresponding to the current magnification value and the coefficient corresponding to the current gain value. The current magnification value and the current gain value are used to construct a 3×3 coefficient matrix. It can be understood that in addition to the coefficient corresponding to the current magnification value and the coefficient corresponding to the current gain value, the linkage coefficient can also set coefficients corresponding to other parameters according to specific application requirements, such as the coefficient corresponding to the brightness value.

[0022] S13: Multiply the coefficient matrix by the reference color correction matrix to generate a current color correction matrix.

[0023] The current color correction matrix can be obtained by multiplying the coefficient matrix with the reference color correction matrix. The current color correction matrix is ​​calculated using the following formula:

[0024] CCM2=A*CCM1 (1)

[0025] Where A is the coefficient matrix, CCM1 is the reference color correction matrix, and CCM2 is the current color correction matrix.

[0026] It can be understood that the reference color correction matrix may be a color correction matrix corresponding to the minimum multiplication value, and the reference color correction matrix is ​​acquired in advance.

[0027] S14: Correct the image to be processed based on the current color correction matrix to generate a color-corrected image.

[0028] After obtaining the current color correction matrix, the pixel values ​​of the image to be processed are multiplied by the current color correction matrix to obtain the pixel values ​​of the corresponding pixels in the color-corrected image.

[0029] In one embodiment, the image to be processed is an RGB image, and the current color correction matrix is ​​a 3*3 matrix. The RGB channel values ​​of the image after color correction (i.e., the color-corrected image) can be obtained by multiplying the current color correction matrix with the RGB channel values ​​of the image to be processed, that is, using the following formula:

[0030]

[0031] Wherein, CMCij is the element value at position (i, j) in the current color correction matrix, 1≤i≤3, 1≤j≤3, and i and j are both integers; Rm is the red channel value of pixel m in the image to be processed, Gm is the green channel value of pixel m, and Bm is the blue channel value of pixel m; Rm' is the red channel value of pixel n in the color-corrected image corresponding to pixel m, Gm' is the green channel value of pixel n, and Bm' is the blue channel value of pixel n.

[0032] This embodiment provides a method for adjusting the color correction matrix of a camera device by linking the magnification and gain. A linkage coefficient is calculated from the two dimensions of magnification and gain. A corresponding coefficient matrix is ​​constructed using the linkage coefficient, and a current color correction matrix is ​​calculated using the coefficient matrix and a reference color correction matrix. The current color correction matrix can be used to correct the processed image. The color correction matrix can be dynamically adjusted, solving the problem of contrast changes caused by magnification changes and color noise changes caused by gain changes, which leads to loss of picture color quality. This helps to improve the color quality of the image.

[0033] See also Figure 2 , Figure 2 FIG. 1 is a flow chart of another embodiment of the image color correction method provided by the present application, the method comprising:

[0034] S21: Acquire the image to be processed captured by the current camera device and relevant parameters of the camera device.

[0035] S21 is the same as S11 in the above embodiment and will not be described in detail here.

[0036] The relevant parameters include the current magnification value and the current gain value. After obtaining the current magnification value and the current gain value, the magnification linkage coefficient is calculated by the current magnification value, and the gain linkage coefficient is calculated by the current gain value. The brightness compensation coefficient is calculated by mixing the current gain, shutter parameters (such as exposure time) and preset target brightness, that is, the linkage coefficient includes the magnification linkage coefficient, the gain linkage coefficient and the brightness compensation coefficient, which are described in detail below.

[0037] S22: Calculate the multiplication linkage coefficient based on the current multiplication value.

[0038] The magnification linkage coefficient is a coefficient that changes dynamically with the magnification. Since variable focal length lenses have the problem of lens contrast decreasing as the magnification increases, contrast compensation can be performed to compensate for the problem of blurred images caused by contrast attenuation at large magnifications. The common means of contrast compensation is to set different gammas, but gamma has an impact on the color module. The standard practice is that one gamma corresponds to one color correction matrix. If the camera equipment switches between several gammas at different magnifications to ensure uniform contrast, the corresponding color correction matrix also needs to be switched accordingly. Furthermore, in order to simplify the calibration of multiple color correction matrices, the color correction matrix that has been calibrated at the minimum magnification value can be used as the reference color correction matrix, and the magnification linkage coefficient can be derived through an algorithm. Then, the magnification linkage coefficient and the reference color correction matrix can be used to obtain the required values ​​at other magnifications.

[0039] In a specific embodiment, first gamma data corresponding to the minimum magnification value of the camera device is obtained; second gamma data corresponding to the current magnification value of the camera device is obtained; and a magnification linkage coefficient is calculated based on the first gamma data and the second gamma data.

[0040] Furthermore, a histogram statistical processing is performed on the image to be processed to obtain histogram statistical information, which is used to represent the distribution of brightness values ​​of pixels in the image to be processed. The histogram statistical information includes the brightness values ​​and brightness quantity of pixels in the image to be processed, where the brightness quantity is the number of brightness values; the maximum value of all brightness quantities in the histogram statistical information is calculated; the first brightness output value is matched with the first gamma data to obtain a brightness input value that matches the first brightness output value, where the first brightness output value is the brightness value corresponding to the maximum value; the brightness input value is matched with the second gamma data to obtain a second brightness output value that matches the brightness input value; the ratio of the second brightness output value to the first brightness output value is calculated to obtain a multiplication linkage coefficient. It can be understood that the scheme for generating histogram statistical information is the same as that in the related art and will not be repeated here.

[0041] In one embodiment, the gamma data at the minimum magnification value (i.e., the first gamma data) is recorded as gammaInit, and the gamma data at the current magnification value (i.e., the second gamma data) is recorded as gammaCur; at the same time, the histogram statistical information of the corresponding scene at the current magnification value is counted, and the brightness value y with the largest number in the histogram statistical information is found, and y is used as the first brightness output value; the input value corresponding to y (i.e., the brightness input value) is reversely looked up in gammaInit, and the brightness input value is recorded as gammaInit_x; then, using gammaInit_x as the input value, its corresponding output value (i.e., the second brightness output value) is found in gammaCur, and it is recorded as gammaCur_y; finally, coff1=gammaCur_y / y is used to calculate the magnification linkage coefficient. Furthermore, the histogram statistics corresponding to the current magnification value represent the brightness distribution of the current scene, and the brightness value with the largest accumulation in the histogram represents the main brightness component of the current scene; the respective input values ​​​​checked from gammaInit and gammaCur are a kind of inverse mapping to compensate for the brightness difference between two different gammas.

[0042] It can be understood that gammaInit and gammaCur are both two-dimensional array data, and their input and output are both brightness, that is, the two-dimensional array data includes multiple brightness values ​​and another brightness value corresponding to the brightness value; the number of elements in the two-dimensional array data can be set according to actual needs and can be any value, such as: 255 or 1024. The more elements, the higher the accuracy of expression.

[0043] This embodiment realizes calculation of the magnification linkage coefficient based on the gamma data before and after the magnification change and the brightness value corresponding to the maximum number in the histogram statistical information.

[0044] S23: Based on the current gain value, a gain linkage coefficient and a brightness compensation coefficient are calculated.

[0045] After obtaining the current gain value, the following scheme can be used to calculate the gain linkage coefficient and brightness compensation coefficient:

[0046] 1) Gain linkage coefficient

[0047] Calculate the difference between the maximum gain value and the current gain value of the camera device; calculate the ratio of the maximum gain value to the difference to obtain the gain linkage coefficient, that is, use the following formula:

[0048] coff2=gainMax / (gainMax-currGain) (3)

[0049] Where currGain represents the current gain value, gainMax represents the maximum gain value supported by the camera device, and the unit of gain can be decibel (dB) or a multiple.

[0050] 2) Brightness compensation coefficient

[0051] A brightness comprehensive value corresponding to a previous magnification value of the imaging device (i.e., the brightness comprehensive value before the magnification change) and a brightness comprehensive value corresponding to a current magnification value of the imaging device (i.e., the brightness comprehensive value after the magnification change) are obtained, respectively, to obtain a first brightness comprehensive value and a second brightness comprehensive value; a ratio of the second brightness comprehensive value to the first brightness comprehensive value is calculated to obtain a brightness compensation coefficient. Specifically, the imaging device includes a shutter, and the calculation of the brightness comprehensive value includes: calculating the product of the shutter exposure time and a gain value to be processed, the gain value to be processed including the gain value of the imaging device before the magnification change or the gain value of the imaging device after the magnification change; and calculating the ratio of the product to a preset target brightness to obtain the brightness comprehensive value, where the preset target brightness is the brightness of the color-corrected image.

[0052] For example, before the camera zooms, the current brightness integrated value L1 is calculated; then the brightness integrated value L2 after the camera zooms is calculated; and then the brightness compensation coefficient is calculated using the following formula:

[0053] coff3=L2 / L1 (4)

[0054] The calculation method of the comprehensive brightness value is as follows:

[0055] L=shut*gain / lumin;

[0056] Where shut is the exposure time, gain is the gain value to be processed, and lumin is the preset target brightness.

[0057] S24: Calculate a coefficient matrix based on the magnification linkage coefficient, the gain linkage coefficient, and the brightness compensation coefficient.

[0058] First, the ratio of the magnification linkage coefficient to the gain linkage coefficient is calculated; then, based on the ratio, the brightness compensation coefficient, and the preset adjustment coefficient, a coefficient matrix is ​​calculated.

[0059] In one embodiment, the preset adjustment coefficients include a red coefficient, a green coefficient, and a blue coefficient. The coefficient matrix can be calculated using the following formula:

[0060] A=[A1;A2;A3] (5)

[0061]

[0062]

[0063]

[0064] Among them, A is the coefficient matrix, cr is the red coefficient, cg is the green coefficient, cb is the blue coefficient, cr+cg+cb=1; coff1 is the magnification linkage coefficient, coff2 is the gain linkage coefficient, and coff3 is the brightness compensation coefficient.

[0065] S25: Multiply the coefficient matrix by the reference color correction matrix to generate a current color correction matrix.

[0066] S26: Correct the image to be processed based on the current color correction matrix to generate a color-corrected image.

[0067] S25 to S26 are the same as S13 to S14 in the above embodiment and will not be described in detail here.

[0068] This embodiment proposes a method for adjusting the color correction matrix of a camera device by linking magnification with gain quantization, which realizes the adjustment of the color correction matrix in two dimensions: magnification change and gain change. It solves the problem of contrast change caused by magnification change and color noise change caused by gain change, which leads to loss of picture color quality, and helps to improve image color quality.

[0069] See also Figure 3 , Figure 3 3 is a structural diagram of an embodiment of a color correction device provided in the present application. The color correction device 30 includes a memory 31 and a processor 32 connected to each other. The memory 31 is used to store a computer program. When the computer program is executed by the processor 32, it is used to implement the image color correction method or gait recognition method in the above-mentioned embodiment.

[0070] See also Figure 4 , Figure 4 This is a structural diagram of an embodiment of a computer-readable storage medium provided in the present application. The computer-readable storage medium 40 is used to store a computer program 41. When the computer program 41 is executed by the processor, it is used to implement the image color correction method or gait recognition method in the above-mentioned embodiment.

[0071] The computer-readable storage medium 40 can be a server, a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc., which can store program codes.

[0072] If the technical solution of this application involves personal information, the product that applies the technical solution of this application has clearly informed the personal information processing rules and obtained the individual's voluntary consent before processing personal information. If the technical solution of this application involves sensitive personal information, the product that applies the technical solution of this application has obtained the individual's separate consent before processing sensitive personal information, and at the same time meets the "explicit consent" requirement. For example, on personal information collection devices such as cameras, a clear and prominent sign is set to inform that the personal information collection scope has been entered and personal information will be collected. If the individual voluntarily enters the collection scope, it is deemed that they agree to the collection of their personal information; or on the personal information processing device, when the personal information processing rules are notified by obvious signs / information, the individual's authorization is obtained through pop-up information or by asking the individual to upload their personal information; among which, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the type of personal information processed.

[0073] In the several embodiments provided in this application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of modules or units is merely a logical functional division. In actual implementation, other division methods may be used. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not implemented.

[0074] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0075] In addition, each functional unit in each embodiment of the present application may be integrated into a processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The above-mentioned integrated units may be implemented in the form of hardware or software functional units.

[0076] The above are merely embodiments of the present application and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A method for image color correction, characterized in that: include: Acquire an image to be processed captured by a current camera device and relevant parameters of the camera device, wherein the relevant parameters include a current magnification value and a current gain value; Constructing a coefficient matrix based on the current magnification value and the current gain value; Multiplying the coefficient matrix by a reference color correction matrix to generate a current color correction matrix; Correcting the image to be processed based on the current color correction matrix to generate a color-corrected image; The step of constructing a coefficient matrix based on the current magnification value and the current gain value includes: Calculating a multiplication linkage coefficient based on the current multiplication value; Calculating a gain linkage coefficient and a brightness compensation coefficient based on the current gain value; Calculating the coefficient matrix based on the magnification linkage coefficient, the gain linkage coefficient, and the brightness compensation coefficient; The step of calculating a brightness compensation coefficient based on the current gain value includes: Respectively acquiring a brightness comprehensive value corresponding to a previous magnification value of the imaging device and a brightness comprehensive value corresponding to a current magnification value of the imaging device to obtain a first brightness comprehensive value and a second brightness comprehensive value; The ratio of the second brightness comprehensive value to the first brightness comprehensive value is calculated to obtain the brightness compensation coefficient.

2. The image color correction method according to claim 1, wherein: The step of calculating the multiplication linkage coefficient based on the current multiplication value includes: respectively acquiring first gamma data corresponding to a minimum magnification value of the camera device and second gamma data corresponding to the current magnification value; The magnification linkage coefficient is calculated based on the first gamma data and the second gamma data.

3. The image color correction method according to claim 2, characterized in that: The step of calculating the magnification linkage coefficient based on the first gamma data and the second gamma data includes: Performing histogram statistical processing on the image to be processed to obtain histogram statistical information, wherein the histogram statistical information includes brightness values ​​and brightness quantities of pixels in the image to be processed, where the brightness quantity is the number of the brightness values; Calculating the maximum value of all brightness quantities in the histogram statistical information; Matching a first brightness output value with the first gamma data to obtain a brightness input value that matches the first brightness output value, where the first brightness output value is a brightness value corresponding to a maximum value; Matching the brightness input value with the second gamma data to obtain a second brightness output value matching the brightness input value; The ratio of the second brightness output value to the first brightness output value is calculated to obtain the magnification linkage coefficient.

4. The image color correction method according to claim 1, wherein: The step of calculating the gain linkage coefficient based on the current gain value includes: Calculating a difference between a maximum gain value of the camera device and the current gain value; The ratio of the maximum gain value to the difference value is calculated to obtain the gain linkage coefficient.

5. The image color correction method according to claim 1, wherein: The camera device includes a shutter, and the calculation of the brightness integrated value includes: Calculating the product of the shutter exposure time and the gain value to be processed, where the gain value to be processed includes the gain value of the camera device before the magnification is changed or the gain value of the camera device after the magnification is changed; The ratio of the product to the preset target brightness is calculated to obtain the brightness comprehensive value.

6. The image color correction method according to claim 1, wherein: The step of calculating the coefficient matrix based on the magnification linkage coefficient, the gain linkage coefficient, and the brightness compensation coefficient includes: Calculating the ratio of the multiplication factor to the gain factor; The coefficient matrix is ​​calculated based on the ratio, the brightness compensation coefficient and a preset adjustment coefficient.

7. A color correction device, characterized in that: The invention comprises a memory and a processor connected to each other, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, it is used to implement the image color correction method according to any one of claims 1 to 6.

8. A computer-readable storage medium for storing a computer program, characterized in that: When the computer program is executed by a processor, it is used to implement the image color correction method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Image pickup device

    JP2001251644A