CN113674164B - Sample color correction method, device, electronic equipment and medium - Google Patents
Sample color correction method, device, electronic equipment and medium Download PDFInfo
- Publication number
- CN113674164B CN113674164B CN202110835812.8A CN202110835812A CN113674164B CN 113674164 B CN113674164 B CN 113674164B CN 202110835812 A CN202110835812 A CN 202110835812A CN 113674164 B CN113674164 B CN 113674164B
- Authority
- CN
- China
- Prior art keywords
- color
- value
- color correction
- srgb
- correction
- 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.)
- Active
Links
- 238000012937 correction Methods 0.000 title claims abstract description 264
- 238000000034 method Methods 0.000 title claims abstract description 55
- 239000011159 matrix material Substances 0.000 claims abstract description 77
- 230000006870 function Effects 0.000 claims description 25
- 238000011161 development Methods 0.000 claims description 9
- 238000004590 computer program Methods 0.000 claims description 8
- 238000013507 mapping Methods 0.000 claims description 6
- 238000004364 calculation method Methods 0.000 abstract description 2
- 238000012360 testing method Methods 0.000 description 8
- 238000010586 diagram Methods 0.000 description 6
- 230000008901 benefit Effects 0.000 description 5
- 238000005286 illumination Methods 0.000 description 5
- 230000008569 process Effects 0.000 description 5
- 238000006243 chemical reaction Methods 0.000 description 3
- 238000004891 communication Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 230000036541 health Effects 0.000 description 2
- 239000007788 liquid Substances 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 239000003086 colorant Substances 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000012804 iterative process Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000009466 transformation Effects 0.000 description 1
- 230000016776 visual perception Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/80—Geometric correction
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/90—Determination of colour characteristics
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/10—Image acquisition modality
- G06T2207/10004—Still image; Photographic image
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/10—Image acquisition modality
- G06T2207/10024—Color image
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)
- Color Image Communication Systems (AREA)
Abstract
The application provides a sample color correction method, a sample color correction device, electronic equipment and a sample color correction medium. The method comprises the following steps: acquiring a target image to be color corrected, and determining a color block to be corrected from a sample area on the target image; taking pixel values of a plurality of color correction color blocks in an sRGB color space as original values, taking a true value as a target value, 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 LINEARsRGB color spaces 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. The application avoids color recognition errors caused by uneven light sources to a large extent by means of evenly distributed color correction color blocks, and the final color correction matrix is obtained by iterative calculation in the LINEAR sRGB color space, thereby reducing the color correction errors.
Description
Technical Field
The application relates to the technical field of artificial intelligence, in particular to a sample color correction method and device, electronic equipment and a computer readable storage medium.
Background
In the health monitoring project, the method for judging the physiological health state is brought by test paper, and the method has the advantages of short-time convenience and the like. There are generally two ways to obtain the reaction results of the test strip: the first is to directly read the color and the colorimetric card for comparison by human eyes, and the scheme has larger error and can not quantitatively obtain the result because of stronger subjective factors. The second is that the operator uses a specific analyzer to directly read the test paper, the result of the mode is not interfered by subjective factors or external factors, the result is accurate, but professional equipment and high cost are required.
At present, intelligent mobile devices are becoming more and more popular, mobile devices are used for photographing, and then image processing technology is utilized to detect the results of various indexes, so that the intelligent mobile devices are a more accurate mode relative to human eyes and a more convenient mode relative to professional equipment. However, in the process of capturing an image, the image often generates overall color cast due to the characteristics of color temperature and the like of a light source, and the color cast of the image can cause huge errors of color value identification and visual perception, so that the color value of pixels in the image is not consistent with the actual situation. Even if the subsequent cameras perform automatic white balance adjustment according to the actual images, the color correction result still becomes abnormal. In addition, in the actual photographing process, color changes of different parts of the image are caused due to uneven light irradiation or improper photographing angle.
Some of the existing technical schemes consider color correction, wherein some color correction schemes only use the difference value between the color value of the color correction color block displayed in the image and the average gray level of the true color value of the color correction color block to perform color cast correction processing on the test paper belt image. However, this method can only perform color shift correction on an image photographed under white light, and if photographing is performed under other illumination environments with color shift, the effect of the color shift correction will be deteriorated. Meanwhile, the color correction is not scientific enough by directly utilizing the difference value between the color value of the color correction color block in the image and the true color value in the sRGB color space, and the color value of the color block to be corrected with accurate correction can be obtained by not simply carrying out linear addition and subtraction because the picture obtained by the camera is nonlinear in the color space.
Therefore, there is still no way to perform low-cost and accurate color correction under most of the illumination, even under uneven 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 first aspect of the present application provides a method for correcting color of a sample, comprising:
Acquiring a target image to be color corrected, 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 each color correction color block comprises 24 standard color blocks and a plurality of standard concentration value color development color blocks corresponding to the sample;
Determining a color patch to be corrected from a sample area on the target image;
taking pixel values of the color correction color blocks in the sRGB color space as original values, taking a true value as a target value, 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 plurality of color correction color blocks in the sRGB color space into LINEARsRGB color space, and iteratively calculating a color correction matrix and a color correction value in 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.
A second aspect of the present application provides a sample color correction device 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 color corrected, 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 each color correction color block comprises 24 standard color blocks and a plurality of standard concentration value color development color blocks corresponding to the sample;
a determining module for determining a color patch to be corrected from a sample area on the target image;
The initial module is used for taking the pixel values of the plurality of color correction color blocks in the sRGB color space as original values, taking the true 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;
The iteration module is used for converting the pixel values of the plurality of color correction color blocks in the sRGB color space into 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 an original value to a target value;
And the correction module 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.
A third aspect of the present application provides an electronic apparatus, comprising: a memory, a processor and a computer program stored on the memory and executable on the processor, the processor executing the computer program to perform the method according to the first aspect of the application.
A fourth aspect of the application provides a computer readable medium having stored thereon computer readable instructions executable by a processor to implement the method according to the first aspect of the application.
Compared with the prior art, the sample color correction method provided by the application has the advantages that the target image to be color corrected is obtained, and the color block to be corrected is determined from the sample area on the target image; taking pixel values of a plurality of color correction color blocks in an sRGB color space as original values, taking a true value as a target value, 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 LINEARsRGB color spaces 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 application avoids color recognition errors caused by uneven light sources to a larger extent by means of evenly distributed color correction color blocks, and the final color correction matrix is obtained in the LINEAR sRGB color space through iterative calculation, thereby reducing the color correction errors.
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 designate like parts throughout the figures. In the drawings:
FIG. 1 is a flow chart of a method for color correction of a sample provided by the present application;
FIG. 2 shows a schematic diagram of an integrated light intelligent calibration colorimetric plate device provided by the application;
FIG. 3 shows an iterative flow chart of a color correction matrix provided by the present application;
FIG. 4 is a schematic diagram of a sample color correction device provided by the present application;
FIG. 5 shows a schematic diagram of an electronic device provided by the present application;
fig. 6 shows a schematic diagram of a computer readable storage medium provided by the present application.
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 noted that unless otherwise indicated, technical or scientific terms used herein should be given the ordinary meaning as understood by one of ordinary skill in the art to which this application belongs.
In addition, the terms "first" and "second" etc. are used to distinguish different objects and are not used to describe a particular order. Furthermore, the terms "comprise" and "have," as well as any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus.
At present, most color correction modes are simple and direct, the difference between the true value and the pixel value of a single color correction color block is calculated in an sRGB color space, and then the value of the color block to be corrected is directly obtained according to the difference, so that the mode ignores that an image acquired by a camera is displayed in a nonlinear color space, and the color correction error is larger.
In view of the above, embodiments of the present application provide a method and apparatus for color correction of a sample, 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 method for color correction of a sample according to some embodiments of the present application is shown, and the method may include the following steps S101 to S105:
Step S101: acquiring a target image to be color corrected, 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 each color correction color block comprises 24 standard color blocks and a plurality of standard concentration value color development color blocks corresponding to the sample;
In the step, the calibration colorimetric plate can be an integrated light intelligent calibration colorimetric plate device, 24 standard color cards and a plurality of standard concentration value color development blocks related to a sample are uniformly distributed on the device, and the influence of light unevenness and light source color cast on color recognition is reduced.
For example, the sample is a test paper tape, which shows different colors when tested for different concentrations of liquid, and the standard concentration value color development block is the color displayed when the test paper tape tests for standard concentration of liquid.
Specifically, fig. 2 shows an integrated light intelligent calibration colorimetric plate device, as shown in fig. 2:
The 24-color ali 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, wherein the color correction color blocks are used as a first color correction color block part.
For each sample, a plurality of standard concentration value development patches associated with the sample are added to the device, and the color correction patches are used as color correction patch parts II.
A sample area for placing a sample is additionally arranged in the device, so that the position of a 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 a test strip can be placed in the sample area.
The present application automatically detects that an image is overexposed or too dark, rather than directly correcting on such an image, and therefore the method further comprises, prior to step S102:
counting 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 to the total color correction color blocks;
And if the proportion is greater than a preset threshold, sending prompt information 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 predetermined range of suitable pixel values, and pixel values outside the predetermined range may be noted as too bright or too dark.
The application automatically detects whether the image is shot in the condition of overexposure or darkness, and does not directly correct the input image at all, thereby reducing errors of subsequent color recognition caused by color correction.
Step S102: determining a color patch to be corrected from a sample area on the target image;
specifically, the positions of all the color correction patches are known, the color patches to be corrected are determined from the sample area according to the positions of the color correction patches, and specifically, the size of the color patch to be corrected can be selected as a square block with a side length of 6.
R average value, G average value and B average value of pixel values in the square block are calculated, and the formula is as follows:
Where N pixels is the total number of pixels within the color block to be corrected. R (x, y) represents the value of the pixel in the R color channel at the (x, y) position, G (x, y) represents the value of the pixel in the G color channel at the (x, y) position, and B (x, y) represents the value of the pixel in the B color channel at the (x, y) position.
Step S103: taking pixel values of the color correction color blocks in the sRGB color space as original values, taking a true value as a target value, 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 plurality of color correction color blocks in the sRGB color space into LINEARsRGB color space, and iteratively calculating a color correction matrix and a color correction value in 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;
Specifically, in order to make the color cast correction process more scientific, the application does not directly calculate the color correction matrix (Color Correction Matrix, CCM) in the sRGB color space, but calculates the CCM by means of the LINEAR sRGB color space. CCM represents the mapping of the true value of the color correction color block and its pixel value in the sRGB color space. The color is converted from sRGB to LINEAR sRGB, CCM and correction values are iteratively calculated in the LINEAR sRGB color space, and correction values generated after each iteration are converted from LINEAR sRGB back to sRGB, and the value of the loss function obtained for that iteration is calculated. The loss function is defined as the sum of squares of differences between the true values and the pixel values of a plurality of color correction color blocks in the sRGB linear color space, and the mapping relation between the pixel values and the true values in the sRGB color space is obtained by continuously reducing the value of the loss function through iteration.
The step S104 specifically includes:
multiplying the pixel values of all the color correction color blocks in LINEARsRGB color space with the initial color correction matrix to obtain color correction values of all the color correction color blocks;
Normalizing all obtained color correction values in [0,1], converting pixel values of the color correction color blocks into an sRGB color space by LINEARsRGB, and calculating a subsequent loss function in the sRGB color space;
the pixel values of all the color correction color blocks and the corresponding true values are respectively subtracted in three RGB color channels in the sRGB color space, and the sum is recorded as a loss function after all the difference values are squared, wherein the formula is as follows:
Wherein num is the number of all color correction color patches, corrected _color (sRGB) is the color correction value of the color correction color patches, and real_color (sRGB) is the true value of the color correction color patches;
The value of the Loss function Loss is reduced as a target, and a new color correction matrix is obtained;
repeating 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 block are converted from the sRGB color space to the line sRGB color space, and the conversion formula is as follows:
gamma=((sRGB+0.055)/1.055)2.4
scale=sRGB/12.92
Specifically, the pixel values of the color block are converted from the LINEAR sRGB color space into the 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
Specifically, an initial CCM is obtained by using a least square method, and a fitting formula is as follows: ax=b.
Wherein A is the pixel value of all color correction patches, b is the true value of all color correction patches by minimizing the Euclidean normAnd obtaining a solution of x, namely the initial CCM.
After the initial CCM is obtained, the CCM needs to be iterated to obtain the final CCM. The iterative process is shown in fig. 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 pixel values 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 with the final color correction matrix to obtain a correction value of the color block to be corrected in the LINEAR sRGB color space;
and 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 application can accurately correct color under the conditions that light rays are uneven and light sources generate color cast, and can accurately correct and restore images acquired under most light sources by means of the 24-standard color blocks and the plurality of color correction color blocks corresponding to the color blocks to be corrected on the light intelligent correction color comparison plate device, and can accurately correct color cast aiming at the condition that local illumination is uneven, and reduce errors of color identification caused by illumination.
In the above embodiment, a sample color correction method is provided, and correspondingly, the application also provides a sample color correction device. Referring to fig. 4, a schematic diagram of a sample color correction device according to some embodiments of the application is shown. Since the apparatus embodiments are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments for relevant points. The device embodiments described below are merely illustrative.
As shown in fig. 4, the sample color correction device 10 may include:
An acquisition module 101, configured to acquire 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 each color correction color block comprises 24 standard color blocks and a plurality of standard concentration value color development color blocks corresponding to the sample;
a determining module 102, configured to determine a color patch to be corrected from a sample area on the target image;
An initial module 103, configured to obtain an initial color correction matrix from the original value to the target value by using a least square method, where the original value is the pixel value of the plurality of color correction color blocks in the sRGB color space, and the actual value is the target value;
An iteration module 104, configured to convert the pixel values of the plurality of color correction color blocks in the sRGB color space into LINEARsRGB color space, and iteratively calculate a color correction matrix and a color correction value in LINEARsRGB color space according to the initial color correction matrix, to obtain a final color correction matrix from the original value to the target value;
And the correction 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 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 before the determining module determines the color blocks to be corrected from the sample area on the target image, and calculating the proportion of the color correction color blocks with the pixel values exceeding a preset range to the total color correction color blocks; and if the proportion is greater than a preset threshold, sending prompt information to prompt a user to adjust the light to shoot the target image again.
According to some embodiments of the application, the iteration module 104 is specifically configured to:
multiplying the pixel values of all the color correction color blocks in LINEARsRGB color space with the initial color correction matrix to obtain color correction values of all the color correction color blocks;
Normalizing all obtained color correction values in [0,1], converting pixel values of the color correction color blocks into an sRGB color space by LINEARsRGB, and calculating a subsequent loss function in the sRGB color space;
the pixel values of all the color correction color blocks and the corresponding true values are respectively subtracted in three RGB color channels in the sRGB color space, and the sum is recorded as a loss function after all the difference values are squared, wherein the formula is as follows:
Wherein num is the number of all color correction color patches, corrected _color (sRGB) is the color correction value of the color correction color patches, and real_color (sRGB) is the true value of the color correction color patches;
The value of the Loss function Loss is reduced as a target, and a new color correction matrix is obtained;
repeating 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 application, the correction module 105 is specifically configured to:
Converting pixel values 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 with the final color correction matrix to obtain a correction value of the color block to be corrected in the LINEAR sRGB color space;
and 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 advantages as the sample color correction method provided in the previous embodiment of the present application due to the same inventive concept.
The embodiment of the application also provides an electronic device, such as a mobile phone, a notebook computer, a tablet computer, a desktop computer and the like, corresponding to the sample color correction method provided by the previous embodiment, so as to execute the sample color correction method.
Referring to fig. 5, a schematic diagram of an electronic device according to some embodiments of the present application is shown. As shown in fig. 5, the electronic device 20 includes: a processor 200, a memory 201, a bus 202 and a communication interface 203, the processor 200, the communication interface 203 and the memory 201 being connected by the bus 202; the memory 201 stores a computer program executable on the processor 200, and the processor 200 executes the sample color correction method according to any one of the foregoing embodiments of the present application when the computer program is executed.
The electronic equipment provided by the embodiment of the application and the sample color correction method provided by the embodiment of the application have the same beneficial effects as the method adopted, operated or realized by the electronic equipment and the sample color correction method provided by the embodiment of the application are based on the same inventive concept.
The embodiment of the present application further provides a computer readable storage medium corresponding to the sample color correction method provided in the foregoing embodiment, referring to fig. 6, the computer readable storage medium is shown as an optical disc 30, on which a computer program (i.e. a program product) is stored, where the computer program, when executed by a processor, performs 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, a phase change memory (PRAM), a Static Random Access Memory (SRAM), a Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a flash memory, or other optical or magnetic storage medium, which will not be described in detail herein.
The computer readable storage medium provided by the above embodiment of the present application has the same advantageous effects as the method adopted, operated or implemented by the application program stored therein, because of the same inventive concept as the sample color correction method provided by the embodiment of the present application.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the application, and are intended to be included within the scope of the appended claims and description.
Claims (10)
1. A method for color correction of a sample, comprising:
Acquiring a target image to be color corrected, 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 each color correction color block comprises 24 standard color blocks and a plurality of standard concentration value color development color blocks corresponding to the sample;
Determining a color patch to be corrected from a sample area on the target image;
taking pixel values of the color correction color blocks in the sRGB color space as original values, taking a true value as a target value, and obtaining an initial color correction matrix from the original values to the target values by using a least square method;
converting pixel values of the plurality of color correction color blocks in an sRGB color space into a LINEAR sRGB color space, and iteratively calculating a color correction matrix and a color correction value in the LINEAR sRGB color space according to an initial color correction matrix to obtain a final color correction matrix from the original value to a target value;
obtaining a correction value of a 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;
The step of iteratively calculating a color correction matrix and a color correction value in a line sRGB color space according to an initial color correction matrix to obtain a final color correction matrix from an original value to a target value, includes:
Converting the color from sRGB to LINEAR sRGB, iteratively calculating CCM and correction values in the LINEAR sRGB color space, converting the correction value generated after each iteration from LINEAR sRGB back to sRGB, and calculating the value of the loss function obtained by the iteration; wherein CCM represents the mapping relationship between the true value of the color correction color block and the pixel value thereof in the sRGB color space, the loss function is defined as the sum of squares of the differences between the true value and the pixel value of a plurality of color correction color blocks in the sRGB linear color space, and the mapping relationship between the pixel value and the true value in the sRGB color space is obtained by iteratively and continuously reducing the value of the loss function.
2. The method of claim 1, wherein prior to determining the color block to be corrected from the sample area on the target image, the method further comprises:
counting 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 to the total color correction color blocks;
And if the proportion is greater than a preset threshold, sending prompt information to prompt a user to adjust the light to shoot the target image again.
3. The method according to claim 1 or 2, wherein iteratively calculating the color correction matrix and the color correction values in the line sRGB color space from the initial color correction matrix, resulting in a final color correction matrix of original to target values, comprises:
multiplying the pixel values of all the color correction color blocks in the LINEAR sRGB color space with an initial color correction matrix to obtain color correction values of all the color correction color blocks;
Normalizing all obtained color correction values in [0,1], converting pixel values of the color correction color blocks into sRGB color space by LINEAR sRGB, and calculating a loss function in the sRGB color space;
the pixel values of all the color correction color blocks and the corresponding true values are respectively subtracted in three RGB color channels in the sRGB color space, and the sum is recorded as a loss function after all the difference values are squared, wherein the formula is as follows:
Wherein num is the number of all color correction color patches, corrected _color (sRGB) is the color correction value of the color correction color patches, and real_color (sRGB) is the true value of the color correction color patches;
The value of the Loss function Loss is reduced as a target, and a new color correction matrix is obtained;
repeating 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. A method according to claim 3, wherein said obtaining a correction value for a color block to be corrected based on said final color correction matrix, correcting a sample color based on said final color correction matrix, comprises:
Converting pixel values 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 with the final color correction matrix to obtain a correction value of the color block to be corrected in the LINEAR sRGB color space;
and 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 device, 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 color corrected, 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 each color correction color block comprises 24 standard color blocks and a plurality of standard concentration value color development color blocks corresponding to the sample;
a determining module for determining a color patch to be corrected from a sample area on the target image;
The initial module is used for taking the pixel values of the plurality of color correction color blocks in the sRGB color space as original values, taking the true 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;
The iteration module is used for converting the pixel values of the plurality of color correction color blocks in the sRGB color space into the 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 original value to the target value;
The correction module 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;
The iteration module is specifically configured to:
Converting the color from sRGB to LINEAR sRGB, iteratively calculating CCM and correction values in the LINEAR sRGB color space, converting the correction value generated after each iteration from LINEAR sRGB back to sRGB, and calculating the value of the loss function obtained by the iteration; wherein CCM represents the mapping relationship between the true value of the color correction color block and the pixel value thereof in the sRGB color space, the loss function is defined as the sum of squares of the differences between the true value and the pixel value of a plurality of color correction color blocks in the sRGB linear color space, and the mapping relationship between the pixel value and the true value in the sRGB color space is obtained by iteratively and continuously reducing the value of the loss function.
6. The apparatus of claim 5, wherein 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 before the determining module determines the color blocks to be corrected from the sample area on the target image, and calculating the proportion of the color correction color blocks with the pixel values exceeding a preset range to the total color correction color blocks; and if the proportion is greater than a preset threshold, sending prompt information 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 LINEAR sRGB color space with an initial color correction matrix to obtain color correction values of all the color correction color blocks;
Normalizing all obtained color correction values in [0,1], converting pixel values of the color correction color blocks into sRGB color space by LINEAR sRGB, and calculating a loss function in the sRGB color space;
the pixel values of all the color correction color blocks and the corresponding true values are respectively subtracted in three RGB color channels in the sRGB color space, and the sum is recorded as a loss function after all the difference values are squared, wherein the formula is as follows:
Wherein num is the number of all color correction color patches, corrected _color (sRGB) is the color correction value of the color correction color patches, and real_color (sRGB) is the true value of the color correction color patches;
The value of the Loss function Loss is reduced as a target, and a new color correction matrix is obtained;
repeating 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 pixel values 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 with the final color correction matrix to obtain a correction value of the color block to be corrected in the LINEAR sRGB color space;
and 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, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor executes to implement the method according to any of claims 1 to 4 when the computer program is run.
10. A computer readable storage medium having stored thereon computer readable instructions executable by a processor to implement the method of any one of claims 1 to 4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110835812.8A CN113674164B (en) | 2021-07-23 | 2021-07-23 | Sample color correction method, device, electronic equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110835812.8A CN113674164B (en) | 2021-07-23 | 2021-07-23 | Sample color correction method, device, electronic equipment and medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113674164A CN113674164A (en) | 2021-11-19 |
CN113674164B true CN113674164B (en) | 2024-09-03 |
Family
ID=78539925
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110835812.8A Active CN113674164B (en) | 2021-07-23 | 2021-07-23 | Sample color correction method, device, electronic equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113674164B (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TWI805112B (en) * | 2021-12-06 | 2023-06-11 | 國立成功大學 | Colorimetric device and checkup system |
CN114840704B (en) * | 2022-04-13 | 2022-10-18 | 云南省农业科学院质量标准与检测技术研究所 | 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 |
CN115529447B (en) * | 2022-11-23 | 2023-05-02 | 芯动微电子科技(珠海)有限公司 | Display method, system and equipment |
CN116416325B (en) * | 2023-06-12 | 2023-09-29 | 广东粤港澳大湾区国家纳米科技创新研究院 | Automatic color block identification method and device and electronic equipment |
CN117593217B (en) * | 2023-09-23 | 2024-09-24 | 深圳市大我云读写科技有限公司 | PDF quick brightening method and device, electronic equipment and storage medium |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104574371A (en) * | 2014-12-20 | 2015-04-29 | 中国科学院西安光学精密机械研究所 | High dynamic color digital camera characterization calibration method |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8605167B2 (en) * | 2010-09-01 | 2013-12-10 | Apple Inc. | Flexible color space selection for auto-white balance processing |
CN104601971B (en) * | 2014-12-31 | 2019-06-14 | 小米科技有限责任公司 | Color adjustment method and device |
CN108282647B (en) * | 2018-01-31 | 2019-11-05 | 上海小蚁科技有限公司 | Color correcting method and device, computer readable storage medium, terminal |
-
2021
- 2021-07-23 CN CN202110835812.8A patent/CN113674164B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104574371A (en) * | 2014-12-20 | 2015-04-29 | 中国科学院西安光学精密机械研究所 | High dynamic color digital camera characterization calibration method |
Also Published As
Publication number | Publication date |
---|---|
CN113674164A (en) | 2021-11-19 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN113674164B (en) | Sample color correction method, device, electronic equipment and medium | |
Pierson et al. | Tutorial: luminance maps for daylighting studies from high dynamic range photography | |
CN108668093B (en) | HDR image generation method and device | |
US9386288B2 (en) | Compensating for sensor saturation and microlens modulation during light-field image processing | |
US6975775B2 (en) | Stray light correction method for imaging light and color measurement system | |
US7733391B2 (en) | Method and system for black-level correction on digital image data | |
US11398055B2 (en) | Color evaluation device, color evaluation method, and indication object used in color evaluation method | |
US8619153B2 (en) | Radiometric calibration using temporal irradiance mixtures | |
CN111083458B (en) | Brightness correction method, system, equipment and computer readable storage medium | |
BR112012016626B1 (en) | METHOD AND APPLIANCE TO DETERMINE COLORIMETRY DATA OF A COLOR SAMPLE FROM AN IMAGE OF THE SAME | |
CN101124611A (en) | Auto White Balance for Color Gain Values | |
CN113516636A (en) | Method, device, equipment and medium for evaluating lens shadow and lens module | |
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 | |
Zhao et al. | Spectral illumination correction: Achieving relative color constancy under the spectral domain | |
CN115343281A (en) | Water quality detection system, water quality detection method, calculation device, and storage medium | |
CN118280238B (en) | Gamma detection method, device and storage medium in display Demura process | |
CN109493830B (en) | Adjusting method and adjusting system of display panel and display device | |
CN112422841B (en) | Image compensation method, image compensation device, computer equipment and storage medium | |
Kibria et al. | Smartphone-based point-of-care urinalysis assessment | |
Fang et al. | Sqad: Automatic smartphone camera quality assessment and benchmarking | |
CN116152361A (en) | Method for estimating chromaticity, electronic device, and computer-readable storage medium | |
CN116412907A (en) | Calibration method and device for ambient light sensor and storage medium | |
US20240102934A1 (en) | Test Strip Carrier, System and Method for Test Strip Detection | |
EP4257942A1 (en) | White transfer camera check | |
CN117676348A (en) | Intelligent equipment and method for acquiring and calibrating spectral sensitivity of image sensor of intelligent equipment |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |