CN111861922A - Method and device for adjusting color correction matrix and storage medium - Google Patents

Method and device for adjusting color correction matrix and storage medium Download PDF

Info

Publication number
CN111861922A
CN111861922A CN202010705620.0A CN202010705620A CN111861922A CN 111861922 A CN111861922 A CN 111861922A CN 202010705620 A CN202010705620 A CN 202010705620A CN 111861922 A CN111861922 A CN 111861922A
Authority
CN
China
Prior art keywords
color
matrix
color space
rgb
transformation
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010705620.0A
Other languages
Chinese (zh)
Inventor
曹阳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Dahua Technology Co Ltd
Original Assignee
Zhejiang Dahua Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Dahua Technology Co Ltd filed Critical Zhejiang Dahua Technology Co Ltd
Priority to CN202010705620.0A priority Critical patent/CN111861922A/en
Publication of CN111861922A publication Critical patent/CN111861922A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/90Dynamic range modification of images or parts thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Facsimile Image Signal Circuits (AREA)
  • Image Processing (AREA)

Abstract

The embodiment of the invention provides a method and a device for adjusting a color correction matrix and a storage medium. The method comprises the following steps: acquiring an initial color correction matrix based on an RGB color space based on a standard color card; mapping the initial color correction matrix based on the RGB color space to a transform matrix based on a YUV color space; coordinate transforming the transform matrix within the YUV color space, the coordinate transforming including at least one of: coordinate transformation for adjusting image saturation and coordinate transformation for rotating image chromaticity; mapping the transformed transform matrix based on the YUV color space after the coordinate transformation to a final color correction matrix based on the RGB color space. The invention solves the problem that the color correction matrix can not be corrected accurately or can not be corrected to obtain the preset effect, and ensures the accurate and predictable correction effect.

Description

