Sampling-Based High-Speed Nonlinear Color Correction Method, Device, and Storage Medium
By establishing a mapping table and interpolation algorithm, the problem of color consistency correction between multiple devices is solved, and a fast and effective color correction effect is achieved, which is suitable for color consistency correction between multiple devices.
Patent Information
- Application Number
- CN202411810365.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2044-12-10
AI Technical Summary
The existing color correction methods have a good correction effect on the brightness near the grayscale grayscale card, but there is a large color difference between high and low grayscale colors, and the calculation volume is large and time-consuming, making it difficult to achieve color consistency correction between multiple devices.
By collecting the contrast and exposure time of multiple devices, a mapping table is established, and combining the interpolation algorithm, color consistency correction between multiple devices is achieved. The table lookup method is used to correct the color of the image taken by the target camera light source to be consistent with the reference camera light source.
The color consistency correction between multiple devices is achieved, which reduces the amount of computing, and is suitable for scenes where the light source brightness and camera contrast exposure time are not much different, and meets the needs of real-time detection.
Smart Images

Figure CN119299864B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of color correction, and particularly relates to a high-speed non-linear color correction method, device and storage medium based on sampling. Background Art
[0002] Currently, there are generally two common color correction methods. One is to directly photograph a white balance gray card and then use the automatic white balance in the camera for correction. The other is to photograph a complete color card and then call an automatic color correction algorithm for color correction. For the method of directly photographing a white balance gray card, only approximate color correction can be achieved. Since the photosensitive coefficient of the photosensitive chip and the color difference of the light source are not linear, the correction effect in actual application is not ideal. There is only a certain correction effect on the brightness near the gray level of the gray card, and there are still large color differences in colors with higher and lower gray levels. For the method of photographing the whole color card for correction, the correction effect is better and the corrected color is more natural. However, its computational complexity is large, the running processing time is long, and the correction effect will also decline for gray levels far from the gray level of the correction color card. Summary of the Invention
[0003] The present invention provides a high-speed non-linear color correction method, device and storage medium based on sampling, aiming to solve at least one of the technical problems existing in the prior art.
[0004] The technical solution of the present invention relates to a high-speed non-linear color correction method based on sampling, and the method includes the following steps:
[0005] S100. Based on a preset exposure time and gain, a reference device photographs an N-level gray scale color card to generate N first gray scale color card images;
[0006] S200. Adjust the exposure time and gain of the device to be calibrated so that the exposure time and gain of the device to be calibrated are consistent with the preset exposure time and gain. The device to be calibrated photographs the same N-level gray scale color card to generate N second gray scale color card images;
[0007] S300. Respectively extract the RGB channel gray scale values of each first gray scale color card image and each second gray scale color card image to generate a reference device lookup table and a device-to-be-calibrated lookup table;
[0008] S400. The device to be calibrated photographs a real object image, extracts the RGB values of each pixel point of the real object image, and respectively calculates the numerical ranges corresponding to the RGB values of each pixel point of the real object image in the reference device lookup table and the device-to-be-calibrated lookup table;
[0009] S500. Calculate the corrected RGB values of each pixel point in the real object image.
[0010] Further, in step S100 and step S200,
[0011] The number of the first grayscale color card images and the second grayscale color card images is consistent with the number of color cards in the N-level grayscale color card.
[0012] Further, the step S300 includes:
[0013] S310, obtaining the RGB value of each pixel of a single first grayscale color card image, calculating the R channel mean, the G channel mean and the B channel mean, and combining them into an RGB mean array of the first grayscale color card image;
[0014] S320, repeating step S310, traversing each first grayscale color card image, generating RGB mean value arrays of N first grayscale color card images, and combining the RGB mean value arrays of the N first grayscale color card images into a reference device lookup table;
[0015] S330, obtaining the RGB value of each pixel of a single second grayscale color card image, calculating the R channel mean, the G channel mean and the B channel mean, and combining them into an RGB mean array of the second grayscale color card image;
[0016] S340, repeat step S330, traverse each second grayscale color card image, generate RGB mean value arrays of N second grayscale color card images, and combine the RGB mean value arrays of the N second grayscale color card images into a lookup table for the device to be calibrated.
[0017] Furthermore, the horizontal axis of the reference device lookup table represents the Nth first grayscale color card image, and the vertical axis represents the average grayscale of the R channel, the G channel, and the B channel in the Nth first grayscale color card image. , and ;
[0018] The horizontal axis of the lookup table of the device to be calibrated represents the Nth second grayscale color card image, and the vertical axis represents the average grayscale of the R channel, the G channel and the B channel in the Nth second grayscale color card image. , and .
[0019] Further, the step S400 includes:
[0020] S410, the device to be calibrated takes a photo of a physical image, and extracts the RGB values R', G' and B' of each pixel point of the physical image;
[0021] S420. Calculate respectively the numerical ranges of the three channel values of each pixel point of the physical image that fall into the corresponding channels of the lookup table of the device to be calibrated, and the left and right endpoints of the numerical ranges respectively correspond to the n-th second gray scale color card image and the (n + 1)-th second gray scale color card image on the horizontal axis in the lookup table of the device to be calibrated, so as to obtain the positions n and n + 1.
[0022] S430. According to the positions of the three channels of each pixel point of the physical image in the lookup table of the device to be calibrated, namely n and n + 1, m and m + 1, and k and k + 1, respectively map the positions of the three channels to the numerical ranges of the corresponding channels in the lookup table of the reference device.
[0023] Furthermore, in the step S420,
[0024] For the R channel, calculate respectively the range of the R channel value R' of each pixel point of the physical image that falls into the R channel of the second gray scale color card image and the interval formed by and the interval corresponds to the positions n and n + 1 of the second gray scale color card image, where < R' < , n is the n-th second gray scale color card image, and n < N;
[0025] For the G channel, calculate respectively the range of the G channel value G' of each pixel point of the physical image that falls into the G channel of the second gray scale color card image and the interval formed by and the interval corresponds to the positions m and m + 1 of the second gray scale color card image, where < G' < , m is the m-th second gray scale color card image, and m < N;
[0026] For the B channel, calculate respectively the range of the B channel value B' of each pixel point of the physical image that falls into the B channel of the second gray scale color card image and the interval formed by and the interval corresponds to the positions k and k + 1 of the second gray scale color card image, where < B' < , k is the k-th second gray scale color card image, and k < N.
[0027] Furthermore, in the step S430,
[0028] For the R channel, map the positions n and n + 1 of each pixel point of the physical image in the lookup table of the device to be calibrated to the positions n and n + 1 of the R channel in the lookup table of the reference device, so as to obtain the values of the positions n and n + 1 of the R channel value of each pixel point in the physical image corresponding to the R channel in the lookup table of the reference device, that is and ;
[0029] For the G channel, the positions m and m + 1 of each pixel of the physical image in the lookup table of the device to be calibrated are corresponding to the positions m and m + 1 of the G channel of the reference device lookup table, and the values corresponding to the positions m and m + 1 of the G channel of each pixel of the physical image in the reference device lookup table are obtained, that is and ;
[0030] For the B channel, the positions k and k + 1 of each pixel of the physical image in the lookup table of the device to be calibrated are corresponding to the positions k and k + 1 of the B channel of the reference device lookup table, and the values corresponding to the positions k and k + 1 of the B channel of each pixel of the physical image in the reference device lookup table are obtained, that is and 。
[0031] Further, in step S500, the corrected RGB values of each pixel in the physical image are respectively:
[0032] The corrected R channel value is R,
[0033]
[0034] wherein, R’ is the R channel value of each pixel in the physical image, is the left end point of the R channel range of the second gray scale color card image into which R’ falls, is the right end point of the R channel range of the second gray scale color card image into which R’ falls, is the value corresponding to the position n of each pixel in the physical image in the lookup table of the device to be calibrated corresponding to the position n of the R channel of the reference device lookup table, is the value corresponding to the position n + 1 of each pixel in the physical image in the lookup table of the device to be calibrated corresponding to the position n + 1 of the R channel of the reference device lookup table;
[0035] The corrected G channel value is G,
[0036]
[0037] wherein, G’ is the G channel value of each pixel in the physical image, is the left end point of the G channel range of the second gray scale color card image into which G’ falls, is the right end point of the G channel range of the second gray scale color card image into which G’ falls, is the value corresponding to the position m of each pixel in the physical image in the lookup table of the device to be calibrated corresponding to the position m of the G channel of the reference device lookup table, is the value corresponding to the position m + 1 of each pixel point in the physical image in the lookup table of the device to be calibrated in the position m + 1 of the G channel of the lookup table of the reference device;
[0038] The corrected B channel value is B,
[0039]
[0040] where B’ is the B channel value of each pixel point in the physical image, is the left endpoint of the B channel range where B’ falls into the B channel of the second grayscale color card image, is the right endpoint of the B channel range where B’ falls into the B channel of the second grayscale color card image, is the value corresponding to the position k of each pixel point in the physical image in the lookup table of the device to be calibrated in the position k of the B channel of the reference device, is the value corresponding to the position k + 1 of each pixel point in the physical image in the lookup table of the device to be calibrated in the position k + 1 of the B channel of the reference device.
[0041] Furthermore, the present invention also proposes a high-speed non-linear color correction device based on sampling for implementing the high-speed non-linear color correction method based on sampling. The high-speed non-linear color correction device based on sampling includes:
[0042] A host computer;
[0043] A reference device, the reference device being electrically connected to the host computer;
[0044] A device to be calibrated, the device to be calibrated being electrically connected to the host computer.
[0045] Furthermore, the present invention also proposes a computer-readable storage medium storing program instructions thereon, and when the program instructions are executed by a processor, the high-speed non-linear color correction method based on sampling is implemented.
[0046] Compared with the existing technology, the present invention has the following characteristics:
[0047] The present invention provides a sampling-based high-speed non-linear color correction method, device, and storage medium, which are mainly used for color consistency calibration among multiple devices. Although multiple devices with the same detection requirements have exactly the same configuration, due to the consistency deviation of photosensitive chips and light source beads, there will always be certain deviations in the actually captured pictures. In order to more stably achieve visual detection, it is necessary to correct the pictures taken by each device to be consistent. The present invention establishes a mapping table by collecting the contrast and exposure time of multiple cameras, and then, through the look-up table method, combined with the interpolation algorithm, corrects the color of the image captured by the target camera light source to be consistent with that of the reference camera light source, thereby achieving consistency correction among multiple devices. The present invention mainly provides a high-speed non-linear color correction algorithm to achieve color correction with less computation, and is suitable for scenarios where multiple devices have the same configuration and the differences in light source brightness, camera contrast, and exposure time are not significant. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 FIG. is a flowchart of a sampling-based high-speed non-linear color correction method.
[0049] Figure 2 FIG. shows N first gray-scale color card images (N = 10) in the sampling-based high-speed non-linear color correction method.
[0050] Figure 3 FIG. shows N second gray-scale color card images (N = 10) in the sampling-based high-speed non-linear color correction method.
[0051] Figure 4 FIG. shows an image to be corrected in an embodiment of the sampling-based high-speed non-linear color correction method.
[0052] Figure 5 FIG. shows the corrected image in an embodiment of the sampling-based high-speed non-linear color correction method. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0053] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0054] The following will clearly and completely describe the concept, specific structure, and technical effects generated by the present invention in combination with the embodiments and the accompanying drawings to fully understand the objectives, solutions, and effects of the present invention.
[0055] It should be noted that, unless otherwise specified, when a certain feature is referred to as "fixed" or "connected" to another feature, it can be directly fixed or connected to the other feature, or indirectly fixed or connected to the other feature. The singular forms of "a", "the", and "said" used in this article are also intended to include the plural forms, unless the context clearly indicates otherwise. In addition, unless otherwise defined, all technical and scientific terms used in this article have the same meaning as commonly understood by those skilled in the technical field of this technology. The terms used in the description of this article are only for describing specific embodiments and are not intended to limit the present invention. The term "and / or" used in this article includes any and all combinations of one or more of the related listed items.
[0056] It should be understood that although the terms first, second, third, etc. may be used in this disclosure to describe various elements, these elements should not be limited to these terms. These terms are only used to distinguish elements of the same type from each other. For example, without departing from the scope of this disclosure, the first element may also be referred to as the second element, and similarly, the second element may also be referred to as the first element. The use of any and all examples or exemplary languages ("for example", "such as", etc.) provided in this article is only intended to better illustrate the embodiments of the present invention and will not impose a limitation on the scope of the present invention unless otherwise required. In addition, the industry term "pose" used in this article refers to the position and orientation of a certain element relative to a spatial coordinate system.
[0057] Referring to Figures 1 to 5 , the embodiments of the present invention provide a high-speed non-linear color correction method based on sampling. Referring to Figure 1 , the method includes the following steps:
[0058] S100. Based on a preset exposure time and gain, the reference device takes pictures of an N-level gray scale color card to generate N first gray scale color card images;
[0059] S200. Adjust the exposure time and gain of the device to be calibrated so that the exposure time and gain of the device to be calibrated are consistent with the preset exposure time and gain. The device to be calibrated takes pictures of the same N-level gray scale color card to generate N second gray scale color card images;
[0060] S300. Extract the RGB channel gray scale values of each first gray scale color card image and each second gray scale color card image respectively to generate a reference device look-up table and a device-to-be-calibrated look-up table;
[0061] S400. The device to be calibrated takes pictures of a real object image, extracts the RGB values of each pixel point of the real object image, and calculates the numerical ranges corresponding to the RGB values of each pixel point of the real object image in the reference device look-up table and the device-to-be-calibrated look-up table respectively;
[0062] S500. Calculate the calibrated RGB value of each pixel in the physical image.
[0063] Specifically, in steps S100 and S200, the same N-level gray scale color card is used.
[0064] In step S100, each first gray scale color card image is an image of a certain color card in the N-level gray scale color card taken by the reference device. Refer to Figure 2 , for example, 01 represents the image of the 1st color card in the N-level gray scale color card taken by the reference device, and 10 represents the image of the 10th color card in the N-level gray scale color card taken by the reference device.
[0065] In step S200, each second gray scale color card image is an image of a certain color card in the N-level gray scale color card taken by the device to be calibrated. Refer to Figure 3 , for example, 01 represents the image of the 1st color card in the N-level gray scale color card taken by the device to be calibrated, and 10 represents the image of the 10th color card in the N-level gray scale color card taken by the device to be calibrated.
[0066] Compared with the existing technology, the present invention has the following characteristics:
[0067] The present invention provides a high-speed non-linear color correction method, device and storage medium based on sampling, which is mainly used for color consistency calibration among multiple devices. Although multiple devices with the same detection requirements have exactly the same configuration, due to the consistency deviation of the photosensitive chips and light source lamp beads, there will always be a certain deviation in the actually captured pictures. In order to more stably achieve visual detection, it is necessary to correct the pictures taken by each device to be consistent. The present invention collects the contrast and exposure time of multiple cameras to establish a mapping table, and then through the look-up table method, combined with the interpolation algorithm, corrects the color of the image taken by the target camera light source to be consistent with that of the reference camera light source, so as to achieve consistency correction among multiple devices. The present invention mainly provides a high-speed non-linear color correction algorithm, which realizes color correction with less computing amount and is suitable for scenarios where multiple devices have the same configuration and the differences in light source brightness, camera contrast and exposure time are not large.
[0068] Further, refer to Figure 2 and Figure 3 , in steps S100 and S200,
[0069] The number of the first gray scale color card images and the second gray scale color card images is the same as the number of color cards in the N-level gray scale color card.
[0070] In some specific embodiments, the number of the N-level gray scale color cards is 9 or 10, which are the 9-level gray scale color card and the 10-level gray scale color card respectively; therefore, the number of the first gray scale color card images and the second gray scale color card images is 9 or 10.
[0071] Further, referring to Figure 1 , step S300 includes:
[0072] S310. Obtain the RGB values of each pixel of a single first grayscale color card image, calculate the average value of the R channel, the average value of the G channel, and the average value of the B channel, and combine them into an RGB average value array of this first grayscale color card image;
[0073] S320. Repeat step S310, traverse each first grayscale color card image, generate N RGB average value arrays of the first grayscale color card images, and combine the N RGB average value arrays of the first grayscale color card images into a reference device lookup table;
[0074] S330. Obtain the RGB values of each pixel of a single second grayscale color card image, calculate the average value of the R channel, the average value of the G channel, and the average value of the B channel, and combine them into an RGB average value array of this second grayscale color card image;
[0075] S340. Repeat step S330, traverse each second grayscale color card image, generate N RGB average value arrays of the second grayscale color card images, and combine the N RGB average value arrays of the second grayscale color card images into a device to be calibrated lookup table.
[0076] In a specific embodiment, in step S310 and step S320, referring to Table 1, the reference device lookup table is:
[0077] Table 1,
[0078] 1 2 3 4 5 6 7 8 9 10 R 67.09 79.50 93.38 109.73 130.00 152.41 181.27 213.54 249.52 255.00 G 67.77 80.46 94.56 111.13 131.72 154.38 183.47 216.53 252.29 255.00 B 69.74 82.75 97.21 114.27 135.38 158.64 188.47 221.70 251.68 254.99
[0079] Referring to Figure 2 , use the reference device to capture 10 first grayscale color card images, respectively extract the RGB channel grayscale values of the 10 first grayscale color card images, use 1 - 10 as the X-axis, and the average grayscale value of the images captured by each level of color card in the three color channels as the Y-axis. For the R channel, 10 points (1, R1) to (10, R10) are obtained, for the G channel, 10 points (1, G1) to (10, G10) are obtained, and for the B channel, 10 points (1, B1) to (10, B10) are obtained.
[0080] In a specific embodiment, in step S330 and step S340, referring to Table 2, the device to be calibrated lookup table is:
[0081] Table 2,
[0082] 1 2 3 4 5 6 7 8 9 10 R 57.08 67.68 79.43 93.20 110.63 129.81 154.20 181.08 211.60 240.89 G 58.24 69.19 81.35 95.60 113.64 133.38 158.30 185.56 215.67 242.28 B 51.64 61.34 72.10 84.70 100.63 118.21 140.44 164.83 193.50 233.41
[0083] Referring to Figure 3, use the device to be calibrated to take 10 grayscale color card images, extract the RGB channel grayscale values of the 10 second grayscale color card images respectively, with 1-10 as the X-axis, and the average grayscale value of the three color channels of the image taken by each level of color card as the Y-axis, and get 10 points (1, R1')~(10, R10') for the R channel, 10 points (1, G1')~(10, G10') for the G channel, and 10 points (1, B1')~(10, B10') for the B channel.
[0084] Furthermore, the horizontal axis of the reference device lookup table represents the Nth first grayscale color card image, and the vertical axis represents the average grayscale of the R channel, the G channel, and the B channel in the Nth first grayscale color card image. , and ;
[0085] The horizontal axis of the lookup table of the device to be calibrated represents the Nth second grayscale color card image, and the vertical axis represents the average grayscale of the R channel, the G channel and the B channel in the Nth second grayscale color card image. , and .
[0086] Further, refer to Figure 1 , the step S400 includes:
[0087] S410, the device to be calibrated takes a photo of a physical image, and extracts the RGB values R', G' and B' of each pixel point of the physical image;
[0088] S420, respectively calculating the three channel values of each pixel point of the real image falling into the numerical range of the corresponding channel in the lookup table of the device to be calibrated, and the left and right endpoints of the numerical range respectively correspond to the nth second grayscale color card image and the n+1th second grayscale color card image of the horizontal axis in the lookup table of the device to be calibrated, and obtaining the position n and the position n+1;
[0089] S430, according to the positions of the three channels of each pixel point of the real image in the lookup table of the device to be calibrated, i.e., n and n+1, m and m+1, and k and k+1, respectively correspond the positions of the three channels to the numerical ranges of the corresponding channels in the lookup table of the reference device.
[0090] Specifically, by looking up the reference device lookup table and the device to be calibrated lookup table and applying an interpolation algorithm, the grayscale of each channel of each pixel on the device to be calibrated is mapped to the grayscale of each channel of the reference device, where the average grayscale of the RGB channels of the ath image in the reference device lookup table is recorded as , , ; The average grayscale of the RGB channels in the ath image in the lookup table of the device to be calibrated is recorded as , , 。
[0091] Furthermore, referring to Figure 1 , in the step S420,
[0092] For the R channel, calculate the range of the R channel values R' of each pixel point of the physical image falling into the R channel of the second grayscale color card image and to form an interval and the positions n and n + 1 of the interval corresponding to the second grayscale color card image, where < R' < , n is the nth second grayscale color card image, and n < N;
[0093] For the G channel, calculate the range of the G channel values G' of each pixel point of the physical image falling into the G channel of the second grayscale color card image and to form an interval and the positions m and m + 1 of the interval corresponding to the second grayscale color card image, where < G' < , m is the mth second grayscale color card image, and m < N;
[0094] For the B channel, calculate the range of the B channel values B' of each pixel point of the physical image falling into the B channel of the second grayscale color card image and to form an interval and the positions k and k + 1 of the interval corresponding to the second grayscale color card image, where < B' < , k is the kth second grayscale color card image, and k < N.
[0095] Furthermore, referring to Figure 1 , in the step S430,
[0096] For the R channel, map the positions n and n + 1 of each pixel point of the physical image in the lookup table of the device to be calibrated to the positions n and n + 1 of the R channel of the reference device lookup table, and obtain the values corresponding to the positions n and n + 1 of the R channel of the reference device lookup table for the R channel value of each pixel point in the physical image, that is, and ;
[0097] For the G channel, map the positions m and m + 1 of each pixel point of the physical image in the lookup table of the device to be calibrated to the positions m and m + 1 of the G channel of the reference device lookup table, and obtain the values corresponding to the positions m and m + 1 of the G channel of the reference device lookup table for the G channel value of each pixel point in the physical image, that is, and ;
[0098] For the B channel, the positions k and k + 1 of each pixel of the physical image in the lookup table of the device to be calibrated are corresponding to the positions k and k + 1 of the B channel in the lookup table of the reference device, obtaining the values corresponding to the positions k and k + 1 of the B channel value of each pixel in the physical image in the lookup table of the reference device B channel, that is and .
[0099] Furthermore, in step S500, the corrected RGB values of each pixel in the physical image are respectively:
[0100] The corrected R channel value is R,
[0101]
[0102] wherein, R’ is the R channel value of each pixel in the physical image, is the left endpoint of the R channel range where R’ falls into the R channel of the second grayscale color card image, is the right endpoint of the R channel range where R’ falls into the R channel of the second grayscale color card image, is the value corresponding to the position n of each pixel in the physical image in the lookup table of the device to be calibrated corresponding to the position n of the R channel in the lookup table of the reference device, is the value corresponding to the position n + 1 of each pixel in the physical image in the lookup table of the device to be calibrated corresponding to the position n + 1 of the R channel in the lookup table of the reference device;
[0103] The corrected G channel value is G,
[0104]
[0105] wherein, G’ is the G channel value of each pixel in the physical image, is the left endpoint of the G channel range where G’ falls into the G channel of the second grayscale color card image, is the right endpoint of the G channel range where G’ falls into the G channel of the second grayscale color card image, is the value corresponding to the position m of each pixel in the physical image in the lookup table of the device to be calibrated corresponding to the position m of the G channel in the lookup table of the reference device, is the value corresponding to the position m + 1 of each pixel in the physical image in the lookup table of the device to be calibrated corresponding to the position m + 1 of the G channel in the lookup table of the reference device;
[0106] The corrected B channel value is B,
[0107]
[0108] wherein, B’ is the B channel value of each pixel in the physical image, is the left endpoint of the B channel range where B’ falls into the B channel of the second grayscale color card image, B’ is the right endpoint of the B-channel range of the second grayscale color card image, is the value corresponding to the position k of each pixel point in the physical image in the lookup table of the device to be calibrated in the B-channel of the lookup table of the reference device at position k, is the value corresponding to the position k+1 of each pixel point in the physical image in the lookup table of the device to be calibrated in the B-channel of the lookup table of the reference device at position k+1.
[0109] In a specific embodiment, the RGB value of a certain point in the image to be calibrated is R’ = 80, G’ = 100, B’ = 110, then:
[0110] The R-channel is in the range of 79.43 - 93.20 of the 3rd and 4th images of the lookup table of the device to be calibrated,
[0111] The G-channel is in the range of 95.60 - 113.64 of the 4th and 5th images of the lookup table of the device to be calibrated,
[0112] The B-channel is in the range of 100.63 - 118.21 of the 5th and 6th images of the lookup table of the device to be calibrated,
[0113] At this time, by checking the lookup tables of the reference device and the device to be calibrated, we get:
[0114] = 79.43, = 93.2;
[0115] = 95.6, = 113.64;
[0116] = 100.63, = 118.21;
[0117] = 93.38, = 109.73;
[0118] = 111.13, = 131.72;
[0119] = 135.38, = 158.64;
[0120] Substitute into the formula for the corrected R-channel value as R, the formula for the corrected G-channel value as G, and the formula for the corrected B-channel value as B, and the corrected RGB value of this point can be calculated.
[0121] Refer to Figure 4 andFigure 5 , since the calibration algorithm is just a simple look-up table mapping, with a small amount of computation and a short time consumption, it can meet the requirements for image preprocessing in real-time detection.
[0122] Furthermore, the present invention also provides a high-speed non-linear color calibration device based on sampling for implementing the high-speed non-linear color calibration method based on sampling. The high-speed non-linear color calibration device based on sampling includes:
[0123] A host computer;
[0124] A reference device, which is electrically connected to the host computer;
[0125] A device to be calibrated, which is electrically connected to the host computer.
[0126] Furthermore, the present invention also provides a computer-readable storage medium, on which program instructions are stored. When the program instructions are executed by a processor, the high-speed non-linear color calibration method based on sampling is implemented.
[0127] It should be recognized that the method steps in the embodiments of the present invention can be implemented or carried out by computer hardware, a combination of hardware and software, or computer instructions stored in a non-transitory computer-readable memory. The method can use standard programming techniques. Each program can be implemented in a high-level procedural or object-oriented programming language to communicate with a computer system. However, if necessary, the program can be implemented in assembly or machine language. In any case, the language can be a compiled or interpreted language. In addition, for this purpose, the program can run on a dedicated integrated circuit programmed for this purpose.
[0128] In addition, the operations of the processes described herein can be performed in any suitable order, unless otherwise indicated herein or otherwise clearly contradicted by the context. The processes described herein (or variations and / or combinations thereof) can be executed under the control of one or more computer systems configured with executable instructions, and can be implemented as code (e.g., executable instructions, one or more computer programs, or one or more applications) that is commonly executed on one or more processors, by hardware, or a combination thereof. The computer program includes a plurality of instructions executable by one or more processors.
[0129] Further, the method can be implemented in any type of computing platform operatively connected to a suitable one, including but not limited to personal computers, minicomputers, mainframes, workstations, network or distributed computing environments, separate or integrated computer platforms, or communicating with charged particle tools or other imaging devices, etc. Aspects of the present invention can be implemented in machine-readable code stored on a non-transitory storage medium or device, whether removable or integrated into the computing platform, such as a hard disk, optical read and / or write storage medium, RAM, ROM, etc., such that it can be read by a programmable computer and can be used to configure and operate the computer to execute the processes described herein when the storage medium or device is read by the computer. Additionally, the machine-readable code, or portions thereof, can be transmitted via a wired or wireless network. When such media includes instructions or programs that implement the above-described steps in conjunction with a microprocessor or other data processor, the inventions described herein include these and other different types of non-transitory computer-readable storage media. When programmed according to the methods and techniques described in the present invention, the present invention can also include the computer itself.
[0130] A computer program can be applied to input data to perform the functions described herein, thereby transforming the input data to generate output data stored in non-volatile memory. The output information can also be applied to one or more output devices such as a display. In a preferred embodiment of the present invention, the transformed data represents physical and tangible objects, including a specific visual depiction of the physical and tangible objects generated on a display.
[0131] As described above, it is only a preferred embodiment of the present invention. The present invention is not limited to the above-described embodiments. As long as it achieves the technical effects of the present invention by the same means, any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included within the scope of protection of the present invention. Within the scope of protection of the present invention, its technical solutions and / or implementation manners can have various different modifications and changes.
Claims
1. A sampling-based high-speed non-linear color correction method, characterized in that The method described above includes the following steps: S100. Based on a preset exposure time and gain, the reference device takes pictures of an N-level gray scale color card to generate N first gray scale color card images. S200. Adjust the exposure time and gain of the device to be calibrated so that the exposure time and gain of the device to be calibrated are consistent with the preset exposure time and gain. The device to be calibrated takes pictures of the same N-level gray scale color card to generate N second gray scale color card images. S300. Extract the RGB channel gray scale values of each first gray scale color card image and each second gray scale color card image respectively to generate a reference device look-up table and a device-to-be-calibrated look-up table. Step S300 includes: S310. Obtain the RGB values of each pixel of a single first gray scale color card image, calculate the mean value of the R channel, the mean value of the G channel, and the mean value of the B channel, and combine them into an RGB mean value array of this first gray scale color card image. S320. Repeat step S310, traverse each first gray scale color card image, generate N RGB mean value arrays of the first gray scale color card images, and combine the N RGB mean value arrays of the first gray scale color card images into a reference device look-up table. S330. Obtain the RGB values of each pixel of a single second gray scale color card image, calculate the mean value of the R channel, the mean value of the G channel, and the mean value of the B channel, and combine them into an RGB mean value array of this second gray scale color card image. S340. Repeat step S330, traverse each second gray scale color card image, generate N RGB mean value arrays of the second gray scale color card images, and combine the N RGB mean value arrays of the second gray scale color card images into a device-to-be-calibrated look-up table. The horizontal axis of the reference device lookup table represents the Nth first gray-scale color card image, and the vertical axis represents the average gray levels of the R channel, G channel, and B channel in the Nth first gray-scale color card image , and ; The horizontal axis of the lookup table of the device to be calibrated represents the Nth second gray-scale color card image, and the vertical axis represents the average gray levels of the R channel, G channel, and B channel in the Nth second gray-scale color card image , and ; S400. The device to be calibrated takes pictures of a real object image, extracts the RGB values of each pixel of the real object image, and respectively calculates the numerical ranges corresponding to the RGB values of each pixel of the real object image in the reference device look-up table and the device-to-be-calibrated look-up table. Step S400 includes: S410. The device to be calibrated takes pictures of a real object image, and extracts the RGB values R', G', and B' of each pixel of the real object image. S420. Respectively calculate the numerical ranges in which the three channel values of each pixel of the real object image fall into the corresponding channels of the device-to-be-calibrated look-up table, and the left and right endpoints of the numerical range respectively correspond to the nth second gray scale color card image and the (n + 1)th second gray scale color card image on the horizontal axis in the device-to-be-calibrated look-up table, to obtain the positions n and n + 1. In step S420, For the R channel, calculate the range of the R channel values R' of each pixel of the physical image that fall into the R channel of the second gray scale color card image and The intervals formed by the intervals corresponding to the ranks n and n + 1 of the second gray scale color card image, where < R'< , n is the nth second gray scale color card image, and n < N; For the G channel, calculate the range of the G channel value G' of each pixel of the physical image falling into the G channel of the second gray scale color card image and The intervals formed and the intervals correspond to the positions m and m + 1 of the second gray scale color card image, where < G' < , m is the m-th second gray scale color card image, and m < N; For the B channel, calculate the range of the B channel values B' of each pixel of the physical image that fall into the B channel of the second grayscale color card image and The intervals formed by the intervals corresponding to the ranks k and k + 1 of the second grayscale color card image, where < B' < , k is the k-th second grayscale color card image, and k < N; S430. According to the positions of the three channels of each pixel of the real object image in the device-to-be-calibrated look-up table, that is, n and n + 1, m and m + 1, and k and k + 1, respectively map the positions of the three channels to the numerical ranges of the corresponding channels in the reference device look-up table. In step S430, For the R channel, map the positions n and n + 1 of each pixel of the physical image in the lookup table of the device to be calibrated to the positions n and n + 1 of the R channel of the lookup table of the reference device, and obtain the values corresponding to the positions n and n + 1 of the R channel of each pixel in the physical image in the R channel of the lookup table of the reference device, that is and ; For the G channel, map the positions m and m + 1 of each pixel in the physical image in the lookup table of the device to be calibrated to the positions m and m + 1 of the G channel in the lookup table of the reference device, obtaining the values corresponding to the positions m and m + 1 of the G channel of each pixel in the physical image in the lookup table of the reference device, that is and ; For channel B, the positions k and k + 1 of each pixel of the physical image in the lookup table of the device to be calibrated are mapped to the positions k and k + 1 of channel B in the lookup table of the reference device, and the values corresponding to the positions k and k + 1 of channel B of each pixel in the physical image in the lookup table of the reference device are obtained, that is and ; S500. Calculate the corrected RGB values of each pixel in the real object image. In step S500, the corrected RGB values of each pixel in the real object image are respectively: The corrected R channel value is R. ; Wherein, R’ is the R-channel value of each pixel point in the physical image, is the left endpoint of the R-channel range where R’ falls into the second grayscale color card image, is the right endpoint of the R-channel range where R’ falls into the second grayscale color card image, is the value corresponding to the position n of each pixel point in the physical image in the lookup table of the device to be calibrated corresponding to the position n of the R-channel in the lookup table of the reference device, is the value corresponding to the position n+1 of each pixel point in the physical image in the lookup table of the device to be calibrated corresponding to the position n+1 of the R-channel in the lookup table of the reference device; The corrected G channel value is G. ; Wherein, G’ is the G-channel value of each pixel in the physical image, is the left endpoint of the G-channel range of G’ falling into the second grayscale color card image, is the right endpoint of the G-channel range of G’ falling into the second grayscale color card image, is the value of the position m of each pixel in the physical image corresponding to the position m of the G-channel in the reference device lookup table in the lookup table of the device to be calibrated, is the value of the position m+1 of each pixel in the physical image corresponding to the position m+1 of the G-channel in the reference device lookup table in the lookup table of the device to be calibrated; The corrected B channel value is B. ; Among them, B’ is the B-channel value of each pixel in the physical image, is the left endpoint of the B-channel range where B’ falls within the B-channel range of the second grayscale color card image, is the right endpoint of the B-channel range where B’ falls within the B-channel range of the second grayscale color card image, is the value corresponding to the position k of each pixel in the physical image in the lookup table of the device to be calibrated mapped to the position k of the B-channel in the lookup table of the reference device, is the value corresponding to the position k+1 of each pixel in the physical image in the lookup table of the device to be calibrated mapped to the position k+1 of the B-channel in the lookup table of the reference device.
2. The sampling-based high-speed non-linear color correction method according to claim 1, characterized in that In steps S100 and S200, The number of the first grayscale color card images and the second grayscale color card images is consistent with the number of color cards in the N-level grayscale color card.
3. A sampling-based high-speed non-linear color correction device for implementing the sampling-based high-speed non-linear color correction method according to any one of claims 1 to 2, characterized in that, The sampling-based high-speed non-linear color correction device includes: A host computer; A reference device, which is electrically connected to the host computer; A device to be calibrated, which is electrically connected to the host computer.
4. A computer-readable storage medium, on which program instructions are stored, and when the program instructions are executed by a processor, the method described in any one of claims 1 to 2 is implemented.
Citation Information
Patent Citations
Method for correcting non-uniformity of image of Bayer filter array color camera
CN102622739A
Image processing device, and image processing method
WO2006057314A1