Image brightness calculation method and device, electronic equipment and storage medium
By detecting the proportion of rectangular and facial regions in an image and adjusting the exposure weight table, the problem of inaccurate image brightness calculation is solved, and the accuracy of image brightness calculation is improved.
Patent Information
- Application Number
- CN202211357417.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-01
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2042-11-01
AI Technical Summary
In the existing technology, inaccurate image brightness calculations can lead to faces appearing too dark or too exposed, affecting the overall brightness of the image.
By performing face detection on the target image, a rectangular face region is determined, and the face area is detected within this region. The proportion of the face region is calculated, and an exposure weight table is determined based on the proportion. The weight table is then adjusted to accommodate the brightness calculation of the rectangular face region.
It improves the accuracy of image brightness calculation, enhances the adaptability of the exposure weight table to the face and edge regions in the face rectangle area, and reduces the deviation of brightness calculation.
Smart Images

Figure CN116112784B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, and in particular to an image brightness calculation method and device, electronic equipment and a storage medium. BACKGROUND
[0002] In the process of photographing, an AE (Automatic Exposure) algorithm will count the brightness of a current image, and then compare it with a target brightness set by the current environment, so as to control the image sensor to select the best shutter combination. Therefore, the calculation of image brightness has a great influence on the exposure result of the AE algorithm. If the image brightness calculation is inaccurate, the face brightness will appear too dark or overexposed, and the overall brightness of the image will also be affected. SUMMARY
[0003] The embodiments of the present application disclose an image brightness calculation method and device, electronic equipment and a storage medium, which can improve the accuracy of image brightness calculation.
[0004] The embodiments of the present application disclose an image brightness calculation method, which comprises the following steps:
[0005] Performing face detection on a target image to determine a face rectangular region in the target image;
[0006] Determining a face region in the face rectangular region;
[0007] Calculating a proportion of the face region in the face rectangular region;
[0008] According to the proportion, determining an exposure weight table corresponding to the face rectangular region;
[0009] Based on the exposure weight table, calculating the brightness of the face rectangular region.
[0010] In one embodiment, the exposure weight table corresponding to the face rectangular region is determined according to the proportion, which comprises the following steps:
[0011] If the proportion is greater than or equal to a proportion threshold, a preset exposure weight table is used as the exposure weight table corresponding to the face rectangular region;
[0012] If the proportion is less than the proportion threshold, the preset exposure weight table is adjusted, and the adjusted exposure weight table is used as the exposure weight table corresponding to the face rectangular region.
[0013] In one embodiment, the weight distribution of the preset exposure weight table satisfies a two-dimensional normal distribution, and the preset exposure weight table is adjusted, which comprises the following steps:
[0014] acquire a preset standard deviation of the preset exposure weight table;
[0015] determine an adjustment ratio corresponding to the preset standard deviation according to the proportion;
[0016] calculate a target standard deviation according to the preset standard deviation and the adjustment ratio, the target standard deviation being smaller than the preset standard deviation;
[0017] adjust the preset exposure weight table to obtain an adjusted exposure weight table, a standard deviation of the adjusted exposure weight table being the target standard deviation.
[0018] In one embodiment, when the proportion is smaller than a proportion threshold, the smaller the proportion, the smaller the exposure weight in the exposure weight table corresponding to an edge region of the face rectangular region, the edge region being other regions of the face rectangular region except the face region.
[0019] In one embodiment, the determination of the face region in the face rectangular region comprises:
[0020] perform skin color detection on the face rectangular region to obtain a skin color feature;
[0021] determine the face region in the face rectangular region according to the skin color feature.
[0022] In one embodiment, the calculation of the proportion of the face region in the face rectangular region comprises:
[0023] detect a first number of pixel points of the face region and a second number of pixel points of the face rectangular region;
[0024] calculate a proportion of the first number of pixel points and the second number of pixel points as the proportion of the face region in the face rectangular region.
[0025] In one embodiment, the exposure weight table comprises a plurality of weight values, a weight value in the exposure weight table corresponding to a pixel point in the face rectangular region one by one, and the calculation of the brightness of the face rectangular region based on the exposure weight table comprises:
[0026] determine a target weight value corresponding to a target pixel point in the exposure weight table, wherein the target pixel point is any pixel point in a plurality of pixel points included in the face rectangular region;
[0027] calculate the brightness of the face rectangular region according to the brightness values of the plurality of pixel points and the target weight values corresponding to the plurality of pixel points respectively.
[0028] The embodiment of the present application discloses a kind of computing device of image brightness, it is characterized in that, the device includes:
[0029] Face detection module, for face detection to target image, determine the face rectangle area in the target image;
[0030] Region determination module, for determining the face area in the face rectangle area;
[0031] Proportion calculation module, for calculating the proportion of the face area in the face rectangle area;
[0032] Weight determination module, for determining the exposure weight table corresponding to the face rectangle area according to the proportion;
[0033] Brightness calculation module, for calculating the brightness of the face rectangle area based on the exposure weight table.
[0034] In one embodiment, the weight determination module is also used to if the proportion is greater than or equal to a proportion threshold, then the preset exposure weight table is used as the exposure weight table corresponding to the face rectangle area;If the proportion is less than the proportion threshold, then the preset exposure weight table is adjusted, and the adjusted exposure weight table is used as the exposure weight table corresponding to the face rectangle area.
[0035] In one embodiment, the weight distribution of the preset exposure weight table satisfies two-dimensional normal distribution, and the weight determination module is also used to obtain a preset standard deviation of the preset exposure weight table;According to the proportion, determine the adjustment proportion corresponding to the preset standard deviation;According to the preset standard deviation and the adjustment proportion, calculate the target standard deviation, the target standard deviation is less than the preset standard deviation;The preset exposure weight table is adjusted to obtain the adjusted exposure weight table, and the standard deviation of the adjusted exposure weight table is the target standard deviation.
[0036] In one embodiment, when the proportion is less than the proportion threshold, the smaller the proportion, the smaller the exposure weight corresponding to the edge region of the face rectangle area in the exposure weight table, and the edge region is other region of the face rectangle area except the face area.
[0037] In one embodiment, the region determination module is also used to perform skin color detection on the face rectangle area to obtain skin color features;According to the skin color features, determine the face area in the face rectangle area.
[0038] In an embodiment, the proportion calculation module is further configured to detect a first number of pixel points of the face region and a second number of pixel points of the face rectangle region; and calculate a proportion of the first number of pixel points to the second number of pixel points as the proportion of the face region in the face rectangle region.
[0039] In an embodiment, the exposure weight table includes a plurality of weight values, each weight value in the exposure weight table corresponding to a pixel point in the face rectangle region; the brightness calculation module is further configured to determine a target weight value corresponding to a target pixel point in the exposure weight table, the target pixel point being any one of a plurality of pixel points included in the face rectangle region; and calculate a brightness of the face rectangle region according to brightness values of the plurality of pixel points and the target weight values corresponding to the plurality of pixel points respectively.
[0040] Embodiments of the present application disclose an electronic device, comprising:
[0041] a memory storing executable program code;
[0042] a processor coupled to the memory;
[0043] The processor invokes the executable program code stored in the memory to execute the method of any of the above embodiments.
[0044] Embodiments of the present application disclose a computer readable storage medium storing a computer program, wherein the computer program, when executed by a processor, causes the processor to execute the method of any of the above embodiments.
[0045] Through the image brightness calculation method and device, the electronic device and the storage medium disclosed in the present application, the electronic device can perform face detection on a target image to determine a face rectangle region in the target image, then determine a face region in the face rectangle region and calculate a proportion of the face region in the face rectangle region, and then determine an exposure weight table corresponding to the face rectangle region according to the proportion. When the proportion is less than a proportion threshold, the smaller the proportion is, the smaller the exposure weight corresponding to an edge region of the face rectangle region in the exposure weight table is. The edge region is a region other than the face region in the face rectangle region. The brightness of the face rectangle region can be calculated based on the exposure weight table. The method of determining the exposure weight table according to the proportion of the face region in the face rectangle region can improve the adaptability of the exposure weight table to the face region and the edge region in the face rectangle region, thereby improving the accuracy of image brightness calculation. BRIEF DESCRIPTION OF DRAWINGS
[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiments will be briefly introduced as follows. Obviously, the drawings in the following description only represent some of the embodiments of the present application, and all other drawings obtained by those of ordinary skill in the art without creative effort based on these drawings also belong to the protection scope of the present application.
[0047] Figure 1 is a schematic diagram of an application scenario of a method for calculating image brightness disclosed by an embodiment of the present application;
[0048] Figure 2 is a flowchart of a method for calculating image brightness disclosed by an embodiment of the present application;
[0049] Figure 3 is a schematic diagram of a face key point in a target image disclosed by an embodiment of the present application;
[0050] Figure 4 is a flowchart of another method for calculating image brightness disclosed by an embodiment of the present application;
[0051] Figure 5A is a schematic diagram of a weight distribution of an exposure weight table disclosed by an embodiment of the present application;
[0052] Figure 5B is a schematic diagram of a weight distribution of another exposure weight table disclosed by an embodiment of the present application;
[0053] Figure 6 is a modularization schematic diagram of a device for calculating image brightness disclosed by an embodiment of the present application;
[0054] Figure 7 is a structural block diagram of an electronic device disclosed by an embodiment of the present application. DETAILED DESCRIPTION
[0055] The technical solutions in the embodiments of the present application will be described clearly and completely with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort belong to the protection scope of the present application.
[0056] It should be noted that the terms “include” and “have” and any variations thereof in the embodiments of the present application are intended to cover the inclusions without exclusivity, for example, a process, method, system, product or device including a series of steps or units need not be limited to those clearly listed steps or units, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0057] It can be understood that the terms "first", "second", and the like used in the present application can be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish a first element from another element. For example, without departing from the scope of the present application, the first pixel point number can be referred to as the second pixel point number, and similarly, the second pixel point number can be referred to as the first pixel point number. Both the first pixel point number and the second pixel point number are pixel point numbers, but they are not the same pixel point number.
[0058] Embodiments of the present application disclose a method and device for calculating image brightness, electronic equipment and storage medium, which can improve the accuracy of image brightness calculation.
[0059] In the related art, for a device supporting face recognition and AE algorithm, after detecting a face in a frame image, the brightness of a face recognition frame is first calculated, and then a certain weight is respectively given to the brightness of the face recognition frame and the brightness of the frame image, so as to obtain the final image brightness. The commonly used light measurement method for the face recognition frame is to use an exposure weight table to calculate the brightness of the face recognition frame. The weights included in the exposure weight table are usually the same, or different weights are set in regions at different distances from the center of the face recognition frame. However, the face recognition frame obtained by face recognition usually cannot completely adapt to the size of the face, that is, the face recognition frame usually contains a background region, and the size of the background region is not fixed. The brightness of the background region will affect the calculation of the brightness of the face recognition frame. If the background region in the face recognition frame is calculated according to the weight corresponding to the face region, the brightness of the face recognition frame obtained will be deviated.
[0060] The following will be described in detail with reference to the accompanying drawings.
[0061] As Figure 1 shown, Figure 1 is an application scenario diagram of a method for calculating image brightness disclosed by an embodiment of the present application. The application scenario diagram includes an electronic device 10 and a user 20. The electronic device 10 can include but is not limited to a mobile phone, a tablet computer, a wearable device, a notebook computer, a PC (Personal Computer), and the like. In addition, the operating system of the electronic device 10 can include but is not limited to an Android operating system, an IOS operating system, a Symbian operating system, a Black Berry operating system, a Windows Phone 8 operating system, and the like, and the present application embodiment is not limited. The electronic device 10 can photograph the user 20 to obtain a target image.
[0062] The electronic device 10 can perform face detection on the target image, determine a face rectangular region in the target image, and then determine a face region in the face rectangular region. The electronic device 10 then calculates a proportion of the face region in the face rectangular region, and determines an exposure weight table corresponding to the face rectangular region according to the proportion. When the proportion is less than a proportion threshold, the smaller the proportion, the smaller the exposure weight in the exposure weight table corresponding to an edge region of the face rectangular region. The edge region is other regions of the face rectangular region except the face region. Finally, the electronic device 10 calculates the brightness of the face rectangular region based on the exposure weight table.
[0063] As shown in Figure 2 , Figure 2 is a flowchart of an image brightness calculation method disclosed by an embodiment of the present application. The image brightness calculation method can be applied to the electronic device in the above embodiment. The image brightness calculation method can include the following steps.
[0064] In step 210, face detection is performed on the target image to determine a face rectangular region in the target image.
[0065] The electronic device can perform face detection on the target image. When a face in the target image is detected, a face rectangular region including the face can be determined.
[0066] As an optional implementation, the electronic device can perform face detection on the target image by face key point recognition to determine a face rectangular region in the target image. The face key points can include a plurality of face key points. After detecting the plurality of face key points, the electronic device can determine the positions of the face key points in the target image, and then select the uppermost face key point, the lowermost face key point, the leftmost face key point, and the rightmost face key point in the target image to determine the face rectangular region in the target image. As shown in Figure 3 , Figure 3 is a schematic diagram of a face key point in a target image disclosed by an embodiment of the present application. The electronic device can recognize 68 face key points in the target image. The face key point 24 or 19 can be selected as the uppermost face key point in the target image. The face key point 8 can be selected as the lowermost face key point in the target image. The face key point 0 can be selected as the leftmost face key point in the target image. The face key point 16 can be selected as the rightmost face key point in the target image.
[0067] In the example of FIG. 3, the electronic device can determine the first rectangular boundary of the face rectangular region according to the uppermost key point, specifically, a straight line at a first distance upward from the uppermost key point can be taken as the first rectangular boundary of the face rectangular region. The electronic device can determine the second rectangular boundary of the face rectangular region according to the lowermost key point, specifically, a straight line at a second distance downward from the lowermost key point can be taken as the second rectangular boundary of the face rectangular region. The electronic device can determine the third rectangular boundary of the face rectangular region according to the leftmost key point, specifically, a straight line at a third distance leftward from the leftmost key point can be taken as the third rectangular boundary of the face rectangular region. The electronic device can determine the fourth rectangular boundary of the face rectangular region according to the rightmost key point, specifically, a straight line at a fourth distance rightward from the rightmost key point can be taken as the fourth rectangular boundary of the face rectangular region. Figure 3 For example, the electronic device can determine the first rectangular boundary 310 according to the face key point 24 or 19, determine the second rectangular boundary 320 according to the face key point 8, determine the third rectangular boundary 330 according to the face key point 0, and determine the fourth rectangular boundary 340 according to the face key point 16.
[0068] Alternatively, the electronic device can determine the first rectangular boundary, the second rectangular boundary, the third rectangular boundary and the fourth rectangular boundary of the face rectangular region in other manners, and then determine the face rectangular region according to the first rectangular boundary, the second rectangular boundary, the third rectangular boundary and the fourth rectangular boundary. For example, the electronic device can determine the face rectangular region 300 according to the first rectangular boundary 310, the second rectangular boundary 320, the third rectangular boundary 330 and the fourth rectangular boundary 340. Figure 3
[0069] In step 220, a face region in the face rectangular region is determined.
[0070] The electronic device can further detect the face region in the face rectangular region by a face detection method. The face detection method can detect a face contour of the face, and then determine the face region according to the face contour. Alternatively, the electronic device can detect another rectangular region in the face rectangular region, the other rectangular region can be the face region, and the number of pixel points included in the other rectangular region can be less than the number of pixel points included in the face rectangular region. In the face rectangular region, other regions except the face region can be edge regions.
[0071] As an optional implementation, when the face region is another rectangular region in the face rectangular region, the electronic device can further determine an exposure weight table corresponding to the face region, and calculate the brightness of the other rectangular region based on the exposure weight table, and take the brightness of the other rectangular region as the brightness of the face rectangular region, so as to replace the face rectangular region with the face region, thereby improving the diversity of the image brightness calculation method.
[0072] In step 230, the proportion of the face region in the face rectangular region is calculated.
[0073] The electronic device can calculate the proportion of the face region in the face rectangular region.
[0074] In one embodiment, the electronic device detects the first number of pixel points of the face region and the second number of pixel points of the face rectangular region, calculates the proportion of the first number of pixel points to the second number of pixel points as the proportion of the face region in the face rectangular region. The first number of pixel points can be less than the second number of pixel points. For example, the first number of pixel points is 80, and the second number of pixel points is 100, so the proportion of the first number of pixel points to the second number of pixel points is 80%.
[0075] As an optional implementation, the electronic device can also calculate the proportion of the third number of pixel points of the edge region to the second number of pixel points of the face rectangular region, and then determine the proportion of the first number of pixel points to the second number of pixel points according to the proportion of the third number of pixel points to the second number of pixel points. In the case that the third number of pixel points is less than the first number of pixel points, the third number of pixel points of the edge region is detected instead of the first number of pixel points of the face region, so as to reduce the calculation amount.
[0076] In step 240, the exposure weight table corresponding to the face rectangular region is determined according to the proportion.
[0077] The electronic device can determine the exposure weight table corresponding to the face rectangular region from the local database according to the proportion. The local database can include a plurality of proportion regions and the exposure weight table corresponding to each proportion region. Each proportion region is independent of each other. For example, the local database can include five proportion regions, which can be 0%-20%, 20%-40%, 40%-60%, 60%-80% and 80%-100% respectively. Optionally, the electronic device can determine the target proportion region corresponding to the proportion, and then determine the exposure weight table corresponding to the target proportion region.
[0078] The exposure weight table includes a plurality of weight values, which can correspond to the pixels in the face rectangular region one by one, that is, the second pixel in the face rectangular region can determine the number of weight values of the exposure weight table, and the electronic device can determine the exposure weight table corresponding to the face rectangular region according to the second pixel value and the proportion. When the proportion is less than the proportion threshold, the smaller the proportion, the smaller the exposure weight corresponding to the edge region of the face rectangular region in the exposure weight table. Optionally, the smaller exposure weight corresponding to the edge region can be that the smaller weight value corresponding to each pixel included in the edge region, or the smaller average weight value corresponding to all pixels included in the edge region.
[0079] In an embodiment, the electronic device can adjust the size of the face rectangular region according to the proportion, and determine the exposure weight table corresponding to the adjusted face rectangular region. The electronic device can determine the preset proportion corresponding to the proportion, and then adjust the size of the face rectangular region. The proportion of the face region included in the adjusted face rectangular region is the preset proportion.
[0080] Optionally, the local database can include one or more preset proportions, and the electronic device can adjust the size of the face rectangular region according to the preset proportion closest to the proportion. For example, the local database includes five preset proportions, which are 80%, 85%, 90%, 95% and 100% respectively. The proportion of the face region in the face rectangular region calculated by the electronic device is 89%, and the preset proportion closest to the proportion in the five preset proportions is 90%. Therefore, the size of the face rectangular region can be adjusted so that the proportion of the face region in the face rectangular region is 90%.
[0081] By implementing this embodiment, the electronic device can adjust the size of the face rectangular region to determine the exposure weight table, thereby improving the accuracy of the exposure weight table.
[0082] Step 250, calculating the brightness of the face rectangular region based on the exposure weight table.
[0083] The electronic device can calculate the brightness of the face rectangular region based on the exposure weight table. Optionally, the electronic device can calculate the brightness of the face rectangular region according to the plurality of weight values included in the exposure weight table and the brightness values of the plurality of pixels included in the face rectangular region. The electronic device can calculate the brightness of the target pixel according to the target weight value and the brightness value of the target pixel corresponding to the target weight value, wherein the target weight value can be any weight value in the plurality of weight values in the exposure weight table. After calculating the brightness of the plurality of pixels included in the face rectangular region, the brightness of the face rectangular region can be obtained according to the brightness of the plurality of pixels.
[0084] In the embodiment of the present application, the electronic device can perform face detection on the target image to determine a face rectangular region in the target image, and then determine a face region in the face rectangular region and calculate a proportion of the face region in the face rectangular region, so as to determine an exposure weight table corresponding to the face rectangular region according to the proportion, and when the proportion is less than a proportion threshold, the smaller the proportion, the smaller the exposure weight corresponding to an edge region of the face rectangular region in the exposure weight table, the edge region being other regions of the face rectangular region except the face region, and the brightness of the face rectangular region can be calculated based on the exposure weight table. The method of determining the exposure weight table according to the proportion of the face region in the face rectangular region can improve the adaptability of the exposure weight table to the face region and the edge region in the face rectangular region, thereby improving the accuracy of image brightness calculation.
[0085] As shown in Figure 4 , Figure 4 is a flow diagram of another image brightness calculation method disclosed in the embodiment of the present application, which can be applied to the electronic device in the above-mentioned embodiments. The image brightness calculation method can include the following steps:
[0086] Step 410: performing face detection on the target image to determine a face rectangular region in the target image.
[0087] The method of step 410 is the same as that of step 210 in the above-mentioned embodiments, and will not be described here.
[0088] Step 420: performing skin color detection on the face rectangular region to obtain skin color features.
[0089] The electronic device can perform skin color detection on the face rectangular region to detect skin color features in the face rectangular region. Optionally, the electronic device can perform image processing methods such as binarization processing, feature extraction, and mask extraction on the face rectangular region to obtain a binarized image, which can be an image composed of 0 and 1. The pixel point corresponding to 1 can be regarded as a skin color pixel point, and it is determined whether the pixel point feature corresponding to the skin color pixel point is a normal skin color feature. If yes, the pixel point feature is regarded as a skin color feature. If not, the parameters of the image processing method can be adjusted, and the face rectangular region is reprocessed.
[0090] As an optional implementation, the electronic device can detect the first pixel value, the second pixel value and the third pixel value of each pixel point in the face rectangular region, and determine whether each pixel point is a pixel point corresponding to the skin color feature according to the first pixel value, the second pixel value and the third pixel value of each pixel point. Specifically, the electronic device can compare the first pixel value with a first threshold, compare the second pixel value with a second threshold, compare the third pixel value with a third threshold, and regard the pixel point satisfying a preset condition as a pixel point corresponding to the skin color feature. The preset condition can include that the first pixel value is greater than or less than the first threshold, the second pixel value is greater than or less than the second threshold, and the third pixel value is greater than or less than the third threshold. The preset condition can be determined according to the skin color of a race, the first pixel value can be a luminance value of a red channel, the second pixel value can be a luminance value of a green channel, and the third pixel value can be a luminance value of a blue channel. For example, the preset conditions corresponding to white people, black people and yellow people can be different.
[0091] In step 430, a face region in the face rectangular region is determined according to the skin color feature.
[0092] The electronic device determines the face region in the face rectangular region according to the skin color feature. Specifically, the electronic device can regard the pixel point corresponding to the skin color feature as a pixel point corresponding to the face region, and thus determine the face region in the face rectangular region.
[0093] In step 440, a proportion of the face region in the face rectangular region is calculated.
[0094] The method in step 440 is the same as the method in step 230 in the above embodiment, and thus will not be described here.
[0095] In step 450, if the proportion is greater than or equal to a proportion threshold, a preset exposure weight table is taken as an exposure weight table corresponding to the face rectangular region.
[0096] The electronic device can compare the proportion with the proportion threshold, which can be preset. If the proportion is greater than or equal to the proportion threshold, the electronic device can take the preset exposure weight table as the exposure weight table corresponding to the face rectangular region. Compared with the case where the proportion is less than the proportion threshold, the error caused by the electronic device using the preset exposure weight table when the proportion is greater than or equal to the proportion threshold is smaller.
[0097] In step 460, if the proportion is less than the proportion threshold, the preset exposure weight table is adjusted, and the adjusted exposure weight table is taken as the exposure weight table corresponding to the face rectangular region.
[0098] If the proportion is less than the proportion threshold, the electronic device can adjust the multiple weight values included in the preset exposure weight table to obtain the adjusted exposure weight table, and use the adjusted exposure weight table as the exposure weight table corresponding to the rectangular area of the face.
[0099] In one embodiment, the weight distribution of the preset exposure weight table satisfies a two-dimensional normal distribution. The electronic device can obtain the preset standard deviation of the preset exposure weight table, determine the adjustment ratio corresponding to the preset standard deviation based on the proportion, calculate the target standard deviation based on the preset standard deviation and the adjustment ratio, and the target standard deviation is less than the preset standard deviation. The preset exposure weight table is adjusted to obtain the adjusted exposure weight table, and the standard deviation of the adjusted exposure weight table is the target standard deviation.
[0100] The preset standard deviation characterizes the magnitude of the weight distribution in the exposure weight table. A smaller preset standard deviation indicates a higher exposure weight for the central region of the corresponding rectangular face area in the exposure weight table. The electronic device can determine the adjustment ratio corresponding to the preset standard deviation based on the proportion. Optionally, the local database can store one or more adjustment ratios and their corresponding proportions. This adjustment ratio is used to adjust the preset standard deviation. Optionally, the electronic device can multiply the preset standard deviation by the adjustment ratio to obtain a target standard deviation. This adjustment ratio can be used to reduce the preset standard deviation, i.e., the target standard deviation is less than the preset standard deviation. The electronic device adjusts the preset exposure weight table according to the two-dimensional normal distribution function corresponding to the target standard deviation to obtain the adjusted exposure weight table.
[0101] like Figure 5A and Figure 5B As shown, Figure 5A This is a schematic diagram of the weight distribution of an exposure weight table disclosed in an embodiment of this application. Figure 5B This application discloses a schematic diagram of the weight distribution of another exposure weight table. Figure 5A The middle section shows the weight distribution of the preset exposure weight table. Figure 5B The middle section shows the weight distribution of the adjusted exposure weight table. It can be seen that, compared to... Figure 5B The weight distribution in the exposure weight table is such that, since the target standard deviation is less than the preset standard deviation, Figure 5B The weight distribution of the exposure weight table is more concentrated in the central region, which corresponds to the central region of the face rectangle.
[0102] Step 470: In the exposure weight table, determine the target weight value corresponding to the target pixel; wherein, the target pixel is any pixel among the multiple pixels included in the face rectangular region.
[0103] The exposure weight table includes multiple weight values, and each weight value in the exposure weight table corresponds one-to-one with a pixel in the rectangular area of the face.
[0104] Step 480: Calculate the brightness of the rectangular region of the face based on the brightness values of multiple pixels and the target weight values corresponding to each pixel.
[0105] Electronic devices can calculate the brightness of each pixel based on the brightness values of multiple pixels and the target weight values corresponding to each pixel. By summing the brightness values of each pixel, the brightness of the rectangular area of the face can be obtained.
[0106] In this embodiment, the electronic device can further perform skin color detection on the rectangular area of the face to obtain skin color features, and determine the facial region within the rectangular area based on the skin color features, thereby improving the accuracy of the facial region and thus improving the precision of the electronic device in calculating the proportion of the facial region within the rectangular area of the face. The electronic device can also compare the proportion with a proportion threshold. If the proportion is greater than or equal to the proportion threshold, a preset exposure weight table is used as the exposure weight table corresponding to the rectangular area of the face. If the proportion is less than the proportion threshold, the preset exposure weight table is adjusted, and the adjusted exposure weight table is used as the exposure weight table corresponding to the rectangular area of the face, improving the adaptability of the exposure weight table to the rectangular area of the face, thereby improving the precision of image brightness calculation.
[0107] like Figure 6 As shown, Figure 6 This is a modular schematic diagram of an image brightness calculation device disclosed in an embodiment of this application. The image brightness calculation device 600 includes a face detection module 610, a region determination module 620, a proportion calculation module 630, a weight determination module 640, and a brightness calculation module 650, wherein:
[0108] The face detection module 610 is used to perform face detection on the target image and determine the rectangular region of the face in the target image.
[0109] The region determination module 620 is used to determine the facial region within the rectangular region of the face.
[0110] The proportion calculation module 630 is used to calculate the proportion of the face region within the rectangular area of the face.
[0111] The weight determination module 640 is used to determine the exposure weight table corresponding to the rectangular area of the face based on the proportion.
[0112] The brightness calculation module 650 is used to calculate the brightness of the rectangular area of the face based on the exposure weight table.
[0113] In an embodiment, the weight determination module 640 is further configured to, if the proportion is greater than or equal to the proportion threshold, use the preset exposure weight table as the exposure weight table corresponding to the face rectangular region; and if the proportion is less than the proportion threshold, adjust the preset exposure weight table, and use the adjusted exposure weight table as the exposure weight table corresponding to the face rectangular region.
[0114] In an embodiment, the weight distribution of the preset exposure weight table satisfies a two-dimensional normal distribution, the weight determination module 640 is further configured to obtain a preset standard deviation of the preset exposure weight table; determine an adjustment proportion corresponding to the preset standard deviation according to the proportion; calculate a target standard deviation according to the preset standard deviation and the adjustment proportion, the target standard deviation being less than the preset standard deviation; and adjust the preset exposure weight table to obtain an adjusted exposure weight table, a standard deviation of the adjusted exposure weight table being the target standard deviation.
[0115] In an embodiment, when the proportion is less than the proportion threshold, the smaller the proportion, the smaller the exposure weight corresponding to the edge region of the face rectangular region in the exposure weight table, the edge region being other regions of the face rectangular region except the face region.
[0116] In an embodiment, the region determination module 620 is further configured to perform skin color detection on the face rectangular region to obtain a skin color feature; and determine the face region in the face rectangular region according to the skin color feature.
[0117] In an embodiment, the proportion calculation module 630 is further configured to detect a first number of pixel points of the face region and a second number of pixel points of the face rectangular region; and calculate a proportion of the first number of pixel points to the second number of pixel points as the proportion of the face region in the face rectangular region.
[0118] In an embodiment, the exposure weight table includes a plurality of weight values, the weight values in the exposure weight table corresponding to the pixel points in the face rectangular region one by one, and the brightness calculation module 650 is further configured to determine a target weight value corresponding to a target pixel point in the exposure weight table, the target pixel point being any one of the plurality of pixel points included in the face rectangular region; and calculate the brightness of the face rectangular region according to the brightness values of the plurality of pixel points and the target weight values corresponding to the plurality of pixel points respectively.
[0119] In the embodiments of the present application, the electronic device can perform face detection on the target image to determine a face rectangular region in the target image, and then determine a face region in the face rectangular region and calculate a proportion of the face region in the face rectangular region, so as to determine an exposure weight table corresponding to the face rectangular region according to the proportion. When the proportion is less than a proportion threshold, the smaller the proportion is, the smaller the exposure weight corresponding to an edge region of the face rectangular region in the exposure weight table is. The edge region is other region of the face rectangular region except the face region. The brightness of the face rectangular region can be calculated based on the exposure weight table. The method of determining the exposure weight table according to the proportion of the face region in the face rectangular region can improve the adaptability of the exposure weight table to the face region and the edge region in the face rectangular region, thereby improving the accuracy of the image brightness calculation.
[0120] As shown in Figure 7 In one embodiment, an electronic device is provided, which can include:
[0121] a memory 710 storing executable program codes;
[0122] a processor 720 coupled with the memory 710;
[0123] The processor 720 invokes the executable program codes stored in the memory 710 to implement the image brightness calculation method provided in the above embodiments.
[0124] The memory 710 can include a random access memory (RAM) and a read-only memory (ROM). The memory 710 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 710 can include a program storage area and a data storage area. The program storage area can store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the above various method embodiments, etc. The data storage area can also store data created by the electronic device during use, etc.
[0125] The processor 720 can include one or more processing cores. The processor 720 connects various parts within the entire electronic device by various interfaces and lines, performs various functions of the electronic device and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 710, and calling data stored in the memory 710. Alternatively, the processor 720 can be implemented in at least one of a hardware form of a digital signal processing (DSP), a field-programmable gate array (FPGA), a programmable logic array (PLA). The processor 720 can integrate a combination of one or several of a central processing unit (CPU), a graphics processor (GPU), and a modem. Among them, the CPU mainly processes an operating system, a user interface, and an application program; the GPU is responsible for rendering and drawing display content; and the modem is used for processing wireless communication. It can be understood that the above-mentioned modem can also not be integrated into the processor 720, but can be implemented by a separate communication chip.
[0126] It can be understood that the electronic device can include more or less structural elements than the above structural block diagram, for example, including a power module, a physical key, a WiFi (Wireless Fidelity) module, a speaker, a Bluetooth module, a sensor, etc., and can also not be limited herein.
[0127] The embodiments of the present application disclose a computer readable storage medium storing a computer program, wherein the computer program causes a computer to execute the method described in the above embodiments.
[0128] In addition, the embodiments of the present application further disclose a computer program product, when the computer program product runs on a computer, causes the computer to execute all or part of the steps in any one of the image brightness calculation methods described in the above embodiments.
[0129] Those skilled in the art can understand that all or part of the steps of various methods in the above embodiments can be completed by instructing the relevant hardware through a program, and the program can be stored in a computer readable storage medium, including Read-Only Memory (ROM), Random Access Memory (RAM), Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), One-time Programmable Read-Only Memory (OTPROM), Electrically-Erasable Programmable Read-Only Memory (EEPROM), Compact Disc Read-Only Memory (CD-ROM) or other optical disk storage, magnetic disk storage, magnetic tape storage, or any other medium that can be used to carry or store data in a computer readable manner.
[0130] The above describes in detail the image brightness calculation method, device, electronic device and storage medium disclosed in the embodiments of the present application. The principles and implementation manners of the present application are described by applying specific examples. The above embodiment descriptions are only used to help understand the method and core idea of the present application. Meanwhile, for those skilled in the art, the specific implementation manners and application ranges can be changed according to the idea of the present application. In conclusion, the content of the specification should not be understood as a limitation of the present application.
Claims
1. A method of calculating luminance of an image, characterized by, The method comprises: performing face detection on a target image to determine a face rectangular region in the target image; determining a face region in the face rectangular region; calculating a proportion of the face region in the face rectangular region; if the proportion is greater than or equal to a proportion threshold, using a preset exposure weight table as an exposure weight table corresponding to the face rectangular region; if the proportion is less than the proportion threshold, adjusting the preset exposure weight table and using an adjusted exposure weight table as the exposure weight table corresponding to the face rectangular region; wherein a weight distribution of the preset exposure weight table satisfies a two-dimensional normal distribution, and a standard deviation of the adjusted exposure weight table is less than a preset standard deviation of the preset exposure weight table; based on the exposure weight table, calculating a brightness of the face rectangular region, wherein a weight value in the exposure weight table corresponds to a pixel point in the face rectangular region in a one-to-one manner; the determination of the face region in the face rectangular region comprises: performing skin color detection on the face rectangular region to obtain a skin color feature; based on the skin color feature, determining the face region in the face rectangular region.
2. The method of claim 1, wherein, the adjustment of the preset exposure weight table comprises: obtaining a preset standard deviation of the preset exposure weight table; based on the proportion, determining an adjustment proportion corresponding to the preset standard deviation; based on the preset standard deviation and the adjustment proportion, calculating a target standard deviation, wherein the target standard deviation is less than the preset standard deviation; adjusting the preset exposure weight table to obtain an adjusted exposure weight table, wherein a standard deviation of the adjusted exposure weight table is the target standard deviation.
3. The method according to claim 1 or 2, characterized in that, when the proportion is less than the proportion threshold, the smaller the proportion, the smaller the exposure weight corresponding to an edge region of the face rectangular region in the exposure weight table, wherein the edge region is a region other than the face region in the face rectangular region.
4. The method according to claim 1 or 2, characterized in that, the calculation of the proportion of the face region in the face rectangular region comprises: detecting a first number of pixel points of the face region and a second number of pixel points of the face rectangular region; calculating a proportion of the first number of pixel points and the second number of pixel points as the proportion of the face region in the face rectangular region.
5. The method according to claim 1 or 2, characterized in that, The exposure weight table comprises a plurality of weight values, and the calculation of the brightness of the face rectangular region based on the exposure weight table comprises: in the exposure weight table, determining a target weight value corresponding to a target pixel point; wherein the target pixel point is any one of a plurality of pixel points included in the face rectangular region; based on the brightness values of the plurality of pixel points and the target weight values corresponding to the plurality of pixel points, the brightness of the face rectangular region is calculated.
6. An apparatus for calculating luminance of an image, characterized by comprising: The device comprises: a face detection module configured to perform face detection on a target image to determine a face rectangular region in the target image; a region determination module configured to determine a face region in the face rectangular region; a proportion calculation module configured to calculate a proportion of the face region in the face rectangular region; The weight determination module is configured to: if the proportion is greater than or equal to a proportion threshold, use a preset exposure weight table as the exposure weight table corresponding to the face rectangular region; if the proportion is less than the proportion threshold, adjust the preset exposure weight table, and use the adjusted exposure weight table as the exposure weight table corresponding to the face rectangular region; wherein the weight distribution of the preset exposure weight table satisfies a two-dimensional normal distribution, and a standard deviation of the adjusted exposure weight table is less than a preset standard deviation of the preset exposure weight table; The brightness calculation module is configured to calculate brightness of the face rectangular region based on the exposure weight table, wherein a weight value in the exposure weight table corresponds to a pixel point in the face rectangular region in a one-to-one manner. The region determination module is further configured to perform skin color detection on the face rectangular region to obtain a skin color feature, and determine a face region in the face rectangular region according to the skin color feature.
7. An electronic device, comprising: The computer readable storage medium stores a computer program, wherein the computer program, when executed by a processor, causes the processor to perform the method of any one of claims 1 to 5. The computer readable storage medium stores a computer program, wherein the computer program, when executed by a processor, causes the processor to perform the method of any one of claims 1 to 5. 8. A computer-readable storage medium, characterized in that,
Citation Information
Patent Citations
A control method based on face region exposure
CN109918993A