Method and device for adjusting color correction matrix and storage medium
Technical Field
The embodiment of the invention relates to the technical field of image processing, in particular to a method and a device for adjusting a color correction matrix and a storage medium.
Background
The scene colors acquired by the camera are closely related to the spectral response of the sensor. The colors collected by different image sensors in the same shooting scene have difference and are different from human eyes. And therefore, color correction is required to restore true color.
Currently, the conventional color correction method is to use a color correction matrix ccm (color correction matrix) for calibration, i.e., a 3 × 3 matrix is multiplied by the red, green, blue (rgb) channel of each pixel for color correction. The response curves of the sensors are subjected to linear transformation in essence.
Since the difference between the different response curves is non-linear, the color correction matrix is often not accurately corrected or corrected to the desired effect.
Disclosure of Invention
The embodiment of the invention provides a method and a device for adjusting a color correction matrix and a storage medium, which are used for at least solving the problem that the color correction matrix cannot be corrected accurately or cannot be corrected to obtain a preset effect in the related art.
According to an embodiment of the present invention, there is provided a method of adjusting a color correction matrix, including: acquiring an initial color correction matrix based on an RGB color space based on a standard color card; mapping the initial color correction matrix based on the RGB color space to a transform matrix based on a YUV color space; coordinate transforming the transform matrix within the YUV color space, the coordinate transforming including at least one of: coordinate transformation for adjusting image saturation and coordinate transformation for rotating image chromaticity; mapping the transformed transform matrix based on the YUV color space after the coordinate transformation to a final color correction matrix based on the RGB color space.
In at least one exemplary embodiment, obtaining the initial color correction matrix based on the RGB color space based on the standard color chip comprises: acquiring a color card standard image corresponding to the standard color card; performing a first type of preprocessing on a target color block of the standard color card in the color card standard image to obtain a color card target image, wherein the first type of preprocessing comprises at least one of the following steps: saturation adjustment, color adjustment and inverse gamma conversion; determining the initial color correction matrix based on the RGB color space according to the color chart standard image and the color chart target image.
In at least one exemplary embodiment, acquiring the color chart standard image corresponding to the standard color chart includes: collecting a color card image of the standard color card; performing second type of preprocessing on the acquired color card image to obtain the color card standard image, wherein the second type of preprocessing comprises at least one of the following steps: black level correction, interpolation of a bayer domain, and white balance correction.
In at least one exemplary embodiment, determining the initial color correction matrix based on the RGB color space from the color chip standard image and the color chip target image comprises: determining an original color matrix CO based on the RGB color space formed by the original values of the RGB channels of each color patch in the color patch standard image and a target color matrix CT based on the RGB color space formed by the original values of the RGB channels of each color patch in the color patch target image; determining the initial color correction matrix CCM based on the RGB color space from the original color matrix CO based on the RGB color space and the target color matrix CT based on the RGB color space, wherein the CCM satisfies the following condition: the least squares error of CCMXCO with the CT is minimal, and a i1+ai2+ai31, wherein aijIs a matrix of i rows and j columns of the CCM.
In at least one exemplary embodiment, mapping the initial color correction matrix based on the RGB color space to a transform matrix based on a YUV color space comprises: the initial color correction matrix CCM based on the RGB color space is multiplied by a first mapping matrix in a left-hand mode and multiplied by a second mapping matrix in a right-hand mode to obtain the transformation matrix T based on the YUV color spaceOWherein the first mapping matrix is a RGB-to-YUV conversion matrix RGB2YUV, the second mapping matrix is a YUV-to-RGB conversion matrix YUV2RGB, and the second mapping matrix is an inverse of the first mapping matrix.
In at least one exemplary embodiment, the coordinate transformation of the transformation matrix for adjusting the saturation of the image in the YUV color space includes: for the transformation matrix T based on the YUV color spaceOThe scaling transformation matrix S is multiplied on the left, and the transformation matrix T which is obtained after the coordinate transformation is S0·T0Wherein, in the step (A),
Figure BDA0002594639090000031
s1,s2the saturation changes in the u-direction and the v-direction, respectively.
In at least one exemplary embodiment, the coordinate transformation of the transform matrix for image chroma rotation within the YUV color space comprises: for the transformation matrix T based on the YUV color space OLeft-hand rotation transformation matrix R0Obtaining the transformation matrix T ═ R after the coordinate transformation0·T0Wherein, in the step (A),
Figure BDA0002594639090000032
θ is the spatial rotation angle along the y-axis.
In at least one exemplary embodiment, performing the coordinate transformation for adjusting the saturation of the image and the coordinate transformation for performing the chromaticity rotation of the image on the transformation matrix in the YUV color space includes: for the transformation matrix T based on the YUV color spaceOFirst, the scaling transformation matrix S is multiplied by the left, and then the rotation transformation matrix R is multiplied by the left0Obtaining the transformation matrix T ═ R after the coordinate transformation0·S0·T0Wherein, in the step (A),
Figure BDA0002594639090000033
s1,s2respectively the saturation change in the u-direction and in the v-direction,
Figure BDA0002594639090000034
θ is the spatial rotation angle along the y-axis.
In at least one exemplary embodiment, mapping the coordinate-transformed YUV color space-based transform matrix to the RGB color space-based final color correction matrix comprises: the transformation matrix T based on the YUV color space after the coordinate transformation is multiplied by a second mapping matrix in a left direction and multiplied by a first mapping matrix in a right direction to obtain a final color correction matrix CCM based on the RGB color spacefinalWherein the first mapping matrix is a RGB-to-YUV conversion matrix RGB2YUV, and the second mapping matrix is a YUV-to-RGB conversion matrix YUV2 rgb and the second mapping matrix is the inverse of the first mapping matrix.
According to another embodiment of the present invention, there is provided an adjusting apparatus of a color correction matrix, including: the acquisition module is arranged for acquiring an initial color correction matrix based on an RGB color space based on a standard color card; a first spatial mapping module arranged to map the initial color correction matrix based on the RGB color space to a transform matrix based on a YUV color space; a coordinate transformation module configured to perform a coordinate transformation on the transformation matrix in the YUV color space, the coordinate transformation including at least one of: coordinate transformation for adjusting image saturation and coordinate transformation for rotating image chromaticity; a second space mapping module configured to map the transformed matrix based on the YUV color space after the coordinate transformation to a final color correction matrix based on the RGB color space.
In at least one exemplary embodiment, the obtaining module includes: the acquisition unit is used for acquiring a color card standard image corresponding to the standard color card; the preprocessing unit is configured to perform first-type preprocessing on a target color block of the standard color card in the color card standard image to obtain a color card target image, wherein the first-type preprocessing includes at least one of the following: saturation adjustment, color adjustment and inverse gamma conversion; a determination unit arranged to determine the initial color correction matrix based on the RGB color space from the color chart standard image and the color chart target image.
According to a further embodiment of the present invention, there is also provided a computer-readable storage medium having a computer program stored thereon, wherein the computer program is arranged to perform the steps of any of the above method embodiments when executed.
According to yet another embodiment of the present invention, there is also provided an electronic device, including a memory in which a computer program is stored and a processor configured to execute the computer program to perform the steps in any of the above method embodiments.
According to the invention, the color correction matrix is mapped from RGB to YUV space and then is subjected to coordinate transformation to realize the adjustment of saturation and chromaticity, and finally is mapped back to RGB color space, so that the adjustment item to be adjusted is accurately adjusted under the condition of not influencing the unadjusted item, and the accurate and predictable correction effect is ensured, therefore, the problem that the color correction matrix cannot be accurately corrected or cannot correct the preset effect can be solved.
Drawings
FIG. 1 is a block diagram of a hardware configuration of a computer according to an embodiment of the present invention;
FIG. 2 is a flow chart of an adjustment method of a color correction matrix according to an embodiment of the present invention;
FIG. 3 is a block diagram of an apparatus for adjusting a color correction matrix according to an embodiment of the present invention;
FIG. 4 is a block diagram illustrating a detailed structure of an apparatus for adjusting a color correction matrix according to an embodiment of the present invention;
fig. 5 is a detailed flowchart of an adjustment method of a color correction matrix according to an embodiment of the present invention.
Detailed Description
In order to obtain a more accurate and more satisfactory color correction matrix, color acquisition can be performed on a standard color card in a standard light source, the dimension of the color correction matrix is increased, a CCM matrix with a smaller error is obtained by using a least square method finally, and in addition, interpolation can be performed on the CCM matrix and a unit matrix which are preliminarily corrected so as to realize the adjustment of the saturation.
However, if only the accurate CCM correction is performed on a standard color chart (e.g., 24 color chart) under a standard light source, due to the dimensional limitation of the 3 × 3 linear transformation, the improvement of the dimension in the calculation process only provides a limited improvement in the final accuracy, and the accurate color correction is not necessarily the color correction effect really desired by the user. If the color correction is adjusted according to the requirements of the user, the CCM and the unit matrix are directly interpolated, which causes the problem of excessive correction on the chromaticity when the saturation is improved, and causes the chromaticity to obviously change when the saturation is changed.
In order to solve the problem that the color correction matrix cannot be accurately corrected or cannot correct a preset effect and also solve the problem that the adjustment of one adjustment item influences the adjustment of other adjustment items when the color correction matrix is adjusted, the embodiment of the invention further corrects the preliminary color correction matrix, so that the color can meet the requirements of users through adjustment, and meanwhile, the adjustment items can be distinguished, and the problems of changing the chromaticity when the saturation is changed and the like are avoided.
Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings in conjunction with the embodiments.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.
The method embodiments provided in the embodiments of the present application may be executed in an arithmetic device for implementing image processing. Taking an example of the present invention running on a computer, fig. 1 is a block diagram of a hardware structure of a computer according to an embodiment of the present invention. As shown in fig. 1, a computer may include one or more (only one shown in fig. 1) processors 102 (the processor 102 may include, but is not limited to, a central processing unit CPU, a microprocessor MCU, or a processing device such as a programmable logic device FPGA), and a memory 104 for storing data, wherein the computer may further include a transmission device 106 for communication functions and an input-output device 108. It will be appreciated by those of ordinary skill in the art that the configuration shown in FIG. 1 is illustrative only and is not intended to limit the configuration of the computer described above. For example, a computer may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
The memory 104 may be used to store a computer program, for example, a software program and a module of an application software, such as a computer program corresponding to the color correction matrix adjustment method in the embodiment of the present invention, and the processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, so as to implement the above-mentioned method. The memory 104 may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to the mobile terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
In the present embodiment, a method for adjusting a color correction matrix running on an arithmetic device is provided, and fig. 2 is a flowchart of a method for adjusting a color correction matrix according to an embodiment of the present invention, as shown in fig. 2, the flowchart includes the following steps:
step S202, acquiring an initial color correction matrix based on an RGB color space based on a standard color card;
Step S204, mapping the initial color correction matrix based on the RGB color space into a transformation matrix based on a YUV color space;
step S206, performing coordinate transformation on the transformation matrix in the YUV color space, wherein the coordinate transformation comprises at least one of the following steps: coordinate transformation for adjusting image saturation and coordinate transformation for rotating image chromaticity;
step S208, mapping the transformed transformation matrix based on the YUV color space after the coordinate transformation to a final color correction matrix based on the RGB color space.
According to the steps, the color correction matrix is mapped from RGB to YUV space and then is subjected to coordinate transformation to realize adjustment of saturation and chromaticity, and finally is mapped back to RGB color space, so that the adjustment item to be adjusted is accurately adjusted under the condition of not influencing the non-adjustment item, and the accurate and predictable correction effect is ensured, therefore, the problem that the color correction matrix cannot be accurately corrected or cannot correct the preset effect can be solved.
The main body of the above steps may be an arithmetic device such as a computer, but is not limited thereto.
In at least one exemplary embodiment, step S202 may include:
Step S2021, acquiring a color card standard image corresponding to the standard color card, wherein in practical application, in consideration of various color temperatures existing in a practical situation, the color card standard image corresponding to the standard color card under different standard color temperature light sources can be acquired;
step S2022, performing a first type of preprocessing on the target color block of the standard color chart in the color chart standard image to obtain a color chart target image, where the first type of preprocessing includes at least one of: the method comprises the following steps of saturation adjustment, color adjustment and inverse gamma transformation, wherein through the steps, adjustment can be performed at a target image selection stage (for example, preprocessing can be performed according to preset conditions, and specific preprocessing operation can be performed according to subjective needs of users), so that preliminary adjustment and intervention are performed on an initial color correction matrix;
step S2023, determining the initial color correction matrix based on the RGB color space according to the color patch standard image and the color patch target image.
In at least one exemplary embodiment, step S2021 may include:
step S2021-1, collecting a color card image of the standard color card (which may be a color card image corresponding to the standard color card under different standard color temperature light sources);
Step S2021-2, performing second type preprocessing on the acquired color card image to obtain the color card standard image, wherein the second type preprocessing comprises at least one of the following steps: black level correction, interpolation of a bayer domain, and white balance correction.
In at least one exemplary embodiment, step S2023 may include:
step S2023-1, determining an original color matrix CO based on the RGB color space formed by the original values of the RGB channels of each color patch in the color chart standard image, and a target color matrix CT based on the RGB color space formed by the original values of the RGB channels of each color patch in the color chart target image;
step S2023-2, based on the original color matrix CO based on the RGB color space and on the RGB color spaceDetermines the initial color correction matrix CCM based on the RGB color space, wherein the CCM satisfies the following condition: the least squares error of CCMXCO with the CT is minimal, and ai1+ai2+ai31, wherein aijIs a matrix of i rows and j columns of the CCM.
In at least one exemplary embodiment, step S204 may include:
step S2041, the initial color correction matrix CCM based on the RGB color space is multiplied by a first mapping matrix in a left-hand way and multiplied by a second mapping matrix in a right-hand way to obtain the transformation matrix T based on the YUV color space OWherein the first mapping matrix is a RGB-to-YUV conversion matrix RGB2YUV, the second mapping matrix is a YUV-to-RGB conversion matrix YUV2RGB, and the second mapping matrix is an inverse of the first mapping matrix.
In at least one exemplary embodiment, the process of performing the coordinate transformation for adjusting the image saturation on the transformation matrix in the YUV color space in step S206 may include: for the transformation matrix T based on the YUV color spaceOThe scaling transformation matrix S is multiplied on the left, and the transformation matrix T which is obtained after the coordinate transformation is S0·T0Wherein, in the step (A),
Figure BDA0002594639090000081
s1,s2the saturation changes in the u-direction and the v-direction, respectively.
In at least one exemplary embodiment, in step S206, the process of performing coordinate transformation for image chromaticity rotation on the transformation matrix in the YUV color space may include: for the transformation matrix T based on the YUV color spaceOLeft-hand rotation transformation matrix R0Obtaining the transformation matrix T ═ R after the coordinate transformation0·T0Wherein, in the step (A),
Figure BDA0002594639090000082
θ is the spatial rotation angle along the y-axis.
In at least one exemplary embodiment, the process of performing coordinate transformation for adjusting saturation of an image and coordinate transformation for performing chromaticity rotation of an image on the transformation matrix in the YUV color space in step S206 may include: for the transformation matrix T based on the YUV color space OFirst, the scaling transformation matrix S is multiplied by the left, and then the rotation transformation matrix R is multiplied by the left0Obtaining the transformation matrix T ═ R after the coordinate transformation0·S0·T0Wherein, in the step (A),
Figure BDA0002594639090000091
s1,s2respectively the saturation change in the u-direction and in the v-direction,
Figure BDA0002594639090000092
θ is the spatial rotation angle along the y-axis.
In at least one exemplary embodiment, step S208 may include:
step S2081, the transformation matrix T based on the YUV color space after coordinate transformation is multiplied by a second mapping matrix in a left direction and multiplied by a first mapping matrix in a right direction to obtain a final color correction matrix CCM based on the RGB color spacefinalWherein the first mapping matrix is a RGB-to-YUV conversion matrix RGB2YUV, the second mapping matrix is a YUV-to-RGB conversion matrix YUV2RGB, and the second mapping matrix is an inverse of the first mapping matrix.
In at least one exemplary embodiment, after step S208, the method may further include:
and performing color correction on the image acquired by the camera according to the final color correction matrix.
After color correction of the image captured by the camera, the color corrected image may also be displayed on a screen or transmitted to a server.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
In this embodiment, an adjusting device of a color correction matrix is further provided, and the device is used to implement the foregoing embodiments and preferred embodiments, and the description of the device is omitted for brevity. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
Fig. 3 is a block diagram of an apparatus for adjusting a color correction matrix according to an embodiment of the present invention, as shown in fig. 3, the apparatus including:
an obtaining module 32 configured to obtain an initial color correction matrix based on the RGB color space based on the standard color card;
a first spatial mapping module 34 arranged to map the initial color correction matrix based on the RGB color space to a transform matrix based on a YUV color space;
a coordinate transformation module 36 configured to perform a coordinate transformation on the transformation matrix in the YUV color space, the coordinate transformation including at least one of: coordinate transformation for adjusting image saturation and coordinate transformation for rotating image chromaticity;
A second space mapping module 38 arranged to map the transformed transformation matrix based on the YUV color space after the coordinate transformation to a final color correction matrix based on the RGB color space.
Fig. 4 is a detailed block diagram of an adjusting apparatus of a color correction matrix according to an embodiment of the present invention, and as shown in fig. 4, the obtaining module 32 includes:
the acquiring unit 322 is configured to acquire a color chart standard image corresponding to the standard color chart, and in practical application, in consideration of the fact that multiple color temperatures exist, the color chart standard image corresponding to the standard color chart under different standard color temperature light sources can be acquired;
a preprocessing unit 324, configured to perform a first type of preprocessing on a target color block of the standard color card in the color card standard image to obtain a color card target image, where the first type of preprocessing includes at least one of: the saturation adjustment, the color adjustment and the inverse gamma transformation can be performed in the target image selection stage through the process (for example, the preprocessing can be performed according to preset conditions, and specific preprocessing operation can be performed according to subjective needs of users), so that the initial color correction matrix is preliminarily adjusted and intervened;
A determining unit 326 arranged to determine the initial color correction matrix based on the RGB color space from the color chip standard image and the color chip target image.
In at least one example embodiment, the obtaining unit 322 may be configured to perform the following operations:
collecting a color card image of the standard color card (which may be a color card image corresponding to the standard color card under different standard color temperature light sources);
performing second type of preprocessing on the acquired color card image to obtain the color card standard image, wherein the second type of preprocessing comprises at least one of the following steps: black level correction, interpolation of a bayer domain, and white balance correction.
In at least one example embodiment, the determining unit 326 may be arranged to perform the following operations:
determining an original color matrix CO based on the RGB color space formed by the original values of the RGB channels of each color patch in the color patch standard image and a target color matrix CT based on the RGB color space formed by the original values of the RGB channels of each color patch in the color patch target image;
according to the base stationDetermining the initial color correction matrix CCM based on the RGB color space by the original color matrix CO of the RGB color space and the target color matrix CT based on the RGB color space, wherein the CCM satisfies the following condition: the least squares error of CCMXCO with the CT is minimal, and a i1+ai2+ai31, wherein aijIs a matrix of i rows and j columns of the CCM.
In at least one example embodiment, the first spatial mapping module 34 may be configured to perform the following operations:
the initial color correction matrix CCM based on the RGB color space is multiplied by a first mapping matrix in a left-hand mode and multiplied by a second mapping matrix in a right-hand mode to obtain the transformation matrix T based on the YUV color spaceOWherein the first mapping matrix is a RGB-to-YUV conversion matrix RGB2YUV, the second mapping matrix is a YUV-to-RGB conversion matrix YUV2RGB, and the second mapping matrix is an inverse of the first mapping matrix.
In at least one exemplary embodiment, the coordinate transformation module 36 may be arranged to perform a coordinate transformation for adjusting image saturation on the transformation matrix in the YUV color space by:
for the transformation matrix T based on the YUV color spaceOThe scaling transformation matrix S is multiplied on the left, and the transformation matrix T which is obtained after the coordinate transformation is S0·T0Wherein, in the step (A),
Figure BDA0002594639090000121
s1,s2the saturation changes in the u-direction and the v-direction, respectively.
In at least one exemplary embodiment, the coordinate transformation module 36 may be arranged to perform a coordinate transformation for image chroma rotation on the transformation matrix in the YUV color space by:
For the transformation matrix T based on the YUV color spaceOLeft-hand rotation transformation matrix R0Obtaining the transformation matrix after the coordinate transformationT=R0·T0Wherein, in the step (A),
Figure BDA0002594639090000122
θ is the spatial rotation angle along the y-axis.
In at least one exemplary embodiment, the coordinate transformation module 36 may be arranged to perform the coordinate transformation for adjusting the saturation of the image and the coordinate transformation for performing the chromaticity rotation of the image on the transformation matrix in the YUV color space by:
for the transformation matrix T based on the YUV color spaceOFirst, the scaling transformation matrix S is multiplied by the left, and then the rotation transformation matrix R is multiplied by the left0Obtaining the transformation matrix T ═ R after the coordinate transformation0·S0·T0Wherein, in the step (A),
Figure BDA0002594639090000123
s1,s2respectively the saturation change in the u-direction and in the v-direction,
Figure BDA0002594639090000124
θ is the spatial rotation angle along the y-axis.
In at least one example embodiment, the second spatial mapping module 38 may be configured to:
the transformation matrix T based on the YUV color space after the coordinate transformation is multiplied by a second mapping matrix in a left direction and multiplied by a first mapping matrix in a right direction to obtain a final color correction matrix CCM based on the RGB color spacefinalWherein the first mapping matrix is a RGB-to-YUV conversion matrix RGB2YUV, the second mapping matrix is a YUV-to-RGB conversion matrix YUV2RGB, and the second mapping matrix is an inverse of the first mapping matrix.
In at least one example embodiment, the apparatus may further include:
and the correction processing module is used for correcting the color of the image acquired by the camera according to the final color correction matrix.
The apparatus may further include:
and the control module is used for displaying the image subjected to color correction on a screen or sending the image subjected to color correction to the server after the image acquired by the camera is subjected to color correction.
It should be noted that, the above modules may be implemented by software or hardware, and for the latter, the following may be implemented, but not limited to: the modules are all positioned in the same processor; alternatively, the modules are respectively located in different processors in any combination.
Embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program is arranged to perform the steps of any of the above-mentioned method embodiments when executed.
In the present embodiment, the above-mentioned computer-readable storage medium may be configured to store a computer program for executing the steps of:
step S1, acquiring an initial color correction matrix based on the RGB color space based on the standard color card;
Step S2, mapping the initial color correction matrix based on the RGB color space to a transform matrix based on a YUV color space;
step S3, performing coordinate transformation on the transformation matrix in the YUV color space, where the coordinate transformation includes at least one of: coordinate transformation for adjusting image saturation and coordinate transformation for rotating image chromaticity;
step S4, mapping the transformed transform matrix based on the YUV color space after the coordinate transformation to a final color correction matrix based on the RGB color space.
In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to: various media capable of storing computer programs, such as a usb disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk.
Embodiments of the present invention also provide an electronic device comprising a memory having a computer program stored therein and a processor arranged to run the computer program to perform the steps of any of the above method embodiments.
In an exemplary embodiment, the electronic apparatus may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
In an exemplary embodiment, the processor may be configured to execute the following steps by a computer program:
step S1, acquiring an initial color correction matrix based on the RGB color space based on the standard color card;
step S2, mapping the initial color correction matrix based on the RGB color space to a transform matrix based on a YUV color space;
step S3, performing coordinate transformation on the transformation matrix in the YUV color space, where the coordinate transformation includes at least one of: coordinate transformation for adjusting image saturation and coordinate transformation for rotating image chromaticity;
step S4, mapping the transformed transform matrix based on the YUV color space after the coordinate transformation to a final color correction matrix based on the RGB color space.
For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary embodiments, and details of this embodiment are not repeated herein.
The following embodiment of the present invention is to better solve the current problem of accurate adjustment after performing accurate color calibration, by using a scheme of determining and adjusting an accurate color correction matrix based on a 24-color chart.
Fig. 5 is a detailed flowchart of an adjusting method of a color correction matrix according to an embodiment of the present invention, as shown in fig. 5, the method includes the following steps:
step S501, a camera collects color card images of a standard 24 color card under a plurality of standard light sources with different color temperatures, wherein the standard light sources can be an A light source, a TL84 light source, a D50 light source, a D65 light source and a D75 light source. The acquired color card image is preprocessed (corresponding to the second type of preprocessing), including black level correction, bayer interpolation, and manual white balance correction. So as to keep consistent with the ISP flow and obtain the original image.
Step S502, preprocessing the target color card standard picture, and directly performing saturation and chroma adjustment and inverse gamma processing (corresponding to the first type of preprocessing) on the standard picture as required to obtain a target image. Specifically, photoshop can be used to adjust the target color block, improve saturation, change partial color, and the like, as required. In the ISP process, gamma to be used can also perform inverse gamma transformation operation on the target color card.
Step S503, counting RBG channel values of color blocks in the processed original image, forming a 3x24 dimensional color card matrix according to the standard value, and forming a source matrix; and counting the RGB channel values of each color block of the color card in the processed target image, and forming a 3x24 dimensional color card matrix according to the reference value to form a target matrix.
Wherein, counting the original values of RGB channels of each color patch of the original image, and forming 24 color patches to form a 3 × 24 original color matrix CO as follows:
Figure BDA0002594639090000151
the target values of the RGB channels of the statistically processed target image color patches are 24 color patches in total to form a 3 × 24 target color matrix CT as follows:
Figure BDA0002594639090000161
and step S504, adding a gray block constraint term based on the source matrix and the target matrix, and fitting an initial color correction matrix CCM through least square.
Specifically, let the color correction matrix CCM be a 3 × 3 matrix
Figure BDA0002594639090000162
The least square error of CCM & CO and CT is calculated by the least square method, and the error is minimum and satisfies:
ai1+ai2+ai31, wherein aijI rows and j columns of CCM.
In step S505, the CCM obtained above is adjusted as necessary. In order to avoid the mutual influence of chroma saturation and brightness when adjusting colors, the color space needs to be mapped to a YUV space for processing. Specifically, the initial color correction matrix CCM may be linearly transformed according to the RGB2YUV matrix used in the ISP system to be represented as a YUV3x3 transform matrix in the YUV domain.
Specifically, the subsequent rgb2yuv matrix used by the isp is multiplied by CCM left, and then multiplied by its yuv2rgb matrix, i.e., rgb2yuv inverse matrix, right. The obtained YUV transformation matrix
Figure BDA0002594639090000163
In step S506, the space is subjected to coordinate transformation. Improving saturation according to needs, performing space expansion transformation in the UV direction on a YUV space, and performing left-hand expansion transformation on a YUV transformation matrix; and (4) performing chrominance rotation according to needs, performing space rotation transformation along the Y axis on the YUV space, and performing left multiplication on the YUV transformation matrix by the rotation matrix.
In particular, the transformation matrix T is transformed when the image saturation needs to be improvedOLeft-multiplying scaling transform matrix S:
Figure BDA0002594639090000171
wherein s is1,s2Respectively the saturation change in the u-direction and in the v-direction,>1 to increase saturation, s is determined by the commonly used yuv matrix1Will mainly increase the saturation in the blue direction, s2The saturation in the red direction is mainly increased. Generally, s should be1,s2Increasing the degree of change.
In particular toWhen the chroma rotation of the image is needed, the transformation matrix T is matchedOLeft-hand rotation transformation matrix R0
Figure BDA0002594639090000172
Where θ is positive and chromaticity increases and vice versa decreases.
In step S507, the transformed YUV transform matrix is linearly transformed into a new CCM using the inverse matrix of RGB2YUV, that is, the left-multiplied transform matrix T is equal to R0·S0·T0The conversion is back to CCM in RGB space.
Specifically, the transformation matrix T is multiplied by the yuv2rgb matrix in the left direction, and the transformed matrix T is multiplied by the yuv2rgb matrix in the right direction to obtain the final CCM final
In the concrete implementation, the coordinate transformation matrixes are all multiplied on the transformation matrix T in a left way0Therefore, the right-multiplied spatial transform matrix of the two spatial transforms can cancel out the undesired multiplication.
In the scheme provided by the embodiment of the invention, certain early-stage adjustment is realized in the target diagram selection stage, and ccm is adjusted by utilizing color space conversion and a space coordinate transformation means. By the scheme, ccm can be further adjusted, the influence range during adjustment is well controlled by utilizing space conversion, in addition, adjustment is carried out at the target map selection stage, and the requirements of users are referred.
It will be apparent to those skilled in the art that the various modules or steps of the invention described above may be implemented using a general purpose computing device, they may be centralized on a single computing device or distributed across a network of computing devices, and they may be implemented using program code executable by the computing devices, such that they may be stored in a memory device and executed by the computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into various integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the principle of the present invention should be included in the protection scope of the present invention.

