Ambient light compensation method and apparatus, electronic device, storage medium, and program product
By shooting an ambient image, the original light color and color offset values are determined, the compensation light color and brightness parameters are calculated, and the light compensation is used to perform light compensation, which solves the problem of poor color adjustment effect of the image color adjustment model when the ambient light changes, and achieves accurate compensation under different ambient lights.
Patent Information
- Application Number
- PCT/CN2024/123621
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-01-03
- Filing Date
- 2024-10-09
- Publication Date
- 2025-07-10
AI Technical Summary
In the prior art, the image color adjustment model only has good effect under fixed ambient light, and the color adjustment effect becomes worse when the ambient light changes, resulting in a deviation from the target color.
By taking an ambient image, the original light color and color offset of the current ambient light are determined, the compensation light color and brightness adjustment parameters are calculated based on the target light color, and the compensation light is emitted by the light compensation module for light compensation.
Accurately determine the compensation light color and brightness under different ambient lights, improve the harmony effect of the image background color, reduce processing overhead, and adapt to various ambient light changes.
Smart Images

Figure CN2024123621_10072025_PF_FP_ABST
Abstract
Description
Ambient light compensation method, device, electronic device, storage medium and program product
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on January 3, 2024, with application number 2024100260337 and application name “Method, device, electronic device and storage medium for compensation of ambient light”. Technical Field
[0002] The present application relates to the field of optoelectronic technology, and in particular to a method, device, electronic device, storage medium, and program product for compensating ambient light.
[0003] Background of the Invention
[0004] With the continuous development of technology, payment methods are also constantly changing. Today, electronic payment is gradually entering the public eye. People can complete transactions safely and quickly through mobile phone code scanning, near-field communication (NFC), facial recognition, fingerprint recognition, palm print recognition, etc. Among them, facial recognition, fingerprint recognition, and palm print recognition payment methods do not require remembering passwords, and the payer does not need to use a card or mobile phone or other devices. The transaction is completed by simply providing facial, fingerprint, or palm print information in front of the corresponding electronic device.
[0005] In related technologies, electronic devices can usually use image sensors to capture images of faces, fingerprints, or palm lines, and then use a pre-trained image color adjustment model to blend the captured images to adjust the background color of the captured images to the target color.
[0006] However, image color adjustment models are typically trained based on a fixed ambient light color, and their color-harmonizing capabilities are only effective for images captured under this fixed ambient light. If the ambient light changes, the color-harmonizing effect deteriorates, and the model's output, based on the original image background color, deviates from the target color.
[0007] In summary, how to improve the adjustment effect for ambient light is an urgent problem to be solved.
[0008] Summary of the Invention
[0009] Embodiments of the present application provide an ambient light compensation method, device, electronic device, storage medium, and program product to improve the accuracy of ambient light compensation.
[0010] An embodiment of the present application provides an ambient light compensation method, which is performed by an electronic device and includes:
[0011] In response to the distance between the object and the distance sensor being less than a preset threshold, capturing an image of the environment;
[0012] Determining, based on the color information in the ambient image, an original light color and a color deviation value of the current ambient light, wherein the color deviation value represents a color distribution state of the original light color in a color gamut;
[0013] Determining a compensation light color corresponding to the current ambient light based on the original light color and a preset target light color of the target ambient light;
[0014] determining a light brightness adjustment parameter based on the compensated light color and the color deviation value; and
[0015] Based on the light brightness adjustment parameter, the compensation light color is used to perform light compensation on the current ambient light.
[0016] An embodiment of the present application provides an ambient light compensation device, comprising:
[0017] a photographing unit, configured to photograph an environment image in response to a distance between the object and the distance sensor being less than a preset threshold;
[0018] a first determining unit, configured to determine an original light color and a color deviation value of the current ambient light based on color information in the ambient image, wherein the color deviation value represents a color distribution state of the original light color in a color gamut;
[0019] a second determining unit, configured to determine a compensation light color corresponding to the current ambient light based on the original light color and a preset target light color of the target ambient light;
[0020] a third determining unit, configured to determine a light brightness adjustment parameter based on the compensated light color and the color deviation value; and
[0021] A compensation unit is configured to perform light compensation on the current ambient light using the compensation light color based on the light brightness adjustment parameter.
[0022] An embodiment of the present application provides an electronic device, including a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of any one of the above-mentioned ambient light compensation methods.
[0023] An embodiment of the present application provides a computer-readable storage medium, which includes a computer program. When the computer program is run on an electronic device, the computer program is used to enable the electronic device to perform the steps of any one of the above-mentioned ambient light compensation methods.
[0024] An embodiment of the present application provides a computer program product, which includes a computer program stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, causing the electronic device to perform the steps of any one of the above-mentioned ambient light compensation methods.
[0025] BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0027] FIG1 is a logical diagram of the training and application process of an image color adjustment model in a related art provided by an embodiment of the present application;
[0028] FIG2 is a schematic diagram of an application scenario of an ambient light compensation method provided in an embodiment of the present application;
[0029] FIG3 is an overall flow chart of an ambient light compensation method provided in an embodiment of the present application;
[0030] FIG4 is a schematic diagram of a shooting environment image provided by an embodiment of the present application;
[0031] FIG5 is a top view of a lighting compensation module provided in an embodiment of the present application;
[0032] FIG6 is a schematic structural diagram of a semiconductor light emitting diode provided in an embodiment of the present application;
[0033] FIG7 is a schematic diagram of three primary colors provided in an embodiment of the present application;
[0034] FIG8 is a schematic diagram of ambient light compensation provided by an embodiment of the present application;
[0035] FIG9 is an overall flow chart of another ambient light compensation method provided in an embodiment of the present application;
[0036] FIG10 is a schematic diagram of the structure of an ambient light compensation device provided in an embodiment of the present application;
[0037] FIG11 is a schematic diagram of a hardware structure of an electronic device provided in an embodiment of the present application.
[0038] Implementation Method
[0039] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of the technical solutions of this application, but not all of them. Based on the embodiments described in this application document, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the technical solutions of this application.
[0040] The following is an introduction to some concepts involved in the embodiments of this application.
[0041] Light color: The color of light, which is mainly divided into original light color, target light color, and compensation light color in this application. The original light color is the original color of the current ambient light, the target light color is the ideal light color that is set in advance based on the requirements, and the compensation light color is the color of the compensation light used to compensate (or adjust) the current ambient light.
[0042] Color information refers to the color information possessed by a color image. The specific values depend on the color space used. When the color space is represented by channels, color information specifically refers to the color information of the environment image across multiple channels, referred to as color channel information. For example, the values based on the red, green, and blue (RGB) color channels, or the values based on the hue, saturation, and brightness / lightness (HSV) channels, etc.
[0043] The following is a brief introduction to the design concept of the embodiment of this application:
[0044] With the continuous development of technology, electronic devices are gradually becoming more and more popular due to their convenience. Electronic devices can use image sensors to collect faces, fingerprints, or palm lines and extract features from them to achieve identity recognition. Because ambient lighting is often not ideal (the ideal state depends on the actual situation, for example, it can be white), in order to accurately extract the features of faces, fingerprints, or palm lines, it is often necessary to process the image to make the background color of the image close to the target background color.
[0045] In related art, a trained image color adjustment model is often used to perform color blending on captured images, adjusting the background color of the captured image from the ambient color to the target color. Figure 1 shows a logical diagram of the training and application process of an image color adjustment model in related art provided by an embodiment of the present application, including a model training phase 110 and a model application phase 120.
[0046] In the early model training stage 110, it includes:
[0047] Step 111, collecting ambient light samples of a single fixed color;
[0048] Step 112 : Use the collected ambient light samples to train and test the image color adjustment model, adjust the model parameters, and obtain a trained image color adjustment model.
[0049] Afterwards, the trained image color adjustment model is put into use. In the model application stage 120, the following steps are performed:
[0050] Step 121: capturing an image containing biometric information, such as a palm print image, a face image, etc.;
[0051] Step 122: Using the trained image color adjustment model, adjust the background color of the image to the target color.
[0052] Step 123: Output the image after background color adjustment as a target image.
[0053] However, because the sample is a single, fixed-color ambient light sample, the trained image color adjustment model only has good color harmony capabilities for images captured under this fixed ambient light. If the ambient light changes, the color harmony effect will deteriorate, and the adjustment results output by the image color adjustment model for the original image background color will deviate from the target color.
[0054] Based on this, embodiments of the present application provide a method, apparatus, electronic device, storage medium, and program product for compensating for ambient light. The electronic device includes at least one built-in light assembly that can emit light of different colors. Therefore, ambient light compensation can be performed directly rather than adjusting the color of the captured image.
[0055] Specifically, in an embodiment of the present application, when an object is detected approaching, an image of the surrounding environment is obtained, and the color information in the image is analyzed to determine the original light color of the current ambient light; further, based on the original light color and the target light color, the compensation light color that the lamp group needs to emit is determined, thereby achieving adjustment of the ambient light.
[0056] Compared with the method of directly adjusting the color of the captured image through the image color adjustment model, the method proposed in the embodiment of the present application does not require model training or adjustment of model parameters, reduces processing overhead, and saves the cost of compensating for ambient light.
[0057] Furthermore, the method proposed in the embodiments of this application is not limited to the training samples used in the model training process, that is, it will not only have a good adjustment effect on the ambient light of the training sample. When the ambient light changes and the adjustment deviation occurs, it can accurately determine the corresponding compensation light for all colors of ambient light, thereby improving the color harmony effect.
[0058] Furthermore, in this embodiment, not only is the color of the compensation light determined, but also its brightness. Compensating for the current ambient light from both hue and brightness perspectives can result in more accurate compensation results. Assuming the target light color is white, after using the compensation light to adjust the current ambient light, the background color of the captured image will be closer to white.
[0059] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application and are not used to limit the present application. In addition, the embodiments and features in the embodiments of the present application can be combined with each other if there is no conflict.
[0060] As shown in FIG2 , which is a schematic diagram of an application scenario of an embodiment of the present application, the application scenario diagram includes two biological collection devices 211 and 212 and a collection object 220 .
[0061] In the embodiments of the present application, biometric collection devices include, but are not limited to, facial recognition devices, palm scanning devices, and fingerprint recognition devices. For example, 211 is a facial recognition device, and 222 is a palm scanning device or a fingerprint recognition device. These biometric collection devices include processors for collecting biometric information and performing ambient light compensation. For example, biometric information can be collected from subject 220 while also performing ambient light compensation.
[0062] It should be noted that the ambient light compensation method in each embodiment of the present application can be executed by an electronic device, that is, the method can be executed independently by the biological collection device 211 or 212. When the biological collection device 211 or 212 is the executing entity, upon detecting that the distance between the object and the distance sensor is less than a preset threshold, the biological collection device 211 or 212 captures an image of the environment and determines the original light color and color deviation value of the current ambient light based on the color information in the environmental image. The biological collection device 211 or 212 then determines the compensation color of the compensation light corresponding to the current ambient light based on the original light color and a preset target ambient light color. Furthermore, the biological collection device 211 or 212 determines the brightness of the compensation light based on the compensation light color and color deviation value, and finally uses the compensation light to compensate for the current ambient light.
[0063] It should be noted that what is shown in FIG. 2 is only an example. In fact, the number of biological collection devices 211 or 212 and the number of collection objects are not limited and are not specifically limited in the embodiments of the present application.
[0064] In addition, the embodiments of the present application can be applied to various scenarios, including not only biometric information collection scenarios, but also including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving and other scenarios.
[0065] The following describes the ambient light compensation method provided by the exemplary embodiment of the present application in combination with the application scenarios described above and with reference to the accompanying drawings. It should be noted that the above application scenarios are only shown to facilitate understanding of the spirit and principles of the present application, and the implementation of the present application is not limited in this respect.
[0066] FIG3 is a flowchart illustrating an implementation of an ambient light compensation method according to an embodiment of the present application. The method is executed by an electronic device, for example, the biological collection device 211 or 212 shown in FIG2 . The specific implementation process of the method is as follows:
[0067] S301: In response to the distance between the object and the distance sensor being smaller than a preset threshold, capturing an environment image.
[0068] Among them, different electronic devices can collect different information such as fingerprints, palm prints, faces, etc. The collected information can be used for identity authentication, payment, clocking in at work, etc.
[0069] In the embodiments of the present application, the description will be mainly based on a palm-scanning device for collecting palm prints. However, the method proposed in the embodiments of the present application is not only applicable to palm-scanning devices, but also to other electronic devices that meet the requirements.
[0070] In the embodiment of the present application, the object can be a user's palm, the user's face, a card, or other objects. The electronic device includes a distance sensor. When the distance sensor senses that the distance between it and an object reaches a predetermined range, for example, when the distance is less than a preset threshold, it can trigger a signal to trigger a camera module in the electronic device to capture an image of the environment.
[0071] The distance sensor may be an infrared distance sensor that detects distance via infrared light and collects data about the distance to an object, or an ultrasonic distance sensor. For example, the infrared distance sensor model is GP2Y0A21YK0F. The camera module may be a camera, etc., and this application does not impose any specific limitations on this.
[0072] In one example, the preset threshold can be set as a distance range, including [minimum distance, maximum distance], where the minimum distance limits the palm from being too close to the electronic device (such as a palm-swiping device), and at the same time, the maximum distance limits the palm from being too far away from the palm-swiping device, so as to ensure that the environmental information within the range near the palm is captured.
[0073] In another example, the preset threshold can be set to a distance threshold, which is usually relatively large, such as greater than 10 cm or 15 cm. The purpose is to trigger shooting when the palm is far away from the palm-swiping device to capture as much environmental information as possible, thereby preventing the palm from being too close to the camera module and blocking most of the environmental information. It should be noted that the setting of the above preset threshold is only an example, and the actual setting can be adjusted according to specific circumstances, and this application does not impose specific limitations.
[0074] In the embodiment of the present application, in order to ensure that the fill light strategy is the most timely and effective, the logical timing for triggering the fill light is when an object approaches, and then performing the capture analysis and fill light.
[0075] For example, consider a mall with a palm-scanning device that uses palm print recognition to identify the user and facilitate payment. When the proximity sensor detects an approaching object and the distance gradually decreases until a preset threshold is met, the camera module captures the surrounding environment and generates an image.
[0076] Taking a real-world scenario as an example, as shown in Figure 4, is a schematic diagram of capturing an environmental image provided by an embodiment of the present application. Assume that there is a palm-swipe device A in a shopping mall, and a subject B uses the palm-swipe device A to pay. The distance sensor built into the palm-swipe device A is responsible for measuring the distance. When it detects an object (the palm of subject B) approaching and the distance gradually decreases to less than or equal to a preset threshold, the distance sensor sends a trigger signal to the camera module, triggering the camera module to capture an environmental image.
[0077] In the embodiment of the present application, the captured environment image may include or exclude the object. However, when the environment image includes the object, the environment image may only include a portion of the object or a blurred object due to the object being far away.
[0078] S302: Determine the original light color and color deviation value of the current ambient light based on the color information in the ambient image.
[0079] The color information includes multiple color channel information, such as the value of each pixel in the environment image on the RGB color channel, the value on the HSV channel, etc.
[0080] To better adapt to local color variations in the ambient image, the processor in the electronic device can divide the ambient image into multiple image regions and perform original light color calculations on a region-by-region basis. For example, the ambient image can be divided into 8×8 regions or 16×16 regions, depending on the specific situation.
[0081] Afterwards, the electronic device determines, for each image area, a local color temperature value corresponding to the image area based on multiple color channel information of each pixel in the image area; and determines an overall color temperature value corresponding to the ambient image based on the local color temperature values corresponding to each image area, wherein the overall color temperature value is used to represent the original light color.
[0082] Specifically, taking the color information as RGB color channel values as an example, for a certain area in the environment image, the RGB color channel values corresponding to each pixel can be obtained by methods such as getPixel() of the Bitmap class. Then, the average value R of the red color channel of all pixels in the area is calculated. - , the average value of the green color channel G - and the average value B of the blue color channel - .
[0083] Furthermore, the calculation formula for the local color temperature value of this area is as follows:
[0084] Local color temperature value = (R - +G - +B - ) / 3
[0085] Afterwards, the local color temperature values of all areas can be averaged to obtain the overall color temperature value corresponding to the ambient image, which is used to represent the original light color of the current ambient light.
[0086] In addition, color channel information can be converted between different channels and used to calculate color temperature values. For example, RGB can be converted to three channels: brightness, red, green, and yellow, or three channels of HSV. Then, the local color temperature value corresponding to each image region is calculated based on the brightness value, thereby obtaining the overall color temperature value of the ambient image.
[0087] In the above process, after the environment image is divided into multiple image regions, the local color temperature values are calculated for each region, and then the average value is taken to obtain the overall color temperature value, which can make the determined original light color more accurate.
[0088] Similar to calculating color temperature, obtaining color deviation requires dividing the area to make the obtained color deviation more accurate. The color deviation represents the color distribution of the original light color in the color gamut, and can also be called color deviation.
[0089] Specifically, the processor of the electronic device divides the environmental image into multiple image areas; for each image area, based on the difference between the multiple color channel information of each pixel in the image area among the multiple color channels, determines the local color deviation value corresponding to the image area; based on the local color deviation value corresponding to each image area, determines the color deviation value.
[0090] Specifically, still taking the RGB color channel value as an example, for a certain area in the environment image, calculate the average value R of the red color channel of all pixels in the area - , the average value of the green color channel G - and the average value B of the blue color channel - , and then calculate the difference between the average values of the two color channels, and then calculate the local color deviation value of the area as follows:
[0091] Afterwards, the local color deviation values of all regions can be averaged to obtain the overall color deviation value corresponding to the ambient image, that is, the color deviation value of the current ambient light.
[0092] In addition, in addition to determining the original light color of the current ambient light through the color temperature value, the reference light color can also be determined based on the method of statistical pixel color. The reference light color can also reflect the color of the current ambient light to a certain extent.
[0093] An optional implementation is that the electronic device determines, for each pixel in the ambient image, a pixel color temperature value and / or a pixel color deviation value corresponding to the pixel based on the color information of the pixel; aggregates pixels belonging to the same interval into a pixel group based on the pixel color temperature value and pre-divided color temperature value intervals, and / or the pixel color deviation value and pre-divided color deviation value intervals; and determines the reference light color of the current ambient light based on the number of pixels in each pixel group and the color classification corresponding to each pixel group.
[0094] Among them, each color temperature value interval corresponds to a color category, and each color deviation value interval corresponds to a color category.
[0095] Taking color temperature as an example, the electronic device obtains the pixel color temperature value corresponding to each pixel in the ambient image. Based on the pixel color temperature value and pre-defined color temperature ranges, pixels belonging to the same range are aggregated into a pixel group. For example, they can be divided into three groups: red, green, and blue, each corresponding to a color temperature range. In this way, each color temperature range corresponds to a color. The number of pixels in each pixel group is then calculated, and the color corresponding to the group with the largest number of pixels is used as the reference light color corresponding to the current ambient light. For example, if the number of pixels in the red group accounts for 50% or more of the total number of pixels, red can be determined as the reference light color, and the reference light color can also reflect the color of the current ambient light.
[0096] The reference light color is primarily determined by statistical proportions and can be used as a reference for comparison with the original light color determined by the color temperature value to ensure that the difference between the original light color determined by the color temperature value and the reference light color is within a certain range. In this way, the original light color obtained by the color temperature value can be adjusted to a certain extent based on the reference light color to achieve higher compensation accuracy.
[0097] It should be noted that the above color grouping is only an example in this application. The specific grouping can be adjusted according to actual needs and this application does not make any specific limitations.
[0098] Following the assumption in S301, after capturing the environmental image, the palm-wiring device A divides the environmental image into regions based on its dimensions, such as length and width. Assume that the regions are divided into 8×8 regions, totaling 64 regions. For each region, the average value R of the red color channel of each pixel in the region is used. - , the average value of the green color channel G - and the average value of the blue color channel B - , get the local color temperature value and local color deviation value of the corresponding area, take the average of 64 local color temperature values to get the overall color temperature value, and take the average of 64 local color deviation values to get the overall color deviation value.
[0099] S303: Determine a compensation light color corresponding to the current ambient light based on the original light color and a preset target light color of the target ambient light.
[0100] The target light color is an ideal light color preset based on specific needs. Generally speaking, images captured under the target light color of the set target ambient light can more accurately extract biological information. However, due to the influence of the external environment, such as the presence of warm lights around, or insufficient or dim light in the room, there is a difference between the original light color of the current ambient light and the ideal light color. Therefore, it is necessary to adjust or compensate the current ambient light through compensation light so that the original light color of the current ambient light plus the compensation light color of the compensation light can reach the target light color of the target ambient light.
[0101] An optional implementation is that the processor of the electronic device determines a compensated color temperature value based on the difference between the overall color temperature value corresponding to the original light color and the target color temperature value corresponding to the target light color, wherein the compensated color temperature value is used to characterize the compensated light color.
[0102] Specifically, the compensation color temperature value is calculated as follows: Compensation color temperature = Overall color temperature - Target color temperature. The target color temperature represents the desired white balance color temperature. The compensation color of the compensation light is then determined based on the compensation color temperature.
[0103] The electronic device proposed in this application includes a light compensation module. Figure 5 shows a top view of a light compensation module provided by an embodiment of this application. The light compensation module includes at least one light group, eight of which are shown in the figure. Each light group includes multiple semiconductor light-emitting diodes (LEDs), including at least one red LED, at least one green LED, and at least one blue LED. Different colors of compensation light can be generated by adjusting the number or ratio of light emitted by different colored LEDs.
[0104] After obtaining the compensation color temperature value of the compensation light, the electronic device triggers the light compensation module and controls the light emission quantity of LEDs of different colors according to the compensation color temperature value, so that the light compensation module emits corresponding compensation light.
[0105] In addition to the method shown in FIG5 above, which includes eight light groups and each light group includes multiple LEDs, eight LED lamp beads can also be placed directly in the light compensation module, wherein each LED lamp bead has two pins: a positive pin and a negative pin; each LED lamp bead is encapsulated with a transparent resin; each LED lamp bead is encapsulated with multiple LED chips for controlling color changes on multiple color channels. For example, by using three LED chips and directly powering on, color changes of red, green, and blue can be achieved. Alternatively, each LED lamp bead has a built-in semiconductor element for controlling color changes, which is used to control color changes of red, green, and blue.
[0106] As shown in Figure 6, it is a structural schematic diagram of a semiconductor light emitting diode provided in an embodiment of the present application. A semiconductor light emitting diode, also known as an LED, is a light emitting device made of semiconductor materials that directly converts electrical energy into light energy and electrical signals into light signals. It is mainly composed of a gold wire bonding part 601, a circular epoxy resin lens 602, a positive pin 603, a negative pin 604, a reflective cap 605 and an LED chip 606.
[0107] In one embodiment, the original light color obtained by color temperature can be adjusted to a certain extent based on the reference light color of the current ambient light to achieve higher compensation accuracy. That is, the electronic device can determine the compensated light color corresponding to the current ambient light based on the reference light color, the original light color, and the preset target light color of the target ambient light.
[0108] Specifically, the overall color temperature of the original light color is adjusted based on the reference color temperature of the reference light color, and then the compensated color temperature of the compensated light color is obtained based on the adjusted overall color temperature and the target color temperature of the target light color. For example, when the difference between the reference color temperature and the overall color temperature is outside a preset range, the average of the two values is determined as the adjusted overall color temperature.
[0109] In another embodiment, after determining the compensated light color based on the original light color and the target light color, a reference compensated color is then determined using the reference light color. This reference compensated color serves as a reference for the compensated light color. In other words, adjustments are made from a compensation perspective, using the reference color temperature of the reference light color to adjust the compensated color temperature of the compensated light color. The adjusted compensated color temperature is then used to represent the compensated light color.
[0110] Among them, when determining the reference compensation color, the principle of obtaining is to add or subtract light of different colors to obtain white light, which can be divided into the following two cases:
[0111] Case 1: Additive mixing of three primary colors, which is based on the principle of additive mixing of three primary colors.
[0112] Figure 7 shows a schematic diagram of three primary colors provided by an embodiment of the present application. Since only black and white images can be displayed, each color is labeled in text form in the figure. The three primary colors are red, green, and blue. Mixing red and green in a 1:1 ratio produces yellow, mixing red and blue in a 1:1 ratio produces magenta (a color between red and violet), mixing blue and green in a 1:1 ratio produces cyan, and mixing red, green, and blue in a 1:1 ratio produces white. In other words, adding the three primary colors of red, green, and blue produces white light.
[0113] Therefore, when the reference light color includes multiple colors, the ratio of red, green, and blue LED lights can be controlled based on the principle of additive mixing of the three primary colors, and the corresponding light can be emitted. By superimposing the three colors of light and the current ambient light, white light can be obtained. The combination of these three colors is then called the reference compensation color.
[0114] Case 2: Subtractive mixing of complementary colors, which is based on the principle of subtractive mixing of complementary colors.
[0115] White light can be obtained by subtracting complementary colors. For example, blue and yellow are complementary colors. Based on the reference color of the current ambient light, the required ratio of blue LEDs to yellow LEDs is calculated, and the corresponding LEDs are controlled accordingly. By subtracting yellow light from blue light, the target light color can be obtained.
[0116] Therefore, when the reference light color includes a single color, controlling LED lights of other hues, when light of one other hue is superimposed on the current ambient light, white light can be obtained, then the color of the other hue is the reference compensation color.
[0117] S304: Determine light brightness adjustment parameters based on the compensated light color and the color deviation value.
[0118] S305: Based on the light brightness adjustment parameter, the compensation light color is used to perform light compensation on the current ambient light.
[0119] In order to make the fill light effect more natural and improve the accuracy of ambient light compensation, this application not only needs to determine the compensation light color of the compensation light, but also can further determine the brightness of the compensation light based on the local color deviation value of each area in the ambient image.
[0120] An optional implementation is that the processor of the electronic device determines the fill light ratio based on each local color deviation value; and determines the light brightness adjustment parameter based on the fill light ratio and the compensated color temperature value corresponding to the compensated light color; the compensated color temperature value is determined based on the overall color temperature value corresponding to the original light color and the target color temperature value corresponding to the target light color of the pre-set target ambient light.
[0121] Specifically, for a certain area in the environmental image, the difference between its local color deviation value and the maximum local color deviation value in all areas is determined as the local deviation between the local color deviation value of the area and the maximum local color deviation value. Then, the local deviations corresponding to each area are averaged to obtain the overall deviation, and finally the overall deviation is used as the fill light ratio.
[0122] Furthermore, the fill light ratio can be multiplied by the compensation color temperature value to obtain a light brightness adjustment parameter. The compensation light color is used to determine the color of the compensation light, and the light brightness adjustment parameter is used to determine the brightness of the compensation light, that is, the brightness of the LED in the electronic device. Specifically, the light brightness adjustment parameter can be used to determine the duty cycle of the pulse width modulation signal, thereby adjusting the current or voltage parameters and further adjusting the brightness of the LED.
[0123] Finally, the processor of the electronic device controls the number of LEDs of different colors that emit light and controls the brightness (ie, luminous intensity) of the LEDs according to the light brightness adjustment parameter, so that the light compensation module emits compensation light.
[0124] In addition, the solution introduced above is mainly that before the object is close to the electronic device and the information of the object is collected, the sensor sends a signal to the camera module to capture the environmental image, thereby triggering the compensation process, that is, parallel scheduling of different colors / numbers of fill lights to harmonize the current imaging, forming an imaging effect that matches the current environment with the highest degree, and solving the problem of different environmental lights affecting the recognition effect.
[0125] In addition, a cycle can be pre-set to cause the electronic device to periodically detect ambient light and obtain the original light color, compensated light color, and light brightness adjustment parameters at each detection moment. Then, based on the difference between the original light color at the current detection moment and the original light color at the previous detection moment, the light brightness adjustment parameters and the compensated light color at the current detection moment are adjusted.
[0126] The preset period can be set by counting the frequency of changes in the original light color in the environment. When the value of the period is short enough, the compensation light can be adjusted once a change in the original light color of the current ambient light is detected, thereby achieving adaptive compensation.
[0127] Following the assumptions in S303, after obtaining the compensated light color of the compensated light, specifically the compensated color temperature value, the palm-brush device A further combines the color deviation value to determine the brightness of the compensated light. Specifically, the palm-brush device A uses the average of the difference between the local color deviation value of each area and the maximum local color deviation value in all areas as the fill light ratio, and multiplies the fill light ratio by the compensated color temperature value to obtain the light brightness adjustment parameter. The light brightness adjustment parameter can be used to adjust the current or voltage of the lamp group to adjust the brightness of the LED. Finally, the processor of the palm-brush device A controls the number of LEDs of different colors that emit light, and controls the brightness (i.e., luminous intensity) of the LED according to the light brightness adjustment parameter, so that the light compensation module emits compensation light. After the compensation light compensates for the current ambient light, the background color of the picture taken by the palm-brush device A is white.
[0128] As shown in Figure 8, a compensation diagram of ambient light provided by an embodiment of the present application is provided. Due to the influence of external stray light, the original light color of the ambient light is often different from the target light color. When the palm is detected approaching, the environmental image is captured in advance, as shown in Figure 4 above, and the current ambient light is collected therefrom. Then, the processor 820 of the electronic device controls the light compensation module 810 to emit compensation light for adjusting the current ambient light according to the original light color of the current ambient light (including various stray lights). The original light color of the current ambient light is superimposed on the compensation light color of the compensation light to accurately obtain the target light color. For example, LED lamp beads of different colors are configured to blend the ambient light to achieve white light, thereby reducing interference to the electronic device when performing biometric information recognition.
[0129] In summary, through the method proposed in this application, the background color of the palm brush (that is, the target light color) can be uniformly set. Assuming it is set to white, the collection object is before the palm is brushed, the palm is close to the device, and when the distance sensor in the device detects that an object is approaching and the distance is less than the preset threshold, the camera module quickly captures the environmental image; the processor analyzes the current ambient light in the image, and combines the color neutralization strategy to adjust the light color and brightness of the lamp group to compensate for the current ambient light, so that the background color of the captured image is white, reducing the image interference factor and further improving the accuracy of palm brush recognition.
[0130] Next, a flowchart of another ambient light compensation method of the present application is introduced. In an optional implementation, S301 to S305 can be implemented according to the flowchart shown in FIG9 , and executed by an electronic device, such as the biological collection device 211 or 212 in FIG2 , including the following steps:
[0131] S901: When the electronic device detects that the distance between the object and the distance sensor is less than a preset threshold, the electronic device captures an environment image.
[0132] The distance sensor in the electronic device sends a signal to the processor, which controls the camera module to capture the environment image after receiving the signal.
[0133] S902: The electronic device divides the environment image into N areas based on the length and width of the environment image.
[0134] S903: The electronic device determines the local color temperature value corresponding to each area according to the color channel information of the pixels in each area.
[0135] Specifically, the electronic device obtains the average value R of the red color channel of each pixel in each area. - , the average value of the green color channel G - and the average value B of the blue color channel - , further R - , G - 、B - The mean of the local color temperature is taken as the local color temperature value of the corresponding area.
[0136] S904: The electronic device determines the local color deviation value corresponding to each area according to the color channel information of the pixels in each area.
[0137] For example, the local color deviation value of an area is based on the average value R of the red color channel of each pixel in the area. - , the average value of the green color channel G - and the average value B of the blue color channel - Got it.
[0138] S905: The electronic device uses the average of the local color temperature values corresponding to each area as the overall color temperature value, and uses the average of the local color deviation values corresponding to each area as the overall color deviation value.
[0139] S906: The electronic device determines a compensation color temperature value based on a difference between the overall color temperature value and a target color temperature value corresponding to a preset target light color of the target ambient light.
[0140] S907: The electronic device obtains a fill light ratio based on an overall deviation between each local color deviation value and the maximum local color deviation value.
[0141] S908: The electronic device determines a light brightness adjustment parameter based on the fill light ratio and the compensated color temperature value corresponding to the compensated light color.
[0142] Multiply the fill light ratio by the compensated color temperature value to obtain the light brightness adjustment parameter, specifically the brightness value.
[0143] S909: The electronic device performs light compensation for the current ambient light using a compensation light color based on the light brightness adjustment parameter.
[0144] Based on the same inventive concept, the embodiment of the present application also provides an ambient light compensation device. As shown in FIG10 , it is a schematic structural diagram of the ambient light compensation device, which may include:
[0145] The photographing unit 1001 is configured to photograph an environment image in response to a distance between an object and a distance sensor being less than a preset threshold;
[0146] A first determining unit 1002 is configured to determine an original light color and a color deviation value of the current ambient light based on the color information in the ambient image, wherein the color deviation value represents a color distribution state of the original light color in a color gamut;
[0147] A second determining unit 1003 is configured to determine a compensation light color corresponding to the current ambient light based on the original light color and a preset target light color of the target ambient light;
[0148] A third determining unit 1004 is configured to determine a light brightness adjustment parameter based on the compensated light color and the color deviation value;
[0149] The compensation unit 1005 is configured to perform light compensation on the current ambient light based on the light brightness adjustment parameter and using the compensation light color.
[0150] Optionally, the color information includes information of multiple color channels, and the first determining unit 1002 is specifically configured to determine the original light color of the current ambient light by:
[0151] dividing the environment image into a plurality of image regions;
[0152] For each image region, determining a local color temperature value corresponding to the image region based on the multiple color channel information of each pixel in the image region;
[0153] Based on the local color temperature values corresponding to the respective image regions, an overall color temperature value corresponding to the environment image is determined, wherein the overall color temperature value is used to represent the original light color.
[0154] Optionally, the color information includes information of multiple color channels, and the first determining unit 1002 is specifically configured to determine the color deviation value of the current ambient light in the following manner:
[0155] dividing the environment image into a plurality of image regions;
[0156] For each image region, determining a local color deviation value corresponding to the image region based on differences between the multiple color channel information of each pixel in the image region between the multiple color channels;
[0157] The color deviation value of the current ambient light is determined based on the local color deviation value corresponding to each image area.
[0158] Optionally, the second determining unit 1003 is specifically configured to determine a compensation color temperature value based on a difference between the overall color temperature value and a target color temperature value corresponding to the target light color, wherein the compensation color temperature value is used to characterize the compensation light color.
[0159] Optionally, the third determination unit 1004 is specifically used to: determine the fill light ratio based on each local color deviation value; determine the light brightness adjustment parameter based on the fill light ratio and the compensated color temperature value corresponding to the compensated light color; the compensated color temperature value is determined based on the overall color temperature value corresponding to the original light color and the target color temperature value corresponding to the target light color.
[0160] Optionally, the first determining unit 1002 is further configured to: determine, for each pixel in the ambient image, a pixel color temperature value and / or a pixel color deviation value corresponding to the pixel based on the color information of the pixel; aggregate pixels belonging to the same interval into a pixel group based on the pixel color temperature value and pre-divided color temperature value intervals, and / or the pixel color deviation value and pre-divided color deviation value intervals; and determine the reference light color of the current ambient light based on the number of pixels in each pixel group and the color classification corresponding to each pixel group;
[0161] The second determining unit 1003 is further configured to determine the compensated light color based on the reference light color, the original light color, and the target light color.
[0162] Optionally, the device further includes:
[0163] The adjustment unit 1006 is used to periodically detect the ambient light, obtain the original light color, the compensated light color and the light brightness adjustment parameter at each detection moment; based on the difference between the original light color at the current detection moment and the original light color at the previous detection moment, adjust the light brightness adjustment parameter and the compensated light color at the current detection moment.
[0164] For the convenience of description, the above parts are divided into modules (or units) according to their functions and described separately. Of course, when implementing this application, the functions of each module (or unit) can be implemented in the same or multiple software or hardware.
[0165] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories), or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0166] After introducing the ambient light compensation method and apparatus according to an exemplary embodiment of the present application, an electronic device according to another exemplary embodiment of the present application is introduced next.
[0167] Those skilled in the art will appreciate that various aspects of the present application can be implemented as systems, methods, or program products. Therefore, various aspects of the present application can be specifically implemented in the following forms: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or an implementation that combines hardware and software aspects, which may be collectively referred to herein as a "circuit," "module," or "system."
[0168] Based on the same inventive concept as the above-mentioned method embodiment, an electronic device is also provided in an embodiment of the present application. In one embodiment, the electronic device can be an electronic device such as a palm scanning device, a fingerprint recognition device, a facial recognition device, or other electronic devices with biometric information collection functions. In this embodiment, the structure of the electronic device can be as shown in Figure 11, including components such as a distance sensor 1101, a camera module 1102, a light compensation module 1103, a processor 1104, a memory 1105, a display unit 1106, and an audio circuit 1107.
[0169] The distance sensor 1101 is used for distance measurement. Once it detects that an object is approaching and the distance is less than a preset threshold, it sends a signal to the processor 1104. After receiving the signal, the processor 1104 controls the camera module 1102 to capture the environment image.
[0170] The camera module 1102 can be a single or multiple camera. The object is projected onto a photosensitive element through a lens to generate an optical image. The photosensitive element can be a charge coupled device (CCD) or a complementary metal oxide semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, which is then transmitted to the processor 1104 for conversion into a digital image signal.
[0171] The light compensation module 1103 is used to emit the required compensation light. Specifically, the processor 1104 determines the luminous ratio of the red, blue, and green LED lights in the light compensation module 1103 based on the obtained compensation color temperature value of the compensation light and the light brightness adjustment parameter, and adjusts the current or voltage according to the light brightness adjustment parameter to control the brightness of the LED, etc., so as to enable the light compensation module 1103 to emit compensation light.
[0172] Memory 1105 can be used to store software programs and data. Processor 1104 executes the software programs or data stored in memory 1105 to perform various functions of electronic device 1100 and process data. Memory 1105 can include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state memory device.
[0173] For some electronic devices, such as face recognition devices and voice recognition devices, the display unit 1106 and the audio circuit 1107 are also included. The display unit 1106 can be used to display information input by the object or information provided to the object, as well as a graphical user interface (GUI) of various menus of the electronic device 1100. Specifically, the display unit 1106 may include a display screen 11061 provided on the front of the electronic device 1100. The display screen 11061 can be configured in the form of a liquid crystal display, a light emitting diode, etc. The display unit 1106 can be used to display the training interface of the classification model in the embodiment of the present application, etc.
[0174] The display unit 1106 can also be used to receive input digital or character information and generate signal input related to the object setting and function control of the electronic device 1100. Specifically, the display unit 1106 may include a touch screen 11062 set on the front of the electronic device 1100, which can collect touch operations of objects on or near it, such as clicking a button, dragging a scroll box, etc.
[0175] The touch screen 11062 can be covered on the display screen 11061, or the touch screen 11062 and the display screen 11061 can be integrated to realize the input and output functions of the electronic device 1100. The integrated display screen can be simply referred to as a touch screen. In this application, the display unit 1106 can display applications and corresponding operation steps.
[0176] The audio circuit 1107, speaker 11071, and microphone 11072 provide an audio interface between the subject and the electronic device 1100. The audio circuit 1107 converts received audio data into electrical signals and transmits them to the speaker 11071, which then converts them into sound signals for output. The electronic device 1100 may also be equipped with a volume button for adjusting the volume of the sound signals. Meanwhile, the microphone 11072 converts the collected sound signals into electrical signals, which are then received by the audio circuit 1107 and converted into audio data. The audio data is then output, or the audio data is sent to the memory 1105 for further processing.
[0177] The processor 1104 is the control center of the electronic device 1100. It uses various interfaces and lines to connect the various parts of the entire electronic device 1100. By running or executing programs stored in the memory 1105 and calling data stored in the memory 1105, it performs various functions of the electronic device and processes data. In some embodiments, the processor 1104 may include one or more processing units; the processor 1104 may also integrate an application processor and a baseband processor, wherein the application processor mainly processes the operating system, object interface and application programs, etc., and the baseband processor mainly processes wireless communications. It is understandable that the above-mentioned baseband processor may not be integrated into the processor 1104. In this application, the processor 1104 can run the operating system, application programs, object interface display and touch response, as well as the training method of the classification model of the embodiment of the application. In addition, the processor 1104 is coupled to the display unit 1106.
[0178] In some possible embodiments, various aspects of the ambient light compensation method provided in the present application can also be implemented in the form of a program product, which includes a computer program. When the program product is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of the ambient light compensation method according to various exemplary embodiments of the present application described above in this specification. For example, the electronic device can execute the steps shown in Figure 3.
[0179] The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0180] The program product of the embodiment of the present application may be a portable compact disc read-only memory (CD-ROM) and include a computer program, and can be run on an electronic device. However, the program product of the present application is not limited thereto. In this document, a readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with a command execution system, apparatus, or device.
[0181] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries a readable computer program. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium that can transmit, propagate, or transfer a program for use by or in conjunction with a command execution system, apparatus, or device.
[0182] The computer program embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0183] The computer program for performing the operations of the present application can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The computer program can be executed entirely on the subject electronic device, partially on the subject electronic device, as a stand-alone software package, partially on the subject electronic device and partially on a remote electronic device, or entirely on a remote electronic device or server. In cases involving remote electronic devices, the remote electronic device can be connected to the subject electronic device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external electronic device (for example, using an Internet service provider to connect through the Internet).
[0184] It should be noted that although several units or subunits of the device are mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, depending on the embodiment of the application, the features and functions of two or more units described above can be embodied in a single unit. Conversely, the features and functions of a single unit described above can be further divided and embodied by multiple units.
[0185] Furthermore, although the operations of the method of the present application are described in a particular order in the accompanying drawings, this does not require or imply that the operations must be performed in this particular order, or that all illustrated operations must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.
[0186] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain a computer-usable computer program.
[0187] The present application is described with reference to the flow chart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present application. It should be understood that each flow process and / or box in the flow chart and / or block diagram and the combination of the flow process and / or box in the flow chart and / or block diagram can be realized by computer program commands. These computer program commands can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processing machine or other programmable data processing device to produce a machine, so that the command executed by the processor of the computer or other programmable data processing device produces a device for realizing the function specified in one flow chart flow or multiple flows and / or one box or multiple boxes of the block diagram.
[0188] These computer program commands may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the commands stored in the computer-readable memory produce a manufactured product including a command device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0189] These computer program commands can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the commands executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0190] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present application.
[0191] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.
Claims
1. An ambient light compensation method, executed by an electronic device, the method comprising: Capturing an ambient image in response to the distance between an object and a distance sensor being less than a preset threshold; Based on the color information in the ambient image, determining the original light color and the color deviation value of the current ambient light, where the color deviation value characterizes the color distribution state of the original light color in the color gamut; Based on the original light color and the target light color of a preset target ambient light, determining the compensation light color corresponding to the current ambient light; Based on the compensation light color and the color deviation value, determining a light brightness adjustment parameter; and, Based on the light brightness adjustment parameter, using the compensation light color to perform light compensation on the current ambient light.
2. The method according to claim 1, wherein The color information includes multiple color channel information. Based on the color information in the ambient image, determining the original light color of the current ambient light includes: Dividing the ambient image into multiple image regions; For each image region, based on the multiple color channel information of each pixel in the image region, determining the local color temperature value corresponding to the image region; Based on the local color temperature values corresponding to the respective image regions, determining the overall color temperature value corresponding to the ambient image, where the overall color temperature value is used to characterize the original light color.
3. The method according to claim 1 or 2, wherein The color information includes multiple color channel information. Based on the color information in the ambient image, determining the color deviation value of the current ambient light includes: Dividing the ambient image into multiple image regions; For each image region, based on the difference between the multiple color channel information of each pixel in the image region among multiple color channels, determining the local color deviation value corresponding to the image region; Based on the local color deviation values corresponding to the respective image regions, determining the color deviation value of the current ambient light.
4. The method according to claim 2, wherein, The determining the compensation light color corresponding to the current ambient light based on the original light color and the target light color of a preset target ambient light includes: Based on the difference between the overall color temperature value and the target color temperature value corresponding to the target light color, determining a compensation color temperature value, where the compensation color temperature value is used to characterize the compensation light color.
5. The method according to any one of claims 1 to 3, wherein, The determining the light brightness adjustment parameter based on the compensation light color and the color deviation value includes: Based on each local color deviation value, determining a fill light ratio; Based on the fill light ratio and the compensation color temperature value corresponding to the compensation light color, determining the light brightness adjustment parameter; the compensation color temperature value is determined based on the overall color temperature value corresponding to the original light color and the target color temperature value corresponding to the target light color.
6. The method according to any one of claims 1 to 5, further comprising: For each pixel in the ambient image, based on the color information of the pixel, determining the pixel color temperature value and / or the pixel color deviation value corresponding to the pixel; Based on the pixel color temperature value and pre-divided color temperature value intervals, and / or, the pixel color deviation value and pre-divided color deviation value intervals, aggregating pixels belonging to the same interval into a pixel group; Based on the number of pixels in each pixel group and the color classification corresponding to each pixel group, determining the reference light color of the current ambient light; Determining a compensation light color corresponding to the current ambient light based on the original light color and the target light color of a preset target ambient light includes: Determining the compensation light color based on the reference light color, the original light color, and the target light color.
7. The method according to any one of claims 1 to 6 further includes: Periodically detecting the ambient light to obtain the original light color, the compensation light color, and the light brightness adjustment parameter at each detection moment; Adjusting the light brightness adjustment parameter and the compensation light color at the current detection moment based on the difference between the original light color at the current detection moment and the original light color at the previous detection moment.
8. A compensation device for ambient light includes: A photographing unit configured to photograph an ambient image in response to a distance between an object and a distance sensor being less than a preset threshold; A first determination unit configured to determine an original light color and a color deviation value of the current ambient light based on color information in the ambient image, where the color deviation value represents a color distribution state of the original light color in a color gamut; A second determination unit configured to determine a compensation light color corresponding to the current ambient light based on the original light color and the target light color of a preset target ambient light; A third determination unit configured to determine a light brightness adjustment parameter based on the compensation light color and the color deviation value; and A compensation unit configured to perform light compensation on the current ambient light by using the compensation light color based on the light brightness adjustment parameter.
9. The device according to claim 8, wherein, The color information includes multiple color channel information. The first determination unit is configured to divide the ambient image into multiple image regions; for each image region, determine a local color temperature value corresponding to the image region based on the multiple color channel information of each pixel in the image region; and determine an overall color temperature value corresponding to the ambient image based on the local color temperature values corresponding to the respective image regions, where the overall color temperature value is used to represent the original light color.
10. The device according to claim 8 or 9, wherein, The color information includes multiple color channel information. The first determination unit is configured to divide the ambient image into multiple image regions; for each image region, determine a local color deviation value corresponding to the image region based on the difference between the multiple color channel information of each pixel in the image region among multiple color channels; and determine the color deviation value of the current ambient light based on the local color deviation values corresponding to the respective image regions.
11. The device according to claim 9, wherein, The second determination unit is configured to determine a compensation color temperature value based on the difference between the overall color temperature value and the target color temperature value corresponding to the target light color, where the compensation color temperature value is used to represent the compensation light color.
12. The device according to any one of claims 8 to 10, wherein The third determination unit is configured to determine a supplementary light ratio based on the respective local color deviation values; determine the light brightness adjustment parameter based on the supplementary light ratio and the compensation color temperature value corresponding to the compensation light color; and the compensation color temperature value is determined based on the overall color temperature value corresponding to the original light color and the target color temperature value corresponding to the target light color.
13. The device according to any one of claims 8 to 12, wherein, The first determination unit is configured to, for each pixel in the environmental image, determine the pixel color temperature value and / or the pixel color deviation value corresponding to the pixel based on the color information of the pixel; aggregate pixels belonging to the same interval into a pixel group based on the pixel color temperature value and the pre-divided color temperature value intervals, and / or, the pixel color deviation value and the pre-divided color deviation value intervals; and determine the reference light color of the current ambient light based on the number of pixels in each pixel group and the color classification corresponding to each pixel group. The second determination unit is configured to determine the compensation light color based on the reference light color, the original light color, and the target light color.
14. The apparatus according to any one of claims 8 to 13, further comprising: An adjustment unit configured to periodically detect the ambient light and obtain the original light color, the compensation light color, and the light brightness adjustment parameter at each detection moment; Adjust the light brightness adjustment parameter and the compensation light color at the current detection moment based on the difference between the original light color at the current detection moment and the original light color at the previous detection moment.
15. An electronic device, comprising a processor and a memory, wherein, The memory stores a computer program, when the computer program is executed by the processor, the processor is caused to execute the steps of the method according to any one of claims 1 to 7.
16. A computer-readable storage medium, comprising a computer program, when the computer program runs on an electronic device, the computer program is configured to cause the electronic device to execute the steps of the method according to any one of claims 1 to 7.
17. A computer program product, comprising a computer program, the computer program is stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, causing the electronic device to execute the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Photographing method, and terminal
CN106210556A
Photographing method, mobile terminal and computer storage medium
CN111885304A
System and method for compensating for color deviation in an image produced by an image capturing
CN1126921A
LED light source automatic calibration method and system for target image acquisition
CN114745510A
Microspur light supplementing method and device, computer equipment and storage medium
CN116132781A
Cited By
Scene-based LED lamp strip adaptive control method, device and equipment
CN120935903A
Image brightness adjusting method and sorting machine
CN121280683A
Light source calibration method and device, electronic equipment and storage medium
CN121463304A
Image redness correction method and device, medium and product
CN122453679A
A method, device, medium and product for correcting image redness
CN122453679B