CN113674164A - Sample color correction method, sample color correction device, electronic device, and medium - Google Patents

Sample color correction method, sample color correction device, electronic device, and medium Download PDF

Info

Publication number
CN113674164A
CN113674164A CN202110835812.8A CN202110835812A CN113674164A CN 113674164 A CN113674164 A CN 113674164A CN 202110835812 A CN202110835812 A CN 202110835812A CN 113674164 A CN113674164 A CN 113674164A
Authority
CN
China
Prior art keywords
color
color correction
value
correction
srgb
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
CN202110835812.8A
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.)
Advanced Institute of Information Technology AIIT of Peking University
Hangzhou Weiming Information Technology Co Ltd
Original Assignee
Advanced Institute of Information Technology AIIT of Peking University
Hangzhou Weiming Information 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 Advanced Institute of Information Technology AIIT of Peking University, Hangzhou Weiming Information Technology Co Ltd filed Critical Advanced Institute of Information Technology AIIT of Peking University
Priority to CN202110835812.8A priority Critical patent/CN113674164A/en
Publication of CN113674164A publication Critical patent/CN113674164A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • G06T5/80
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10024Color image

Abstract

The application provides a sample color correction method, a sample color correction device, an electronic device and a medium. The method comprises the following steps: acquiring a target image to be subjected to color correction, and determining a color block to be corrected from a sample area on the target image; taking pixel values of the color correction color blocks in an sRGB color space as original values, taking real values as target values, and obtaining an initial color correction matrix from the original values to the target values by using a least square method; iteratively calculating a color correction matrix and a color correction value in a LINEARsRGB color space according to the initial color correction matrix to obtain a final color correction matrix from an original value to a target value; and obtaining a correction value of the color block to be corrected according to the final color correction matrix, and correcting the color of the sample according to the final color correction matrix. According to the color correction method and device, the color identification errors caused by uneven light sources are avoided to a large extent by means of the color correction color blocks which are uniformly distributed, the final color correction matrix is obtained through iterative calculation in the LINEAR sRGB color space, and the color correction errors are reduced.

Description

