Image adjusting method and electronic equipment
By determining the portrait area and face area in the image, generating gain image and mask image, and adjusting the brightness value of pixel points, the problem of image contrast reduction under backlight shooting is solved, and a better shooting effect is achieved.
Patent Information
- Application Number
- CN202311745508.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-11-23
- Filing Date
- 2023-12-15
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2043-12-15
AI Technical Summary
In backlight shooting scenes, the contrast of the image is easily reduced, resulting in poor shooting results.
By determining the portrait area and the face area in the image, generating a gain image and a mask image respectively, adjusting the brightness value of the pixel points to achieve brightness darkening and brightness protection.
It effectively improves the contrast of images in backlight scenes, eliminating or alleviating negative effects caused by backlight shooting, such as glow and glare.
Smart Images

Figure CN120070278A_ABST
Abstract
Description
[0001] This application claims the priority of a Chinese patent application with the application number 202311583519.2 and the application title "Image Adjustment Method and Terminal Device" submitted to the Chinese Patent Office on November 23, 2023, the entire content of which is incorporated herein by reference. Technical Field
[0002] This application relates to the field of terminal technologies, and in particular, to an image adjustment method and an electronic device. Background Art
[0003] With the continuous development of terminal device technologies, current terminal devices generally have the function of image shooting.
[0004] In daily life, there is a scenario of image shooting called backlight shooting, where backlight shooting is a situation where the subject to be photographed is exactly between the light source and the lens. When shooting in backlight, since the light in the picture is bright, it may bring about a situation of reducing the contrast of the picture, resulting in poor image shooting effects. Summary of the Invention
[0005] Embodiments of this application provide an image adjustment method and an electronic device, which are applied to the field of terminal technologies to improve the contrast of images taken in backlight scenarios.
[0006] In a first aspect, embodiments of this application propose an image adjustment method. The method includes:
[0007] Determine a portrait area and a face area in a first image;
[0008] Determine a mask image according to the face area in the first image, where the mask image is used to indicate the brightness adjustment degree of each first pixel point in the first image;
[0009] Determine a gain image according to the portrait area in the first image, where the gain image is used to reduce the brightness of the portrait area;
[0010] Adjust the brightness value corresponding to each second pixel point in a second image according to the mask image and the gain image.
[0011] In this implementation, by determining a gain image for the portrait area and then adjusting the brightness value of the pixel points in the second image based on the gain image, the brightness of the portrait area can be darkened, so as to alleviate or eliminate the negative effects caused by backlight shooting. At the same time, by determining a mask image for the face area and then adjusting the brightness value of the pixel points in the second image based on the mask image, the brightness protection of the face area can be achieved to a certain extent, avoiding the face being too dark after the brightness darkening process and affecting the final imaging effect.
[0012] In a possible implementation, determining a mask image according to the face region in the first image includes:
[0013] Determining the center point position of the face region in the first image;
[0014] For any first pixel point in the first image, determining a first distance between the pixel position of the first pixel point in the first image and the center point position;
[0015] Determining a mask value corresponding to the first pixel point according to the first distance corresponding to the first pixel point;
[0016] Determining the mask image according to the mask values respectively corresponding to the respective first pixel points in the first image.
[0017] In a possible implementation, determining the mask value corresponding to the first pixel point according to the first distance corresponding to the first pixel point includes:
[0018] If the first distance is greater than or equal to a preset distance, determining the mask value of the first pixel point as a first value, where the first value is the minimum value of the mask value; or,
[0019] If the first distance is less than the preset distance, determining the mask value of the first pixel point according to a preset transition coefficient and the first distance.
[0020] In this implementation, by determining the mask value according to the distance between the first pixel point and the center position of the face region, it is possible to achieve brightness protection only for the face region and avoid affecting the adjustment effect of brightness darkening for the remaining regions.
[0021] In a possible implementation, the first distance is inversely proportional to the mask value.
[0022] In a possible implementation, determining the mask value of the first pixel point according to a preset transition coefficient and the first distance includes:
[0023] Determining a first ratio according to the first distance and the preset distance;
[0024] Determining a first difference between a preset value and the first ratio, and determining a target ratio as the product of the first difference and the preset transition coefficient;
[0025] Determining the mask value of the first pixel point according to the product of the target ratio and the maximum value of the pixel value.
[0026] In this way, in the mask image, the mask value corresponding to the first pixel point closer to the center point of the face region is larger, and the mask value corresponding to the first pixel point farther from the center point of the face region is smaller. Thus, effective brightness protection for the face region can be achieved, and at the same time, brightness transition processing from the face region to other regions of the portrait part is realized.
[0027] In a possible implementation manner, determining a gain image according to the portrait region in the first image includes:
[0028] For any first pixel point outside the portrait region in the first image, determining the gain value of the first pixel point as the preset maximum gain value;
[0029] For any first pixel point inside the portrait region in the first image, determining the gain value of the first pixel point according to the maximum gain value and the preset minimum gain value;
[0030] Determining the gain image according to the respective gain values of the first pixel points in the first image.
[0031] In this implementation manner, by directly setting the gain value to the maximum gain value for the pixel points outside the portrait region, and then setting the gain value to a value within the range from the maximum gain value to the minimum gain value for the pixel points inside the portrait region, it is possible to achieve only brightness darkening processing for the portrait region and avoid problems such as poor brightness performance or abnormal brightness performance caused by brightness darkening for the remaining regions outside the portrait region.
[0032] In a possible implementation manner, determining the gain value of the first pixel point according to the maximum gain value and the preset minimum gain value includes:
[0033] Starting from the topmost position of the portrait region and moving downward along the first vertical direction, the portrait region is sequentially divided into M sub-regions, where M is an integer greater than or equal to 1, and the first vertical direction is the vertical direction of the first image;
[0034] Sequentially determining M target values within the numerical range from the minimum gain value to the maximum gain value, where the i-th target value among the M target values is less than the (i - 1)-th target value, and the value range of i is 1 to M;
[0035] For the j-th sub-region among the M sub-regions, determining the gain value corresponding to each first pixel point in the j-th sub-region as the j-th target value, where the value range of j is 1 to M.
[0036] In this implementation, for the pixel points within the portrait area, the gain value can increase successively from the top position of the portrait area downward along the first vertical direction, so as to significantly darken the brightness of the top part of the portrait area and slightly darken the brightness of the body part of the portrait area. Thus, it is possible to achieve brightness adjustment suitable for backlight shooting scenarios, adjust to obtain an appropriate image brightness condition, and then enhance the image contrast and eliminate or alleviate the negative effects in the output image.
[0037] In a possible implementation, the M sub-regions are divided according to the first step length, where the lengths of the 1st to M - 1th sub-regions in the first vertical direction are all the first step length, and the length of the Mth sub-region in the first vertical direction is less than or equal to the first step length; and,
[0038] The M target values are uniformly selected within the numerical range from the minimum gain value to the maximum gain value. The 1st target value among the M target values is the minimum gain value, and the Mth target value among the M target values is the maximum gain value.
[0039] In this implementation, it can be achieved that the pixel points in the portrait area can move downward along the first vertical direction, and the gain value uniformly increases from the minimum gain value to the maximum gain value.
[0040] In a possible implementation, according to the mask image and the gain image, adjusting the brightness values corresponding to each second pixel point in the second image includes:
[0041] For any second pixel point in the second image, determining the target mask value corresponding to the second pixel point in the mask image;
[0042] Determining the target gain value corresponding to the second pixel point in the gain image;
[0043] Adjusting the brightness value of the second pixel point according to the target gain value and the target mask value.
[0044] In a possible implementation, adjusting the brightness value of the second pixel point according to the target gain value and the target mask value includes:
[0045] Obtaining the initial brightness value of the second pixel point;
[0046] Determining a first adjustment value according to the product of the initial brightness value, the target gain value, and the second difference corresponding to the target mask value, where the second difference is the difference between the target mask value and the maximum value of the mask value;
[0047] Determining a second adjustment value according to the product of the initial brightness value and the target mask value;
[0048] Determine the sum of the first adjustment value and the second adjustment value, and determine the ratio of the sum value to the maximum value of the pixel values as the target brightness value of the second pixel point after adjustment.
[0049] In this implementation manner, the brightness adjustment of the second image can be effectively implemented to achieve dimming the brightness of the portrait area and protecting the brightness of the face area, while there is also a good transition effect between the brightness of the face area and the remaining areas in the portrait area. Thus, the contrast of the second image can be enhanced, and negative effects such as image blurring or glare can be eliminated or alleviated.
[0050] In a possible implementation manner, the generation time of the second image is later than the generation time of the first image.
[0051] For example, the first image is one of multiple preview images collected by the camera application; or, the first image is one of multiple collected images, and the multiple collected images are collected by the camera application in response to a user operation on the capture control.
[0052] And also for example, the second image is an image obtained by fusing multiple collected images.
[0053] In this implementation manner, by setting the specific selection of the first image and the second image, it can be ensured that the brightness adjustment process is performed on the output image that the camera application will finally output. And it is ensured that the determined gain image and mask image can be effectively applied in the brightness adjustment stage of the second image, thereby ensuring the orderly and effective execution of the brightness adjustment.
[0054] Second aspect, an embodiment of the present application provides an image adjustment device, which may be an electronic device, or a chip or a chip system inside the electronic device. The image adjustment device may include a display unit and a processing unit. When the image adjustment device is an electronic device, the display unit may be a display screen. The display unit is configured to perform the display step, so that the electronic device implements an image adjustment method described in the first aspect or any possible implementation manner of the first aspect. When the image adjustment device is an electronic device, the processing unit may be a processor. The image adjustment device may further include a storage unit, and the storage unit may be a memory. The storage unit is configured to store instructions, and the processing unit executes the instructions stored in the storage unit, so that the electronic device implements an image adjustment method described in the first aspect or any possible implementation manner of the first aspect. When the image adjustment device is a chip or a chip system inside the electronic device, the processing unit may be a processor. The processing unit executes the instructions stored in the storage unit, so that the electronic device implements an image adjustment method described in the first aspect or any possible implementation manner of the first aspect. The storage unit may be a storage unit inside the chip (for example, registers, caches, etc.), or a storage unit outside the chip and inside the electronic device (for example, read-only memory, random access memory, etc.).
[0055] Third aspect, an embodiment of the present application provides an electronic device, including a processor and a memory. The memory is configured to store code instructions, and the processor is configured to run the code instructions to execute the method described in the first aspect or any possible implementation manner of the first aspect.
[0056] Fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program or instructions are stored. When the computer program or instructions run on a computer, the computer is caused to execute the method described in the first aspect or any possible implementation manner of the first aspect.
[0057] Fifth aspect, an embodiment of the present application provides a computer program product including a computer program. When the computer program runs on a computer, the computer is caused to execute the method described in the first aspect or any possible implementation manner of the first aspect.
[0058] Sixth aspect, the present application provides a chip or a chip system, which includes at least one processor and a communication interface. The communication interface and the at least one processor are interconnected by a line, and the at least one processor is configured to run a computer program or instructions to execute the method described in the first aspect or any possible implementation manner of the first aspect. Among them, the communication interface in the chip may be an input / output interface, a pin or a circuit, etc.
[0059] In a possible implementation, the chip or chip system described above in this application further includes at least one memory, and instructions are stored in the at least one memory. The memory may be a storage unit inside the chip, such as a register, a cache, etc., or may be a storage unit of the chip (such as a read-only memory, a random access memory, etc.).
[0060] It should be understood that the technical solutions of the second to sixth aspects of this application correspond to those of the first aspect of this application, and the beneficial effects obtained by each aspect and the corresponding feasible implementation manners are similar, and will not be elaborated herein. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] Figure 1 It is a schematic diagram of the effect of contrast provided by an embodiment of this application;
[0062] Figure 2 It is a schematic diagram of the scene of image shooting provided by an embodiment of this application;
[0063] Figure 3 It is a schematic diagram of the negative effect provided by an embodiment of this application Figure 1 ;
[0064] Figure 4 It is a schematic diagram of the negative effect provided by an embodiment of this application Figure 2 ;
[0065] Figure 5 It is a schematic diagram of the hardware structure of a terminal device provided by an embodiment of this application;
[0066] Figure 6 It is a schematic diagram of the software structure of a terminal device provided by an embodiment of this application;
[0067] Figure 7 It is a schematic diagram of image selection provided by an embodiment of this application;
[0068] Figure 8 It is a schematic diagram of the processing process of image fusion provided by an embodiment of this application;
[0069] Figure 9 It is a schematic diagram of a mask provided by an embodiment of this application;
[0070] Figure 10 It is a schematic diagram of the first distance provided by an embodiment of this application;
[0071] Figure 11 It is a schematic diagram of a mask image provided by this application;
[0072] Figure 12 It is a schematic diagram of the implementation of determining the gain value of a pixel point provided by an embodiment of this application;
[0073] Figure 13 Schematic diagram of the enhanced image provided by this application;
[0074] Figure 14 Schematic diagram of the transition region provided by the embodiment of this application;
[0075] Figure 15 Schematic diagram of adjusting the brightness value of the second pixel point provided by the embodiment of this application. Detailed implementation manners
[0077] For the convenience of clearly describing the technical solutions of the embodiments of this application, the following briefly introduces some terms and technologies involved in the embodiments of this application:
[0078] 1. Contrast
[0079] The contrast of an image can be understood as the degree of brightness difference between the bright area and the dark area in the image. If there is an obvious difference between the bright area and the dark area in an image, then the contrast of this image is relatively high. On the contrary, if the difference between the bright area and the dark area is small, then the contrast is low. In image processing, contrast can affect the clarity and visual effect of the image.
[0080] If the contrast is high enough, then there are more gradation levels from black to white in the image, and the details and colors of the image will be more rich and clear. Exemplarily, if the contrast of the image is increased, then the bright area in the image will be brighter and the dark area will be darker.
[0081] If the contrast is low, it means that the difference degree between the bright area and the dark area in the image is small, and correspondingly, there are fewer gradation levels from black to white in the image, resulting in the details and colors in the image being difficult to identify. Specifically, when the contrast of the image is low, because there are few gradation levels from black to white, the image will present a grayish effect, that is, the image turns gray and the details are difficult to identify.
[0082] For example, reference can be made to Figure 1 to understand the influence of the high or low contrast on the image, Figure 1 which is a schematic diagram of the effect of contrast provided by the embodiment of this application.
[0083] As Figure 1 shown, for the same image, if the contrast of the image is low, it presents the effect shown in (a) in Figure 1 , that is, the overall image shows a grayish effect, and the details and colors are also difficult to identify.
[0084] However, if the contrast of the image is high, it presents Figure 1The effect shown in (b) is that the details and colors of the image will appear richer and clearer.
[0085] Understandably, Figure 1 The contrast ratios "high" and "low" are for Figure 1 The two images provided are relative to each other as references.
[0086] 2. Saturation
[0087] Saturation refers to the vividness of color, which can also be called purity. The higher the saturation of an image, the brighter the colors of the image.
[0088] 3. HDR Fusion
[0089] HDR (high dynamic range) fusion algorithm is an image processing technology that improves color and detail problems caused by non-uniform brightness of images. It fuses a high dynamic range image from multiple images shot with different brightness, thereby improving the color in the image and enhancing the details of the image. It is a very effective image enhancement technology.
[0090] The HDR fusion algorithm uses multiple photos with different brightness as the original images, each of which can be represented by pixel grayscale values, thereby constructing an image with a wider range so as to have stronger contrast and more grayscale values, as well as more details. At the same time, a richer scale transformation space can be obtained. The image can be made clearer by using image and contrast stretching algorithms. By using the HDR fusion algorithm, the sharpness and dynamic range of the image can be increased, thereby realizing the brightness enhancement processing of the HDR image.
[0091] 4. Other terms
[0092] In the embodiments of the present application, words such as "first" and "second" are used to distinguish the same or similar items with substantially the same functions and effects. For example, the first chip and the second chip are only used to distinguish different chips, and their order is not limited. Those skilled in the art can understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit them to be different.
[0093] It should be noted that in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0094] In the embodiments of the present application, "at least one" means one or more, and "a plurality" means two or more. "And / or" describes the association relationship of associated objects and indicates that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone, where A and B may be singular or plural. The character " / " generally represents an "or" relationship between the associated objects before and after. "At least one (item)" or its similar expression refers to any combination of these items, including any combination of single item(s) or plural item(s). For example, at least one (item) of a, b, or c may represent: a, b, c, a - b, a - c, b - c, or a - b - c, where a, b, and c may be single or multiple.
[0095] 5. Electronic device
[0096] The electronic device according to the embodiments of the present application may include a handheld device with an image capturing function, a vehicle-mounted device, etc. For example, some electronic devices are: mobile phone, tablet computer, handheld computer, laptop computer, mobile internet device (MID), wearable device, virtual reality (VR) device, augmented reality (AR) device, wireless terminal in industrial control, wireless terminal in self-driving, wireless terminal in remote medical surgery, wireless terminal in smart grid, wireless terminal in transportation safety, wireless terminal in smart city, wireless terminal in smart home, cellular phone, cordless phone, session initiation protocol (SIP) phone, wireless local loop (WLL) station, personal digital assistant (PDA), handheld device with wireless communication function, computing device or other processing devices connected to a wireless modem, vehicle-mounted device, wearable device, terminal device in a 5G network, or terminal device in a future evolved public land mobile network (PLMN), etc. The embodiments of the present application are not limited thereto.
[0097] By way of example and not limitation, in the embodiments of the present application, the electronic device may also be a wearable device. A wearable device, also known as a wearable intelligent device, is a general term for devices developed by applying wearable technologies to the intelligent design of daily wear, such as glasses, gloves, watches, clothing, and shoes.
[0098] The electronic device in the embodiments of the present application may also be referred to as: terminal device, user equipment (UE), mobile station (MS), mobile terminal (MT), access terminal, user unit, user station, mobile station, mobile terminal, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication device, user agent, or user device, etc.
[0099] In the embodiments of the present application, the electronic device or each network device includes a hardware layer, an operating system layer running on the hardware layer, and an application layer running on the operating system layer. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and a memory (also known as main memory). The operating system can be any one or more computer operating systems that implement service processing through processes, for example, Linux operating system, Unix operating system, Android operating system, iOS operating system, or Windows operating system, etc. The application layer includes applications such as a browser, an address book, a word processing software, and an instant messaging software.
[0100] Currently, terminal devices usually have the function of image capture. Exemplarily, a sensor module and a lens may be included in the terminal device to achieve the purpose of image capture.
[0101] To better understand the technical solution of the present application, the related technologies involved in the present application will be further introduced in detail below.
[0102] When using an electronic device for image capture, there is an image capture scenario called backlight capture, where backlight is a situation where the subject to be photographed is exactly between the light source and the lens. For example, reference may be made to Figure 2 to understand the backlight capture scenario. Figure 2 This is a schematic diagram of the image capture scenario for the embodiments of the present application.
[0103] As Figure 2 shown, when the user is backlit and uses the front camera for image capture, this situation where the subject 202 is between the light source 203 and the lens 201 may occur.
[0104] Figure 2 Exemplified is a scenario where the user uses the front camera to take an image. When the user uses the rear camera to take an image, it is also possible that the subject to be photographed is located between the light source and the lens as introduced above.
[0105] In the case of backlit photography introduced above, since the subject to be photographed is located between the lens and the light source, it is very likely that the contrast of the image in the picture is poorly presented.
[0106] Exemplarily, when the quality of the sensor module in the terminal device is poor, if an image is taken in the backlit scenario introduced above, due to the bright light in the picture, for example, non-imaging light from the sun or other strong light sources irradiates the lens, resulting in problems such as lens flare and halos, and accompanied by a significant reduction in the contrast of the picture. It should be understood that the "reduction" of the contrast introduced here is compared with the contrast of the image collected when taking an image in a non-backlit scenario. That is to say, usually, for the same shooting object, the contrast of the image taken in the backlit scenario is less than the contrast of the image taken in the non-backlit scenario.
[0107] Based on the above introduction, it can be understood that when the contrast of the image is low, the image will have a hazy effect. Then, for an image containing a portrait, a low contrast will cause negative effects such as the portrait in the picture looking blurred and whitish. The blurred effect can be understood as a hazy effect appearing on the portrait part, and the whitish effect can be understood as the overall color of the portrait part being whitish.
[0108] However, it should be understood that the whitish here is still due to the hazy effect of the image, resulting in the image looking gray and presenting a whitish effect. It can be understood by analogy with the feeling that the surrounding environment looks whitish when observing the surrounding environment with the human eye in a foggy weather. But actually, it still presents a hazy gray effect. Or it can also be referred to Figure 1 Understand, refer to Figure 1 It can be determined that Figure 1 in (a) compared with Figure 1 in (b), it presents a blurred effect (a hazy feeling), and a whitish feeling (still caused by the image looking gray).
[0109] In one implementation, the negative effects mentioned in this application are the related effects caused by the low contrast of the image. For example, when the contrast is less than the preset contrast, it can be considered that the contrast of the image is low. At this time, the negative effects that appear in the image are the negative effects introduced in this application. Or, specifically, in the case of backlit shooting, due to the influence of the backlit scene, the contrast of the picture is low, and the resulting image performance effects can be determined as the negative effects in this application.
[0110] That is to say, the negative effects introduced in this application can be understood as the effects caused by the low contrast of the image, where "low contrast" can be quantified as the contrast of the image being less than the preset contrast. Therefore, any effects that appear in the image due to the low contrast of the image can be the negative effects introduced in this application. The low contrast can be caused by the backlit shooting scene described above, or it can be caused by other reasons. This embodiment does not limit this.
[0111] Exemplarily, the negative effects can include the image being too white and the image being hazy as described above. This embodiment does not limit the specific negative effects.
[0112] To solve the problem that in the case of backlit shooting described above, negative effects appear in the image, resulting in poor image performance, it is usually necessary to adjust the contrast of the image so that the contrast performance in the image is better, thereby specifically alleviating or eliminating negative effects such as the image being too white and hazy.
[0113] In one implementation, the low contrast described above may cause negative effects in the portrait part of the image. Therefore, the contrast of the image can be adjusted to alleviate or eliminate the negative effects in the portrait part of the image. For example, it can be referred to Figure 3 to understand the implementation of adjusting the negative effects in the portrait part of the image. Figure 3 is a schematic diagram of the negative effects provided by the embodiments of this application. Figure 1 .
[0114] Figure 3 In (a) shows an image. Referring to Figure 3 it can be determined that the image may include a portrait, and the portrait part may have the negative effects of being hazy and too white as described above. In Figure 3 in (a), this negative effect is indicated by shading.
[0115] Then, by adjusting the contrast of the image, the negative effects in the portrait part can be eliminated or alleviated to a certain extent, thereby obtaining Figure 3The adjusted image shown in (b) therein. The negative effects in the portrait part can be eliminated or alleviated.
[0116] Currently, it is specifically introduced that the reduction of contrast causes negative effects in the portrait part of the picture. Therefore, the above Figure 3 exemplarily illustrates the elimination of negative effects for the portrait part (the implementation method for the analog face part is the same).
[0117] However, in fact, the reduction of contrast may cause the above-mentioned negative effects to appear in the whole image, not limited to the portrait part or the face part. Therefore, in the actual implementation process, when adjusting the contrast of the image, it is also possible to alleviate or eliminate the negative effects for the whole image in terms of visual effects.
[0118] For example, it can be referred to Figure 4 to understand the implementation of adjusting the negative effects for the whole image, Figure 4 which is a schematic illustration of the negative effects provided by the embodiments of the present application Figure 2 .
[0119] Figure 4 (a) in shows an image. It can be determined by referring to Figure 4 that the image may include a portrait, but in fact, the whole image may have the above-mentioned negative effects of being hazy and whitish. In Figure 4 (a), this negative effect is represented by shading.
[0120] Then, by adjusting the contrast of the image, the negative effects in the image can be eliminated or alleviated to a certain extent, so as to obtain Figure 4 the adjusted image shown in (b) therein. In terms of visual effects, it can be presented that the negative effects for the whole image can be eliminated or alleviated.
[0121] In the actual implementation process, specifically which part of the image has negative effects depends on the actual image generation situation, and this embodiment does not limit this. In short, the technical solution of the present application can alleviate or eliminate the negative effects caused by too low contrast in the image.
[0122] To solve the problem of negative effects in images, the present application proposes the following technical concept: The reason for the negative effects such as over - white and foggy introduced above is that the brightness of the portrait area in the image is too high. Therefore, the portrait area and the face area can be identified in the image, and then the portrait area is subjected to gain processing to reduce the brightness of the portrait area, so as to optimize the contrast in the backlight shooting scenario. At the same time, the face area is subjected to masking processing to avoid problems such as excessive reduction of face intensity or sudden change of face brightness, which may lead to abnormal brightness performance in the face area, so that the output image after shooting has a good contrast.
[0123] The technical solution provided by the present application can be applied to terminal devices. First, a brief introduction to terminal devices is given below.
[0124] Exemplarily, Figure 5 FIG. is a schematic diagram of the hardware structure of a terminal device provided by an embodiment of the present application.
[0125] The terminal device may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, a key 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.
[0126] Among them, the processor 110 may include one or more processing units. Among them, different processing units may be independent devices or integrated in one or more processors. A memory may also be provided in the processor 110 for storing instructions and data.
[0127] The terminal device realizes the display function through the GPU, the display screen 194, and the application processor, etc. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering.
[0128] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. In some embodiments, the terminal device may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0129] The terminal device can implement camera functions such as shooting and video recording through the ISP, camera 193, video codec, GPU, display screen 194, application processor, etc.
[0130] The camera 193 is used to capture static images or videos. In some embodiments, the terminal device may include one or N cameras 193, where N is a positive integer greater than 1.
[0131] The ISP is used to process the data fed back by the camera 193. For example, when taking a photo, the shutter is opened, and light passes through the lens and is transmitted to the camera's photosensitive element. The light signal is converted into an electrical signal, and the camera's photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. The ISP can also optimize the noise, brightness, and skin color of the image through algorithms. The ISP can also optimize parameters such as the exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 193.
[0132] It can be understood that the interface connection relationship between the modules illustrated in the embodiments of the present application is only for illustrative purposes and does not constitute a limitation on the structure of the terminal device. In other embodiments of the present application, the terminal device may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0133] The software system of the above terminal device may adopt a layered architecture, event-driven architecture, microkernel architecture, microservices architecture, or cloud architecture. In the embodiments of the present invention, a system with a layered architecture is taken as an example to exemplarily illustrate the software structure of the terminal device.
[0134] Exemplarily, Figure 6 FIG. is a schematic diagram of the software structure of a terminal device provided by an embodiment of the present application.
[0135] As Figure 6 shown, the layered architecture divides the software into several layers, and each layer has a clear role and division of labor. The layers communicate with each other through interfaces. In some embodiments, the system may include an application layer, an application framework layer, a hardware abstraction layer (HAL), a driver layer, and a hardware layer.
[0136] It should be noted that the embodiments of the present application take the Android system as an example for illustration. In other operating systems (such as the HarmonyOS, IOS system, etc.), as long as the functions implemented by each functional module are similar to those of the embodiments of the present application, the solutions of the present application can also be implemented.
[0137] Among them, the application layer may include a series of application program packages. As Figure 6As shown, the application package may include applications such as the camera and the gallery. Among them, the camera application is an application used to implement the image capture function introduced in this application. Also, after the image capture is completed, the user can view the captured image in the gallery application.
[0138] And the application layer may also include the calendar, phone, map, navigation, mailbox, social, wireless local area networks (WLAN), Bluetooth, music, video, short message, lock screen application, and settings application. Of course, the application layer may also include other application packages, such as third-party applications like payment applications, shopping applications, bank applications, and social applications, which are not limited in this application.
[0139] Among them, the application framework layer provides application programming interfaces (APIs) and programming frameworks for the applications in the application layer. For example, as Figure 6 shown, the application framework layer may include a camera access interface. The camera access interface may include camera management and camera devices. Among them, camera management can be used to provide an access interface for managing the camera, and the camera device can be used to provide an interface for accessing the camera.
[0140] Also, the application framework layer may also include some predefined functions. For example, it may include an activity manager, a window manager, a content provider, a view system, a resource manager, a notification manager, and a camera server unit, etc., which are not restricted in the embodiments of this application. Among them, the camera server unit in the application framework layer can be started at the startup stage of the terminal device and can be used to transfer and save relevant information of the camera.
[0141] Also, the hardware abstraction layer is used to abstract the hardware, implement the encapsulation of the Linux kernel driver, provide an interface upward, and shield the implementation details of the lower-layer hardware. For example, the hardware abstraction layer may include Figure 6 the camera hardware abstraction layer, other hardware device abstraction layers, and the camera algorithm library as shown.
[0142] Among them, the camera hardware abstraction layer may include camera device 1, camera device 2, etc. The camera hardware abstraction layer can be connected to the camera algorithm library, and the camera hardware abstraction layer can call the algorithms in the camera algorithm library.
[0143] The camera algorithm library may include algorithm instructions such as camera algorithms and image algorithms, as well as execute some image processing steps. Exemplarily, in the camera algorithm library, for example, a first algorithm or a first set of algorithms may be included, where the first algorithm or the first set of algorithms is used to implement the relevant processing for contrast debugging of portrait images introduced in this application.
[0144] Alternatively, it can also be understood that a processing unit is included in the HAL layer, where the processing unit is used to implement the relevant processing for contrast debugging of portrait images introduced in this application.
[0145] Moreover, the driver layer is used to provide drivers for different hardware devices. For example, the driver layer may include a camera driver, a digital signal processor driver, and a graphics processor driver. The camera driver is the driver layer of the camera device and is mainly responsible for interacting with the hardware module.
[0146] Moreover, the hardware layer may include sensors, image processors, digital signal processors, graphics processors, memories, and other hardware devices. It is used to interact with the camera driver to achieve the purpose of image capture.
[0147] During the photo-taking process, for example, the camera application in the application layer can respond to user operations and send an image acquisition instruction to the camera device in the camera access interface, where image acquisition includes image acquisition in the preview stage and images in the shooting stage. Then the camera device sends relevant instructions to the camera HAL, and the camera HAL sends relevant instructions to the camera device driver, and the camera device driver then interacts with the relevant sensors and processors in the hardware layer to complete the purpose of image capture.
[0148] After the image acquisition is completed, the collected image will be displayed in the camera application or the gallery application through the data flow opposite to that introduced above. Among them, in the opposite data flow, the collected image can also be further processed in some hierarchical structures.
[0149] For example, it can be set that the HAL layer will further process the collected image. Exemplarily, the HAL layer, for example, can call the first algorithm or the first set of algorithms in the camera algorithm library, and combine the interaction content with the relevant drivers in the driver layer and the relevant hardware units in the hardware layer to perform the contrast debugging introduced in this application on the collected image, so that the contrast map of the finally presented output image performs well.
[0150] Based on the above introduction, the specific implementation of contrast debugging for images provided by this application will be described below.
[0151] In this application, contrast adjustment of an image can be achieved based on a mask image determined according to a face region and a gain image determined according to a portrait region.
[0152] In one implementation, the technical solution of this application is to perform contrast adjustment on a to-be-displayed image to be output. The to-be-displayed image is an image generated by a camera application in response to a click operation on a capture button after the user clicks the capture button. By performing contrast adjustment on the to-be-displayed image, it is possible to ensure that the contrast performance of the finally captured output image is good.
[0153] Then, in order to ensure that the contrast adjustment of the to-be-displayed image can be achieved, the above-mentioned mask image and gain image can be determined in advance before the to-be-displayed image is generated. Then, the contrast of the to-be-displayed image can be directly adjusted according to the mask image and the gain image, and an output image that can be output after adjustment can be obtained.
[0154] Exemplarily, in this application, the to-be-displayed image that needs to be contrast-adjusted can be referred to as a second image, and the image generated before the second image for determining the mask image and the gain image can be referred to as a first image.
[0155] First, the selection methods of the first image and the second image will be briefly introduced in combination with Figure 7 This is a schematic diagram of image selection provided for an embodiment of this application. Figure 7
[0156] As Figure 7 shown, it is assumed that the user clicks the capture button at time t1. Then, before time t1, it is in the capture preview stage, and after time t1, it is in the stage of generating the to-be-displayed image.
[0157] During the capture preview stage, the camera of the terminal device continuously captures images to generate a preview stream. That is to say, the preview stream includes multiple images. As Figure 7 shown, for example, the preview stream includes images a1, a2, and a3, etc.
[0158] In addition, during the image generation stage, the camera application in the terminal device responds to the user operation on the capture button and can continuously capture n captured images (n is an integer greater than or equal to 1). For example, in the Figure 7 example, the terminal device continuously captures 6 captured images. Then, the terminal device can perform fusion processing on at least some of the n captured images to obtain Figure 7 the fused to-be-displayed image shown. The to-be-displayed image introduced here is also the second image that needs to be contrast-adjusted.
[0159] In a possible implementation, when selecting the first image for determining the mask image and the gain image, an image can be selected from the preview stream as the first image. Exemplarily, any image in the preview stream can be determined as the first image, or any image in the preview stream with a time interval less than a preset duration from the moment t1 can also be determined as the first image.
[0160] Alternatively, the first image can also be selected from the n captured images continuously captured in response to a user operation on the capture button. Exemplarily, the s-th image among the continuously captured n images can be determined as the reference image, and then the reference image can be used as the first image described in this application. For example, in Figure 7 the example, the 3rd image among the 6 continuously captured images is determined as the reference image, so the reference image b3 can be used as the first image described in this application.
[0161] In the actual implementation process, s can be preset, where s is an integer greater than or equal to 1 and less than or equal to n.
[0162] Alternatively, any one of the continuously captured n images can also be determined as the first image, and this embodiment does not limit this.
[0163] In a possible implementation manner, the first image in this application is an image generated at a node relatively later in the processing flow of the camera. For example, an image generated after the node located in tone mapping in the processing flow, or the image finally output by the camera in response to the user's capture operation (such as the reference image described above) is determined as the first image in this application.
[0164] Next, in combination with Figure 8 The reason for determining the mask image and the gain image based on the first image, and then adjusting the contrast of the second image according to the mask image and the gain image (that is, the image for determining the mask image and the gain image and the image for applying the mask image and the gain image are not the same). Instead of directly determining the mask image and the gain image based on the second image, and then determining the contrast of the second image according to the mask image and the gain image (that is, the image for determining the mask image and the gain image and the image for applying the mask image and the gain image are the same) will be further introduced. Figure 8 It is a schematic diagram of the processing process of image fusion provided by the embodiment of this application.
[0165] As Figure 8 shown, after capturing n consecutive captured images in response to a user operation on the capture button (that is Figure 8For the images b1 to b6), the continuous n captured images can be first fused to obtain an initial fused image.
[0166] Exemplarily, the fusion process introduced here can be the HDR fusion introduced above. Therefore, after image fusion, it is usually necessary to adjust the brightness of the fused image to obtain an image with normal brightness.
[0167] In Figure 8 the initial fused image has not been brightness-adjusted yet. Therefore, the initial fused image actually appears very dark and does not conform to human eye judgment, that is, it does not conform to the brightness of the real scene observed by the human eye. Therefore, the brightness information in the initial fused image has not been processed and its brightness information is inaccurate.
[0168] Continuing to refer to Figure 8 , after fusing to obtain the initial fused image, the next step is to perform brightness adjustment on the initial fused image. The purpose of brightness adjustment is to brighten the dark areas in the image and darken the bright areas so that the brightness effect in the image conforms to human eye judgment. The contrast adjustment introduced in this application is completed in the brightness adjustment stage. It can also be understood that the contrast adjustment is an adjustment operation in the brightness adjustment stage.
[0169] After performing brightness adjustment on the initial fused image, other image parameter adjustment processes can also be performed to obtain Figure 8 the final fused image shown, where the final fused image is the output image of the final image after taking a photo introduced above. If the user views the photo-taking result in the gallery application, the image viewed is the final fused image introduced here.
[0170] Then based on the current situation introduced, if the mask image and the gain image are determined according to the second image, then there are the following two options currently:
[0171] The first option is to determine the mask image and the gain image according to Figure 8 the initial fused image shown. However, the brightness information of the initial fused image has not been processed, so the brightness information of the initial fused image is inaccurate, and the mask image and the gain image determined according to the initial fused image cannot guarantee accuracy either.
[0172] Therefore, the mask image and the gain image cannot be determined according to the initial fused image.
[0173] The second option is to determine according to Figure 8The final fused image shown is used to determine the mask image and the gain image. However, the contrast adjustment is completed before the final fused image is obtained. Therefore, after the final fused image is obtained, it is no longer possible to apply the contrast parameters determined based on the final fused image to the contrast adjustment of the final fused image.
[0174] Therefore, although the mask image and the gain image determined based on the final fused image are accurate, they cannot be applied to the contrast adjustment.
[0175] Based on the above analysis, it can be determined that in this embodiment, the mask image and the gain image cannot be determined based on the second image. To achieve the contrast adjustment of the second image, the mask image and the gain image need to be determined in advance. Therefore, in this embodiment, the mask image and the gain image are selected to be determined based on the first image, and then the contrast of the second image is adjusted based on the mask image and the gain image.
[0176] Among them, the generation time of the first image is before the second image. Therefore, it can be ensured that the mask image and the gain image generated based on the first image are in time for the contrast parameter adjustment of the second image. And the first image in this embodiment is either the image in the preview stream introduced above or the reference image introduced above. Therefore, the first image can be obtained without undergoing fusion processing. Correspondingly, there is no need to perform related adjustment operations after fusion processing on the first image. Therefore, the generation speed of the first image is relatively fast. Correspondingly, the speed of determining the mask image and the gain image based on the first image is also relatively fast. Therefore, it can be ensured that the mask image and the gain image determined based on the first image can be effectively applied to the brightness adjustment of the second image. And determining the mask image and the gain image in advance can also improve the speed of contrast adjustment for the second image.
[0177] And, the contrast adjustment introduced in this embodiment is completed during Figure 8 the brightness adjustment stage introduced. Therefore, the mask image and the gain image actually adjust the contrast of the initial fused image shown in Figure 8 this embodiment. Therefore, the second image that needs to undergo contrast adjustment introduced in this embodiment is the initial fused image introduced here, and the initial fused image is the same concept as the to-be-displayed image introduced above.
[0178] After the brightness adjustment of the initial fused image, the final fused image shown in Figure 8 will be obtained. The final fused image is the output image of the camera application program's final image output.
[0179] The above introduced the related implementations of the first image and the second image. Next, the specific implementations of determining the mask image and the gain image will be introduced.
[0180] After determining the first image, the mask image and the gain image introduced above can be determined based on the first image. In a possible implementation, the preview image in the preview stream introduced above, as well as the n continuously captured images, can all be YUV images. Among them, YUV is a color encoding mode, where Y represents luminance, that is, the grayscale value, and UV respectively represent chrominance and chroma. Or these images introduced here can also be images in other formats, which depends on the implementation of the terminal device, and this embodiment does not limit this.
[0181] In this embodiment, before determining the mask image based on the first image and determining the gain image based on the first image, the face region and the portrait region can be first determined in the first image.
[0182] Exemplarily, for example, the face detection algorithm can be used to perform face detection on the first image to obtain the face region in the first image, and the representation of the face region can be, for example, a face frame. And, the portrait segmentation algorithm can also be used to perform portrait detection on the first image to obtain the portrait region in the first image.
[0183] After that, the mask image can be determined based on the face region in the first image, and the gain image can be determined based on the portrait region in the first image. The following will introduce these two parts separately.
[0184] The first part: Determine the mask image according to the face region in the first image.
[0185] In this embodiment, the role of the mask image is to protect the original brightness of the face region. Exemplarily, the mask image can indicate the brightness adjustment degree of each first pixel point in the first image, where the brightness adjustment degree is smaller closer to the center point position of the face region and larger farther away from the center point position of the face region, so as to effectively protect the original brightness of the face region.
[0186] To better understand the role of the mask image, the following will combine Figure 9 to briefly explain the principle of the mask. Figure 9 This is the mask schematic diagram provided by the embodiment of the present application.
[0187] As Figure 9 shown, assume that there is currently a 3×3 original image. In Figure 9The pixel values corresponding to each of the nine pixels in the original image are shown. And it is assumed that there is currently also a 3×3 mask image. In Figure 9 the pixel values corresponding to each of the nine pixel points in the mask image are also shown.
[0188] Exemplarily, it is assumed that an AND operation is performed on each pixel in the original image and the image at the corresponding position in the mask image. Then, correspondingly, the Figure 9 shown effect diagram can be obtained. Referring to Figure 9 the pixel values of each pixel point in the shown effect diagram, it can be understood that for the area in the mask image where the pixel value is 0, the corresponding pixel value in the effect diagram is also 0, thereby correspondingly realizing the screening or protection of a certain area.
[0189] Based on the above content, for example, the mask image can be determined through the following process.
[0190] 1. In the first image, determine the center point position of the face area.
[0191] Exemplarily, the manifestation form of the face area can be, for example, a face frame. Then, for example, based on the center of the face frame, the center point position of the face area can be determined. Or, when the manifestation form of the face area is an irregular area, based on the outer frame of the irregular area, the center point position of the face area can also be determined. This embodiment does not limit the implementation of determining the center point position.
[0192] Exemplarily, for example, the center point position of the face area can be represented as (centerX, centerY).
[0193] 2. For any first pixel point in the first image, determine the first distance between the pixel position of the first pixel point in the first image and the center point position.
[0194] Among them, the pixel point in the first image is called the first pixel point. And in this embodiment, the same processing will be performed for each first pixel point in the first image. Therefore, the following introduces it taking any first pixel point in the first image as an object.
[0195] In this embodiment, the first pixel point corresponds to a pixel position in the first image. Therefore, the first distance between the pixel position of the first pixel point in the first image and the center point position of the face area introduced above can be determined.
[0196] Exemplarily, for example, the pixel position of the first pixel point can be represented as (i, j), and the center point position of the face area can be represented as (centerX, centerY). Then, for example, the first distance can be determined according to these two coordinate positions.
[0197] Among them, the determination method of the first distance can be expressed as the following formula 1 for example:
[0198] rTemp = (i - centreX) * (i - centreX) + (j - centreY) * (j - centreY) Formula 1
[0199] Among them, rTemp is the first distance between the pixel position of the first pixel point and the center point position of the face area.
[0200] Furthermore, for example, it can be understood with reference to Figure 10 for understanding. Figure 10 is a schematic diagram of the first distance provided by the embodiment of the present application.
[0201] In Figure 10 16 first pixel points of the first image are exemplarily shown, and one square represents one first pixel point. Assuming that the pixel point a therein is the pixel point corresponding to the center point position of the face area, then the distance between the first pixel point b and the center point position can be understood with reference to Figure 10 d1 in, and the distance between the first pixel point c and the center point position can be understood with reference to Figure 10 d2 in. The processing method for the first distance of the remaining first pixel points is similar and will not be elaborated here.
[0202] 3. Determine the mask value corresponding to the first pixel point according to the first distance corresponding to the first pixel point.
[0203] In the backlight shooting scenario introduced in the present application, since more light enters at the contour of the portrait, the portrait area will appear over - bright. Correspondingly, the brightness adjustment in the present application is to reduce the brightness of the portrait area to improve the contrast of the image. At the same time, in the backlight shooting scenario, usually the brightness of the face area is normal, or at least there will be no over - bright situation. Therefore, in this embodiment, a mask image is set to ensure that when the brightness of the portrait area is reduced, the brightness of the face area is affected as little as possible.
[0204] Furthermore, if it is set that the face area completely maintains the original brightness and only the part of the portrait area other than the face area is reduced in brightness, then there will be a brightness discontinuity between the face area and the remaining areas of the portrait area other than the face area. Then, in order to ensure a good brightness transition between the face area and the remaining areas of the portrait area, in this embodiment, the mask value corresponding to each first pixel point can be determined, where the mask value is used to indicate the brightness adjustment degree corresponding to each first pixel point.
[0205] In this embodiment, for example, it can be set that the closer the first pixel point is to the center point position of the face region, the larger the corresponding mask value, and the smaller the degree of adjustment of the corresponding brightness value. Also, the farther the first pixel point is from the center point position of the face region, the smaller the corresponding mask value, and the greater the degree of adjustment of the corresponding brightness value.
[0206] For example, in Figure 10 the example, the first distance d1 corresponding to the first pixel point b is less than the first distance d2 corresponding to the first pixel point c. Therefore, the mask value corresponding to the first pixel point b is greater than the mask value corresponding to the first pixel point c, so as to achieve that the degree of protection received by the first pixel point b is greater, and the degree of adjustment of the corresponding brightness value is smaller.
[0207] Among them, the principle of the negative correlation correspondence between the mask value and the degree of adjustment of the brightness value will be introduced in detail in the following embodiments of brightness adjustment. Here, it can be temporarily understood that there is such a negative correlation correspondence.
[0208] Based on the above introduction, in this embodiment, the mask value corresponding to the first pixel point can be determined according to the first distance corresponding to the first pixel point.
[0209] In one implementation, for example, the first distance of the first pixel point can be compared with a preset distance. If the first distance is greater than the preset distance, it can be confirmed that the first pixel point is relatively far from the center point position of the face region. In this case, it can be considered that there is no need to perform brightness protection on this first pixel point. Therefore, the mask value of the first pixel point can be directly determined as the first value, where the first value can be the minimum value of the mask value.
[0210] Or, if the first distance is less than or equal to the preset distance, it can be confirmed that the first pixel point is not particularly far from the center point position of the face region, and a certain degree of brightness protection is still required. And based on the above introduction, it can be determined that in this embodiment, a transition process needs to be performed on the brightness. For example, the mask value of the first pixel point can be determined according to the preset transition coefficient and the first distance.
[0211] Exemplarily, in this embodiment, for example, a face mask radius r and a preset transition coefficient coefficien can be set. For example, the square of the face mask radius r can be determined as the preset distance described above. Then, the first distance rTemp corresponding to the first pixel point can be compared with the square of the face mask radius r to measure the distance of the first distance.
[0212] Also, in this embodiment, the value range of the mask value can be 0 to 255, that is, the minimum value of the mask value is 0, and the maximum value of the mask value is 255.
[0213] Based on this, if it is determined that the first distance rTemp corresponding to the first pixel point > r * r, it can be determined that the mask value corresponding to the first pixel point is 0. Among the first pixel points with a mask value of 0, during the subsequent brightness processing, they will not be protected by brightness, that is, their brightness may be affected by the brightness reduction process.
[0214] If it is determined that the first distance rTemp corresponding to the first pixel point ≤ r * r, then based on the preset transition coefficient coefficien and the first distance rTemp corresponding to the first pixel point, the mask value of the first pixel point can be determined.
[0215] In one implementation, for example, according to the first distance and the preset distance, the first ratio can be determined first, then the first difference between the preset value and the first ratio is determined, and the product of the first difference and the preset transition coefficient is determined as the target ratio. The preset value in this embodiment can be set to 1, for example, or it can also be set to other values, and this embodiment does not limit this.
[0216] Then, based on the product of the target ratio and the maximum value of the pixel value, the mask value of the first pixel point is determined.
[0217] The above-described process of determining the mask value of the first pixel point can be understood, for example, with reference to the following formula two.
[0218] ratio = coefficient * (1.0f - (rTemp / (r * r))) Formula Two
[0219] Among them, rTemp / (r * r) represents the first ratio described above. In the current example, the preset value can be 1.0f in Formula Two, and 1.0f represents 1.0 as a floating-point number, which can also be directly understood as the numerical value 1. ratio is the target ratio.
[0220] After that, for example, the determined target ratio ratio and the maximum value of the pixel value can be multiplied. Assuming that the value range of the pixel value is 0 to 255, the maximum value of the pixel value can be determined to be 255. Therefore, for example, the target ratio ratio can be multiplied by 255 to obtain the mask value corresponding to the first pixel point, which can be expressed as the mask value faceMask of the first pixel point = ratio * 255.
[0221] In the actual implementation process, the implementation method of determining the target ratio or the mask value is not limited to the above-described Formula Two. Adding coefficients on the basis of Formula Two, or performing an identical transformation on the basis of Formula Two, can achieve the purpose of determining the target ratio or the mask value.
[0222] Also, as can be understood with reference to the above formula (2), the larger the first distance of the first pixel point, the smaller the corresponding target ratio ratio. Then, further, the mask value corresponding to the first pixel point is smaller, and the degree of influence by the brightness adjustment is greater. Therefore, it can be understood that the first distance and the mask value are in an inverse proportional relationship. In one implementation, the mask value can be determined as long as it follows this principle, and the specific determination method can be selected and extended according to actual requirements.
[0223] 4. Determine a mask image according to the mask values respectively corresponding to the respective first pixel points in the first image.
[0224] In this embodiment, the size of the mask image is the same as the size of the first image. For example, if the first image includes W×T pixel points, the corresponding mask image also includes W×T pixel points. Therefore, it can be understood that each pixel point in the mask image corresponds one-to-one in position to each pixel point in the first image. Among them, both W and T are integers greater than or equal to 1.
[0225] After obtaining the mask values respectively corresponding to the respective first pixel points, the mask value corresponding to each first pixel point can be used as the pixel value of the pixel point at the corresponding position in the mask image, and then the mask image can be obtained. That is to say, the image formed by using the mask value corresponding to each first pixel point as the pixel value is the mask image in this embodiment.
[0226] Based on the above introduction content, for example, reference can be made to Figure 11 to understand the finally obtained mask image, Figure 11 which is a schematic diagram of the mask image provided by this application.
[0227] Figure 11 The image shown in [reference] is the mask image. The black part in the mask image can be understood as having a pixel value equal to 0 (the pixel value in the mask image is the mask value introduced above, so correspondingly, the mask value is equal to 0), and the pixel value of the white part is greater than 0 (correspondingly, the mask value is greater than 0).
[0228] Exemplarily, the white part corresponds to the face region and the transition region around the face in the first image. Its pixel value is greater than 0, which correspondingly means that the mask value of the first pixel points corresponding to the white part is greater than 0. Correspondingly, in the subsequent brightness adjustment stage, the brightness of these first pixel points will be protected to a certain extent, and it can also be understood that the influence of the brightness value adjustment generated by the brightness adjustment process is weakened.
[0229] In the mask image, the pixel value of the pixel closer to the center point of the face region is larger. Correspondingly, it means that the mask value of the first pixel at the corresponding position is larger, and the degree of brightness adjustment for the corresponding position is smaller. Furthermore, the degree of protection for the brightness of the first pixel is larger.
[0230] And, Figure 11 The corresponding black part of the neutralization is the non-face region in the first image except for the face region and the transition region. Its pixel value is 0, which correspondingly means that the mask value of the first pixel corresponding to the black part is equal to 0. Correspondingly, in the subsequent brightness adjustment stage, the brightness values of these first pixels will not be protected and will be directly affected by the brightness adjustment process.
[0231] In this embodiment, by setting the mask image, in the mask image, the mask value corresponding to the first pixel closer to the center point of the face region is larger, and the mask value corresponding to the first pixel farther from the center point of the face region is smaller. Thus, it can effectively achieve the brightness protection of the face region and at the same time achieve the brightness transition processing of other regions from the face region to the portrait part.
[0232] The above introduced the determination method of the mask image. Next, the determination method of the gain image will be described.
[0233] Second part: Determine the gain image according to the portrait region in the first image.
[0234] Based on the above analysis, it can be understood that in the backlight shooting scenario, because the edge part of the portrait receives the most light, it will cause the brightness of the portrait region to be too high, and then present a negative effect of being too white and hazy in the image. Therefore, it is necessary to reduce the brightness of the portrait part to achieve the purpose of optimizing glare and haziness.
[0235] Therefore, the gain image can be determined according to the portrait region in the first image. The function of the gain image is to reduce the brightness of the portrait region, thereby dimming the brightness of the portrait part in the first image. For example, the determination of the gain image can be achieved through the following steps.
[0236] 1. For any first pixel outside the portrait region in the first image, determine the gain value of the first pixel as the preset maximum gain value.
[0237] In this embodiment, for each first pixel in the first image, the gain value corresponding to each first pixel can be determined respectively, where the gain value is used to maintain or reduce the brightness value of the first pixel.
[0238] In one implementation, in this embodiment, the maximum gain value can be preset to 1. In this case, for the first pixel, its gain value is either 1, and correspondingly, the brightness value of the first pixel remains the original brightness value without any brightness reduction processing.
[0239] Alternatively, since the maximum gain value is only 1, the gain value of the first pixel is either less than 1, so that the brightness value of the first pixel can be reduced.
[0240] In this embodiment, it is necessary to perform brightness reduction processing on the portrait area. Therefore, for the areas other than the portrait area in the first portrait, their original brightness can be maintained, and only the brightness value of the portrait area needs to be reduced. Therefore, in this embodiment, the portrait area in the first image and the areas other than the portrait area in the first image can be processed separately.
[0241] For example, for any first pixel outside the portrait area in the first image, the gain value of the first pixel can be determined as the maximum gain value. Exemplarily, the maximum gain value can be 1, so that the brightness values of the areas other than the portrait area in the first image can be maintained unchanged.
[0242] 2. For any first pixel in the portrait area of the first image, determine the gain value of the first pixel according to the maximum gain value and the preset minimum gain value.
[0243] Secondly, for the portrait area in the first image, brightness reduction processing is required. In this embodiment, in addition to the maximum gain value that can be preset, for example, a minimum gain value (or called the initial gain value GainInit) can also be preset to control the degree of darkening of the portrait area and avoid the situation of over-darkening after the portrait area is darkened.
[0244] Exemplarily, the minimum gain value can be set to 0.8, that is to say, for the first pixel in the portrait area, its brightness value is reduced by at most 20%. The specific setting of the minimum gain value can be selected according to actual needs, and this embodiment does not limit this.
[0245] Then, for any first pixel in the portrait area of the first image, the gain value of the first pixel can be determined according to the maximum gain value and the minimum gain value. It can be understood that the gain value of the first pixel belongs to the numerical range from the maximum gain value to the minimum gain value.
[0246] Next, a possible implementation manner of determining the gain value of the first pixel according to the maximum gain value and the minimum gain value is introduced.
[0247] In a backlit shooting scenario, usually the top part of the portrait area is the part with the most incident light, and from the top position downwards, for example, extending to the body part of the portrait area, the incident light will gradually decrease. Therefore, in this embodiment, for each first pixel point in the portrait area of the first image, the gain value can be gradually increased from top to bottom, so as to achieve the purpose that the brightness reduction degree of the top part of the portrait is the highest, and from the top part of the portrait downwards, the brightness reduction degree gradually decreases.
[0248] In one implementation, the portrait area can be sequentially divided into M sub-areas along the first vertical direction from the topmost position of the portrait area, where M is an integer greater than or equal to 1, and the first vertical direction is the vertical direction of the first image.
[0249] Exemplarily, the topmost position introduced in this embodiment can be understood as the horizontal position in the horizontal direction of the first image corresponding to the pixel point at the topmost of the portrait area. For example, it can be understood with reference to Figure 12 for understanding. Figure 12 It is a schematic diagram for implementing the determination of the gain value of the pixel point provided by the embodiment of the present application.
[0250] Figure 12 The portrait area 1201 is shown in Figure 12 and assuming that the pixel point 1 in Figure 12 is used to indicate the pixel point at the topmost of the portrait area, then the horizontal position corresponding to the pixel point 1 in the horizontal direction of the first image, that is, the horizontal position indicated by the line a in
[0251] can be determined as the topmost position of the portrait area. Figure 12 And the horizontal direction and vertical direction of the first image are also shown in Figure 12 As shown, starting from the topmost position a of the portrait area, along the vertical direction of the first image downwards, the portrait area can be divided into Figure 12 the 5 sub-areas shown in Figure 12 In this embodiment, the portrait area is partially divided to obtain 5 sub-areas. Therefore, it should be understood that in the example of
[0252] only the portrait area within the range of the horizontal direction indicated by each brace is the divided sub-area when dividing the sub-areas.
[0253] Alternatively, the lengths of the M sub-regions can also be different. For example, M sub-regions are obtained by dividing each sub-region with a random length, or M sub-regions are obtained by dividing them with lengths increasing or decreasing in sequence. This embodiment does not limit the specific division method of the M sub-regions, and it can be selected according to actual needs.
[0254] In addition, in this embodiment, M target values can also be sequentially determined within the numerical range from the minimum gain value to the maximum gain value, where the i-th target value among the M target values is less than the (i - 1)-th target value, and the value range of i is from 1 to M. That is, M target values are determined within the numerical range from the minimum gain value to the maximum gain value in the order of increasing numerical values.
[0255] For example, the M target values are uniformly selected within the numerical range from the minimum gain value to the maximum gain value. The first target value among the M target values is the minimum gain value, and the M-th target value among the M target values is the maximum gain value. The meaning of uniform selection is that the difference between every two adjacent target values is the same.
[0256] Alternatively, M target values can also be randomly selected within the numerical range from the minimum gain value to the maximum gain value, as long as it is ensured that the M target values increase in sequence. This embodiment does not limit this.
[0257] For example, reference can be made to Figure 12 to understand the target values. As Figure 12 shown, assume that the minimum gain value is 0.8 and the maximum gain value is 1. Then it is necessary to select M target values within the numerical range of 0.8 to 1. In the current example, M is equal to 5.
[0258] Then, for example, 5 target values are uniformly selected within this numerical range. Exemplarily, the 5 target values selected can be Figure 12 shown as: 0.8, 0.85, 0.9, 0.95, and 1.
[0259] After determining the M sub-regions and the M target values, for the j-th sub-region among the M sub-regions, it can be determined that the gain value corresponding to each first pixel point in the j-th sub-region is the j-th target value, where the value range of j is from 1 to M.
[0260] For example, in Figure 12In the example, for the first sub-region, it is possible to determine that the gain value corresponding to each first pixel point in the first sub-region is 0.8 (i.e., the first target value). And for the second sub-region, it is possible to determine that the gain value corresponding to each first pixel point in the second sub-region is 0.85 (i.e., the second target value). The corresponding relationships between the remaining sub-regions and the target values can be inferred in this way.
[0261] Based on the implementation method introduced above, for the portrait region, it is possible to achieve that along the first vertical direction downward from the topmost position of the portrait region, the gain values corresponding to the first pixel points increase in sequence. Correspondingly, it is also possible to achieve that the degree of brightness reduction at the top of the head is the largest, and the degree of brightness reduction decreases in sequence from the top of the head downward. Thus, it is possible to adaptively adjust the abnormal brightness of the portrait in the backlight shooting scenario.
[0262] And it should also be noted that the above introduction is only one implementation method for determining the gain value for each first pixel point in the portrait region. However, it is not limited to the implementation method of dividing the sub-regions and determining the target values introduced above. The ultimate purpose of the above technical means is to achieve "for the portrait region, along the first vertical direction downward from the topmost position of the portrait region, the gain values corresponding to the first pixel points increase in sequence". As long as the purpose of increasing the gain value from top to bottom can be achieved, any possible implementation method can be extended.
[0263] For example, a function of the coordinate position of a pixel point and the corresponding gain value can also be preset. As long as the coordinate position of the pixel point is input into this function, this function can output the gain value corresponding to the pixel point. The role of this function is to make the gain values of the first pixel points in the portrait region transition from the minimum gain value to the maximum gain value along the first vertical direction downward.
[0264] 3. Determine the gain image according to the gain value of each first pixel point in the first image.
[0265] In this embodiment, the size of the gain image is the same as that of the first image. For example, the first image includes W×T pixel points, and correspondingly, the gain image also includes W×T pixel points. Therefore, it can be understood that each pixel point in the gain image corresponds one-to-one with each pixel point in the first image in terms of position.
[0266] After the gain value corresponding to each first pixel point, the gain value corresponding to each first pixel point can be used as the pixel value of the pixel point at the corresponding position in the gain image, and then the gain image can be obtained. That is to say, the image formed by using the gain value corresponding to each first pixel point as the pixel value is the gain image in this embodiment.
[0267] Based on the above introduction, for example, reference can be made to Figure 13 understand the finally obtained gain image, Figure 13 which is a schematic diagram of the gain image provided by this application.
[0268] Figure 13 The image shown in [reference] is the gain image. In the gain image, the darker the color of a part, the smaller the corresponding pixel value (the pixel value in the gain image is the gain value introduced above, so correspondingly, the smaller the gain value), and the lighter the color of a part, the larger the corresponding pixel value (correspondingly, the larger the gain value, where the pixel value of the pixel point with the lightest color is 1, which correspondingly means that the maximum value of the gain value is 1).
[0269] Exemplarily, the lighter part corresponds to the part outside the portrait area in the first image, and also some parts near the bottom position of the portrait area. Its gain value can be understood as equal to 1, which correspondingly means that the brightness of the first pixel point corresponding to this part of the area will maintain the original brightness and will not darken its brightness, thus realizing the brightness protection for the part outside the portrait area.
[0270] And, the darker part corresponds to the part of the portrait area in the first image (or the part of the portrait area except the bottom position). Its gain value is less than 1, which correspondingly means that the brightness gain of the first pixel point corresponding to this part of the area will be reduced, that is, the brightness of this part of the pixel points will be darkened, so as to realize the brightness darkening for the portrait area.
[0271] And reference is made to Figure 13 It can be understood that the part corresponding to the portrait area in the gain image becomes lighter in color in sequence along the first vertical direction, with a transitional effect. Correspondingly, when the brightness of the portrait area is darkened, the degree of brightness darkening is greater closer to the top of the head. From the top of the head position downwards, the degree of brightness darkening will decrease in sequence, so as to realize the adaptive reduction of the brightness of the portrait area photographed in the backlight scene.
[0272] When introducing the determination of the gain image in the above embodiments, the portrait area is used as the object for processing. In another implementation manner, in this application, a transition area can be determined based on the portrait area in the first image, and then the gain image is determined based on the transition area as the object.
[0273] For example, for each first pixel point outside the transition region in the first image, its gain value is determined as the maximum gain value. And for each first pixel point within the transition region in the first image, the gain value is gradually increased from top to bottom, thereby achieving the purpose that the brightness reduction degree of the top part of the portrait is the highest, and from the top part of the portrait downwards, the brightness reduction degree decreases successively.
[0274] First, the determination of the transition region will be introduced as follows:
[0275] In a possible implementation manner, for example, the length k of the transition region can be preset in advance, where k is a value greater than or equal to 0. After that, starting from the topmost position of the portrait region and moving down along the vertical direction of the first image, the end position at a distance of length k from the topmost position is determined, and then the portrait region between the topmost position and the end position in the first image is determined as the transition region.
[0276] Exemplarily, the topmost position introduced in this embodiment can be understood as the horizontal position in the horizontal direction of the first image corresponding to the topmost pixel point of the portrait region. And the end position can be understood as the end pixel point at a distance of length k from the topmost pixel point in the vertical direction, corresponding to the horizontal position in the horizontal direction of the first image. Therefore, the portrait region between the topmost position and the end position can be determined according to the topmost position and the end position.
[0277] For example, reference can be made to Figure 14 to understand the transition region. Figure 14 FIG. is a schematic diagram of the transition region provided for the embodiments of the present application.
[0278] In Figure 14 the portrait region 1401 in the first image is shown, and in Figure 14 the horizontal and vertical directions of the first image are also shown. The implementation manner is similar to the above embodiment and will not be elaborated here.
[0279] As Figure 14 shown, assuming that the pixel point 1 therein is used to indicate the topmost pixel point of the portrait region, then the horizontal position in the horizontal direction of the first image corresponding to the pixel point 1, that is, Figure 14 the horizontal position indicated by the line a in
[0280] can be determined as the topmost position of the portrait region. Figure 14The horizontal position indicated by line b in the figure is determined as the end position of the portrait area. After that, the portrait area between the topmost position a and the end position b can be determined as the transition area.
[0281] After that, for each first pixel point in the transition area, according to the maximum gain value and the minimum gain value, the gain value of each first pixel point is determined. The implementation method is similar to that introduced in the above embodiment. As long as the portrait area in the above embodiment is replaced with the transition area introduced here, the corresponding implementation method can be obtained. Therefore, it will not be elaborated here. Refer to Figure 14 For example, for the transition area, it can be realized that, starting from the topmost position and moving down along the first vertical direction, the gain values corresponding to each first pixel point gradually transition from 0.8 to 1.
[0282] In this implementation method, by determining a transition area with a vertical length of k downward from the top position based on the portrait area according to the preset length k, when performing the brightness reduction process of gradually reducing the brightness reduction degree from top to bottom for the portrait area, the brightness reduction of the portrait area can be realized from the topmost position of the portrait area downward within a certain length range. Refer to Figure 14 It can be understood that a part of the portrait area may not be within the range of the transition area.
[0283] Thus, when the length of the portrait area in the image is too long in the vertical direction, it can be avoided that for the part near the bottom of the portrait area that actually does not need to have its brightness reduced, unnecessary brightness processing is performed, and at the same time, for the part near the top of the area that actually needs to have its brightness reduced, the brightness reduction of the due degree is not obtained. Therefore, this implementation method of determining the transition area according to the preset length k can effectively improve the final brightness reduction effect, that is, a relatively large degree of brightness reduction can be achieved for the part of the portrait area near the top of the head, and by controlling the processing range of the brightness reduction process through the length k, unnecessary brightness reduction for the part of the portrait area near the bottom can be avoided.
[0284] In the actual implementation process, whether to determine the gain value of each first pixel point specifically based on the transition area introduced above or directly based on the portrait area can be selected according to actual needs. The various implementation methods in this embodiment are similar, and only the transition area and the portrait area need to be replaced with each other.
[0285] After determining the mask image and the gain image introduced above based on the first image, the second image can be processed for brightness adjustment according to the mask image and the gain image. In this embodiment, by adjusting the brightness values corresponding to the second pixel points respectively, the purpose of enhancing the contrast can be achieved. Therefore, the brightness adjustment can also be understood as contrast adjustment.
[0286] Based on the above introduction, it can be determined that in this embodiment, the brightness of the portrait area in the image is to be darkened to achieve the purpose of optimizing the negative effects of glare and fogginess. Therefore, in one possible implementation, when the second image is an image in YUV format, the Y channel of the second image can be directly extracted to obtain the brightness map of the second image, and then optimization processing is performed on the basis of the brightness map of the second image.
[0287] Among them, the brightness map of the second image can indicate the initial brightness values of the respective second pixel points in the second image, and the initial brightness value is the pixel value corresponding to the Y channel.
[0288] In addition, in this embodiment, the sizes of the second image and the first image are the same, so the pixel points in the second image and the gain image also correspond one by one. Therefore, for any second pixel point, the target mask value corresponding to the second pixel point can be determined in the mask image. In fact, the target mask value is the pixel value of the pixel point at the corresponding position in the mask image to the second pixel point.
[0289] For example, it can be understood with reference to Figure 15 which is Figure 15 a schematic diagram of the brightness value adjustment of the second pixel point provided by the embodiment of the present application.
[0290] As Figure 15 shown, assuming that the second image, the mask image, and the gain image are all 5×5 images, then the pixel points in these three images can correspond to each other in pixel positions. Taking the second pixel point a in the second image as an example, the pixel point at the same position as the second pixel point a in the mask image is the Figure 15 pixel point a1 shown, so the pixel value of the pixel point a1 in the mask image can be determined as the target mask value corresponding to the second pixel point a.
[0291] In addition, the target gain value corresponding to the second pixel point can also be determined in the gain image. Similarly, the target gain value is the pixel value of the pixel point at the corresponding position in the gain image to the second pixel point.
[0292] Similarly, it can be understood with reference to Figure 15 The pixel point at the same position as the second pixel point a in the gain image is Figure 15The pixel point a2 shown, so the pixel value of the pixel point a2 in the gain image can be determined as the target gain value corresponding to the second pixel point a.
[0293] After referring to Figure 15 , the brightness value of the second pixel point can be adjusted according to the target gain value and the target mask value of the second pixel point.
[0294] In one implementation, for example, the first adjustment value can be first determined according to the product of the initial brightness value, the target gain value, and the second difference corresponding to the target mask value. The second difference is the difference between the target mask value and the maximum value of the mask value. Then, according to the product of the initial brightness value and the target mask value, the second adjustment value can be determined. Finally, the sum of the first adjustment value and the second adjustment value can be determined, and the ratio of the sum value to the maximum value of the pixel value can be determined as the target brightness value after adjustment for the second pixel point.
[0295] For example, the above implementation process can be understood with reference to Formula 3:
[0296] Y` = (Y * Gain * (255 - maskV) + Y * maskV) / 255 Formula 3
[0297] Among them, Y is the initial brightness value of the second pixel point, Gain is the target gain value corresponding to the second pixel point, maskV is the target mask value corresponding to the second pixel point, and Y` is the target brightness value after adjustment for the second pixel point.
[0298] The first part "Y * Gain * (255 - maskV)" in the above Formula 3 corresponds to the first adjustment value introduced above.
[0299] Among them, the purpose of the part "Y * Gain" is to add the influence of the gain value on the basis of the initial brightness value of the second pixel point, so as to achieve the purpose of darkening the brightness.
[0300] And, the effect of "(255 - maskV)" is to perform the opposite effect processing on the mask part in the mask image. Specifically, for a mask value of 255, it will be processed as 0 in the current formula part, and for a mask value of 0, it will be processed as 255 in the current formula part. That is to say, the larger the mask value of a pixel point, the smaller the influence of brightness darkening here, and the smaller the mask value area, the greater the influence of brightness darkening here.
[0301] Based on the above introduction, it can be determined that in the mask image, the closer the pixel point is to the center point of the face area, the larger its mask value, and the less affected it is by brightness darkening. Also, the farther the pixel point is from the center point of the face area, the smaller its mask value, and the greater the impact of brightness darkening it receives, thus achieving brightness protection for the face area and at the same time achieving a smooth brightness transition from the face area to other areas in the portrait area.
[0302] Also, for the face area and the transition area near the face area, since the first part of the formula introduced above will protect these areas, the solution result of the first part of the formula introduced above will not correspondingly reflect the brightness situation of the face area and the transition area near the face area. For example, for the most central area of the face image, its mask value is 255. Substituting it into the first part of the above formula, the solution result is 0, but in fact, the brightness of the most central area of the face image is not 0.
[0303] Therefore, in addition to achieving brightness protection for the face area and the transition area near the face area, it is also necessary to ensure that the finally solved result can correctly reflect the brightness situation of the face area and the transition area near the face area. Therefore, the second part "Y*maskV" introduced above is also set in the formula, and this part corresponds to the second adjustment value introduced above.
[0304] In the second part here, for pixel points with a larger mask value, the corresponding solution result is closer to the original brightness, and for pixel points with a smaller mask value, the corresponding solution result is closer to 0.
[0305] Since both the first part and the second part introduced above are multiplied by the mask value with a value range of 0 to 255, based on the first part and the second part introduced above, dividing by 255 can obtain the target brightness value of the optimized second pixel point.
[0306] It can be understood that in the actual implementation process, the above-introduced formula three is performed for the brightness value of each second pixel point of the second image, and correspondingly, the optimized target brightness value corresponding to each second pixel point of the second image will be obtained. Then, based on the optimized target brightness value corresponding to each second pixel point of the second image, the brightness map of the second image after brightness adjustment is obtained, and the optimized second image can be obtained based on the adjusted brightness map.
[0307] It should be noted that the module names involved in the embodiments of the present application can all be defined as other names, as long as the functions of each module can be realized, and no specific restrictions are imposed on the module names.
[0308] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the embodiments of the present application are all information and data that have been authorized by the user or fully authorized by all parties. Moreover, the collection, use, and processing of relevant data need to comply with the relevant laws, regulations, and standards of relevant countries and regions, and corresponding operation entrances are provided for users to choose to authorize or refuse.
[0309] The image adjustment method of the embodiments of the present application has been described above. Next, the apparatus for executing the above method provided by the embodiments of the present application will be described. Those skilled in the art can understand that the method and the apparatus can be combined and cited with each other. The relevant apparatus provided by the embodiments of the present application can execute the steps in the above image adjustment method.
[0310] The image adjustment method provided by the embodiments of the present application can be applied to an electronic device with image taking and data processing functions. The electronic device includes a terminal device. The specific device form of the terminal device and the like can refer to the above relevant description and will not be elaborated here.
[0311] The embodiments of the present application provide a terminal device, which includes: a processor and a memory; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, so that the terminal device executes the above method.
[0312] The embodiments of the present application provide a chip. The chip includes a processor, and the processor is used to call a computer program in the memory to execute the technical solutions in the above embodiments. Its implementation principle and technical effects are similar to those of the above relevant embodiments and will not be elaborated here.
[0313] The embodiments of the present application also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the above method is implemented. The methods described in the above embodiments can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. If implemented in software, the functions can be stored on or transmitted over a computer-readable medium as one or more instructions or codes. The computer-readable medium can include a computer storage medium and a communication medium, and can also include any medium that can transfer a computer program from one place to another. The storage medium can be any target medium accessible by a computer.
[0314] In one possible implementation, the computer-readable medium may include RAM, ROM, compact disc read-only memory (CD-ROM), or other optical disc storage, magnetic disk storage, or any other medium targeted to carry or store the required program code in the form of instructions or data structures and accessible by a computer. Moreover, any connection is properly termed a computer-readable medium. For example, if software is transmitted from a website, server, or other remote source using coaxial cable, fiber optic cable, twisted pair, Digital Subscriber Line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of the medium. As used herein, disk and optical disc include optical disc, laser disc, optical disc, Digital Versatile Disc (DVD), floppy disk, and Blu-ray disc, where disks typically reproduce data magnetically, while optical discs utilize lasers to optically reproduce data. Combinations of the above should also be included within the scope of computer-readable media.
[0315] An embodiment of the present application provides a computer program product. The computer program product includes a computer program that, when run, causes a computer to execute the above method.
[0316] Embodiments of the present application are described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, as well as combinations of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to the processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable devices to generate a machine such that the instructions executed by the processing unit of the computer or other programmable data processing device generate means for implementing the functions specified in one Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0317] The above specific implementation manners further elaborate on the object, technical solution, and beneficial effects of the present invention. It should be understood that the above are only specific implementation manners of the present invention and are not used to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solution of the present invention should be included within the protection scope of the present invention.
Claims
1. An image adjustment method, characterized in that, it includes: Determine the portrait area and the face area in the first image; According to the face area in the first image, determine a mask image, where the mask image is used to indicate the brightness adjustment degree of each first pixel point in the first image; According to the portrait area in the first image, determine a gain image, where the gain image is used to reduce the brightness of the portrait area; According to the mask image and the gain image, adjust the brightness value corresponding to each second pixel point in the second image.
2. The method according to claim 1, characterized in that, The step of determining the mask image according to the face area in the first image includes: In the first image, determine the center point position of the face area; For any first pixel point in the first image, determine the first distance between the pixel position of the first pixel point in the first image and the center point position; According to the first distance corresponding to the first pixel point, determine the mask value corresponding to the first pixel point; According to the mask values corresponding to each first pixel point in the first image, determine the mask image.
3. The method according to claim 2, characterized in that, The step of determining the mask value corresponding to the first pixel point according to the first distance corresponding to the first pixel point includes: If the first distance is greater than a preset distance, determine the mask value of the first pixel point as a first value, where the first value is the minimum value of the mask value; or, If the first distance is less than or equal to the preset distance, determine the mask value of the first pixel point according to a preset transition coefficient and the first distance.
4. The method according to claim 3, characterized in that, The first distance is inversely proportional to the mask value.
5. The method according to claim 3 or 4, characterized in that, The step of determining the mask value of the first pixel point according to a preset transition coefficient and the first distance includes: According to the first distance and the preset distance, determine a first ratio; Determine the first difference between a preset value and the first ratio, and determine the product of the first difference and the preset transition coefficient as the target ratio; According to the product of the target ratio and the maximum value of the pixel value, determine the mask value of the first pixel point.
6. The method according to any one of claims 1-5, characterized in that, The step of determining the gain image according to the portrait area in the first image includes: For any first pixel point outside the portrait area in the first image, determine the gain value of the first pixel point as the maximum gain value set in advance; For any first pixel point inside the portrait area in the first image, determine the gain value of the first pixel point according to the maximum gain value and the minimum gain value set in advance; According to the gain values of each first pixel point in the first image, determine the gain image.
7. The method according to claim 6, characterized in that, Determining the gain value of the first pixel according to the maximum gain value and a preset minimum gain value includes: Starting from the topmost position of the portrait area and moving downward along a first vertical direction, dividing the portrait area into M sub-areas in sequence, where M is an integer greater than or equal to 1, and the first vertical direction is the vertical direction of the first image; Sequentially determining M target values within the numerical range from the minimum gain value to the maximum gain value, where the i-th target value among the M target values is less than the (i - 1)-th target value, and the value range of i is 1 to M; For the j-th sub-area among the M sub-areas, determining that the gain value corresponding to each first pixel in the j-th sub-area is the j-th target value, where the value range of j is 1 to M.
8. The method according to claim 7, wherein, The M sub-areas are divided according to a first step length, where the lengths of the first to the M - 1-th sub-areas in the first vertical direction are all the first step length, and the length of the M-th sub-area in the first vertical direction is less than or equal to the first step length; and, The M target values are uniformly selected within the numerical range from the minimum gain value to the maximum gain value, the first target value among the M target values is the minimum gain value, and the M-th target value among the M target values is the maximum gain value.
9. The method according to any one of claims 1 - 8, wherein, Adjusting the brightness value corresponding to each second pixel in the second image according to the mask image and the gain image includes: For any second pixel in the second image, determining the target mask value corresponding to the second pixel in the mask image; Determining the target gain value corresponding to the second pixel in the gain image; Adjusting the brightness value of the second pixel according to the target gain value and the target mask value.
10. The method according to claim 9, wherein, Adjusting the brightness value of the second pixel according to the target gain value and the target mask value includes: Obtaining the initial brightness value of the second pixel; Determining a first adjustment value according to the product of the initial brightness value, the target gain value, and a second difference corresponding to the target mask value, where the second difference is the difference between the target mask value and the maximum value of the mask value; Determining a second adjustment value according to the product of the initial brightness value and the target mask value; Determining the sum of the first adjustment value and the second adjustment value, and determining the ratio of the sum value to the maximum value of the pixel value as the target brightness value after adjustment of the second pixel.
11. The method according to any one of claims 1 - 10, wherein, The first image is one of multiple preview images collected by a camera application; or, the first image is one of multiple captured images, and the multiple captured images are captured by the camera application in response to a user operation on a photographing control.
12. The method according to claim 11, wherein, the second image is an image obtained by fusing the multiple captured images.
13. An electronic device, wherein, comprising: a processor and a memory; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, so that the electronic device executes the method according to any one of claims 1-12.
14. A computer-readable storage medium storing a computer program, wherein, the computer program, when executed by a processor, implements the method according to any one of claims 1-12.
15. A chip system, wherein, comprising at least one processor and a communication interface, the communication interface and the at least one processor are interconnected by a line, and the at least one processor is configured to run a computer program or instructions to execute the method according to any one of claims 1-12.
16. A computer program product, wherein, comprising a computer program, when the computer program is run, it causes a computer to execute the method according to any one of claims 1-12.
Citation Information
Patent Citations
Backlight portrait scene photographing processing method and device
CN104038704A
Image processing method, device, mobile terminal and computer readable storage medium
CN107451969A
Image processing method and device, storage medium and electronic device
CN110047060A
Image information processing method and device, storage medium and electronic equipment
CN110473156A
Image processing method and device, electronic equipment and computer readable storage medium
CN111402135A