A color correction method

Calculating camera parameters through standard color cards and Levenberg-Marquard algorithm solves the problem of complex and time-consuming color correction in the existing technology, achieving simplified operations and effective color correction effects.

CN113132693BActive Publication Date: 2024-10-01CHANGSHA YUNZHIJIAN INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201911424392.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-12-31
Publication Date
2024-10-01
Estimated Expiration
2039-12-31

AI Technical Summary

Technical Problem

Existing color correction methods require knowing camera parameters in advance or collecting multiple images at the same time. The operation is complex, time-consuming, and resource intensive, making it difficult to effectively reduce color deviations between different cameras.

Method used

Using a standard color card, including the substrate, detection area and sample area, through binary image processing and Levenberg-Marquard optimal algorithm, the gain, offset and gamma parameters of the camera are calculated to achieve image color correction.

Benefits of technology

It simplifies the operation, reduces the amount of calculation, is suitable for different cameras with unknown parameters, achieves effective correction of color deviation, has wide adaptability and is low-cost to implement.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113132693B_ABST
    Figure CN113132693B_ABST
Patent Text Reader

Abstract

The present invention discloses a color correction method, comprising the following steps: using a barcode recognition algorithm to identify the barcode image to obtain barcode data; then obtaining the position coordinates and size of each standard color block, each white check color block and the target according to the configuration scheme obtained from the barcode data, and then locating the position and contour of each standard color block, each white check color block and the target object in the original complete detection area image; based on the above characteristics, after preprocessing each original color image, obtaining the image color value of each original standard color block image and white check color block as the correction color block color value; obtaining the image color value of the target object. The present invention can be used to solve the color deviation problem when different cameras with unknown parameters capture images of different target objects, and has the advantages of wide adaptability, simple operation, small amount of calculation, and can be implemented at low cost based on general hardware and software.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of image processing, and in particular relates to a color correction method. Background Art

[0002] A camera is an electronic device that can capture images and convert optical image signals into electrical signals, thereby realizing image acquisition and storage. The color of an object seen by the human eye is the true color of the object. The color observed by the human eye is not affected by the surrounding light. This phenomenon is called color constancy. However, due to different parameters of different cameras, the color of images captured by different cameras for the same object will have different degrees of deviation. In order to achieve accurate color acquisition and recognition of cameras with different parameters, a more practical color correction method and device are designed to reduce the color deviation when capturing images of target objects between different cameras.

[0003] The various mainstream color correction methods currently available either require knowing the camera parameter values ​​in advance, or use different cameras to simultaneously capture approximate images of the target object, identify them through algorithms, and select enough pixels in the same area for analysis. These methods have certain limitations, are difficult to operate, time-consuming, and consume a lot of resources. Summary of the invention

[0004] In view of the above-mentioned shortcomings of the prior art, an object of the present invention is to provide a color correction method to solve the problems raised in the above-mentioned background technology.

[0005] To achieve the above object, the present invention provides the following technical solutions:

[0006] An existing standard color card for color correction comprises a substrate and a card holding area and a detection area distributed on the substrate; the detection area comprises a product parameter area, a standard color area, a positioning area, a verification area and a sample area; the parameter area is pasted or printed with detection parameters, which may be bar codes or other forms of codes; the standard color area comprises a plurality of standard color blocks of different colors; the verification area comprises a plurality of white verification blocks; and each of the verification blocks is distributed between each of the standard color blocks in the detection area; the positioning area is used to assist an image acquisition device in performing image acquisition and color block positioning on a standard color card; the sample area is provided with a sample positioning quadrilateral or polygonal frame line for placing a target object of a color to be acquired.

[0007] A color correction method comprises the following steps:

[0008] Step 1, placing the target object in the sample area on the standard color card, and using two different cameras to respectively capture the standard color card and the original complete image including the standard color card and the target object;

[0009] Step 2, the original complete image is a color image; the color original complete image is converted into a binary image, and the binary image is a black and white image;

[0010] Step 3: Based on the binary mathematical features of the four positioning marks, determine whether the final four positioning marks can be identified in the complete black-and-white image. If not, abandon the original complete image and return to step 1 to re-collect the original complete image including the standard color card and the target object; if yes, execute step 4;

[0011] Step 4, using the detection and analysis module of the detection device to obtain the mark points of each identified positioning mark, and sequentially connect the mark points of each positioning mark to form a quadrilateral outline, the inner area of ​​the quadrilateral outline is the candidate standard color card; thereby obtaining the shape and size of the candidate standard color card detection area;