Sample color correction method, sample color correction device, electronic device, and medium
Technical Field
The application relates to the technical field of artificial intelligence, in particular to a sample color correction method and device, an electronic device and a computer-readable storage medium.
Background
In the health monitoring project, the method for judging the physiological health state through the test paper has the advantages of short time, convenience and the like. The reaction results of the test strip are generally obtained by two methods: the first is to directly read the color and compare with the color comparison card by human eyes, and the scheme has larger error due to stronger subjective factors and cannot quantitatively obtain the result. The second method is that an operator uses a specific analyzer to directly read the test paper, and the result is not interfered by subjective factors or external factors, so that the result is accurate, but professional equipment is required, and the cost is high.
At present, intelligent mobile equipment is more and more popular, and the result that uses mobile equipment to shoot, then utilizes image processing technique to detect each index is more accurate for the human eye, more convenient mode for professional equipment. However, in the process of shooting an image, the image often generates an overall color cast due to characteristics such as color temperature of a light source, and the color cast of the image causes a huge error of color value recognition and visual perception, so that the color value of a pixel in the image is not in accordance with an actual situation. Even if the subsequent camera performs automatic white balance adjustment according to the actual image, the color correction result is still abnormal. In addition, in the actual shooting process, the colors of different parts of the image are changed due to uneven light irradiation, improper shooting angle and the like.
At present, some color correction schemes consider color correction, wherein some color correction schemes only use the difference value between the color value displayed in an image by a color correction color block and the average gray scale of the real color value of the color correction color block to perform color cast correction processing on an image in a test strip. However, this method can only perform the color shift correction processing on the image photographed under white light, and if the image is photographed under other illumination environments with color shift, the effect of the color shift correction processing will be deteriorated. Meanwhile, the direct color correction in the sRGB color space by using the difference value between the color value of the color correction color block in the image and the real color value is not scientific enough, and the image obtained by the camera is nonlinear in the color space, and the accurate color block color value to be corrected can be obtained not simply by linear addition and subtraction.
Therefore, there is no way to perform color correction at low cost and accurately under most illumination, even non-uniform illumination.
Disclosure of Invention
The application aims to provide a sample color correction method and device, an electronic device and a computer readable storage medium.
The application provides a sample color correction method in a first aspect, which comprises the following steps:
acquiring a target image to be subjected to color correction, wherein the target image comprises a calibration colorimetric plate and a sample placed on the calibration colorimetric plate; a plurality of color correction color blocks are uniformly distributed on the calibration colorimetric plate, and the color correction color blocks comprise 24-color standard color blocks and a plurality of standard concentration value color development blocks corresponding to the sample;
determining a color block to be corrected from a sample area on a target image;
taking the pixel values of the color correction color blocks in an sRGB color space as original values, taking the real values as target values, and obtaining an initial color correction matrix from the original values to the target values by using a least square method;
converting the pixel values of the color correction color blocks in the sRGB color space into a LINEARsRGB color space, and iteratively calculating a color correction matrix and a color correction value in the LINEARsRGB color space according to the initial color correction matrix to obtain a final color correction matrix from the initial value to a target value;
and obtaining a correction value of the color block to be corrected according to the final color correction matrix, and correcting the color of the sample according to the final color correction matrix.
A second aspect of the present application provides a sample color correction apparatus comprising:
the device comprises an acquisition module, a color correction module and a color correction module, wherein the acquisition module is used for acquiring a target image to be subjected to color correction, and the target image comprises a calibration colorimetric plate and a sample placed on the calibration colorimetric plate; a plurality of color correction color blocks are uniformly distributed on the calibration colorimetric plate, and the color correction color blocks comprise 24-color standard color blocks and a plurality of standard concentration value color development blocks corresponding to the sample;
the determining module is used for determining a color block to be corrected from a sample area on the target image;
the initial module is used for taking the pixel values of the color correction color blocks in the sRGB color space as original values, taking the real values as target values, and obtaining an initial color correction matrix from the original values to the target values by utilizing a least square method;
the iteration module is used for converting the pixel values of the color correction color blocks in the sRGB color space into the LINEARsRGB color space, and iteratively calculating a color correction matrix and a color correction value in the LINEARsRGB color space according to the initial color correction matrix to obtain a final color correction matrix from the initial value to a target value;
and the correction module is used for obtaining the correction value of the color block to be corrected according to the final color correction matrix and correcting the color of the sample according to the final color correction matrix.
A third aspect of the present application provides an electronic device comprising: memory, a processor and a computer program stored on the memory and executable on the processor, the processor executing the computer program when executing the computer program to perform the method of the first aspect of the application.
A fourth aspect of the present application provides a computer readable medium having computer readable instructions stored thereon which are executable by a processor to implement the method of the first aspect of the present application.
Compared with the prior art, the sample color correction method provided by the application obtains a target image to be color-corrected, and determines a color block to be corrected from a sample area on the target image; taking pixel values of the color correction color blocks in an sRGB color space as original values, taking real values as target values, and obtaining an initial color correction matrix from the original values to the target values by using a least square method; iteratively calculating a color correction matrix and a color correction value in a LINEARsRGB color space according to the initial color correction matrix to obtain a final color correction matrix from an original value to a target value; and obtaining a correction value of the color block to be corrected according to the final color correction matrix, and correcting the color of the sample according to the final color correction matrix. Therefore, the color identification errors caused by uneven light sources are avoided to a large extent by the aid of the color correction color blocks which are uniformly distributed, the final color correction matrix is obtained by iterative calculation in the LINEAR sRGB color space, and the color correction errors are reduced.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the application. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 illustrates a flow chart of a sample color correction method provided herein;
FIG. 2 shows a schematic view of an integrated light intelligent calibration cuvette device provided by the present application;
FIG. 3 illustrates a color correction matrix iteration flow diagram provided herein;
FIG. 4 shows a schematic diagram of a sample color correction apparatus provided herein;
FIG. 5 illustrates a schematic diagram of an electronic device provided herein;
FIG. 6 illustrates a schematic diagram of a computer-readable storage medium provided herein.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
It is to be noted that, unless otherwise specified, technical or scientific terms used herein shall have the ordinary meaning as understood by those skilled in the art to which this application belongs.
In addition, the terms "first" and "second", etc. are used to distinguish different objects, rather than to describe a particular order. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
At present, most of color correction modes simply and directly calculate the difference value between the true value and the pixel value of a single color correction color block in an sRGB color space, and then directly obtain the value of the color block to be corrected according to the difference value, and such modes ignore that an image acquired by a camera is presented in a nonlinear color space, and the color correction error is larger.
In view of the above, embodiments of the present application provide a sample color correction method and apparatus, an electronic device, and a computer-readable storage medium, which are described below with reference to the accompanying drawings.
Referring to fig. 1, a flowchart of a sample color calibration method provided in some embodiments of the present application is shown, which may include the following steps S101 to S105:
step S101: acquiring a target image to be subjected to color correction, wherein the target image comprises a calibration colorimetric plate and a sample placed on the calibration colorimetric plate; a plurality of color correction color blocks are uniformly distributed on the calibration colorimetric plate, and the color correction color blocks comprise 24-color standard color blocks and a plurality of standard concentration value color development blocks corresponding to the sample;
in this step, the calibration color comparison board can be the light intelligence calibration color comparison board device of integral type, and the device goes up evenly distributed 24 look standard colour cards and a plurality of standard concentration value color development pieces relevant with the sample, reduces the influence of light inequality and light source color cast to colour discernment.
For example, the sample is a test strip which displays different colors when testing liquids of different concentrations, and the standard concentration value color-developing patch is the color displayed when the test strip tests liquids of standard concentration.
Specifically, the light intelligent calibration colorimetric plate device shown in fig. 2 is an integrated device, as shown in fig. 2:
24-color Alice standard color cards meeting various industry standards are added into the device, and color correction color blocks made of the 24 standard color values are uniformly distributed on the device and serve as a part of the color correction color blocks.
For each sample, a plurality of standard density value color patches related to the sample are added to the apparatus, and this portion of the color correction patches is regarded as a color correction patch portion two.
The sample area for placing the sample is additionally arranged in the device, so that the position of the color block to be corrected on the sample can be conveniently and correctly positioned. As shown in fig. 2, the sample area is located in the middle of the light intelligent calibration colorimetric plate device, and the test paper strip can be put in.
The present application automatically detects whether an image is overexposed or too dark, rather than performing a correction directly on such an image, and therefore before step S102, the method further includes:
counting pixel values of all color correction color blocks on the target image, and calculating the proportion of the color correction color blocks with the pixel values exceeding a preset range in the total color correction color blocks;
and if the proportion is larger than a preset threshold value, sending a prompt message to prompt a user to adjust the light to shoot the target image again.
Specifically, a target image is acquired first, and automatic positioning and perspective transformation are performed on the target image. Normalizing the color of the target image, scaling the pixel value of the target image from [0,255] to [0,1], specifically, dividing the pixel value of the target image by 255 to obtain a normalized image; specifically, [0.02-0.98] may be selected as a suitable preset range of pixel values, and pixel values that are outside the preset range may be written as too bright or too dark.
The method and the device can automatically detect whether the image is shot in the condition of overexposure or over darkness, and do not directly correct the input image all the time, so that the error of subsequent color identification caused by color correction is reduced.
Step S102: determining a color block to be corrected from a sample area on a target image;
specifically, the positions of all color correction patches are known, and the patch to be corrected is determined from the sample region according to the position of the color correction patch, specifically, the size of the range of the patch to be corrected may be a square block with a side length of 6.
Calculating the R average value, the G average value and the B average value of the pixel values in the square blocks, wherein the formula is as follows:
Figure BDA0003177253320000061
Figure BDA0003177253320000062
Figure BDA0003177253320000063
wherein N ispixelsIs the total number of pixels in the color block to be corrected. R (x, y) represents the value of the pixel point at the (x, y) position in the R color channel, G (x, y) represents the value of the pixel point at the (x, y) position in the G color channel, and B (x, y) represents the value of the pixel point at the (x, y) position in the B color channel.
Step S103: taking the pixel values of the color correction color blocks in an sRGB color space as original values, taking the real values as target values, and obtaining an initial color correction matrix from the original values to the target values by using a least square method;
step S104: converting the pixel values of the color correction color blocks in the sRGB color space into a LINEARsRGB color space, and iteratively calculating a color correction matrix and a color correction value in the LINEARsRGB color space according to the initial color correction matrix to obtain a final color correction matrix from the initial value to a target value;
specifically, in order to make the Color cast Correction more scientific, the Color Correction Matrix (CCM) is not directly calculated in the sRGB Color space, but the CCM is calculated by means of the LINEAR sRGB Color space. CCM represents the mapping of the true values of the color correction patches and their pixel values in the sRGB color space. And converting the color from the sRGB into the LINEAR sRGB, iteratively calculating CCM and a correction value in the LINEAR sRGB color space, converting the correction value generated after each iteration from the LINEAR sRGB back to the sRGB, and calculating the value of the loss function obtained by the iteration. The loss function is defined as the sum of squares of difference values of real values and pixel values of a plurality of color correction color blocks in an sRGB linear color space, and the value of the loss function is reduced continuously through iteration to obtain the mapping relation from the pixel value to the real value in the sRGB color space.
The step S104 specifically includes:
multiplying the pixel values of all the color correction color blocks in the LINEARsRGB color space by the initial color correction matrix to obtain the color correction values of all the color correction color blocks;
normalizing all the obtained color correction values in [0,1], converting pixel values of color correction color blocks into an sRGB color space by LINEARsRGB, and calculating a subsequent loss function in the sRGB color space;
in the sRGB color space, the pixel values of all color correction color patches and their corresponding true values are subtracted in the three RGB color channels, and after all the differences are squared, they are summed and recorded as a loss function, and the formula is as follows:
Figure BDA0003177253320000071
wherein num is the number of all color correction color blocks, Corrected _ color(sRGB)Color correction values for color correction patches, Real color(sRGB)Correcting the true value of the color patch for the color;
obtaining a new color correction matrix by taking the value of the Loss function Loss as a target;
and repeating the iteration of the steps until the value of the Loss function Loss is smaller than a preset threshold value, and obtaining a final color correction matrix from the original value to the target value.
Specifically, the pixel values of the color patch are converted from the sRGB color space to the LINEAR sRGB color space by the following formula:
gamma=((sRGB+0.055)/1.055)2.4
scale=sRGB/12.92
Figure BDA0003177253320000072
specifically, the pixel values of the color blocks are converted into sRGB color space from LINEAR sRGB color space, and the conversion formula is as follows:
gamma=1.055×LINEAR sRGB(1/2.4)-0.055
sacle=LINEAR sRGB×12.92
Figure BDA0003177253320000073
specifically, an initial CCM is obtained by using a least square method, and the fitting formula is as follows: ax ═ b.
Wherein A is the pixel value of all color correction color blocks, b is the true value of all color correction color blocks, and the pixel value is obtained by minimizing the Euclidean norm
Figure BDA0003177253320000074
And obtaining the solution of x, namely the initial CCM.
After the initial CCM is obtained, iteration CCM is needed to obtain the final CCM. The iterative process is shown in figure 3.
Step S105: and obtaining a correction value of the color block to be corrected according to the final color correction matrix, and correcting the color of the sample according to the final color correction matrix.
Specifically, step S105 includes:
converting the pixel value of the color block to be corrected from sRGB to LINEAR sRGB color space;
multiplying the pixel value of the color block to be corrected in the LINEAR sRGB color space by the final color correction matrix to obtain the correction value of the color block to be corrected in the LINEAR sRGB color space;
normalizing the correction value of the color block to be corrected in [0,1], and converting the pixel value of the LINEAR sRGB color space into sRGB to obtain the pixel value of the corrected sample in the sRGB color space.
This application still can carry out accurate color correction under the condition that light is inhomogeneous and the light source can produce the color cast, with the help of 24 color standard color lumps on the light intelligence calibration colorimetric plate device and with a plurality of color correction color lumps that wait to rectify the color lump and correspond, can accurately rectify and restore the image that obtains under most light sources to the inhomogeneous condition of local illumination, accurate color cast correction is handled also can be carried out to this device, reduces the colour and leads to the error of colour discernment because of illumination.
In the above embodiments, a sample color correction method is provided, and correspondingly, the present application also provides a sample color correction apparatus. Please refer to fig. 4, which illustrates a schematic diagram of a sample color calibration apparatus according to some embodiments of the present application. Since the apparatus embodiments are substantially similar to the method embodiments, they are described in a relatively simple manner, and reference may be made to some of the descriptions of the method embodiments for relevant points. The device embodiments described below are merely illustrative.
As shown in fig. 4, the sample color correction apparatus 10 may include:
an obtaining module 101, configured to obtain a target image to be color-corrected, where the target image includes a calibration colorimetric plate and a sample placed on the calibration colorimetric plate; a plurality of color correction color blocks are uniformly distributed on the calibration colorimetric plate, and the color correction color blocks comprise 24-color standard color blocks and a plurality of standard concentration value color development blocks corresponding to the sample;
a determining module 102, configured to determine a color patch to be corrected from a sample area on a target image;
an initial module 103, configured to use pixel values of the multiple color correction color blocks in an sRGB color space as original values, use real values as target values, and obtain an initial color correction matrix from the original values to the target values by using a least square method;
an iteration module 104, configured to convert pixel values of the multiple color correction color blocks in an sRGB color space into a LINEARsRGB color space, and iteratively calculate a color correction matrix and a color correction value in the LINEARsRGB color space according to an initial color correction matrix to obtain a final color correction matrix from the initial value to a target value;
and the correcting module 105 is used for obtaining a correction value of the color block to be corrected according to the final color correction matrix and correcting the color of the sample according to the final color correction matrix.
According to some embodiments of the present application, the apparatus further comprises:
the prompting module is used for counting the pixel values of all the color correction color blocks on the target image and calculating the proportion of the color correction color blocks with the pixel values exceeding a preset range in the total color correction color blocks before the determining module determines the color blocks to be corrected from the sample area on the target image; and if the proportion is larger than a preset threshold value, sending a prompt message to prompt a user to adjust the light to shoot the target image again.
According to some embodiments of the present application, the iteration module 104 is specifically configured to:
multiplying the pixel values of all the color correction color blocks in the LINEARsRGB color space by the initial color correction matrix to obtain the color correction values of all the color correction color blocks;
normalizing all the obtained color correction values in [0,1], converting pixel values of color correction color blocks into an sRGB color space by LINEARsRGB, and calculating a subsequent loss function in the sRGB color space;
in the sRGB color space, the pixel values of all color correction color patches and their corresponding true values are subtracted in the three RGB color channels, and after all the differences are squared, they are summed and recorded as a loss function, and the formula is as follows:
Figure BDA0003177253320000091
wherein num is the number of all color correction color blocks, Corrected _ color(sRGB)Color correction values for color correction patches, Real color(sRGB)Correcting the true value of the color patch for the color;
obtaining a new color correction matrix by taking the value of the Loss function Loss as a target;
and repeating the iteration of the steps until the value of the Loss function Loss is smaller than a preset threshold value, and obtaining a final color correction matrix from the original value to the target value.
According to some embodiments of the present application, the correction module 105 is specifically configured to:
converting the pixel value of the color block to be corrected from sRGB to LINEAR sRGB color space;
multiplying the pixel value of the color block to be corrected in the LINEAR sRGB color space by the final color correction matrix to obtain the correction value of the color block to be corrected in the LINEAR sRGB color space;
normalizing the correction value of the color block to be corrected in [0,1], and converting the pixel value of the LINEAR sRGB color space into sRGB to obtain the pixel value of the corrected sample in the sRGB color space.
The sample color correction device 10 provided in the embodiment of the present application has the same beneficial effects as the sample color correction method provided in the previous embodiment of the present application based on the same inventive concept.
The present application further provides an electronic device, such as a mobile phone, a notebook computer, a tablet computer, a desktop computer, etc., corresponding to the sample color calibration method provided in the foregoing embodiments, so as to execute the sample color calibration method.
Please refer to fig. 5, which illustrates a schematic diagram of an electronic device according to some embodiments of the present application. As shown in fig. 5, the electronic device 20 includes: the system comprises a processor 200, a memory 201, a bus 202 and a communication interface 203, wherein the processor 200, the communication interface 203 and the memory 201 are connected through the bus 202; the memory 201 stores a computer program that can be executed on the processor 200, and the processor 200 executes the sample color correction method provided in any of the foregoing embodiments when executing the computer program.
The electronic device provided by the embodiment of the application and the sample color correction method provided by the embodiment of the application have the same inventive concept and have the same beneficial effects as the method adopted, operated or realized by the electronic device.
Referring to fig. 6, the computer readable storage medium is an optical disc 30, on which a computer program (i.e., a program product) is stored, and when the computer program is executed by a processor, the computer program executes the sample color correction method provided in any of the foregoing embodiments.
It should be noted that examples of the computer-readable storage medium may also include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory, or other optical and magnetic storage media, which are not described in detail herein.
The computer-readable storage medium provided by the above-mentioned embodiments of the present application and the sample color correction method provided by the embodiments of the present application have the same beneficial effects as the method adopted, executed or implemented by the application program stored in the computer-readable storage medium.
Finally, it should be noted that: the above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; such modifications and substitutions do not depart from the spirit and scope of the present disclosure, and the present disclosure should be construed as being covered by the claims and the specification.