Claims (12)

1. A method for adjusting a color correction matrix, comprising:
acquiring an initial color correction matrix based on an RGB color space based on a standard color card;
mapping the initial color correction matrix based on the RGB color space to a transform matrix based on a YUV color space;
coordinate transforming the transform matrix within the YUV color space, the coordinate transforming including at least one of: coordinate transformation for adjusting image saturation and coordinate transformation for rotating image chromaticity;
mapping the transformed transform matrix based on the YUV color space after the coordinate transformation to a final color correction matrix based on the RGB color space.
2. The method of claim 1, wherein obtaining an initial color correction matrix based on an RGB color space based on a standard color target comprises:
Acquiring a color card standard image corresponding to the standard color card;
performing a first type of preprocessing on a target color block of the standard color card in the color card standard image to obtain a color card target image, wherein the first type of preprocessing comprises at least one of the following steps: saturation adjustment, color adjustment and inverse gamma conversion;
determining the initial color correction matrix based on the RGB color space according to the color chart standard image and the color chart target image.
3. The method of claim 2, wherein obtaining a color chart standard image corresponding to the standard color chart comprises:
collecting a color card image of the standard color card;
performing second type of preprocessing on the acquired color card image to obtain the color card standard image, wherein the second type of preprocessing comprises at least one of the following steps: black level correction, interpolation of a bayer domain, and white balance correction.
4. The method of claim 2, wherein determining the initial color correction matrix based on the RGB color space from the color chip standard image and the color chip target image comprises:
determining an original color matrix CO based on the RGB color space formed by the original values of the RGB channels of each color patch in the color patch standard image and a target color matrix CT based on the RGB color space formed by the original values of the RGB channels of each color patch in the color patch target image;
Determining the initial color correction matrix CCM based on the RGB color space from the original color matrix CO based on the RGB color space and the target color matrix CT based on the RGB color space, wherein the CCM satisfies the following condition: the least squares error of CCMXCO with the CT is minimal, and ai1+ai2+ai31, wherein aijIs a matrix of i rows and j columns of the CCM.
5. The method of claim 1, wherein mapping the initial color correction matrix based on the RGB color space to a transform matrix based on a YUV color space comprises:
the initial color correction matrix CCM based on the RGB color space is multiplied by a first mapping matrix in a left-hand mode and multiplied by a second mapping matrix in a right-hand mode to obtain the transformation matrix T based on the YUV color spaceOWherein the first mapping matrix is a RGB-to-YUV conversion matrix RGB2YUV, the second mapping matrix is a YUV-to-RGB conversion matrix YUV2RGB, andthe second mapping matrix is an inverse of the first mapping matrix.
6. The method of claim 1, wherein performing a coordinate transformation of the transformation matrix in the YUV color space for adjusting image saturation comprises:
For the transformation matrix T based on the YUV color spaceOThe scaling transformation matrix S is multiplied on the left, and the transformation matrix T which is obtained after the coordinate transformation is S0·T0Wherein, in the step (A),
Figure FDA0002594639080000021
s1,s2the saturation changes in the u-direction and the v-direction, respectively.
7. The method of claim 1, wherein performing a coordinate transformation of the transformation matrix for image chroma rotation in the YUV color space comprises:
for the transformation matrix T based on the YUV color spaceOLeft-hand rotation transformation matrix R0Obtaining the transformation matrix T ═ R after the coordinate transformation0·T0Wherein, in the step (A),
Figure FDA0002594639080000031
θ is the spatial rotation angle along the y-axis.
8. The method of claim 1, wherein performing a coordinate transformation for adjusting image saturation and a coordinate transformation for performing image chroma rotation on the transformation matrix in the YUV color space comprises:
for the transformation matrix T based on the YUV color spaceOFirst, the scaling transformation matrix S is multiplied by the left, and then the rotation transformation matrix R is multiplied by the left0Obtaining the transformation matrix T ═ R after the coordinate transformation0·S0·T0Wherein, in the step (A),
Figure FDA0002594639080000032
s1,s2respectively the saturation change in the u-direction and in the v-direction,
Figure FDA0002594639080000033
θ is the spatial rotation angle along the y-axis.
9. The method of claim 1, wherein mapping the coordinate-transformed YUV color space-based transform matrix to the RGB color space-based final color correction matrix comprises:
the transformation matrix T based on the YUV color space after the coordinate transformation is multiplied by a second mapping matrix in a left direction and multiplied by a first mapping matrix in a right direction to obtain a final color correction matrix CCM based on the RGB color spacefinalWherein the first mapping matrix is a RGB-to-YUV conversion matrix RGB2YUV, the second mapping matrix is a YUV-to-RGB conversion matrix YUV2RGB, and the second mapping matrix is an inverse of the first mapping matrix.
10. An apparatus for adjusting a color correction matrix, comprising:
the acquisition module is arranged for acquiring an initial color correction matrix based on an RGB color space based on a standard color card;
a first spatial mapping module arranged to map the initial color correction matrix based on the RGB color space to a transform matrix based on a YUV color space;
a coordinate transformation module configured to perform a coordinate transformation on the transformation matrix in the YUV color space, the coordinate transformation including at least one of: coordinate transformation for adjusting image saturation and coordinate transformation for rotating image chromaticity;
A second space mapping module configured to map the transformed matrix based on the YUV color space after the coordinate transformation to a final color correction matrix based on the RGB color space.
11. The apparatus of claim 10, wherein the obtaining module comprises:
the acquisition unit is used for acquiring a color card standard image corresponding to the standard color card;
the preprocessing unit is configured to perform first-type preprocessing on a target color block of the standard color card in the color card standard image to obtain a color card target image, wherein the first-type preprocessing includes at least one of the following: saturation adjustment, color adjustment and inverse gamma conversion;
a determination unit arranged to determine the initial color correction matrix based on the RGB color space from the color chart standard image and the color chart target image.
12. A computer-readable storage medium, in which a computer program is stored, wherein the computer program is arranged to perform the method of any of claims 1 to 9 when executed.
CN202010705620.0A 2020-07-21 2020-07-21 Method and device for adjusting color correction matrix and storage medium Pending CN111861922A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010705620.0A CN111861922A (en) 2020-07-21 2020-07-21 Method and device for adjusting color correction matrix and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010705620.0A CN111861922A (en) 2020-07-21 2020-07-21 Method and device for adjusting color correction matrix and storage medium