[0012] Step 5, read the real shape and real size of the real detection area of ​​the pre-stored standard color card of the same specification; then determine whether the deviation in shape and size between the candidate standard color card detection area and the real standard color card detection area is within the design threshold; if not, return to step 1 and re-collect the original complete image including the standard color card and the target object; if yes, it indicates that the shape and size of the candidate standard color card detection area and the real standard color card detection area are very close, and then execute step 6;

[0013] Step 6, segmenting the original complete detection area image from the original complete image according to the candidate standard color card detection area; wherein the original complete detection area image is a color image;

[0014] Step 7, reading the position coordinates and the size of the barcode area of ​​the pre-stored standard color card of the same specification; then, based on the position coordinates and the size of the barcode area, accurately locating the outline of the barcode area in the original complete detection area image;

[0015] Step 8, obtaining a complete barcode image according to the outline of the located barcode area; then, using a barcode recognition algorithm to recognize the barcode image to obtain barcode data;

[0016] Step 9, obtaining a configuration scheme according to the barcode data in step 8; and then obtaining the position coordinates and size of each standard color block, each white verification color block and the target according to the configuration scheme, and then locating the position and outline of each standard color block, each white verification color block and the target object in the original complete detection area image;

[0017] Step 10, based on the positions and contours of the standard color blocks, the white verification color blocks and the target object, the color images of the standard color blocks, the white verification color blocks and the target object are obtained in the original complete detection area image; then, after preprocessing each original color image, the image color values ​​of each original standard color block image and the white verification color block are obtained as the correction color block color values; and the image color value of the target object is obtained;

[0018] Step 11, using the standard color card captured by camera A as a reference image, using the image including the standard color card and the target object captured by camera B as a target image, and then correcting the color of the image of the target object captured by camera B to be consistent with the color of the image of the target object captured by camera A;

[0019] There are three main parameters that affect the color of the image captured by the camera, namely gain, offset and gamma. The mathematical expression of the image pixel value and the three parameters is as follows:

[0020] Gain: P ref =P tar ×C gain

[0021] Offset: P ref =P tar +C offset

[0022] Gamma:

[0023] Where P ref and P tar Represent the pixel value of a point in the reference and target images respectively, C gain , C offset , C Gamma Represent the gain (Gain), offset (Offset) and gamma (Gamma) parameters of the target camera respectively, 2 bitdepth Represents the total number of grayscales in the image color space; generally, images use 8-bit grayscale; combining the three parameters to obtain the mathematical expression of the image pixel value captured by the camera is as follows:

[0024]

[0025] Step 12, using the pixel points at the corresponding positions of the reference correction color block and the target correction color block image, the Levenberg-Marquard optimal algorithm is used to fit and calculate the three parameters of the gain (Gain), offset (Offset) and gamma (Gamma) of the target camera relative to the reference camera. The specific steps are as follows:

[0026] Step (1), first define an error function as follows:

[0027]

[0028] where y i and x i are the RGB values ​​of the pixels at the corresponding positions of the reference correction color block image and the target correction color block image respectively; It is a vector composed of three parameters: gain (Gain), offset (Offset) and gamma (Gamma) of the target camera. gain ,C offset ,C Gamma}, expressed as {β0, β1, β2}, the expression of function f is:

[0029] Step (2): Select the initial vector based on experience is {1, 0, 1} or other empirical values, and the RGB values ​​of all corresponding pixel points in the reference correction color block image and the target correction color block image are calculated. And use the following formula to find the sum of squares:

[0030] Step (3), then continuously calculate the correction parameters in is the function e i The vector and matrix composed of is an m×3 function matrix, where m is the number of views and the value of its i-th row is The initial value of the damping coefficient λ is the empirical value λ0, and then from the second time onwards, λ / v,v is set to any number greater than 0 each time. If the calculated value after λ adjustment is If it does not become smaller, then continue to double v and then continue to adjust λ until the calculated becomes smaller; using the formula Calculate the new vector use Iteratively calculate the new until If it approaches the minimum value, it will stop looping and go to step (4);

[0031] Step (4), remove noise, and calculate the RGB values ​​of all corresponding pixel points in the target correction color block image calculated in step (3) above. Calculate the mean deviation h, where the parameter a is a constant, such as 1.5, x i : Correct the RGB values ​​of all corresponding pixels in the target color block image, x e for The formula is as follows:

[0032]

[0033] The RGB values ​​of all corresponding pixel points in the reference original correction color block image and the target correction color block image are calculated, and the pixels with a difference greater than 2 times h are considered as noise points and removed;

[0034] Step (5), using the reference original corrected color block image after noise removal and the RGB values ​​of all corresponding pixel points in the target corrected color block image, re-execute steps (2)-(4) until the number of noise points is 0 and proceed to step (6);

[0035] Step (6), use the final result of step (5) As a parameter, the RGB values ​​of all pixels in the target object image are corrected for their color deviation using the following formula to obtain the corrected RGB values ​​of each pixel in the target object image;

[0036]

[0037] Compared with the prior art, the present invention can be used to solve the color deviation problem when different cameras with unknown parameters capture images of different target objects. It has the advantages of wide adaptability, simple operation, small amount of calculation, and can be implemented at low cost based on general hardware and software. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 The figure is a schematic diagram of the structure of an existing standard color card. DETAILED DESCRIPTION

[0039] The technical solution of this patent is further described in detail below in conjunction with specific implementation methods.

[0040] like Figure 1 As shown, an existing standard color card for color correction includes a substrate and a card holding area 1 and a detection area 1 distributed on the substrate; the detection area 2 includes a product parameter area 3, a standard color area 4, a positioning area 5, a verification area 6 and a sample area 7; the parameter area 3 is pasted or printed with detection parameters, which can be a bar code or other forms of coding; the standard color area 4 includes a plurality of standard color blocks of different colors; the verification area 6 includes a plurality of white verification blocks; and each of the verification blocks is distributed between each of the standard color blocks in the detection area; the positioning area 5 is used to assist the image acquisition device in performing image acquisition and color block positioning on the standard color card; the sample area 7 is provided with a sample positioning quadrilateral or polygonal frame line for placing the target object of the color to be acquired.

[0041] A color correction method comprises the following steps:

[0042] Step 1, placing the target object in the sample area on the standard color card, and using two different cameras to respectively capture the standard color card and the original complete image including the standard color card and the target object;

[0043] Step 2, the original complete image is a color image; the color original complete image is converted into a binary image, and the binary image is a black and white image;

[0044] Step 3: Based on the binary mathematical features of the four positioning marks, determine whether the final four positioning marks can be identified in the complete black-and-white image. If not, abandon the original complete image and return to step 1 to re-collect the original complete image including the standard color card and the target object; if yes, execute step 4;

[0045] Step 4, using the detection and analysis module of the detection device to obtain the mark points of each identified positioning mark, and sequentially connect the mark points of each positioning mark to form a quadrilateral outline, the inner area of ​​the quadrilateral outline is the candidate standard color card; thereby obtaining the shape and size of the candidate standard color card detection area;

[0046] Step 5, read the real shape and real size of the real detection area of ​​the pre-stored standard color card of the same specification; then determine whether the deviation in shape and size between the candidate standard color card detection area and the real standard color card detection area is within the design threshold; if not, return to step 1 and re-collect the original complete image including the standard color card and the target object; if yes, it indicates that the shape and size of the candidate standard color card detection area and the real standard color card detection area are very close, and then execute step 6;

[0047] Step 6, segmenting the original complete detection area image from the original complete image according to the candidate standard color card detection area; wherein the original complete detection area image is a color image;

[0048] Step 7, reading the position coordinates and the size of the barcode area of ​​the pre-stored standard color card of the same specification; then, based on the position coordinates and the size of the barcode area, accurately locating the outline of the barcode area in the original complete detection area image;

[0049] Step 8, obtaining a complete barcode image according to the outline of the located barcode area; then, using a barcode recognition algorithm to recognize the barcode image to obtain barcode data;

[0050] Step 9, obtaining a configuration scheme according to the barcode data in step 8; and then obtaining the position coordinates and size of each standard color block, each white verification color block and the target according to the configuration scheme, and then locating the position and outline of each standard color block, each white verification color block and the target object in the original complete detection area image;

[0051] Step 10, based on the positions and contours of the standard color blocks, the white verification color blocks and the target object, the color images of the standard color blocks, the white verification color blocks and the target object are obtained in the original complete detection area image; then, after preprocessing each original color image, the image color values ​​of each original standard color block image and the white verification color block are obtained as the correction color block color values; and the image color value of the target object is obtained;

[0052] Step 11, using the standard color card captured by camera A as a reference image, using the image including the standard color card and the target object captured by camera B as a target image, and then correcting the color of the image of the target object captured by camera B to be consistent with the color of the image of the target object captured by camera A;

[0053] There are three main parameters that affect the color of the image captured by the camera, namely gain, offset and gamma. The mathematical expression of the image pixel value and the three parameters is as follows:

[0054] Gain: P ref =P tar ×C gain

[0055] Offset: P ref =P tar +C offset

[0056] Gamma:

[0057] Where P ref and P ta r represents the pixel value of a point in the reference and target images, respectively, and C gain , C offset , C Gamma Represent the gain (Gain), offset (Offset) and gamma (Gamma) parameters of the target camera respectively, 2 bitdepth Represents the total number of grayscales in the image color space; generally, images use 8-bit grayscale; combining the three parameters to obtain the mathematical expression of the image pixel value captured by the camera is as follows:

[0058]

[0059] Step 12, using the pixel points at the corresponding positions of the reference correction color block and the target correction color block image, the Levenberg-Marquard optimal algorithm is used to fit and calculate the three parameters of the gain (Gain), offset (Offset) and gamma (Gamma) of the target camera relative to the reference camera. The specific steps are as follows:

[0060] Step (1), first define an error function as follows:

[0061]

[0062] where y i and x i are the RGB values ​​of the pixels at the corresponding positions of the reference correction color block image and the target correction color block image respectively; It is a vector composed of three parameters: gain (Gain), offset (Offset) and gamma (Gamma) of the target camera. gain ,C offset ,C Gamma}, expressed as {β0, β1, β2}, the expression of function f is:

[0063] Step (2): Select the initial vector based on experience is {1, 0, 1} or other empirical values, and the RGB values ​​of all corresponding pixel points in the reference correction color block image and the target correction color block image are calculated. And use the following formula to find the sum of squares:

[0064] Step (3), then continuously calculate the correction parameters in is the function e i The vector and matrix composed of is an m×3 function matrix, where m is the number of views and the value of its i-th row is The initial value of the damping coefficient λ is the empirical value λ0, and then from the second time onwards, λ / v,v is set to any number greater than 0 each time. If the calculated value after λ adjustment is If it does not become smaller, then continue to double v and then continue to adjust λ until the calculated becomes smaller; using the formula Calculate the new vector in use Iteratively calculate the new until If it approaches the minimum value, it will stop looping and go to step (4);

[0065] Step (4), remove noise, and calculate the RGB values ​​of all corresponding pixel points in the target correction color block image calculated in step (3) above. Calculate the mean deviation h, where the parameter a is a constant, such as 1.5, x i: Correct the RGB values ​​of all corresponding pixels in the target color block image, x e for The formula is as follows:

[0066]

[0067] The RGB values ​​of all corresponding pixel points in the reference original correction color block image and the target correction color block image are calculated, and the pixels with a difference greater than 2 times h are considered as noise points and removed;

[0068] Step (5), using the reference original corrected color block image after noise removal and the RGB values ​​of all corresponding pixel points in the target corrected color block image, re-execute steps (2)-(4) until the number of noise points is 0 and proceed to step (6);

[0069] Step (6), use the final result of step (5) As a parameter, the RGB values ​​of all pixels in the target object image are corrected for their color deviation using the following formula to obtain the corrected RGB values ​​of each pixel in the target object image;

[0070]

[0071] The above describes in detail the preferred implementation of this patent, but this patent is not limited to the above implementation. Various changes can be made within the knowledge scope of ordinary technicians in this field without departing from the purpose of this patent.

Claims

1. A color correction method, It is characterized in that The following steps are involved: Step 1, placing the target object in the sample area on the standard color card, and using two different cameras to respectively capture the standard color card and the original complete image including the standard color card and the target object; Step 2, the original complete image is a color image; the color original complete image is converted into a binary image, and the binary image is a black and white image; Step 3: Based on the binary mathematical features of the four positioning marks, determine whether the final four positioning marks can be identified in the complete black-and-white image. If not, abandon the original complete image and return to step 1 to re-collect the original complete image including the standard color card and the target object; if yes, execute step 4; Step 4, using the detection and analysis module of the detection device to obtain the mark points of each identified positioning mark, and sequentially connect the mark points of each positioning mark to form a quadrilateral outline, the inner area of ​​the quadrilateral outline is the candidate standard color card; thereby obtaining the shape and size of the candidate standard color card detection area; Step 5, reading the real shape and real size of the real detection area of ​​the pre-stored standard color card of the same specification; then judging whether the deviation in shape and size between the candidate standard color card detection area and the real standard color card detection area is within the design threshold; if not, returning to step 1, re-collecting the original complete image including the standard color card and the target object; If yes, go to step 6; Step 6, segmenting the original complete detection area image from the original complete image according to the candidate standard color card detection area; wherein the original complete detection area image is a color image; Step 7, reading the position coordinates and the size of the barcode area of ​​the pre-stored standard color card of the same specification; then, based on the position coordinates and the size of the barcode area, accurately locating the outline of the barcode area in the original complete detection area image; Step 8, obtaining a complete barcode image according to the outline of the located barcode area; then, using a barcode recognition algorithm to recognize the barcode image to obtain barcode data; Step 9, obtaining a configuration scheme according to the barcode data of step 8; and then obtaining the position coordinates and size of each standard color block, each white verification color block and the target according to the configuration scheme, and then locating the position and outline of each standard color block, each white verification color block and the target object in the original complete detection area image; Step 10, based on the positions and contours of the standard color blocks, the white verification color blocks and the target object, the color images of the standard color blocks, the white verification color blocks and the target object are obtained in the original complete detection area image; then, after preprocessing each original color image, the image color value of each standard color block and the white verification color block is obtained as the correction color block color value; and the image color value of the target object is obtained; Step 11, using the standard color card captured by the reference camera as the reference image, using the image including the standard color card and the target object captured by the target camera as the target image, and then correcting the color of the image of the target object captured by the target camera to be consistent with the color of the image of the target object captured by the reference camera; The mathematical expression of the pixel value of the image collected by the camera is as follows: Where P ref and P tar Represent the pixel value of a point in the reference and target images respectively, C gain , C offset , C Gamma Represent the gain (Gain), offset (Offset) and gamma (Gamma) parameters of the target camera respectively, 2 bitdepth Represents the total number of gray levels in the image color space; Step 12, using the pixel points at the corresponding positions of the reference correction color block and the target correction color block image; calculating the three parameters of gain (Gain), offset (Offset) and gamma (Gamma) of the target camera relative to the reference camera, and using the Levenberg-Marquard optimal algorithm for fitting calculation, the specific steps are as follows: Step (1), first define an error function as follows: where y i and x i are the RGB values ​​of the pixels at the corresponding positions of the reference correction color block image and the target correction color block image respectively; It is a vector composed of three parameters: gain (Gain), offset (Offset) and gamma (Gamma) of the target camera. gain ,C offset ,C Gamma }, expressed as {β 0 , β 1 , β 2 }, the expression of function f is: Step (2): Select the initial vector based on experience is {1, 0, 1} or other empirical values, and the RGB values ​​of all corresponding pixel points in the reference correction color block image and the target correction color block image are calculated. And use the following formula to find the sum of squares: Step (3), then continuously calculate the correction parameters in is the function e i The vector and matrix composed of is an m×3 function matrix, where m is the number of views and the value of its i-th row is The initial value of the damping coefficient λ is the empirical value λ 0 , and then from the second time onwards, each time λ / v,v is set to any number greater than 0. If the calculated value after λ adjustment is If it does not become smaller, then continue to double v and then continue to adjust λ until the calculated becomes smaller; using the formula Calculate the new vector use Iteratively calculate the new until If it approaches the minimum value, it will stop looping and go to step (4); Step (4), remove noise, and calculate the RGB values ​​of all corresponding pixel points in the target correction color block image calculated in step (3) above. Calculate the mean deviation h, where parameter a is a constant and x i Correct the RGB values ​​of all corresponding pixels in the target color block image, x e for The formula is as follows: The RGB values ​​of all corresponding pixel points in the reference original correction color block image and the target correction color block image are calculated, and the pixels with a difference greater than 2 times h are considered as noise points and removed; Step (5), using the reference original corrected color block image after noise removal and the RGB values ​​of all corresponding pixel points in the target corrected color block image, re-execute steps (2)-(4) until the number of noise points is 0 and proceed to step (6); Step (6), use the final result of step (5) As a parameter, the RGB values ​​of all pixels in the target object image are corrected for their color deviation using the following formula to obtain the corrected RGB values ​​of each pixel in the target object image;