Claims (10)

1. A method for color correction of a sample, comprising:
acquiring a target image to be subjected to color correction, wherein the target image comprises a calibration colorimetric plate and a sample placed on the calibration colorimetric plate; a plurality of color correction color blocks are uniformly distributed on the calibration colorimetric plate, and the color correction color blocks comprise 24-color standard color blocks and a plurality of standard concentration value color development blocks corresponding to the sample;
determining a color block to be corrected from a sample area on a target image;
taking the pixel values of the color correction color blocks in an sRGB color space as original values, taking the real values as target values, and obtaining an initial color correction matrix from the original values to the target values by using a least square method;
converting the pixel values of the color correction color blocks in the sRGB color space into LINEAR sRGB color space, and iteratively calculating a color correction matrix and a color correction value in the LINEAR sRGB color space according to the initial color correction matrix to obtain a final color correction matrix from the initial value to a target value;
and obtaining a correction value of the color block to be corrected according to the final color correction matrix, and correcting the color of the sample according to the final color correction matrix.
2. The method of claim 1, wherein prior to determining the color patch to be corrected from the sample area on the target image, the method further comprises:
counting pixel values of all color correction color blocks on the target image, and calculating the proportion of the color correction color blocks with the pixel values exceeding a preset range in the total color correction color blocks;
and if the proportion is larger than a preset threshold value, sending a prompt message to prompt a user to adjust the light to shoot the target image again.
3. The method of claim 1 or 2, wherein iteratively calculating a color correction matrix and color correction values in a LINEAR sRGB color space from an initial color correction matrix to obtain a final color correction matrix of original values to target values comprises:
multiplying the pixel values of all the color correction color blocks in a LINEAR sRGB color space by an initial color correction matrix to obtain the color correction values of all the color correction color blocks;
normalizing all the obtained color correction values in [0,1], converting pixel values of color correction color blocks into an sRGB color space by LINEAR sRGB, and calculating a loss function in the sRGB color space;
in the sRGB color space, the pixel values of all color correction color patches and their corresponding true values are subtracted in the three RGB color channels, and after all the differences are squared, they are summed and recorded as a loss function, and the formula is as follows:
Figure FDA0003177253310000011
wherein num is the number of all color correction color blocks, Corrected _ color(sRGB)Color correction values for color correction patches, Real color(sRGB)Correcting the true value of the color patch for the color;
obtaining a new color correction matrix by taking the value of the Loss function Loss as a target;
and repeating the iteration of the steps until the value of the Loss function Loss is smaller than a preset threshold value, and obtaining a final color correction matrix from the original value to the target value.
4. The method according to claim 3, wherein the obtaining of the correction value of the color block to be corrected according to the final color correction matrix and the correcting of the sample color according to the final color correction matrix comprise:
converting the pixel value of the color block to be corrected from sRGB to LINEAR sRGB color space;
multiplying the pixel value of the color block to be corrected in the LINEAR sRGB color space by the final color correction matrix to obtain the correction value of the color block to be corrected in the LINEAR sRGB color space;
normalizing the correction value of the color block to be corrected in [0,1], and converting the pixel value of the LINEAR sRGB color space into sRGB to obtain the pixel value of the corrected sample in the sRGB color space.
5. A sample color correction apparatus, comprising:
the device comprises an acquisition module, a color correction module and a color correction module, wherein the acquisition module is used for acquiring a target image to be subjected to color correction, and the target image comprises a calibration colorimetric plate and a sample placed on the calibration colorimetric plate; a plurality of color correction color blocks are uniformly distributed on the calibration colorimetric plate, and the color correction color blocks comprise 24-color standard color blocks and a plurality of standard concentration value color development blocks corresponding to the sample;
the determining module is used for determining a color block to be corrected from a sample area on the target image;
the initial module is used for taking the pixel values of the color correction color blocks in the sRGB color space as original values, taking the real values as target values, and obtaining an initial color correction matrix from the original values to the target values by utilizing a least square method;
the iteration module is used for converting the pixel values of the color correction color blocks in the sRGB color space into the LINEARsRGB color space, and iteratively calculating a color correction matrix and a color correction value in the LINEARsRGB color space according to the initial color correction matrix to obtain a final color correction matrix from the initial value to a target value;
and the correction module is used for obtaining the correction value of the color block to be corrected according to the final color correction matrix and correcting the color of the sample according to the final color correction matrix.
6. The apparatus of claim 5, further comprising:
the prompting module is used for counting the pixel values of all the color correction color blocks on the target image and calculating the proportion of the color correction color blocks with the pixel values exceeding a preset range in the total color correction color blocks before the determining module determines the color blocks to be corrected from the sample area on the target image; and if the proportion is larger than a preset threshold value, sending a prompt message to prompt a user to adjust the light to shoot the target image again.
7. The apparatus according to claim 5 or 6, wherein the iteration module is specifically configured to:
multiplying the pixel values of all the color correction color blocks in the LINEARsRGB color space by the initial color correction matrix to obtain the color correction values of all the color correction color blocks;
normalizing all the obtained color correction values in [0,1], converting pixel values of color correction color blocks into an sRGB color space by LINEARsRGB, and calculating a loss function in the sRGB color space;
in the sRGB color space, the pixel values of all color correction color patches and their corresponding true values are subtracted in the three RGB color channels, and after all the differences are squared, they are summed and recorded as a loss function, and the formula is as follows:
Figure FDA0003177253310000031
wherein num is the number of all color correction color blocks, Corrected _ color(sRGB)Color correction values for color correction patches, Real color(sRGB)Correcting the true value of the color patch for the color;
obtaining a new color correction matrix by taking the value of the Loss function Loss as a target;
and repeating the iteration of the steps until the value of the Loss function Loss is smaller than a preset threshold value, and obtaining a final color correction matrix from the original value to the target value.
8. The apparatus according to claim 7, wherein the correction module is specifically configured to:
converting the pixel value of the color block to be corrected from sRGB to LINEAR sRGB color space;
multiplying the pixel value of the color block to be corrected in the LINEAR sRGB color space by the final color correction matrix to obtain the correction value of the color block to be corrected in the LINEAR sRGB color space;
normalizing the correction value of the color block to be corrected in [0,1], and converting the pixel value of the LINEAR sRGB color space into sRGB to obtain the pixel value of the corrected sample in the sRGB color space.
9. An electronic device, comprising: memory, processor and computer program stored on the memory and executable on the processor, characterized in that the processor executes when executing the computer program to implement the method according to any of claims 1 to 4.
10. A computer-readable storage medium having computer-readable instructions stored thereon, the computer-readable instructions being executable by a processor to implement the method of any one of claims 1 to 4.
CN202110835812.8A 2021-07-23 2021-07-23 Sample color correction method, sample color correction device, electronic device, and medium Pending CN113674164A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110835812.8A CN113674164A (en) 2021-07-23 2021-07-23 Sample color correction method, sample color correction device, electronic device, and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110835812.8A CN113674164A (en) 2021-07-23 2021-07-23 Sample color correction method, sample color correction device, electronic device, and medium

Publications (1)

Publication Number Publication Date
CN113674164A true CN113674164A (en) 2021-11-19

Family

ID=78539925

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110835812.8A Pending CN113674164A (en) 2021-07-23 2021-07-23 Sample color correction method, sample color correction device, electronic device, and medium

Country Status (1)

Country Link
CN (1) CN113674164A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114840704A (en) * 2022-04-13 2022-08-02 云南省农业科学院质量标准与检测技术研究所 Plant color comparison method, device, equipment and storage medium
CN115456894A (en) * 2022-09-02 2022-12-09 北京墨境天合数字图像科技有限公司 Video production color correction method, device, equipment and storage medium
CN115529447A (en) * 2022-11-23 2022-12-27 芯动微电子科技(珠海)有限公司 Display method, system and equipment
TWI805112B (en) * 2021-12-06 2023-06-11 國立成功大學 Colorimetric device and checkup system
CN116416325B (en) * 2023-06-12 2023-09-29 广东粤港澳大湾区国家纳米科技创新研究院 Automatic color block identification method and device and electronic equipment

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI805112B (en) * 2021-12-06 2023-06-11 國立成功大學 Colorimetric device and checkup system
CN114840704A (en) * 2022-04-13 2022-08-02 云南省农业科学院质量标准与检测技术研究所 Plant color comparison method, device, equipment and storage medium
CN115456894A (en) * 2022-09-02 2022-12-09 北京墨境天合数字图像科技有限公司 Video production color correction method, device, equipment and storage medium
CN115529447A (en) * 2022-11-23 2022-12-27 芯动微电子科技(珠海)有限公司 Display method, system and equipment
CN116416325B (en) * 2023-06-12 2023-09-29 广东粤港澳大湾区国家纳米科技创新研究院 Automatic color block identification method and device and electronic equipment

Similar Documents

Publication Publication Date Title
CN113674164A (en) Sample color correction method, sample color correction device, electronic device, and medium
US7522767B2 (en) True color communication
CN113170028B (en) Method for generating image data of machine learning based imaging algorithm
BR112012016626B1 (en) METHOD AND APPLIANCE TO DETERMINE COLORIMETRY DATA OF A COLOR SAMPLE FROM AN IMAGE OF THE SAME
US11398055B2 (en) Color evaluation device, color evaluation method, and indication object used in color evaluation method
US11044450B2 (en) Image white balancing
US20210299651A1 (en) Multi-factor urine test system that adjusts for lighting and timing
US9307214B1 (en) Automatic white balance methods and systems for electronic cameras
CN102985943A (en) Color image processing method, color image processing device, and color image processing program
US8929650B2 (en) Image color correction
CN106468661A (en) A kind of urine test paper colour imaging correlation detection methods and system
Ratnasingam et al. Chromaticity space for illuminant invariant recognition
Zhao et al. Spectral illumination correction: Achieving relative color constancy under the spectral domain
JP2023528942A (en) Methods, mobile devices, kits, computer programs and computer readable storage media for determining the concentration of an analyte in a sample of bodily fluid
US9307215B1 (en) Automatic white balance methods and systems for electronic cameras
CN113628135A (en) Image color correction method, image color correction device, computer device, and storage medium
US11740132B2 (en) Method and apparatus for color lookup using a mobile device
CN111537447A (en) Spectrum reconstruction method, printing quality evaluation method and system and electronic equipment
CN112422841B (en) Image compensation method, image compensation device, computer equipment and storage medium
CN112165616B (en) Camera module testing method and device, electronic equipment and storage medium
Kibria et al. Smartphone-based point-of-care urinalysis assessment
US11928842B2 (en) Method and apparatus for measuring chromaticity of a target object
CN113596427B (en) Image white balance improving method and device, electronic equipment and storage medium
Zhao et al. Pixel-wise Illumination Correction Algorithms for Relative Color Constancy Under the Spectral Domain
EP4286939A1 (en) Imaging condition setting system, imaging condition setting method, and program

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