Image-based data processing method and apparatus, device, and medium
By extracting the gain of a specified color channel from the input image, obtaining the calibrated gain, and performing error calculation, the accuracy and efficiency problems of image processing with large color deviations in the prior art are solved, and more efficient and accurate color balance adjustment is achieved.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2025-10-10
- Publication Date
- 2026-06-11
AI Technical Summary
Existing grayscale world schemes and white point statistical schemes have low accuracy and high complexity in image processing with large color deviations, which reduces the efficiency and accuracy of image processing.
By extracting the gain of a specified color channel from the input image, obtaining a calibrated gain that matches the gain, calculating the gain error and adjusting the specified color channel, and then using the calibrated gain and the white balance gain based on the green channel for color balance adjustment.
It improves the accuracy and efficiency of image color balance adjustment and enhances the reliability of image-based data processing.
Smart Images

Figure CN2025126763_11062026_PF_FP_ABST
Abstract
Description
Image-based data processing methods, devices, equipment, and media
[0001] Related applications
[0002] This application claims priority to Chinese patent application filed on December 3, 2024, with application number 202411767742.7, entitled "Image-based data processing method, apparatus, device and medium", the entire contents of which are incorporated herein by reference. Technical Field
[0003] This application relates to the field of computer technology, and more specifically, to an image-based data processing method, an image-based data processing apparatus, an electronic device, and a computer-readable medium. Background Technology
[0004] In related technologies, two main schemes are used for color balance adjustment of images: the grayscale world scheme and the white point statistical scheme. The grayscale world scheme mainly assumes that the average reflectance of light by objects in nature is a constant value, which approximates gray. This assumption is forced onto the image to eliminate the influence of ambient light and obtain the original image. The white point statistical scheme mainly assumes that the brightest part of the image is white. By adjusting the intensity of each color channel, the desired white point is achieved.
[0005] However, the grayscale world scheme is only suitable for images with small color deviations, and its accuracy is low for images with large color deviations. The white point statistics scheme relies on the selection of white points, which is complex and reduces the efficiency of image processing. Furthermore, the inconsistency in the selection of white points reduces the accuracy of image processing.
[0006] Therefore, how to better adjust the color balance of images to ensure the reliability of image-based data processing is an urgent problem to be solved. Summary of the Invention
[0007] The embodiments of this application provide an image-based data processing method, apparatus, device, and medium that improves the accuracy, efficiency, and flexibility of image color balance adjustment, and the image-based data processing has high reliability.
[0008] In a first aspect, embodiments of this application provide an image-based data processing method executed by an electronic device. The method includes: extracting the gain of a specified color channel from an input image; obtaining a calibration gain that matches the gain, the calibration gain being obtained based on a calibration image acquired under a calibration color temperature environment; calculating a gain error based on the calibration gain and a white balance gain based on the green channel, and calculating a gain adjustment value based on the gain error and historical gain errors; and adjusting the specified color channel based on the gain adjustment value to obtain a color balanced image.
[0009] Secondly, embodiments of this application provide an image-based data processing apparatus, the apparatus comprising: an extraction module configured to extract the gain of a specified color channel from an input image; an acquisition module configured to acquire a calibration gain matching the gain, the calibration gain being obtained based on a calibration image acquired under a calibration color temperature environment; a calculation module configured to calculate a gain error based on the calibration gain and a white balance gain based on the green channel, and to calculate a gain adjustment value for the specified color channel based on the gain error and historical gain errors; and an adjustment module configured to adjust the specified color channel based on the gain adjustment value to obtain a color balanced image.
[0010] Thirdly, embodiments of this application provide an electronic device, including one or more processors; and a memory for storing one or more computer programs, which, when executed by the one or more processors, cause the electronic device to implement the image-based data processing method described above.
[0011] Fourthly, embodiments of this application provide a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the image-based data processing method described above.
[0012] Fifthly, embodiments of this application provide a computer program product, including computer instructions, which, when executed by a processor, implement the image-based data processing method described above.
[0013] Details of one or more embodiments of this application are set forth in the following drawings and description. Other features, objects, and advantages of this application will become apparent from the specification, drawings, and claims. Attached Figure Description
[0014] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the published drawings without creative effort.
[0015] Figure 1 is a schematic diagram of an exemplary implementation environment in which the technical solutions of the embodiments of this application can be applied.
[0016] Figure 2 is a flowchart illustrating an image-based data processing method in an exemplary embodiment of this application.
[0017] Figure 3 is a schematic diagram of a system illustrated in an exemplary embodiment of this application.
[0018] Figure 4 is a schematic diagram illustrating the calibration in an exemplary embodiment of this application.
[0019] Figure 5 is a flowchart illustrating an image-based data processing method in another exemplary embodiment of this application.
[0020] Figure 6 is a schematic diagram illustrating an image-based data processing method in another exemplary embodiment of this application.
[0021] Figure 7 is a block diagram illustrating an image-based data processing apparatus according to an exemplary embodiment of this application.
[0022] Figure 8 is a schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application. Detailed Implementation
[0023] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0024] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0025] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0026] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0027] It should be noted that "multiple" as mentioned in this application refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0028] In related technologies, two main schemes are used for color balance adjustment of images: the grayscale world scheme and the white point statistical scheme. The grayscale world scheme mainly assumes that the average reflectance of light by objects in nature is a constant value, which approximates gray. This assumption is forced onto the image to eliminate the influence of ambient light and obtain the original image. The white point statistical scheme mainly assumes that the brightest part of the image is white. By adjusting the intensity of each color channel, the desired white point is achieved.
[0029] However, the grayscale world scheme is only suitable for images with small color deviations, and its accuracy is low for images with large color deviations. The white point statistics scheme relies on the selection of white points, which is complex and reduces the efficiency of image processing. Furthermore, the inconsistency in the selection of white points reduces the accuracy of image processing.
[0030] Therefore, in order to better adjust the color balance of images and ensure the reliability of image-based data processing, this application provides an image-based data processing scheme. Please refer to Figure 1, which is a schematic diagram of an implementation environment involved in this application. This implementation environment mainly includes a terminal device 101 and a server 102; wherein:
[0031] Terminal devices 101 include, but are not limited to, extended reality devices (virtual reality devices, augmented reality devices, mixed reality devices, etc.), mobile phones, computers (tablets, laptops, desktop computers, etc.), smart home devices (televisions, refrigerators, air conditioners, washing machines, robot vacuums, etc.), smart wearable devices (bracelets, watches, etc.).
[0032] Server 102 can be a standalone physical server, or a server cluster or distributed system consisting of multiple physical servers. The server cluster or distributed system includes cloud servers used to provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0033] It is understood that terminal device 101 and server 102 establish a communication connection via a wired or wireless network. Exemplarily, the wireless or wired network uses standard communication technologies and / or protocols. The network is typically the Internet, but can also be any other network, including but not limited to a Local Area Network (LAN), Metropolitan Area Network (MAN), Wide Area Network (WAN), mobile, wired or wireless networks, private networks, or any combination of virtual private networks.
[0034] In one embodiment of this application, the image-based data processing method can be executed by server 102. Specifically, server 102 extracts the gain of a specified color channel from the input image; then obtains a calibration gain that matches the gain, the calibration gain being obtained based on a calibration image acquired under a calibration color temperature environment; then calculates the gain error based on the calibration gain and the white balance gain based on the green channel, and calculates the gain adjustment value based on the gain error and the historical gain error; then adjusts the specified color channel based on the gain adjustment value to obtain a color balanced image.
[0035] In other embodiments of this application, the image-based data processing method can be executed by the terminal device 101 alone, or by the terminal device 101 and the server 102 together. In practical applications, the executing entity of the image-based data processing method can be flexibly adjusted according to the specific application scenario.
[0036] It should be noted that the number of terminal devices 101 and servers 102 in Figure 1 is merely illustrative. Depending on actual needs, there can be any number of terminal devices 101 and servers 102.
[0037] It should be noted that in the specific implementation of this application, user-related data is involved. When the embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0038] The following details the various implementation details of the technical solutions in the embodiments of this application:
[0039] Please refer to Figure 2, which is a flowchart illustrating an image-based data processing method according to an embodiment of this application. As shown in Figure 2, the image-based data processing method includes at least steps S201 to S204, which are described in detail below:
[0040] S201, Extract the gain of the specified color channel from the input image.
[0041] In this embodiment of the application, the input image refers to the image to be adjusted for color balance, which includes, but is not limited to, biometric images, landscape images, object images, etc., wherein biometric images include, but are not limited to, palm images, face images, etc.
[0042] In this embodiment, the specified color channel is at least one of the red channel and the blue channel. Optionally, the specified color channel is the red channel; alternatively, the specified color channel is the blue channel; alternatively, the specified color channel is both the red channel and the blue channel.
[0043] In this embodiment, the gain of a specified color channel refers to a parameter used to amplify or reduce the channel value of a specified color channel to ensure color balance in the image. A gain greater than 1 indicates amplification of the channel value, while a gain less than 1 indicates reduction. It is understood that in white balance, the green channel is typically used as a reference, set to 1. Accordingly, the gain of a specified color channel refers to the ratio of the gain between the specified color channel and the green channel.
[0044] In one embodiment of this application, prior to the process of extracting the gain of a specified color channel from the input image in S201, the following may also be included:
[0045] Acquire biometric images, including at least one of palm images and face images, and use the biometric images as input images.
[0046] That is, in the optional embodiment, considering that biometric images have more details and have higher requirements for image color balance, the optional embodiment acquires biometric images, wherein the biometric images include at least one of palm images and face images, and the acquired palm images and / or face images are used as input images.
[0047] By implementing this optional embodiment, color balance adjustments are made to biometric images, resulting in better image color balance and adaptability to various scenarios.
[0048] In one embodiment of this application, the process of extracting the gain of a specified color channel from the input image in S201 may include: performing image segmentation processing on the input image to obtain multiple image blocks, and extracting the gain of a specified color channel from each image block; averaging the gains corresponding to the multiple image blocks to obtain an average gain, and using the average gain as the gain of the specified color channel.
[0049] That is, in the optional embodiment, an input image is acquired, and then the input image is first processed by image segmentation to obtain multiple image blocks. Then, the gain of a specified color channel is extracted from each image block, and then the average gain of the gains corresponding to the multiple image blocks is calculated to obtain the average gain. At this time, the average gain is the gain of the specified color channel.
[0050] Specifically, for each image block, calculate the sum S of all pixel values for the specified color channel within that image block. spec S, the sum of all pixel values in the green channel green The ratio, i.e. The ratio G block The gain is used as the gain for a specified color channel in the image patch; the average gain is obtained by averaging the gains corresponding to multiple image patches. Where n is the number of image patches, and the average gain is... As the gain of a specified color channel.
[0051] For example, the input image Image is divided into four image blocks: image block I_b1, image block I_b2, image block I_b3, and image block I_b4. The gain G_e1 of a specified color channel is extracted from image block I_b1, the gain G_e2 of the specified color channel is extracted from image block I_b2, the gain G_e3 of the specified color channel is extracted from image block I_b3, and the gain G_e4 of the specified color channel is extracted from image block I_b4. Then, the average gain G_e1, gain G_e2, gain G_e3, and gain G_e4 are averaged to obtain the average gain G_e_a, i.e., G_e_a = (G_e1 + G_e2 + G_e3 + G_e4) / 4. This average gain G_e_a is the gain G_e of the specified color channel.
[0052] By implementing this optional embodiment, after performing image segmentation on the input image, the gain of the specified color channel of each image block is extracted and averaged. This allows for a simple and accurate way to obtain the gain of the specified color channel of the input image, providing strong support for image color balance adjustment.
[0053] In one of the optional embodiments, the process of extracting the gain of a specified color channel from each image block may include: generating an extraction task for each image block to obtain multiple extraction tasks; and executing multiple extraction tasks in parallel to extract the gain of a specified color channel from each image block.
[0054] That is, in an optional embodiment, multiple extraction tasks are executed in parallel to achieve the extraction of the gain of a specified color channel from multiple image blocks in parallel.
[0055] By implementing this optional embodiment, the gains of specified color channels of multiple image patches are extracted in parallel, thereby improving the efficiency of extracting the gains of specified color channels in the input image and thus improving the efficiency of image color balance adjustment.
[0056] S202, Obtain the calibration gain that matches the gain, which is obtained based on the calibration image acquired under the calibration color temperature environment.
[0057] In this embodiment, the gain of a specified color channel is extracted from the input image, and then a calibration gain matching the extracted gain can be obtained, wherein the calibration gain is obtained based on the calibration image acquired under the calibration color temperature environment.
[0058] In one embodiment of this application, the process of obtaining a calibration gain that matches the gain in S202 may include:
[0059] Obtain the calibration table, which includes multiple calibration color temperatures and multiple calibration gains corresponding to each calibration color temperature. The multiple calibration gains are the calibration gains corresponding to different color channels.
[0060] Select candidate calibration gains for the specified color channel corresponding to each calibration color temperature from the calibration table to obtain multiple candidate calibration gains;
[0061] Select the candidate calibration gain that has the smallest difference from the current gain from multiple candidate calibration gains, and use the selected candidate calibration gain as the calibration gain that matches the current gain.
[0062] That is, in an optional embodiment, a calibration table is first obtained, which includes multiple calibration color temperatures and calibration gains for different color channels corresponding to each calibration color temperature. Optionally, each calibration color temperature corresponds to a calibration gain for the red channel and a calibration gain for the blue channel. Then, candidate calibration gains for the specified color channel corresponding to each calibration color temperature are selected from the calibration table to obtain multiple candidate calibration gains. Then, the candidate calibration gain with the smallest difference from the extracted gain is selected from the multiple candidate calibration gains. At this time, the selected candidate calibration gain is the calibration gain that matches the extracted gain.
[0063] For example, please refer to Table 1, which is a calibration table for one example.
[0064] Table 1
[0065] Let the specified color channel be the red channel, and let the gain of the extracted red channel be RG_e. Then, select RG_s1, RG_s2, and RG_s3 from the calibration table shown in Table 1 as candidate calibration gains. Then, select the candidate calibration gain that is the smallest difference from the gain RG_e from the candidate calibration gains RG_s1, RG_s2, and RG_s3.
[0066] Alternatively, if the specified color channel is the blue channel, and the gain of the extracted blue channel is BG_e, then BG_s1, BG_s2, and BG_s3 are selected from the calibration table shown in Table 1 as candidate calibration gains. Then, the candidate calibration gain with the smallest difference from the gain BG_e is selected from the candidate calibration gains BG_s1, BG_s2, and BG_s3.
[0067] By implementing this optional embodiment, the calibration gain that differs the least from the extracted gain in the calibration table is taken as the calibration gain that matches the extracted gain and participates in the image color balance adjustment, making the image color balance adjustment more accurate and improving the accuracy of image color balance adjustment.
[0068] In one optional embodiment, the process of selecting candidate calibration gains for a specified color channel corresponding to each calibration color temperature from the calibration table to obtain multiple candidate calibration gains may include: obtaining the color temperature extracted from the input image; generating a color temperature range based on the color temperature, wherein the color temperature is located within the color temperature range; searching for multiple candidate calibration color temperatures located within the color temperature range from the calibration table, and selecting candidate calibration gains for a specified color channel corresponding to each candidate calibration color temperature to obtain multiple candidate calibration gains.
[0069] That is, in the optional embodiment, in addition to extracting the gain of a specified color channel from the input image, the color temperature can also be extracted from the input image. Then, the extracted color temperature is used to generate a color temperature range, where the extracted color temperature is located in the color temperature range. Then, multiple candidate calibration color temperatures located in the color temperature range are searched from the calibration table, and the candidate calibration gain of the specified color channel corresponding to each candidate calibration color temperature is selected, thereby obtaining multiple candidate calibration gains.
[0070] Specifically, by calculating the pixel value ratio of different color channels in the input image, the color temperature T extracted from the input image is obtained using the color temperature calculation formula T = f(R / G, B / G) (where R, G, and B are the average pixel values of the red, green, and blue channels in the input image, respectively, and f is a predetermined color temperature calculation function). input Based on color temperature T input Generate color temperature range [T input -ΔT,T input +ΔT], where ΔT is a preset color temperature range; find multiple candidate calibration color temperatures in the calibration table that are located in the color temperature range, and select the candidate calibration gain of the specified color channel corresponding to each candidate calibration color temperature to obtain multiple candidate calibration gains.
[0071] For example, the color temperature CT_e is extracted from the input image, where the starting color temperature CT_e1 (which is less than CT_e) and the ending color temperature CT_e2 (which is greater than CT_e) are determined, and the color temperature range [CT_e1, CT_e2] is generated using the starting color temperature CT_e1 and the ending color temperature CT_e2.
[0072] Let the specified color channel be the red channel, and let the calibration color temperature Ct1 and calibration color temperature Ct2 located in the color temperature range [CT_e1, CT_e2] be found from the calibration table shown in Table 1. In this case, the calibration color temperature Ct1 and calibration color temperature Ct2 are candidate calibration color temperatures. Then, RG_s1 corresponding to candidate calibration color temperature Ct1 and RG_s2 corresponding to candidate calibration color temperature Ct2 are selected from the calibration table shown in Table 1 as candidate calibration gains. Then, the candidate calibration gain with the smallest difference from the gain RG_e is selected from the candidate calibration gains RG_s1 and RG_s2.
[0073] Alternatively, let the specified color channel be the blue channel, and let the calibration color temperature Ct1 and calibration color temperature Ct2 located in the color temperature range [CT_e1, CT_e2] be found from the calibration table shown in Table 1. In this case, the calibration color temperature Ct1 and calibration color temperature Ct2 are candidate calibration color temperatures. Then, select BG_s1 corresponding to candidate calibration color temperature Ct1 and BG_s2 corresponding to candidate calibration color temperature Ct2 from the calibration table shown in Table 1 as candidate calibration gains. Then, select the candidate calibration gain with the smallest difference from the gain BG_e from the candidate calibration gains BG_s1 and BG_s2.
[0074] By implementing this optional embodiment, a color temperature range is generated using the extracted color temperature, and candidate calibration gains for the specified color channels corresponding to the calibration color temperatures within the color temperature range are selected from the calibration table. This avoids the tedious operation of comparing the extracted gains with the calibration gains of the specified color channels corresponding to each calibration color temperature, thus improving the efficiency of obtaining calibration gains that match the extracted gains and consequently improving the efficiency of image color balance adjustment.
[0075] In one of the optional embodiments, the process of selecting the candidate calibration gain with the smallest difference from the gain from multiple candidate calibration gains may include: performing a subtraction operation between the gain and multiple candidate calibration gains to obtain multiple gain difference values; and selecting the candidate calibration gain corresponding to the smallest gain difference value from multiple candidate calibration gains.
[0076] That is, in the optional embodiment, the extracted gain is first subtracted from multiple candidate calibration gains to obtain multiple gain difference values, and then the candidate calibration gain corresponding to the smallest gain difference value is selected from the multiple candidate calibration gains.
[0077] For example, continuing from the previous example of selecting the candidate calibration gain with the smallest difference from the gain RG_e among the candidate calibration gains RG_s1, RG_s2, and RG_s3, the gain difference RG_es1 is obtained by subtracting the gain RG_e from the candidate calibration gain RG_s1, i.e., RG_es1 = RG_e - RG_s1. The gain difference RG_e is obtained by subtracting the gain RG_s2 from the candidate calibration gain RG_s2, i.e., RG_es2 = RG_e - RG_s2. The gain difference RG_e is obtained by subtracting the gain RG_s3 from the candidate calibration gain RG_s3, i.e., RG_es3 = RG_e - RG_s3. At the same time, let's assume that RG_es2 is the smallest among the gain differences RG_es1, RG_es2, and RG_es3. Then, RG_s2 is selected from the candidate calibration gains RG_s1, RG_s2, and RG_s3 because it has the smallest difference from the gain RG_e.
[0078] Alternatively, continuing with the example of selecting the candidate calibration gain with the smallest difference from the candidate calibration gains BG_s1, BG_s2, and BG_s3, the difference between the gain BG_e and the candidate calibration gain BG_s1 is calculated to obtain the gain difference BG_es1, i.e., BG_es1 = BG_e - BG_s1. The difference between the gain BG_e and the candidate calibration gain BG_s2 is calculated to obtain the gain difference BG_es2, i.e., BG_es1 - BG_s1. _es2 = BG_e - BG_s2. The gain difference BG_e is obtained by subtracting the candidate calibration gain BG_s3, i.e., BG_es3 = BG_e - BG_s3. At the same time, let BG_es2 be the smallest among the gain differences BG_es1, BG_es2 and BG_es3. Then, BG_s2 is the candidate calibration gain that has the smallest difference from the gain BG_e.
[0079] By implementing this optional embodiment, a calibration gain that matches the extracted gain can be obtained easily and accurately.
[0080] In an optional embodiment, before obtaining the calibration table, the process may further include: acquiring calibration images under different calibration color temperature environments; extracting calibration gains corresponding to different color channels from each calibration image to obtain multiple calibration gains for each calibration image, wherein the different color channels include red channels and blue channels; associating the calibration color temperature and multiple calibration gains corresponding to the same calibration image to generate a calibration table.
[0081] That is, in an optional embodiment, calibration images under different calibration color temperature environments are pre-acquired, and calibration gains corresponding to different color channels are extracted from each calibration image to obtain multiple calibration gains for each calibration image. Optionally, different color channels include red channels and blue channels. Then, the calibration color temperature and multiple calibration gains corresponding to the same calibration image are associated to generate a calibration table.
[0082] By implementing this optional embodiment, a calibration table can be obtained simply and accurately, providing strong support for obtaining a calibration gain that matches the extracted gain.
[0083] S203 calculates the gain error based on the calibrated gain and the white balance gain with the green channel as a reference, and calculates the gain adjustment value based on the gain error and the historical gain error.
[0084] In this embodiment, a calibration gain matching the extracted gain is obtained. Then, the gain error (referred to as the current gain error for easy distinction from historical gain errors) can be calculated using the calibration gain and the white balance gain based on the green channel. Finally, the gain adjustment value for the specified color channel is calculated using the current gain error and the historical gain error. This can be achieved using the formula E = G. wb -G cal The gain error is calculated, where E represents the current gain error, and G... wb G represents the white balance gain relative to the green channel. cal This represents the calibrated gain. It can be expressed using the formula... The gain adjustment value for the specified color channel is calculated, where A represents the gain adjustment value and K... p K i K d These are the proportional, integral, and differential coefficients, respectively, E i E represents the historical gain error of the i-th time. prev Δt represents the gain error of the previous iteration, and Δt represents the time interval.
[0085] In the embodiments of this application, the white balance gain refers to the ideal gain for a balanced white, which is typically close to 1.
[0086] In this embodiment, historical gain error refers to the gain error calculated earlier than the current time, and it can be one or more. Optionally, historical gain error can be all gain errors regardless of color channel; for example, suppose there are 10 gain errors for the red channel and 10 gain errors for the blue channel calculated earlier than the current time, then all 20 gain errors can be regarded as historical gain errors. Optionally, historical gain error can be a portion of the gain errors that need to distinguish color channels; for example, continuing the previous example, if the specified color channel is the red channel, then the 10 gain errors calculated earlier than the current time for the red channel are historical gain errors, or if the specified color channel is the blue channel, then the 10 gain errors calculated earlier than the current time for the blue channel are historical gain errors.
[0087] In this embodiment, the gain adjustment value refers to a more accurate gain error relative to the current gain error. It can be used to obtain the correction gain of a specified color channel, thereby adjusting the specified color channel. The correction gain refers to a parameter calculated based on the gain adjustment value and the white balance gain, used to adjust the specified color channel to achieve color balance in the image.
[0088] In one embodiment of this application, the process of calculating the gain error in S203 based on the calibration gain and the white balance gain relative to the green channel may include:
[0089] Obtain the white balance gain based on the green channel, with a white balance gain of 1;
[0090] The gain error is obtained by subtracting the white balance gain from the calibration gain.
[0091] That is, in the optional embodiment, when the white balance gain is set to 1, the difference between the white balance gain and the calibration gain is calculated to obtain the current gain error.
[0092] For example, following the previous example of obtaining a calibration gain RG_s2 that matches the gain RG_e, the difference between 1 and the calibration gain RG_s2 is used to obtain the current gain error E_RG_p, that is, E_RG_p=1-RG_s2.
[0093] Alternatively, following the example above where a calibration gain BG_s2 matching the gain BG_e was obtained, the difference between 1 and the calibration gain BG_s2 is used to obtain the current gain error E_BG_p, i.e., E_BG_p = 1 - BG_s2.
[0094] By implementing this optional embodiment, the current gain error can be obtained easily and accurately, providing strong support for image color balance adjustment.
[0095] In one embodiment of this application, the process of calculating the gain adjustment value based on the gain error and the historical gain error in S203 may include: calculating the gain adjustment auxiliary parameter based on the historical gain error, the generation time of the historical gain error, the gain error, and the generation time of the gain error; and calculating the gain adjustment value based on the gain error and the gain adjustment auxiliary parameter.
[0096] That is, in the optional embodiment, before / after / simultaneously obtaining the current gain error, the historical gain error and the generation time of the historical gain error can be obtained. Then, the gain adjustment auxiliary parameter is calculated using the historical gain error, the generation time of the historical gain error, the current gain error, and the generation time of the current gain error. Finally, the gain adjustment value is calculated using the gain error and the gain adjustment auxiliary parameter.
[0097] For example, continuing from the previous example of obtaining the current gain error E_RG_p, suppose we obtain the historical gain error E_RG_h, the generation time T_h of the historical gain error E_RG_h, and the generation time T_p of the current gain error E_RG_p. At this time, we first use the historical gain error E_RG_h, the generation time T_h, the current gain error E_RG_p, and the generation time T_p to calculate the gain adjustment auxiliary parameter E_RG_s. Then, we use the current gain error E_RG_p and the gain adjustment auxiliary parameter E_RG_s to calculate the gain adjustment value E_RG_a.
[0098] By implementing this optional embodiment, combining historical gain error and current gain error, and taking into account the historical changes in gain error, a more accurate gain adjustment value can be obtained, providing strong support for image color balance adjustment.
[0099] In the optional embodiment, the historical gain error includes multiple factors; correspondingly, the process of calculating the gain adjustment auxiliary parameter based on the historical gain error, the generation time of the historical gain error, the gain error, and the generation time of the gain error can include at least the following three cases:
[0100] Case 1: Based on multiple historical gain errors, the generation time of each historical gain error, the gain error itself, and the generation time of the gain error, perform an integral operation to obtain the integral value of the gain error, which is used to characterize the accumulation of the gain error. The integral value of the gain error is then used as an auxiliary parameter for gain adjustment.
[0101] In Case 1, when there are multiple historical gain errors, the integral value of the gain error is obtained by performing an integral operation on the multiple historical gain errors, the generation time corresponding to the multiple historical gain errors, the current gain error, and the generation time of the current gain error. The integral value of the gain error is used to characterize the accumulation of gain error, and the integral value of the gain error is the auxiliary parameter for gain adjustment.
[0102] The integral value of gain error refers to the value obtained by integrating multiple historical gain errors, their respective generation times, the current gain error, and the generation time of the current gain error when there are multiple historical gain errors. It is used to characterize the accumulation of gain error and can be used as an auxiliary parameter for gain adjustment.
[0103] For example, using the integral formula to perform the integration operation, let the integral value of the gain error be E_RG_si, where the integral formula is: E_RG_si=∫error(t)dt, where error(t) refers to the gain error at time t (which can be the historical gain error, or the historical gain error and the current gain error, and dt refers to the time interval between the generation times of two adjacent gain errors).
[0104] Optionally, in Case 1, the process of calculating the gain adjustment value based on the gain error and the gain adjustment auxiliary parameter may include: obtaining the gain coefficients corresponding to the gain error and the integral value of the gain error, respectively; and performing a weighted summation operation based on the gain error, the integral value of the gain error, and the gain coefficients to obtain the gain adjustment value.
[0105] For example, the gain adjustment formula is used for calculation, where the gain adjustment formula is: E_RG_a=K p ×error+K i ×∫error(t)dt, where error refers to the current gain error, error(t) refers to the gain error over a period of time (which can be the historical gain error, or the historical gain error and the current gain error, and dt refers to the time interval between the generation times of two adjacent gain errors), K p K refers to the gain coefficient corresponding to the current gain error. i This refers to the gain coefficient corresponding to the integral value of the gain error.
[0106] Case 2: Based on multiple historical gain errors, the generation time of each historical gain error, the gain error itself, and the generation time of the gain error, perform differential operations to obtain the differential value of the gain error used to characterize the change of the gain error, and use the differential value of the gain error as an auxiliary parameter for gain adjustment.
[0107] The differential value of gain error refers to the value obtained by differentiating multiple historical gain errors, their corresponding generation times, the current gain error, and the generation time of the current gain error when there are multiple historical gain errors. It is used to characterize the change of gain error and can be used as an auxiliary parameter for gain adjustment.
[0108] In Case 2, when there are multiple historical gain errors, the differential value of the gain error is obtained by performing differential operations on the multiple historical gain errors, the generation time corresponding to the multiple historical gain errors, the current gain error, and the generation time of the current gain error. The differential value of the gain error is used to characterize the change of the gain error. At this time, the differential value of the gain error is the auxiliary parameter for gain adjustment.
[0109] For example, using a differential formula to perform differential operations, let the differential value of the gain error be E_RG_sd, where the differential formula is: E_RG_sd=d(error-error(t)) / dt, where error refers to the current gain error, error(t) refers to the gain error (which can be the historical gain error, or the combination of the historical gain error and the current gain error, and dt refers to the time interval between the generation times of two adjacent gain errors).
[0110] Optionally, in Case 2, the process of calculating the gain adjustment value based on the gain error and the gain adjustment auxiliary parameter may include: obtaining the gain coefficients corresponding to the gain error and the differential value of the gain error, respectively; and performing a weighted summation operation based on the gain error, the differential value of the gain error, and the gain coefficients to obtain the gain adjustment value.
[0111] For example, the gain adjustment formula is used for calculation, where the gain adjustment formula is: E_RG_a=K p ×error+K d ×(d(error-error(t)) / dt), where error refers to the current gain error, error(t) refers to the gain error over a period of time (which can be the historical gain error, or the historical and current gain errors, and dt refers to the time interval between the generation times of two adjacent gain errors), K p K refers to the gain coefficient corresponding to the current gain error. d It refers to the gain coefficient corresponding to the differential value of the gain error.
[0112] Case 3: Based on multiple historical gain errors, the generation time of each historical gain error, the gain error itself, and the generation time of the gain error, perform integration to obtain the integral value of the gain error, which characterizes the accumulation of the gain error; and based on multiple historical gain errors, the generation time of each historical gain error, the gain error itself, and the generation time of the gain error, perform differentiation to obtain the differential value of the gain error, which characterizes the change of the gain error; use the integral value of the gain error and the differential value of the gain error as auxiliary parameters for gain adjustment.
[0113] Case 3 is a combination of Case 1 and Case 2, where both the integral value of the gain error and the derivative value of the gain error are auxiliary parameters for gain adjustment.
[0114] Optionally, in case 3, the process of calculating the gain adjustment value based on the gain error and the gain adjustment auxiliary parameter may include: obtaining the gain error, the integral value of the gain error, and the gain coefficients corresponding to the differential value of the gain error; and performing a weighted summation operation based on the gain error, the integral value of the gain error, the differential value of the gain error, and the gain coefficients to obtain the gain adjustment value.
[0115] For example, the gain adjustment formula is used for calculation, where the gain adjustment formula is: E_RG_a=K p ×error+K i ×∫error(t)dt+K d ×(d(error-error(t)) / dt), where error refers to the current gain error, error(t) refers to the gain error over a period of time (which can be the historical gain error, or the historical and current gain errors, and dt refers to the time interval between the generation times of two adjacent gain errors), K p K refers to the gain coefficient corresponding to the current gain error. i K refers to the gain coefficient corresponding to the integral value of the gain error. d It refers to the gain coefficient corresponding to the differential value of the gain error.
[0116] By implementing this optional embodiment, the integral value of the gain error is used as an auxiliary parameter for gain adjustment, taking into account the accumulation of the gain error, and / or the derivative value of the gain error is used as an auxiliary parameter for gain adjustment, taking into account the changes in the gain error, thereby improving the accuracy of the gain adjustment value calculation and thus improving the accuracy of image color balance adjustment.
[0117] S204, adjust the specified color channel based on the gain adjustment value to obtain a color balanced image.
[0118] In this embodiment, a gain adjustment value is obtained, which can then be used to adjust a specified color channel to obtain a color-balanced image. This can be achieved using formula V. adj =V org ×(1+A) adjusts the specified color channel to obtain a color balanced image, where V adj V represents the adjusted channel value. org A represents the original channel value, and A represents the gain adjustment value.
[0119] In this embodiment, the color-balanced image refers to the image obtained after adjusting the color balance of the input image. Compared with the input image, it has a better color balance effect and is more convenient for corresponding operations (such as verification).
[0120] In one embodiment of this application, the process of adjusting a specified color channel based on a gain adjustment value to obtain a color balanced image in step S204 may include:
[0121] The correction gain is calculated based on the gain adjustment value and the white balance gain;
[0122] A color-balanced image is obtained by adjusting the specified color channel based on the correction gain.
[0123] That is, in the optional embodiment, the correction gain is first calculated using the gain adjustment value and the white balance gain, and then the correction gain is used to adjust the specified color channel to obtain a color balanced image.
[0124] For example, continuing from the previous example, the correction gain RG_t is calculated using the gain adjustment value E_RG_a and the white balance gain, and then the correction gain RG_t is used to adjust the specified color channel to obtain a color balanced image.
[0125] By implementing this optional embodiment, the final correction gain is obtained by using the gain adjustment value and the white balance gain, thereby enabling image color balance adjustment and improving the accuracy of image color balance adjustment.
[0126] In one of the optional embodiments, the process of calculating the correction gain based on the gain adjustment value and the white balance gain may include: performing a difference operation on the white balance gain and the gain adjustment value to obtain the correction gain.
[0127] That is, in the optional embodiment, when the white balance gain is set to 1, the correction gain is obtained by subtracting the white balance gain and the gain adjustment value.
[0128] For example, the difference between 1 and the gain adjustment value E_RG_a is used to obtain the correction gain RG_t, that is, RG_t = 1 - E_RG_a.
[0129] By implementing this optional embodiment, the correction gain can be obtained easily and accurately, providing strong support for image color balance adjustment.
[0130] In one optional embodiment, the specified color channels include a red channel and a blue channel, and the correction gain includes a first correction gain for the red channel and a second correction gain for the blue channel. Accordingly, the process of adjusting the specified color channels based on the correction gain to obtain a color-balanced image may include: adjusting the channel value corresponding to the red channel of a pixel in the input image based on the first correction gain to obtain the adjusted channel value for the red channel; adjusting the channel value corresponding to the blue channel of a pixel in the input image based on the second correction gain to obtain the adjusted channel value for the blue channel; and generating a color-balanced image based on the channel value corresponding to the green channel of a pixel in the input image, the adjusted channel value for the red channel, and the adjusted channel value for the blue channel.
[0131] The first correction gain refers to the correction gain for the red channel when the specified color channel includes both red and blue channels. It is used to adjust the channel value corresponding to the red channel of the pixel in the input image.
[0132] In an optional embodiment, when the specified color channel includes a red channel and a blue channel, the corresponding correction gain includes a first correction gain for the red channel and a second correction gain for the blue channel. In this case, the channel value corresponding to the red channel of the pixel in the input image is first adjusted using the first correction gain to obtain the adjusted channel value for the red channel, and the channel value corresponding to the blue channel of the pixel in the input image is adjusted using the second correction gain to obtain the adjusted channel value for the blue channel. Then, the color balanced image is generated using the channel value corresponding to the green channel of the pixel in the input image, the adjusted channel value for the red channel, and the adjusted channel value for the blue channel.
[0133] The second correction gain refers to the correction gain for the blue channel when the specified color channel includes both red and blue channels. It is used to adjust the channel value corresponding to the blue channel of each pixel in the input image.
[0134] Specifically, when the specified color channels include both red and blue channels, the correction gain includes the first correction gain RG of the red channel. t And the second correction gain BG of the blue channel. t The specific method for adjusting a specified color channel based on the correction gain to obtain a color balanced image is as follows: based on the first correction gain RG t For the channel value V corresponding to the red channel of the pixel in the input image r_org Adjustments are made to obtain the channel value V adjusted for the red channel. r_adj The calculation formula is V r_adj =V r_org ×RG t Based on the second correction gain BG tFor the channel value V corresponding to the blue channel of the pixel in the input image b_org Adjustments are made to obtain the adjusted channel value V for the blue channel. b_adj The calculation formula is V b_adj =V b_org ×BG t Based on the channel value V corresponding to the green channel of the pixel in the input image. g_org The adjusted channel value V for the red channel r_adj And the adjusted channel value V for the blue channel. b_adj Generate a color-balanced image.
[0135] For example, continuing from the previous example, let the correction gains include a first correction gain RG_tr and a second correction gain BG_tb. Then, the first correction gain BG_tr is used to adjust the channel value r corresponding to the red channel of a pixel in the input image, resulting in the adjusted channel value r' for the red channel. The second correction gain BG_tb is used to adjust the channel value b corresponding to the blue channel of a pixel in the input image, resulting in the adjusted channel value b' for the blue channel. Simultaneously, let g be the channel value g corresponding to the green channel of a pixel in the input image. Then, using the channel value g corresponding to the green channel of a pixel in the input image, the adjusted channel value r' for the red channel, and the adjusted channel value b' for the blue channel, a color-balanced image is generated. It can be understood that the pixel value of the same pixel in the input image can be represented as (r, g, b) before adjustment, and as (r', g, b') after adjustment.
[0136] By implementing this optional embodiment, the efficiency of image color balance adjustment is improved by simultaneously adjusting both the red and blue channels.
[0137] In one optional embodiment, the process of adjusting the channel value corresponding to the red channel of a pixel in the input image based on the first correction gain to obtain the adjusted channel value for the red channel, and adjusting the channel value corresponding to the blue channel of a pixel in the input image based on the second correction gain to obtain the adjusted channel value for the blue channel, may include: generating adjustment tasks for the red channel and the blue channel respectively to obtain multiple adjustment tasks; executing multiple adjustment tasks in parallel to obtain the adjusted channel value for the red channel and the adjusted channel value for the blue channel.
[0138] That is, in an optional embodiment, multiple adjustment tasks are executed in parallel to achieve parallel adjustment of the channel values of the corresponding color channels.
[0139] By implementing this optional embodiment, the channel values corresponding to the red and blue channels are adjusted in parallel, further improving the efficiency of image color balance adjustment.
[0140] In one embodiment of this application, after adjusting the specified color channel based on the gain adjustment value to obtain a color balance image in S204, the process may further include: verifying the object corresponding to the input image based on the color balance image, and performing the pending task after the verification is passed.
[0141] In other words, in an optional embodiment, a color balance image is used to verify the object corresponding to the input image, and a processing task is executed after successful verification. Specifically, the color balance image can be matched with a pre-stored template image to calculate the matching degree. When the matching degree is greater than a set threshold, the verification is successful, and the processing task is executed after successful verification. The processing task refers to the task to be executed after the object corresponding to the input image based on the color balance image has been verified, such as a payment task or an unlocking task.
[0142] For example, in a payment application scenario, an image of the hand input by the object is collected. Then, the hand image can be adjusted using the technical solution provided in the embodiments of this application to obtain a hand image with better color balance. The object is then verified using the hand image with better color balance, and the payment task is executed after the verification is successful, thereby completing the payment.
[0143] Alternatively, in the unlocking application scenario, an image of the hand input by the object is collected. Then, the hand image can be adjusted using the technical solution provided in the embodiments of this application to obtain a hand image with better color balance. The object is then verified using the hand image with better color balance, and the unlocking task is executed after the verification is passed, thereby completing the unlocking.
[0144] By implementing this optional embodiment, the color-balanced image is applied to scenarios that require verification to perform the task to be processed, thus avoiding the phenomenon that the verification accuracy is low due to the poor color balance effect of the input image, improving the verification accuracy, and thereby improving the accuracy of task execution.
[0145] In this embodiment, a relatively accurate calibration gain for a specified color channel in the input image is obtained through pre-calibration. The gain error between the white balance gain and the calibration gain is then calculated based on the white balance gain. This gain error, along with historical gain errors, yields a more accurate gain error, thereby enabling adjustment of the specified color channel in the input image. Compared to related technical solutions, this embodiment is unaffected by ambient color temperature and is applicable to images acquired in any environment. Specifically, it is not limited to images with small color deviations and eliminates the need to select a white point, thus improving the accuracy, efficiency, and flexibility of image color balance adjustment. Furthermore, the reliability of image-based data processing is high.
[0146] The following provides a detailed description of specific scenarios in the embodiments of this application:
[0147] Please refer to Figure 3, which is a schematic diagram of a system according to an embodiment of this application. As shown in Figure 3, the system mainly includes calibration services and adjustment services, wherein:
[0148] The calibration service is mainly used to acquire calibration images at a calibration color temperature and extract the calibration gains corresponding to different color channels from each calibration image to obtain multiple calibration gains for each calibration image. The different color channels include the red channel and the blue channel. Then, the calibration color temperature and multiple calibration gains corresponding to the same calibration image are associated to generate a calibration table.
[0149] For each calibration image, calculate the sum S of all pixel values in the red channel of that image. red S, the sum of all pixel values in the green channel green The ratio, i.e. The ratio G red As the calibration gain of the red channel; calculate the sum S of all pixel values in the blue channel of the image. blue S, the sum of all pixel values in the green channel green The ratio, i.e. The ratio G blue As the calibration gain of the blue channel, multiple calibration gains are obtained for each calibration image. Different color channels include the red channel and the blue channel. Then, the calibration color temperature and multiple calibration gains corresponding to the same calibration image are associated to generate a calibration table.
[0150] Specifically, first prepare a standard light source, which includes, but is not limited to, fluorescent lamps, incandescent lamps, and fluorescent lamps, and determine the different color temperatures corresponding to the standard light source. These different color temperatures are then designated as different calibration color temperatures. Next, take images at different calibration color temperatures and designate the captured images as calibration images. Then, extract RGB values from the calibration images corresponding to different calibration color temperatures (e.g., using color analysis tools), and associate the RGB values corresponding to the same calibration image with the calibration color temperature to generate a calibration table.
[0151] For easier understanding, please refer to Figure 4, which shows the acquired calibration image and the corresponding calibration color temperature and RGB values. Because the calibration image in Figure 4 has undergone grayscale processing, the color differences are not obvious. The calibration color temperature in Figure 4 involves two fields, where field 1 includes uppercase letters, or uppercase letters and numbers, which is used to characterize the standard light source.
[0152] For easier understanding, please refer to Table 2, which is a calibration table for another example.
[0153] Table 2
[0154] The adjustment service primarily extracts the gain for the red channel from the received input image, retrieves the calibration gain matching the red channel gain from the calibration table, calculates the gain error based on the calibration gain and the white balance gain based on the green channel, and calculates the gain adjustment value for the red channel based on the gain error and historical gain errors. Similarly, it extracts the gain for the blue channel from the received input image, retrieves the calibration gain matching the blue channel gain from the calibration table, calculates the gain error based on the calibration gain and the white balance gain based on the green channel, and calculates the gain adjustment value for the blue channel based on the gain error and historical gain errors. Finally, it adjusts the red channel in the input image based on the gain adjustment value for the red channel, and adjusts the blue channel in the input image based on the gain adjustment value for the blue channel, thereby generating a color-balanced image.
[0155] Optionally, the adjustment service includes proportional control service, integral control service, derivative control service, and execution control service. The proportional control service, a part of the adjustment service, is used to calculate the gain error of the red and blue channels. It is obtained by subtracting the calibrated gain from the white balance gain based on the green channel. The integral control service, also a part of the adjustment service, is used to calculate the integral value of the gain error of the red and blue channels. It is obtained by integrating multiple historical gain errors, the generation times corresponding to the historical gain errors, the current gain error, and the generation time of the current gain error. This value characterizes the accumulation of gain error. The derivative control service, also a part of the adjustment service, is used to calculate the derivative value of the gain error of the red and blue channels. It is obtained by differentiating multiple historical gain errors, the generation times corresponding to the historical gain errors, the current gain error, and the generation time of the current gain error. This value characterizes the change in gain error. The execution control service is part of the adjustment service. It calculates the gain adjustment values for the red and blue channels based on the gain error, integral value of the gain error, and derivative value of the gain error of the red and blue channels, and then adjusts the red and blue channels based on these gain adjustment values.
[0156] Specifically, the gain error of the red channel and the gain error of the blue channel are calculated through proportional control service; the integral value of the gain error of the red channel and the integral value of the gain error of the blue channel are calculated through integral control service; the differential value of the gain error of the red channel and the differential value of the gain error of the blue channel are calculated through differential control service; the gain adjustment value of the red channel is calculated based on the gain error, the integral value of the gain error, and the differential value of the gain error of the red channel through execution control service, and then the red channel is adjusted based on the gain adjustment value of the red channel; and the gain adjustment value of the blue channel is calculated based on the gain error, the integral value of the gain error, and the differential value of the gain error of the blue channel, and then the blue channel is adjusted based on the gain adjustment value of the blue channel.
[0157] Based on the system shown in Figure 3, please refer to Figure 5, which is a flowchart illustrating an image-based data processing method according to an embodiment of this application. As shown in Figure 5, the image-based data processing method includes at least S501 to S506, which are described in detail below:
[0158] S501 extracts the gain of the red channel and the gain of the blue channel from the palm image.
[0159] S502, obtain the calibration gain that matches the red channel gain and the calibration gain that matches the blue channel gain.
[0160] S503 calculates the gain error of the red channel by subtracting the white balance gain and the calibration gain of the red channel, and calculates the gain error of the blue channel by subtracting the white balance gain and the calibration gain of the blue channel.
[0161] S504, based on the historical gain error of the red channel and the generation time of the historical gain error, calculates the integral value and differential value of the gain error of the red channel; and based on the historical gain error of the blue channel and the generation time of the historical gain error, calculates the integral value and differential value of the gain error of the blue channel.
[0162] S505 calculates the gain adjustment value of the red channel based on the gain error, the integral value of the gain error, and the derivative value of the gain error of the red channel, and calculates the gain adjustment value of the blue channel based on the gain error, the integral value of the gain error, and the derivative value of the gain error of the blue channel.
[0163] Optionally, the gain adjustment value for a specified color channel can be expressed as: output = K p ×error+K i ×integral+K d ×derivative
[0164] Wherein, error refers to the difference between the white balance gain and the calibration gain (i.e., gain error), and the white balance gain is usually set to 1; integral refers to the accumulation of error over time (i.e., the integral value of gain error); derivative refers to the rate of change of error (i.e., the derivative value of gain error), K p K i K d These are the gain coefficients for the gain error, the integral value of the gain error, and the derivative value of the gain error, respectively.
[0165] Specifically, regarding the red channel: error r =1 - current_r_gatio output r =K p ×error r +K i ×integral r +K d ×derivative r
[0166] Specifically, regarding the blue channel: error b =1 - current_b_gatio output b =K p ×error b +K i ×integral b +K d ×derivative b
[0167] S506, adjusts the red channel based on the gain adjustment value of the red channel, and adjusts the blue channel based on the gain adjustment value of the blue channel.
[0168] For ease of understanding, please refer to Figure 6. To obtain the input image, the gain adjustment value corresponding to the red channel and the gain adjustment value corresponding to the blue channel are calculated based on the input image. Then, the gain of the red channel is updated according to the gain adjustment value corresponding to the red channel, and the gain of the blue channel is updated according to the gain adjustment value corresponding to the blue channel, thereby realizing the color balance adjustment of the input image, obtaining a color balanced image, and outputting the color balanced image.
[0169] For ease of understanding, the main implementation code is as follows:
[0170] Use design examples:
[0171] import numpy as np
[0172] # Create a sample image (random noise image)
[0173] image=np.random.rand(100,100,3)
[0174] #Initialize the PID controller
[0175] pid_r=PIDController(kp=0.1, ki=0.01, kd=0.05)
[0176] pid_b=PIDController(kp=0.1, ki=0.01, kd=0.05)
[0177] #Adjust the white balance of the image
[0178] dt = 1.0 # Assuming the interval between each call is 1 second
[0179] adjusted_image=adjust_white_balance(image, pid_r, pid_b, dt)
[0180] # View the adjusted image (in practical applications, image display functions should be used, such as matplotlib's imshow) print(adjusted_image)
[0181] White balance adjustment design example:
[0182] def adjust_white_balance(image, pid_r, pid_b, dt):
[0183] #Assume image is a three-dimensional array containing RGB values
[0184] #Calculate the current ratio of red and blue channels to green channel.
[0185] r_g_ratio=np.mean(image[:,:,0]) / np.mean(image[:,:,1])
[0186] b_g_ratio=np.mean(image[:,:,2]) / np.mean(image[:,:,1])
[0187] #Calculation error
[0188] error_r = 1 - r_g_ratio
[0189] error_b = 1 - b_g_ratio
[0190] #Update PID controller
[0191] r_gain=pid_r.update(error_r,dt)
[0192] b_gain=pid_b.update(error_b,dt)
[0193] g_gain = 1 # Normally, the green channel gain is kept at 1.
[0194] #Adjust image channels
[0195] image[:,:,0]*=r_gain
[0196] image[:,:,1]*=g_gain
[0197] image[:,:,2]*=b_gain
[0198] return image
[0199] Example of PID controller design:
[0200] class PIDController:
[0201] def init(self, kp, ki, kd):
[0202] self.kp = kp
[0203] self.ki = ki
[0204] self.kd = kd
[0205] self.integral = 0
[0206] self.previous_error = 0
[0207] def update(self, error, dt):
[0208] "Update the output of the PID controller based on the given error and time interval"
[0209] self.integral += error × dt
[0210] derivative=(error-self.previous_error) / dt
[0211] output=self.kp×error+self.ki×self.integral+self.kd×derivative
[0212] self.previous_error = error
[0213] return output
[0214] It should be noted that in the aforementioned PID controller, P represents proportional, which corresponds to the aforementioned gain error; I represents integral, which corresponds to the aforementioned integral of the gain error; and D represents derivative, which corresponds to the aforementioned derivative of the gain error.
[0215] The embodiment of this application uses the calibration gain obtained under the calibration color temperature environment, as well as the gain error between it and the white balance gain and the historical gain error, to adjust the specified color channel in the input image. This is not affected by the ambient color temperature and is applicable to images acquired in any environment. Specifically, it is not limited to images with small color deviations, and there is no need to select a white point, thereby improving the accuracy, efficiency, and flexibility of image color balance adjustment, and the reliability of image data processing is high.
[0216] Figure 7 is a block diagram illustrating an image-based data processing apparatus according to an embodiment of this application. As shown in Figure 7, the apparatus includes:
[0217] Extraction module 701 is configured to extract the gain of a specified color channel from the input image;
[0218] The acquisition module 702 is configured to acquire a calibration gain that matches the gain, wherein the calibration gain is obtained based on a calibration image acquired under a calibration color temperature environment;
[0219] The calculation module 703 is configured to calculate the gain error based on the calibration gain and the white balance gain based on the green channel, and to calculate the gain adjustment value of the specified color channel based on the gain error and the historical gain error.
[0220] The adjustment module 704 is configured to adjust the specified color channel based on the gain adjustment value to obtain a color balanced image.
[0221] In one embodiment of this application, based on the aforementioned scheme, the acquisition module 702 is specifically configured to: acquire a calibration table, the calibration table including multiple calibration color temperatures and multiple calibration gains corresponding to each calibration color temperature, the multiple calibration gains being calibration gains corresponding to different color channels; select candidate calibration gains for the specified color channel corresponding to each calibration color temperature from the calibration table to obtain multiple candidate calibration gains; select the candidate calibration gain with the smallest difference from the gain from the multiple candidate calibration gains, and use the selected candidate calibration gain as the calibration gain that matches the gain.
[0222] In one embodiment of this application, based on the aforementioned scheme, the acquisition module 702 is further specifically configured to: acquire the color temperature extracted from the input image; generate a color temperature range based on the color temperature, wherein the color temperature is located within the color temperature range; search for multiple candidate calibration color temperatures located within the color temperature range from the calibration table, and select the candidate calibration gain of the specified color channel corresponding to each candidate calibration color temperature to obtain multiple candidate calibration gains.
[0223] In one embodiment of this application, based on the aforementioned scheme, the acquisition module 702 is further configured to: perform subtraction operations between the gain and the plurality of candidate calibration gains respectively to obtain a plurality of gain difference values; and select the candidate calibration gain corresponding to the smallest gain difference value from the plurality of candidate calibration gains.
[0224] In one embodiment of this application, based on the foregoing scheme, the device further includes a generation module configured to: acquire calibration images under different calibration color temperature environments; extract calibration gains corresponding to different color channels from each calibration image to obtain multiple calibration gains for each calibration image, wherein the different color channels include a red channel and a blue channel; and associate the calibration color temperature corresponding to the same calibration image with the multiple calibration gains to generate a calibration table.
[0225] In one embodiment of this application, based on the aforementioned scheme, the calculation module 703 is specifically configured as follows: obtaining the white balance gain based on the green channel, wherein the white balance gain is 1; performing a difference operation on the white balance gain and the calibration gain to obtain the gain error; calculating the gain adjustment auxiliary parameter based on the historical gain error, the generation time of the historical gain error, the gain error, and the generation time of the gain error; and calculating the gain adjustment value based on the gain error and the gain adjustment auxiliary parameter.
[0226] In one embodiment of this application, based on the foregoing scheme, the historical gain error includes multiple errors; the calculation module 703 is further specifically configured to: perform integration operations based on the multiple historical gain errors, the generation times corresponding to the multiple historical gain errors, the gain error, and the generation time of the gain error to obtain a gain error integral value used to characterize the accumulation of gain error, and use the gain error integral value as a gain adjustment auxiliary parameter; and / or, perform differentiation operations based on the multiple historical gain errors, the generation times corresponding to the multiple historical gain errors, the gain error, and the generation time of the gain error to obtain a gain error differential value used to characterize the change of gain error, and use the gain error differential value as a gain adjustment auxiliary parameter.
[0227] In one embodiment of this application, based on the aforementioned scheme, the gain adjustment auxiliary parameter includes the integral value of the gain error and the differential value of the gain error; the calculation module 703 is further specifically configured to: obtain the gain error, the integral value of the gain error, and the gain coefficients corresponding to the differential value of the gain error respectively; and perform a weighted summation operation based on the gain error, the integral value of the gain error, the differential value of the gain error, and the gain coefficients to obtain the gain adjustment value.
[0228] In one embodiment of this application, based on the aforementioned scheme, the adjustment module 704 is specifically configured to: perform a difference operation on the white balance gain and the gain adjustment value to obtain a correction gain; and adjust the specified color channel based on the correction gain to obtain a color balance image.
[0229] In one embodiment of this application, based on the aforementioned scheme, the specified color channel includes a red channel and a blue channel, and the correction gain includes a first correction gain for the red channel and a second correction gain for the blue channel; the adjustment module 704 is further specifically configured to: adjust the channel value corresponding to the red channel of the pixel in the input image based on the first correction gain to obtain the adjusted channel value for the red channel; adjust the channel value corresponding to the blue channel of the pixel in the input image based on the second correction gain to obtain the adjusted channel value for the blue channel; and generate a color balanced image based on the channel value corresponding to the green channel of the pixel in the input image, the adjusted channel value for the red channel, and the adjusted channel value for the blue channel.
[0230] In one embodiment of this application, based on the aforementioned scheme, the extraction module 701 is specifically configured to: perform image segmentation processing on the input image to obtain multiple image blocks, and extract the gain of the specified color channel from each image block; perform an averaging operation on the gains corresponding to the multiple image blocks respectively to obtain an average gain, and use the average gain as the gain of the specified color channel.
[0231] In one embodiment of this application, based on the foregoing scheme, the device further includes a data acquisition module configured to: acquire biometric images, the biometric images including at least one of palm images and face images, and use the biometric images as input images.
[0232] In one embodiment of this application, based on the foregoing scheme, the device further includes an execution module configured to: verify the object corresponding to the input image based on the color balance image, and execute the task to be processed after the verification is passed.
[0233] It should be noted that the apparatus provided in the foregoing embodiments and the method provided in the foregoing embodiments belong to the same concept, and the specific way in which each module and unit performs operations has been described in detail in the method embodiments.
[0234] Embodiments of this application also provide an electronic device, including: one or more processors; and a memory for storing one or more computer programs, which, when executed by one or more processors, cause the electronic device to implement the aforementioned image-based data processing method.
[0235] Figure 8 is a schematic diagram of the structure of a computer system suitable for implementing an electronic device (such as the terminal device or server shown in Figure 1) in the embodiments of this application.
[0236] It should be noted that the computer system 800 of the electronic device shown in Figure 8 is only an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0237] As shown in Figure 8, the computer system 800 includes a Central Processing Unit (CPU) 801, which can perform various appropriate actions and processes, such as executing the methods described in the above embodiments, based on a computer program stored in Read-Only Memory (ROM) 802 or a computer program loaded from storage portion 808 into Random Access Memory (RAM) 803. The RAM 803 also stores various computer programs and data required for system operation. The CPU 801, ROM 802, and RAM 803 are interconnected via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0238] The following components are connected to I / O interface 805: an input section 806 including a keyboard, mouse, etc.; an output section 807 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to I / O interface 805 as needed. A removable medium 811, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 810 as needed so that computer programs read from it can be installed into storage section 808 as needed.
[0239] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing computer instructions for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 809, and / or installed from removable medium 811. When the computer program is executed by central processing unit (CPU) 801, it performs various functions defined in the system of this application.
[0240] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. For example, a computer-readable medium can be an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable medium can be any tangible medium containing or storing a computer program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying a computer-readable computer program. Such transmitted data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.
[0241] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. Each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0242] The units described in the embodiments of this application can be implemented in software or hardware, and the described units can also be located in a processor. The names of these units do not necessarily limit the specific unit itself.
[0243] Another aspect of this application provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the aforementioned image-based data processing method. This computer-readable medium may be included in the electronic device described in the above embodiments, or it may exist independently and not assembled into the electronic device.
[0244] Another aspect of this application provides a computer program product or computer program including computer instructions stored in a computer-readable medium. A processor of an electronic device reads the computer instructions from the computer-readable medium and executes the computer instructions, causing the electronic device to perform the image-based data processing methods provided in the various embodiments described above.
[0245] In summary, this application provides an image-based data processing method, apparatus, device, computer-readable medium, and computer program product. The electronic device extracts the gain of a specified color channel from an input image. This process involves the quantification and extraction of image color features, providing fundamental data for subsequent adjustments. A calibration gain matching this gain is obtained from a calibration image acquired under a calibrated color temperature environment. The calibration image is acquired under a standard calibrated color temperature environment, ensuring high accuracy and representativeness of its calibration gain, providing a reliable reference for adjusting the input image. Gain error is calculated based on the calibration gain and a white balance gain based on the green channel. The white balance gain based on the green channel is an ideal reference value for image color balance. By comparing the error with the calibration gain, the degree of deviation in the color channel can be clearly identified. A gain adjustment value is calculated by combining historical gain errors. Historical gain errors reflect the error situation in previous adjustment processes, allowing for a more comprehensive consideration of error trends and making the gain adjustment value more accurate. The color balance image is obtained by adjusting the specified color channel based on the gain adjustment value. The whole process forms a closed-loop adjustment mechanism that is not affected by the ambient color temperature. It avoids the limitations of traditional methods such as the gray world scheme and white point statistical scheme, improves the accuracy, efficiency and flexibility of image color balance adjustment, enhances the reliability of image-based data processing, and reduces data processing errors caused by environmental factors and method limitations.
[0246] Furthermore, the electronic device acquires a calibration table containing multiple calibrated color temperatures and corresponding calibrated gains for different color channels. This calibration table is a systematic record of color channel gains at different calibrated color temperatures, providing rich data resources for subsequent selection of appropriate calibrated gains. Candidate calibrated gains for a specified color channel are selected from the calibration table, and then the gain with the smallest difference from the extracted gain is chosen as the matching calibrated gain. Through precise difference comparison, the calibrated gain that best matches the actual color channels of the input image can be selected from numerous candidate gains. This makes subsequent adjustments more closely resemble the true colors of the image, reduces color deviation caused by improper selection of calibrated gains, and improves the accuracy of image color balance adjustment.
[0247] Furthermore, the electronic device acquires the color temperature of the input image, generates a color temperature range based on this, searches for candidate calibrated color temperatures within this range in the calibration table, and selects the corresponding candidate calibrated gain. The color temperature of the input image reflects the overall color temperature characteristics of the image. The generated color temperature range narrows the search range, avoids comparing the gains corresponding to all calibrated color temperatures one by one, reduces unnecessary computation, improves the efficiency of acquiring matching calibrated gains, and thus accelerates the speed of image color balance adjustment.
[0248] Furthermore, the electronic device performs a difference operation between the extracted gain and multiple candidate calibration gains, selecting the candidate calibration gain corresponding to the smallest gain difference. The difference operation provides a quantitative basis for selection. Using the smallest difference as the standard, the calibration gain that best matches the extracted gain can be objectively and accurately determined, avoiding the uncertainty caused by subjective judgment and improving the accuracy and reliability of the matching process.
[0249] Furthermore, the electronic device pre-captures calibration images under different calibration color temperature environments, extracts the calibration gains of the red and blue channels, and correlates them with the calibration color temperatures to generate a calibration table. The calibration images under different calibration color temperature environments cover a wider range of color features. The extraction and correlation of the calibration gains of the red and blue channels constructs a comprehensive and accurate calibration data system, providing a solid data foundation for subsequently obtaining calibration gains that match the input images, and ensuring the accuracy and stability of the entire color balance adjustment process.
[0250] Furthermore, the electronic device acquires a white balance gain set to 1, calculates the difference between this and the calibrated gain to obtain the gain error, and combines this with historical gain errors and their generation times to calculate auxiliary parameters for gain adjustment, thereby obtaining the adjusted gain value. Setting the white balance gain to 1 simplifies the calculation process and improves computational efficiency. Combining historical gain errors and their generation times takes into account the changes in error over time. By calculating auxiliary parameters for gain adjustment, the adjusted gain value better reflects the actual errors and trends in the image's color channels, improving the accuracy and adaptability of the adjustment.
[0251] Furthermore, when there are multiple historical gain errors, the electronic device performs an integral operation on the gain error at a relevant time and the current gain error to obtain the integral value of the gain error, which serves as an auxiliary parameter for gain adjustment. The integral operation can accumulate and sum the gain errors over a period of time, reflecting the cumulative effect of the errors. Using the integral value of the gain error as an auxiliary parameter comprehensively considers the cumulative impact of historical errors, avoiding over- or under-adjustment due to the limitations of single-error calculations, thus improving the stability and accuracy of the gain adjustment value and making image color balance adjustment more precise.
[0252] Furthermore, when there are multiple historical gain errors, the electronic device performs differential operations on these errors, along with the gain errors at relevant times and the current gain error, to obtain a differential value of the gain error, which serves as an auxiliary parameter for gain adjustment. The differential operation can calculate the rate of change of the gain error, reflecting the dynamic changes in the error. Using the differential value of the gain error as an auxiliary parameter allows for timely capture of the error's changing trend, enabling the adjustment process to dynamically adjust according to real-time changes in the error. This improves the timeliness and adaptability of the adjustment, and optimizes the effect of image color balance adjustment.
[0253] Furthermore, when the gain adjustment auxiliary parameters include the integral value and the derivative value of the gain error, the electronic device obtains the corresponding gain coefficients and performs a weighted summation to obtain the gain adjustment value. By comprehensively considering the accumulation and changes in the gain error, and quantifying the integral and derivative values of the gain error through weighted summation, the characteristics of the gain error can be reflected more comprehensively and accurately. This makes the gain adjustment value more consistent with the actual error situation of the image color channel, improving the accuracy and reliability of image color balance adjustment.
[0254] Furthermore, the electronic device calculates the correction gain by subtracting the white balance gain from the gain adjustment value, and then adjusts the specified color channel based on the correction gain to obtain a color-balanced image. Converting the gain adjustment value into a correction gain clarifies the specific parameters for color channel adjustment, making the adjustment process more intuitive and operable. Adjusting based on the correction gain allows for more accurate adjustment of the specified color channel, reducing uncertainties in the adjustment process and improving the accuracy of image color balance adjustment.
[0255] Furthermore, when the specified color channels include red and blue channels, and the correction gains include corresponding first and second correction gains, the electronic device adjusts the channel values of the red and blue channels using the correction gains respectively, and combines them with the green channel values to generate a color-balanced image. Simultaneous adjustment of the red and blue channels fully utilizes the parallelism of data processing, reduces the number of steps in the adjustment process, improves data processing efficiency, shortens the image color balance adjustment time, and makes the entire adjustment process more efficient.
[0256] Furthermore, the electronic device segments the input image into multiple image patches, extracts the gain of a specified color channel from each patch, and calculates the average as the final gain. Segmenting the input image divides it into multiple local regions, and extracting the gain of each patch allows for a more detailed analysis of the color characteristics of different regions. The averaging method integrates the gain information from each region, reducing the impact of local color deviations on the overall gain calculation. This makes the obtained gain more representative of the overall color characteristics of the image, improves the accuracy of gain calculation, and provides a more reliable basis for subsequent color balance adjustments.
[0257] Furthermore, before extracting the gain of the specified color channels, the electronic device acquires biometric images such as palm and face images as input images. Biometric images have rich details and unique color features, requiring a high degree of color balance. Selecting biometric images as input allows for specialized color balance adjustments for these special images, better preserving image details and true colors during data processing, and improving the targeting and applicability of image color balance adjustments.
[0258] Furthermore, the specification mentions that when extracting the gain of a specified color channel from each image patch, an extraction task can be generated for each image patch, and multiple extraction tasks can be executed in parallel. Parallel execution of extraction tasks fully utilizes the parallel processing capabilities of computing resources; the gain extraction process for multiple image patches can be performed simultaneously, reducing the overall extraction time and improving the efficiency of extracting the gain of a specified color channel from the input image, thereby enhancing the efficiency of image color balance adjustment.
[0259] Furthermore, after obtaining the color-balanced image, the electronic device verifies the object corresponding to the input image based on this image. The color-balanced image has a better color balance effect and can more accurately reflect the true characteristics of the object. During the verification process, it reduces feature misjudgment caused by color deviation, improves the accuracy and reliability of verification, and enhances the effectiveness of the entire image-based data processing workflow.
[0260] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0261] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. An image-based data processing method, executed by an electronic device, comprising: Extract the gain of a specified color channel from the input image; Obtain a calibration gain that matches the stated gain, the calibration gain being based on a calibration image acquired under a calibration color temperature environment; Based on the calibrated gain and the white balance gain with the green channel as a reference, the gain error is calculated, and based on the gain error and the historical gain error, the gain adjustment value is calculated. and The specified color channel is adjusted based on the gain adjustment value to obtain a color balanced image.
2. The method according to claim 1, wherein obtaining the calibration gain matching the gain comprises: Obtain a calibration table, which includes multiple calibration color temperatures and multiple calibration gains corresponding to each calibration color temperature. The multiple calibration gains are calibration gains corresponding to different color channels. From the calibration table, select the candidate calibration gain for the specified color channel corresponding to each calibration color temperature to obtain multiple candidate calibration gains; Select the candidate calibration gain that differs the least from the given gain from the plurality of candidate calibration gains, and use the selected candidate calibration gain as the calibration gain that matches the given gain.
3. The method according to claim 2, wherein selecting candidate calibration gains for the specified color channel corresponding to each calibration color temperature from the calibration table to obtain multiple candidate calibration gains includes: Obtain the color temperature extracted from the input image; A color temperature range is generated based on the color temperature, and the color temperature is located within the color temperature range; Find multiple candidate calibration color temperatures located in the color temperature range from the calibration table, and select the candidate calibration gain of the specified color channel corresponding to each candidate calibration color temperature to obtain multiple candidate calibration gains.
4. The method according to claim 2 or 3, wherein selecting the candidate calibration gain that differs smallest from the plurality of candidate calibration gains includes: The difference between the gain and the plurality of candidate calibration gains is calculated to obtain a plurality of gain difference values; Select the candidate calibration gain corresponding to the smallest gain difference from the plurality of candidate calibration gains.
5. The method according to any one of claims 2 to 4, wherein before obtaining the calibration table, the method further comprises: Acquire calibration images under different calibration color temperature environments; The calibration gain corresponding to different color channels is extracted from each calibration image to obtain multiple calibration gains for each calibration image, wherein the different color channels include the red channel and the blue channel; The calibration color temperature and multiple calibration gains corresponding to the same calibration image are correlated to generate a calibration table.
6. The method according to any one of claims 1 to 5, wherein calculating the gain error based on the calibration gain and the white balance gain relative to the green channel includes: Obtain the white balance gain based on the green channel, where the white balance gain is 1; The gain error is obtained by subtracting the white balance gain from the calibration gain. The calculation of the gain adjustment value based on the gain error and the historical gain error includes: Based on the historical gain error, the generation time of the historical gain error, the gain error, and the generation time of the gain error, the gain adjustment auxiliary parameters are calculated. The gain adjustment value is calculated based on the gain error and the gain adjustment auxiliary parameter.
7. The method according to claim 6, wherein the historical gain error includes multiple parameters; the step of calculating the gain adjustment auxiliary parameter based on the historical gain error, the generation time of the historical gain error, the gain error, and the generation time of the gain error includes: Based on multiple historical gain errors, the generation time corresponding to each of the multiple historical gain errors, the gain error itself, and the generation time of the gain error, an integral operation is performed to obtain a gain error integral value that characterizes the accumulation of gain error, and the gain error integral value is used as an auxiliary parameter for gain adjustment.
8. The method according to claim 6 or 7, wherein the historical gain error includes multiple parameters; the step of calculating the gain adjustment auxiliary parameter based on the historical gain error, the generation time of the historical gain error, the gain error, and the generation time of the gain error includes: Differential operations are performed based on the multiple historical gain errors, the generation times corresponding to the multiple historical gain errors, the gain error itself, and the generation time of the gain error to obtain a differential value of the gain error that characterizes the change of the gain error. This differential value of the gain error is then used as an auxiliary parameter for gain adjustment.
9. The method of claim 7 or 8, the gain adjustment auxiliary parameter comprising the gain error integral value and the gain error derivative value; The calculation of the gain adjustment value based on the gain error and the gain adjustment auxiliary parameter includes: Obtain the gain error, the integral value of the gain error, and the gain coefficients corresponding to the differential value of the gain error, respectively; The gain adjustment value is obtained by performing a weighted summation operation based on the gain error, the integral value of the gain error, the derivative value of the gain error, and the gain coefficient.
10. The method according to any one of claims 1 to 9, wherein adjusting the specified color channel based on the gain adjustment value to obtain a color balanced image comprises: The correction gain is obtained by subtracting the white balance gain from the gain adjustment value. The specified color channel is adjusted based on the correction gain to obtain a color balanced image.
11. The method according to claim 10, wherein the specified color channel includes a red channel and a blue channel, the correction gain includes a first correction gain for the red channel and a second correction gain for the blue channel; and the step of adjusting the specified color channel based on the correction gain to obtain a color balanced image includes: Based on the first correction gain, the channel value corresponding to the red channel of the pixel in the input image is adjusted to obtain the adjusted channel value for the red channel; Based on the second correction gain, the channel value corresponding to the blue channel of the pixel in the input image is adjusted to obtain the adjusted channel value for the blue channel; A color-balanced image is generated based on the channel values corresponding to the green channel of the pixels in the input image, the channel values adjusted for the red channel, and the channel values adjusted for the blue channel.
12. The method according to any one of claims 1 to 11, wherein extracting the gain of a specified color channel from the input image comprises: The input image is segmented to obtain multiple image blocks, and the gain of the specified color channel is extracted from each image block; The average gain of each of the multiple image blocks is calculated to obtain the average gain, and the average gain is used as the gain of the specified color channel.
13. The method according to any one of claims 1 to 12, wherein before extracting the gain of a specified color channel from the input image, the method further comprises: Acquire biometric images, including at least one of palm images and face images, and use the biometric images as input images.
14. The method according to any one of claims 1 to 13, wherein after adjusting the specified color channel based on the gain adjustment value to obtain a color balanced image, the method further comprises: The object corresponding to the input image is verified based on the color balance image, and the pending task is executed after the verification is successful.
15. An image-based data processing apparatus, comprising: The extraction module is configured to extract the gain of a specified color channel from the input image; The acquisition module is configured to acquire a calibration gain that matches the gain, wherein the calibration gain is obtained based on a calibration image acquired under a calibration color temperature environment; The calculation module is configured to calculate the gain error based on the calibrated gain and the white balance gain based on the green channel, and to calculate the gain adjustment value of the specified color channel based on the gain error and the historical gain error. The adjustment module is configured to adjust the specified color channel based on the gain adjustment value to obtain a color balanced image.
16. An electronic device comprising: One or more processors; A memory for storing one or more computer programs that, when executed by one or more processors, cause the electronic device to implement the image-based data processing method according to any one of claims 1 to 14.
17. A computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the image-based data processing method according to any one of claims 1 to 14.
18. A computer program product comprising computer instructions that, when executed by a processor, implement the image-based data processing method according to any one of claims 1 to 14.