Publications (1)

Publication Number Publication Date
CN111861922A true CN111861922A (en) 2020-10-30

Family

ID=73001329

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010705620.0A Pending CN111861922A (en) 2020-07-21 2020-07-21 Method and device for adjusting color correction matrix and storage medium

Country Status (1)

Country Link
CN (1) CN111861922A (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113096046A (en) * 2021-04-15 2021-07-09 北京有竹居网络技术有限公司 Image processing method and device
CN113596422A (en) * 2021-07-13 2021-11-02 浙江大华技术股份有限公司 Method for adjusting color correction matrix CCM and monitoring equipment
CN113674163A (en) * 2021-07-13 2021-11-19 浙江大华技术股份有限公司 Image saturation adjusting method, device and computer readable storage medium
CN113676712A (en) * 2021-06-25 2021-11-19 浙江大华技术股份有限公司 Color correction method and related device thereof
CN114782444A (en) * 2022-06-22 2022-07-22 江苏美克医学技术有限公司 Auxiliary interpretation method, medium and electronic device for in vitro diagnosis of color development result
CN115474028A (en) * 2022-08-26 2022-12-13 中国大恒(集团)有限公司北京图像视觉技术分公司 Quick color correction device and method for industrial camera
CN117492207A (en) * 2023-12-29 2024-02-02 深圳臻像科技有限公司 Static light field color gamut reconstruction algorithm and system for inverse problem optimization
WO2024027090A1 (en) * 2022-08-04 2024-02-08 浙江宇视科技有限公司 Color correction matrix optimization method and apparatus, and electronic device and medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101009851A (en) * 2007-01-19 2007-08-01 北京中星微电子有限公司 Image processing method and its device
US20120154625A1 (en) * 2010-12-15 2012-06-21 Samsung Electronics Co., Ltd. Image processing apparatus, image processing method, and program recording medium
CN111079738A (en) * 2019-11-23 2020-04-28 中国科学院长春光学精密机械与物理研究所 Image processing method, system and terminal equipment
CN111292246A (en) * 2018-12-07 2020-06-16 上海安翰医疗技术有限公司 Image color correction method, storage medium, and endoscope

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101009851A (en) * 2007-01-19 2007-08-01 北京中星微电子有限公司 Image processing method and its device
US20120154625A1 (en) * 2010-12-15 2012-06-21 Samsung Electronics Co., Ltd. Image processing apparatus, image processing method, and program recording medium
CN111292246A (en) * 2018-12-07 2020-06-16 上海安翰医疗技术有限公司 Image color correction method, storage medium, and endoscope
CN111079738A (en) * 2019-11-23 2020-04-28 中国科学院长春光学精密机械与物理研究所 Image processing method, system and terminal equipment

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113096046A (en) * 2021-04-15 2021-07-09 北京有竹居网络技术有限公司 Image processing method and device
CN113676712A (en) * 2021-06-25 2021-11-19 浙江大华技术股份有限公司 Color correction method and related device thereof
CN113676712B (en) * 2021-06-25 2023-08-01 浙江大华技术股份有限公司 Color correction method and related device thereof
CN113596422B (en) * 2021-07-13 2024-02-06 浙江大华技术股份有限公司 Method for adjusting CCM (color correction matrix) and monitoring equipment
CN113596422A (en) * 2021-07-13 2021-11-02 浙江大华技术股份有限公司 Method for adjusting color correction matrix CCM and monitoring equipment
CN113674163A (en) * 2021-07-13 2021-11-19 浙江大华技术股份有限公司 Image saturation adjusting method, device and computer readable storage medium
CN114782444A (en) * 2022-06-22 2022-07-22 江苏美克医学技术有限公司 Auxiliary interpretation method, medium and electronic device for in vitro diagnosis of color development result
CN114782444B (en) * 2022-06-22 2022-09-02 江苏美克医学技术有限公司 Auxiliary interpretation method, medium and electronic device for in vitro diagnosis color development result
WO2024027090A1 (en) * 2022-08-04 2024-02-08 浙江宇视科技有限公司 Color correction matrix optimization method and apparatus, and electronic device and medium
CN115474028A (en) * 2022-08-26 2022-12-13 中国大恒(集团)有限公司北京图像视觉技术分公司 Quick color correction device and method for industrial camera
CN115474028B (en) * 2022-08-26 2023-10-17 中国大恒(集团)有限公司北京图像视觉技术分公司 Industrial camera color correction device and method
CN117492207A (en) * 2023-12-29 2024-02-02 深圳臻像科技有限公司 Static light field color gamut reconstruction algorithm and system for inverse problem optimization
CN117492207B (en) * 2023-12-29 2024-04-16 深圳臻像科技有限公司 Static light field color gamut reconstruction algorithm and system for inverse problem optimization

Similar Documents

Publication Publication Date Title
CN111861922A (en) Method and device for adjusting color correction matrix and storage medium
CN110830778B (en) Imaging device color correction method, imaging device color correction device, electronic device and storage medium
US9959604B2 (en) Dynamic global tone mapping with integrated 3D color look-up table
US10757386B2 (en) White balance calibration method based on skin color data and image processing apparatus using the same
CN111641819B (en) Method, device, system and computer device for white balance gain correction
CN108337496B (en) White balance processing method, processing device, processing equipment and storage medium
CN111292246B (en) Image color correction method, storage medium, and endoscope
CN112752023B (en) Image adjusting method and device, electronic equipment and storage medium
CN111899182B (en) Color enhancement method and device
CN108230407B (en) Image processing method and device
WO2019200640A1 (en) Color gamut mapping method and device
WO2020093653A1 (en) Color adjustment method, color adjustment device, electronic device and computer-readable storage medium
US9961236B2 (en) 3D color mapping and tuning in an image processing pipeline
EP3888345A1 (en) Method for generating image data for machine learning based imaging algorithms
CN104935900A (en) Image sensing device, color correction matrix correction method and lookup table establishment method
CN111587573B (en) Image processing method and device and computer storage medium
TW201830337A (en) Method and device for performing automatic white balance on an image
Afifi et al. Color temperature tuning: Allowing accurate post-capture white-balance editing
CN110751607A (en) Skin color correction method and device, storage medium and electronic device
CN109792474B (en) Method for determining a chroma mapping function
WO2018209984A1 (en) Image processing method and apparatus
EP3301902A1 (en) Lightness independent non-linear relative chroma mapping
JP2015041856A (en) Image processing device, imaging device, and program
WO2024000473A1 (en) Color correction model generation method, correction method and apparatus, and medium and device
CN117201950A (en) Hue adjustment method, hue adjustment device, and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination