Image adjustment methods and electronic devices
By identifying portrait and face areas in backlit shooting and adjusting brightness values using mask and gain images, the problem of low contrast in backlit shooting is solved, improving image contrast and visual effects.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-15
- Publication Date
- 2026-03-13
Smart Images

Figure CN120070278B_ABST
Abstract
Description
[0001] This application claims priority to Chinese Patent Application No. 202311583519.2, filed on November 23, 2023, entitled "Image Adjustment Method and Terminal Device", the entire contents of which are incorporated herein by reference. Technical Field
[0002] This application relates to the field of terminal technology, and in particular to an image adjustment method and an electronic device. Background Technology
[0003] With the continuous development of terminal device technology, current terminal devices usually have the function of image capture.
[0004] In everyday life, there is a scenario where images are shot in backlight, where the subject is positioned directly between the light source and the lens. In backlighting, the bright light in the frame can reduce contrast, resulting in poor image quality. Summary of the Invention
[0005] This application provides an image adjustment method and electronic device, applied in the field of terminal technology, to improve the contrast of images captured in backlit scenes.
[0006] In a first aspect, embodiments of this application propose an image adjustment method. The method includes:
[0007] Identify the human figure region and the face region in the first image;
[0008] Based on the face region in the first image, a mask image is determined. The mask image is used to indicate the degree of brightness adjustment for each first pixel in the first image.
[0009] Based on the human figure region in the first image, a gain image is determined, which is used to reduce the brightness of the human figure region.
[0010] Based on the mask image and the gain image, adjust the brightness value of each second pixel in the second image.
[0011] In this implementation, a gain image is determined for the portrait area, and then the brightness values of pixels in the second image are adjusted based on the gain image. This achieves brightness suppression processing for the portrait area, mitigating or eliminating the negative effects caused by backlighting. Simultaneously, a mask image is determined for the face area, and then the brightness values of pixels in the second image are adjusted based on the mask image. This provides a degree of brightness protection for the face area, preventing the face from becoming too dark after brightness suppression processing, which would negatively impact the final image quality.
[0012] In one possible implementation, determining the mask image based on the face region in the first image includes:
[0013] In the first image, determine the location of the center point of the face region;
[0014] For any first pixel in the first image, determine the first distance between the pixel position and the center point position in the first image;
[0015] The mask value corresponding to the first pixel is determined based on the first distance corresponding to the first pixel.
[0016] The mask image is determined based on the mask value corresponding to each first pixel in the first image.
[0017] In one possible implementation, determining the mask value corresponding to the first pixel based on the first distance corresponding to the first pixel includes:
[0018] If the first distance is greater than or equal to the preset distance, then the mask value of the first pixel is determined as the first value, which is the minimum value of the mask; or,
[0019] If the first distance is less than the preset distance, the mask value of the first pixel is determined based on the preset transition coefficient and the first distance.
[0020] In this implementation, the mask value is determined based on the distance between the first pixel and the center of the face region, thereby enabling brightness protection only for the face region and avoiding affecting the brightness adjustment effect for other regions.
[0021] In one possible implementation, the first distance is inversely proportional to the mask value.
[0022] In one possible implementation, determining the mask value of the first pixel based on a preset transition coefficient and a first distance includes:
[0023] Determine the first ratio based on the first distance and the preset distance;
[0024] Determine the first difference between the preset value and the first ratio, and determine the target ratio by multiplying the first difference and the preset transition coefficient;
[0025] The mask value of the first pixel is determined by multiplying the target ratio and the maximum value of the pixel.
[0026] In this way, the mask value of the first pixel in the mask image can be larger the closer it is to the center point of the face region, and smaller the mask value of the first pixel in the mask image can be further away from the center point of the face region. This can effectively protect the brightness of the face region, while also achieving brightness transition processing from the face region to other areas of the portrait.
[0027] In one possible implementation, determining the gain image based on the human figure region in the first image includes:
[0028] For any first pixel in the first image that is outside the human figure area, the gain value of the first pixel is determined to be the preset maximum gain value;
[0029] For any first pixel within the human image region in the first image, determine the gain value of the first pixel based on the maximum gain value and the preset minimum gain value;
[0030] The gain image is determined based on the gain value of each first pixel in the first image.
[0031] In this implementation, the gain value is set to the maximum gain value for pixels outside the portrait area, and the gain value is set to a value within the range of the maximum to the minimum gain value for pixels within the portrait area. This allows for brightness suppression processing only on the portrait area, and avoids the problem of poor or abnormal brightness performance caused by suppressing the brightness of other areas outside the portrait area.
[0032] In one possible implementation, determining the gain value of the first pixel based on the maximum gain value and a preset minimum gain value includes:
[0033] Starting from the top of the portrait area, divide the portrait area into M sub-regions along the first vertical direction downwards, 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] Within the range of minimum gain value to maximum gain value, M target values are determined sequentially, where the i-th target value among the M target values is less than the (i-1)-th target value, and the value of i ranges from 1 to M.
[0035] For the j-th sub-region among M sub-regions, determine the gain value corresponding to each first pixel in the j-th sub-region as the j-th target value, where the value of j ranges from 1 to M.
[0036] In this implementation, the gain value of pixels within the portrait area can be increased sequentially downwards along a first vertical direction from the top of the head. This allows for greater darkness of the top portion of the head and less darkness of the body. This enables brightness adjustment suitable for backlit shooting scenarios, achieving appropriate image brightness, improving image contrast, and eliminating or mitigating negative effects in the output image.
[0037] In one possible implementation, the M sub-regions are divided according to the first step length, where the length of the 1st to M-1th sub-regions in the first vertical direction is 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 from the range of minimum gain value to maximum gain value. The first 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, the pixels in the portrait area can be moved downwards along the first vertical direction, and the gain value can be increased uniformly from the minimum gain value to the maximum gain value.
[0040] In one possible implementation, the brightness value corresponding to each second pixel in the second image is adjusted based on the mask image and the gain image, including:
[0041] For any second pixel in the second image, determine the target mask value corresponding to the second pixel in the mask image;
[0042] Determine the target gain value corresponding to the second pixel in the gain image;
[0043] Adjust the brightness value of the second pixel based on the target gain value and the target mask value.
[0044] In one possible implementation, adjusting the brightness value of the second pixel based on the target gain value and the target mask value includes:
[0045] Obtain the initial brightness value of the second pixel;
[0046] The first adjustment value is determined by multiplying 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.
[0047] The second adjustment value is determined based on the product of the initial brightness value and the target mask value;
[0048] Determine the sum of the first and second adjustment values, and then use the ratio of the summed value to the maximum pixel value as the target brightness value for the second pixel after adjustment.
[0049] This implementation effectively adjusts the brightness of the second image, darkening the portrait area while protecting the face area, and ensuring a smooth transition in brightness between the face area and other areas of the portrait. This improves the contrast of the second image and eliminates or mitigates negative effects such as blurring or glare.
[0050] In one possible implementation, the second image is generated later than the first image.
[0051] For example, the first image is one of a plurality of preview images captured by the camera application; or, the first image is one of a plurality of captured images captured by the camera application in response to user actions on the camera control.
[0052] And, for example, the second image is an image obtained by fusing multiple acquired images.
[0053] In this implementation, by setting the specific selection of the first and second images, it can be ensured that the brightness adjustment process is performed on the final output image to be produced by the camera application. Furthermore, it ensures that the determined gain image and mask image can be effectively applied in the brightness adjustment stage of the second image, thereby guaranteeing the orderly and effective execution of the brightness adjustment.
[0054] Secondly, embodiments of this application provide an image adjustment apparatus, which may be an electronic device, a chip, or a chip system within an electronic device. The image adjustment apparatus may include a display unit and a processing unit. When the image adjustment apparatus is an electronic device, the display unit may be a display screen. The display unit is used to perform display steps to enable the electronic device to implement an image adjustment method described in the first aspect or any possible implementation of the first aspect. When the image adjustment apparatus is an electronic device, the processing unit may be a processor. The image adjustment apparatus may further include a storage unit, which may be a memory. The storage unit is used to store instructions, and the processing unit executes the instructions stored in the storage unit to enable the electronic device to implement an image adjustment method described in the first aspect or any possible implementation of the first aspect. When the image adjustment apparatus is a chip or a chip system within an electronic device, the processing unit may be a processor. The processing unit executes the instructions stored in the storage unit to enable the electronic device to implement an image adjustment method described in the first aspect or any possible implementation of the first aspect. The storage unit can be a storage unit within the chip (e.g., a register, cache, etc.) or a storage unit located outside the chip within the electronic device (e.g., a read-only memory, random access memory, etc.).
[0055] Thirdly, embodiments of this application provide an electronic device including a processor and a memory, the memory for storing code instructions, and the processor for running the code instructions to perform the methods described in the first aspect or any possible implementation of the first aspect.
[0056] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program or instructions that, when executed on a computer, cause the computer to perform the methods described in the first aspect or any possible implementation thereof.
[0057] Fifthly, embodiments of this application provide a computer program product including a computer program, which, when run on a computer, causes the computer to perform the methods described in the first aspect or any possible implementation thereof.
[0058] Sixthly, this application provides a chip or chip system including at least one processor and a communication interface. The communication interface and the at least one processor are interconnected via a circuit. The at least one processor is used to run computer programs or instructions to perform the methods described in the first aspect or any possible implementation of the first aspect. The communication interface in the chip can be an input / output interface, pins, or circuits, etc.
[0059] In one possible implementation, the chip or chip system described above in this application further includes at least one memory storing instructions. The memory can be an internal storage unit of the chip, such as a register or cache, or it can be a storage unit of the chip itself (e.g., read-only memory, random access memory, etc.).
[0060] It should be understood that the second to sixth aspects of this application correspond to the technical solutions of the first aspect of this application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation are similar, and will not be repeated here. Attached Figure Description
[0061] Figure 1 This is a schematic diagram illustrating the contrast effect provided in an embodiment of this application;
[0062] Figure 2 A schematic diagram of a scene captured by images in an embodiment of this application;
[0063] Figure 3 Illustration of the negative effects provided in the embodiments of this application Figure 1 ;
[0064] Figure 4 Illustration of the negative effects provided in the embodiments of this application Figure 2 ;
[0065] Figure 5 This is a schematic diagram of the hardware structure of a terminal device provided in an embodiment of this application;
[0066] Figure 6 This is a schematic diagram of the software structure of a terminal device provided in an embodiment of this application;
[0067] Figure 7 This is a schematic diagram of image selection provided for an embodiment of this application;
[0068] Figure 8 A schematic diagram illustrating the image fusion processing procedure provided in an embodiment of this application;
[0069] Figure 9 A schematic diagram of the mask provided in the embodiments of this application;
[0070] Figure 10 A schematic diagram of the first distance provided for an embodiment of this application;
[0071] Figure 11 A schematic diagram of the mask image provided in this application;
[0072] Figure 12 This is a schematic diagram illustrating the implementation of determining the gain value of a pixel in an embodiment of this application;
[0073] Figure 13 A schematic diagram of the gain image provided in this application;
[0074] Figure 14 A schematic diagram of the transition region provided in the embodiments of this application;
[0075] Figure 15 This is a schematic diagram illustrating the adjustment of the brightness value of the second pixel in an embodiment of this application. Detailed Implementation
[0076] To facilitate a clear description of the technical solutions in the embodiments of this application, some terms and technologies involved in the embodiments of this application will be briefly introduced below:
[0077] 1. Contrast
[0078] Image contrast can be understood as the degree of difference in brightness between bright and dark areas in an image. If there is a significant difference between the bright and dark areas of an image, then the image has high contrast. Conversely, if the difference between the bright and dark areas is small, then the contrast is low. In image processing, contrast can affect the sharpness and visual effect of an image.
[0079] If the contrast is high enough, the more gradations from black to white there will be in the image, resulting in richer and clearer details and colors. For example, increasing the contrast of an image can make bright areas brighter and dark areas darker.
[0080] Low contrast means that the difference between bright and dark areas in an image is smaller, resulting in fewer gradations from black to white. Consequently, details and colors in the image become harder to discern. Specifically, when an image has low contrast, the fewer gradations from black to white result in a hazy, grayish appearance, making details difficult to identify.
[0081] For example, you can refer to Figure 1 Understanding the impact of contrast on images Figure 1 This is a schematic diagram illustrating the contrast effect provided in an embodiment of this application.
[0082] like Figure 1 As shown, for the same image, if the image has low contrast, it will appear... Figure 1 The effect shown in (a) is that the image as a whole appears grayish, and details and colors are difficult to discern.
[0083] However, if the image has high contrast, it will appear... Figure 1The effect shown in (b) is that the details and colors of the image will be more rich and clear.
[0084] Understandable, Figure 1 The "high" and "low" contrast ratios described herein are for... Figure 1 The two images provided serve as references to each other.
[0085] 2. Saturation
[0086] Saturation refers to the vividness of a color, also known as purity. The higher the saturation of an image, the more vivid the colors appear.
[0087] 3. HDR fusion
[0088] HDR (high dynamic range) fusion algorithm is an image processing technique that improves color and detail caused by non-uniform brightness in images. It improves the color and enhances the detail of the image by fusing multiple images with different brightness levels. It is a very effective image enhancement technique.
[0089] HDR fusion algorithms use multiple photos with different brightness levels as the original images, each of which can be represented by pixel grayscale values. This allows for the construction of a wider range of images, resulting in stronger contrast, more grayscale values, and more detail. It also provides a richer scale transformation space. By utilizing image and contrast stretching algorithms, images can be made clearer. By using HDR fusion algorithms, the sharpness and dynamic range of images can be increased, thereby achieving brightness enhancement processing for HDR images.
[0090] 4. Other terms
[0091] In the embodiments of this application, terms such as "first" and "second" are used to distinguish identical or similar items with substantially the same function and purpose. For example, "first chip" and "second chip" are used only to distinguish different chips and do not limit their order of execution. Those skilled in the art will understand that terms such as "first" and "second" do not limit the quantity or execution order, and that "first" and "second" do not necessarily imply that they are different.
[0092] It should be noted that, in the embodiments of this application, the terms "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design scheme described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0093] In this application embodiment, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, a--c, bc, or abc, where a, b, and c can be single or multiple.
[0094] 5. Electronic equipment
[0095] The electronic devices in this application embodiment may include handheld devices with image capturing capabilities, vehicle-mounted devices, etc. For example, some electronic devices include: mobile phones, tablets, PDAs, laptops, mobile internet devices (MIDs), wearable devices, virtual reality (VR) devices, augmented reality (AR) devices, wireless terminals in industrial control, wireless terminals in self-driving vehicles, wireless terminals in remote medical surgery, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, cellular phones, cordless phones, session initiation protocol (SIP) phones, wireless local loop (WLL) stations, personal digital assistants (PDAs), handheld devices with wireless communication capabilities, computing devices or other processing devices connected to a wireless modem, in-vehicle devices, wearable devices, terminal devices in 5G networks, or future evolution of public land mobile communication networks. Terminal devices in a network (PLMN), etc., are not limited to this in the embodiments of this application.
[0096] By way of example and not limitation, in this embodiment, the electronic device can also be a wearable device. Wearable devices, also known as wearable smart devices, are a general term for devices that utilize wearable technology to intelligently design and develop everyday wearables, such as glasses, gloves, watches, clothing, and shoes.
[0097] The electronic devices in the embodiments of this application may also be referred to as: terminal equipment, user equipment (UE), mobile station (MS), mobile terminal (MT), access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication equipment, user agent, or user device, etc.
[0098] In this embodiment, the electronic device or various network devices include a hardware layer, an operating system layer running on top of the hardware layer, and an application layer running on top of the operating system layer. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and memory (also called main memory). The operating system can be any one or more computer operating systems that implement business processing through processes, such as Linux, Unix, Android, iOS, or Windows. The application layer includes applications such as browsers, address books, word processing software, and instant messaging software.
[0099] Currently, terminal devices typically have image capture capabilities. For example, a terminal device may include a sensor module and a lens to achieve the purpose of image capture.
[0100] To better understand the technical solution of this application, the relevant technologies involved in this application will be further described in detail below.
[0101] When taking pictures using electronic devices, there is a shooting scenario called backlighting. Backlighting occurs when the subject is positioned precisely between the light source and the lens. For example, you can refer to... Figure 2 Understanding backlit shooting scenarios. Figure 2 This is a schematic diagram of a scene captured using images from an embodiment of this application.
[0102] like Figure 2 As shown, when a user takes a picture with the backlight on and uses the front-facing camera, the subject 202 may be located between the light source 203 and the lens 201.
[0103] Figure 2 The example illustrates a scenario where a user takes a picture using the front-facing camera. When a user takes a picture using the rear-facing camera, the subject may also be positioned between the light source and the lens, as described above.
[0104] The backlighting situation described above, where the subject is positioned between the lens and the light source, is very likely to result in poor image contrast.
[0105] For example, when the sensor module in a terminal device is of poor quality, if an image is captured in the backlit scene described above, the bright light in the image, such as sunlight or other strong non-imaging light sources, will cause lens flare and other problems, resulting in a significant reduction in image contrast. It is important to understand that this "reduction" in contrast is relative to the contrast of an image captured in a non-backlit scene. In other words, generally speaking, for the same subject, the contrast of an image captured in a backlit scene is less than the contrast of an image captured in a non-backlit scene.
[0106] Based on the above explanation, it's understandable that when an image has low contrast, it will appear hazy. Therefore, for images containing portraits, low contrast can cause the portrait to appear blurry and washed out, resulting in negative effects. The blurry effect can be understood as the portrait appearing hazy, while the washed-out effect can be understood as the overall color of the portrait appearing too white.
[0107] However, it's important to understand that the whitening effect here is still due to the hazy appearance of the image, resulting in a grayish appearance. This can be compared to how the human eye perceives the surrounding environment as whiter in foggy weather, but the actual image still appears as a hazy gray. Alternatively, you can refer to... Figure 1 Understanding, reference Figure 1 What is certain is that Figure 1 (a) in comparison to Figure 1 In (b), a hazy effect (a foggy feeling) and a whiter feel (still caused by the image being grayish).
[0108] In one implementation, the negative effect mentioned in this application refers to the effect caused by low image contrast. For example, when the contrast is less than a preset contrast, the image can be considered to have low contrast, and the negative effect appearing in the image at this time is the negative effect described in this application. Alternatively, it can be specifically defined as the image performance effect caused by low image contrast due to the backlighting scene in a backlit shooting scenario.
[0109] In other words, the negative effects described in this application can be understood as effects caused by low image contrast, where "low contrast" can be quantified, for example, as an image contrast being less than a preset contrast. Therefore, any effect appearing in an image due to low image contrast can be considered a negative effect described in this application. Low contrast can be caused by the backlighting scenario described above, or by other reasons; this embodiment does not limit this.
[0110] For example, negative effects may include the image whitening and image blurring described above. This embodiment does not limit the specific negative effects.
[0111] To address the issue of negative effects in backlit shooting scenarios, resulting in poor image quality, it is typically necessary to adjust the image contrast to improve its performance. This will effectively mitigate or eliminate negative effects such as a washed-out or hazy appearance.
[0112] In one implementation, the low contrast described above may cause a negative effect on the portrait portion of the image. Therefore, the image contrast can be adjusted to alleviate or eliminate the negative effect on the portrait portion. For example, refer to... Figure 3 Understand how to adjust the negative effects on the human figure portion of an image. Figure 3 Illustration of the negative effects provided in the embodiments of this application Figure 1 .
[0113] Figure 3 (a) in the figure illustrates an image, for reference Figure 3 It is certain that the image may include portraits, and the portrait portions may exhibit the aforementioned blurring and whitening negative effects. Figure 3 In (a), this negative effect is represented by shading.
[0114] Therefore, by adjusting the contrast of the image, the negative effects on the portrait can be eliminated or mitigated to some extent, thus achieving... Figure 3The adjusted image shown in (b) shows how the negative effects on the human figure can be eliminated or mitigated.
[0115] The current explanation specifically addresses how reduced contrast can negatively impact the appearance of human figures in an image; therefore, the above... Figure 3 This example illustrates the elimination of negative effects on the human figure portion (the implementation is similar to that of the human face portion).
[0116] However, in reality, reducing contrast can cause the negative effects described above to appear throughout the entire image, not just in the portrait or face area. Therefore, in practice, adjusting the image contrast can also mitigate or eliminate the negative effects on the entire image visually.
[0117] For example, you can refer to Figure 4 Understand how to adjust the overall negative effects of an image. Figure 4 Illustration of the negative effects provided in the embodiments of this application Figure 2 .
[0118] Figure 4 (a) in the figure illustrates an image, for reference Figure 4 It is certain that the image may include portraits, but the overall image may exhibit the aforementioned blurring and whitening negative effects. Figure 4 In (a), this negative effect is represented by shading.
[0119] Therefore, by adjusting the image contrast, negative effects in the image can be eliminated or mitigated to some extent, thus achieving... Figure 4 The adjusted image shown in (b) demonstrates that, visually, any negative effects on the overall image can be eliminated or mitigated.
[0120] In actual implementation, which part of the image exhibits a negative effect depends on the specific image generation process, and this embodiment does not impose any limitations on this. In summary, the technical solution of this application can alleviate or eliminate negative effects caused by excessively low contrast in images.
[0121] To address the issue of negative effects in images, this application proposes the following technical concept: The aforementioned whitening and blurring effects occur because the brightness of the portrait area in the image is too high. Therefore, the portrait area and face area can be identified in the image. Then, gain processing is applied to the portrait area to reduce its brightness, thereby optimizing contrast in backlit shooting scenarios. Simultaneously, masking is applied to the face area to avoid excessive reduction in face intensity or abrupt changes in face brightness, which could lead to abnormal brightness performance in the face area. This results in a well-contrast image in the output image.
[0122] The technical solution provided in this application can be applied to terminal devices. The terminal devices will be briefly introduced below.
[0123] For example, Figure 5 This is a schematic diagram of the hardware structure of a terminal device provided in an embodiment of this application.
[0124] 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, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.
[0125] The processor 110 may include one or more processing units. These processing units may be independent devices or integrated within one or more processors. The processor 110 may also include memory for storing instructions and data.
[0126] The terminal device implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connecting the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering.
[0127] 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 one or N display screens 194, where N is a positive integer greater than 1.
[0128] Terminal devices can perform camera functions such as shooting and recording through ISP, camera 193, video codec, GPU, display 194 and application processor.
[0129] Camera 193 is used to capture still 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.
[0130] The ISP (Image Signal Processor) is used to process data fed back from the camera 193. For example, when taking a picture, the shutter is opened, and light is transmitted through the lens 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, transforming it into an image visible to the naked eye. The ISP can also perform algorithmic optimization of image noise, brightness, and skin tone. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 193.
[0131] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the terminal device. In other embodiments of this application, the terminal device may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0132] The software system of the aforementioned terminal device can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This embodiment of the invention uses a layered architecture system as an example to exemplify the software structure of the terminal device.
[0133] For example, Figure 6 This is a schematic diagram of the software structure of a terminal device provided in an embodiment of this application.
[0134] like Figure 6 As shown, the layered architecture divides the software into several layers, each with a clear role and function. 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.
[0135] It should be noted that the embodiments of this application use the Android system as an example. In other operating systems (such as HarmonyOS, iOS, etc.), as long as the functions implemented by each functional module are similar to those in the embodiments of this application, the solution of this application can also be implemented.
[0136] The application layer can include a series of application packages. For example... Figure 6As shown, the application package may include applications such as a camera and a gallery. The camera application is used to implement the image capturing function described in this application. Furthermore, after an image is captured, the user can view the captured image in the gallery application.
[0137] The application layer may also include calendar, phone, maps, navigation, email, social networking, wireless local area networks (WLAN), Bluetooth, music, video, SMS, lock screen applications, and settings applications. Of course, the application layer may also include other application packages, such as third-party applications like payment applications, shopping applications, banking applications, and social networking applications; this application does not limit this.
[0138] The application framework layer provides application programming interfaces (APIs) and programming frameworks for applications in the application layer. For example, ... Figure 6 As shown, the application framework layer may include a camera access interface. The camera access interface may include camera management and camera devices. Specifically, camera management provides an access interface for managing the camera, and camera devices provide an interface for accessing the camera.
[0139] Furthermore, the application framework layer may also include some predefined functions. For example, it may include an activity manager, window manager, content provider, view system, resource manager, notification manager, and camera server unit, etc., and this application embodiment does not impose any limitations on this. The camera server unit of the application framework layer can be started during the terminal device's boot phase and can be used to transmit and save relevant camera information.
[0140] Furthermore, the Hardware Abstraction Layer (HAL) is used to abstract hardware, encapsulate Linux kernel drivers, provide interfaces to higher-level systems, and shield the implementation details of lower-level hardware. For example, the HAL may include... Figure 6 The diagram shows the camera hardware abstraction layer, other hardware device abstraction layers, and camera algorithm library.
[0141] The camera hardware abstraction layer can include camera device 1, camera device 2, etc. The camera hardware abstraction layer can connect to the camera algorithm library, and can call algorithms from the camera algorithm library.
[0142] The camera algorithm library may include algorithm instructions such as camera algorithms and image algorithms, as well as some image processing steps. For example, the camera algorithm library may include a first algorithm or a first set of algorithms, wherein the first algorithm or the first set of algorithms is used to implement the contrast adjustment related processing for portrait images described in this application.
[0143] Alternatively, it can be understood that the HAL layer includes a processing unit, which is used to implement the contrast adjustment related processing for portrait images described in this application.
[0144] Additionally, the driver layer provides drivers for different hardware devices. For example, the driver layer can include camera drivers, digital signal processor drivers, and graphics processor drivers. The camera driver is the driver layer for camera devices and is mainly responsible for interacting with the hardware module.
[0145] Furthermore, the hardware layer may include sensors, image processors, digital signal processors, graphics processors, memory, and other hardware devices. These are used to interact with the camera driver to achieve image capture.
[0146] During the image capture process, for example, the camera application at the application layer can respond to user operations by sending image acquisition commands to the camera device in the camera access interface. Image acquisition includes image acquisition during the preview stage and image capture during the shooting stage. The camera device then sends relevant commands to the camera HAL, which in turn sends relevant commands to the camera device driver. The camera device driver then interacts with the relevant sensors and processors at the hardware layer to complete the image capture.
[0147] After image acquisition is complete, the data flows in the opposite direction to that described above, displaying the acquired image in the camera application or gallery application. In this reverse data flow, some hierarchical structures may further process the acquired image.
[0148] For example, the HAL layer can be configured to further process the acquired images. For instance, the HAL layer can call a first algorithm or a set of first algorithms in the camera algorithm library, and combine the interaction content with the relevant drivers of the driver layer and the relevant hardware units of the hardware layer to perform contrast adjustment on the acquired images as described in this application, so that the contrast of the final output image is well presented.
[0149] Based on the above introduction, the specific implementation of image contrast adjustment provided in this application will be described below.
[0150] In this application, the contrast of an image can be adjusted based on a mask image determined according to the face region and a gain image determined according to the portrait region.
[0151] In one implementation, the technical solution of this application involves adjusting the contrast of the image to be displayed. The image to be displayed is generated by the camera application in response to the click operation of the shutter button after the user clicks it. By adjusting the contrast of the image to be displayed, it is possible to ensure that the final output image has good contrast performance.
[0152] To ensure that the contrast of the image to be displayed can be adjusted, the mask image and gain image described above can be determined in advance before generating the image to be displayed. Then, the contrast of the image to be displayed can be adjusted directly according to the mask image and gain image to obtain the output image after adjustment.
[0153] For example, in this application, the image to be displayed that requires contrast adjustment may be referred to as the second image, and the image generated before the second image for determining the mask image and the gain image may be referred to as the first image.
[0154] The following is a combination of... Figure 7 The selection methods for the first and second images will be briefly introduced. Figure 7 This is a schematic diagram of image selection provided for an embodiment of this application.
[0155] like Figure 7 As shown, assuming the user clicks the camera button at time t1, the user is in the camera preview stage before time t1 and in the image generation stage after time t1.
[0156] During the photo preview stage, the terminal device's camera continuously captures images to generate a preview stream, meaning the preview stream includes multiple images. For example... Figure 7 As shown, for example, the preview stream includes images a1, a2, and a3, etc.
[0157] Furthermore, during the image generation stage, the camera application in the terminal device responds to the user's action of pressing the shutter button, and can continuously capture n images (n is an integer greater than or equal to 1), for example in... Figure 7 In the example, the terminal device continuously captures 6 images. Then, the terminal device can perform fusion processing on at least a portion of the n captured images to obtain... Figure 7 The image shown here is the merged image to be displayed. This image is the second image that requires contrast adjustment.
[0158] In one 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. For example, any image in the preview stream can be selected as the first image, or any image in the preview stream whose time interval with time t1 is less than a preset duration can be selected as the first image.
[0159] Alternatively, a first image can be selected from n images captured consecutively in response to a user action on the camera button. For example, the s-th image among the n consecutively captured images can be determined as a reference image, which is then used as the first image described in this application. For example, in... Figure 7 In the example, the third image among the six consecutively acquired images is determined as the reference image, and therefore the reference image b3 can be used as the first image described in this application.
[0160] In actual implementation, s can be a pre-set integer, where s is an integer greater than or equal to 1 and less than or equal to n.
[0161] Alternatively, any one of the n consecutively acquired images can be designated as the first image; this embodiment does not impose any restrictions on this.
[0162] In one possible implementation, the first image in this application is selected from the image generated by a node relatively late in the camera's processing flow. For example, the image generated after the tonal mapping node in the processing flow, or the image finally output by the camera in response to the user's photo-taking operation (such as the reference image described above), is determined as the first image in this application.
[0163] Next, let's combine... Figure 8 The reason why the mask image and gain image are determined based on the first image, and then the contrast of the second image is adjusted based on the mask image and gain image (that is, the image used to determine the mask image and gain image is not the same image as the image used to apply the mask image and gain image), instead of directly determining the mask image and gain image based on the second image, and then adjusting the contrast of the second image based on the mask image and gain image (that is, the image used to determine the mask image and gain image is the same image as the image used to apply the mask image and gain image), will be further explained. Figure 8 This is a schematic diagram of the image fusion processing procedure provided in an embodiment of this application.
[0164] like Figure 8 As shown, after a user action on the camera button is performed, and n consecutive images are captured (that is...) Figure 8Images b1 to b6 in the image can be fused from n consecutive acquired images to obtain an initial fused image.
[0165] For example, the fusion process described here can be the HDR fusion described above. Therefore, after image fusion, it is usually necessary to adjust the brightness of the fused image in order to obtain an image with normal brightness.
[0166] exist Figure 8 In the initial fused image, the brightness has not yet been adjusted, so it actually appears very dark, which does not conform to human visual perception; that is, it does not match the brightness of the real scene as observed by the human eye. Therefore, the brightness information in the initial fused image has not been processed and is inaccurate.
[0167] Continue to refer to Figure 8 After obtaining the initial fused image, the next step is to adjust its brightness. The purpose of brightness adjustment is to brighten dark areas and darken bright areas to make the image's brightness consistent with human visual perception. The contrast adjustment described in this application is performed during the brightness adjustment stage; in other words, contrast adjustment is an adjustment operation within the brightness adjustment stage.
[0168] After adjusting the brightness of the initial fused image, further image parameter adjustments can be made to obtain... Figure 8 The final fused image shown is the output image after the photo is taken, as described above. If a user views the photo in a photo gallery application, the image they see is the final fused image described here.
[0169] Based on the current situation, if we determine the mask image and gain image based on the second image, then we have the following two options:
[0170] The first option is based on Figure 8 The initial fused image is used to determine the mask image and gain image. However, the brightness information of the initial fused image is unprocessed, so the brightness information of the initial fused image is not accurate. Therefore, the accuracy of the mask image and gain image determined based on the initial fused image cannot be guaranteed.
[0171] Therefore, the mask image and gain image cannot be determined based on the initial fused image.
[0172] The second option is based on Figure 8The final fused image is used to determine the mask image and gain image. However, the contrast adjustment is completed before the final fused image is obtained. Therefore, determining the contrast parameters based on the final fused image after it is obtained is no longer applicable to the contrast adjustment of the final fused image.
[0173] Therefore, although the mask image and gain image determined based on the final fused image are accurate, they cannot be applied to contrast adjustment.
[0174] Based on the above analysis, it can be determined that in this embodiment, the mask image and gain image cannot be determined based on the second image. To achieve contrast adjustment of the second image, the mask image and gain image must be determined in advance. Therefore, in this embodiment, the mask image and gain image are determined based on the first image, and then the contrast of the second image is adjusted based on the mask image and gain image.
[0175] In this embodiment, the first image is generated before the second image, ensuring that the mask image and gain image generated from the first image are sufficient for adjusting the contrast parameters of the second image. Furthermore, the first image in this embodiment is either an image from the preview stream or a reference image, as described above; therefore, the first image can be obtained without fusion processing. Consequently, no post-fusion adjustments are needed for the first image, resulting in a faster generation speed. This also allows for faster determination of the mask image and gain image, ensuring that the mask image and gain image determined from the first image can be effectively applied to the brightness adjustment of the second image. Pre-determining the mask image and gain image further improves the speed of contrast adjustment for the second image.
[0176] Furthermore, the contrast adjustment described in this embodiment is... Figure 8 The brightness adjustment stage described above is completed; therefore, in this embodiment, the adjustment based on the mask image and gain image is actually... Figure 8 The contrast of the initial fused image shown is such that the second image that needs to be adjusted for contrast in this embodiment is the initial fused image described here, and the initial fused image and the image to be displayed described above are the same concept.
[0177] Only after brightness adjustments are made to the initial fused image will the final result be obtained. Figure 8 The final fused image shown is the output image of the camera application.
[0178] The above describes the implementation of the first and second images. The following describes the specific implementation of determining the mask image and the gain image.
[0179] After determining the first image, the mask image and gain image described above can be determined based on the first image. In one possible implementation, the preview image in the preview stream described above, as well as the n consecutively acquired images, can all be YUV images. YUV is a color encoding mode, where Y represents luminance (grayscale value), and UV represents chrominance and chroma, respectively. Alternatively, the images described here can also be images of other formats, depending on the implementation of the terminal device; this embodiment does not limit this.
[0180] In this embodiment, before determining the mask image and the gain image based on the first image, the face region and the portrait region can be determined first in the first image.
[0181] For example, face detection can be performed on the first image based on a face detection algorithm to obtain the face regions in the first image, where the face regions can be represented, for example, by face bounding boxes. Alternatively, face detection can be performed on the first image based on a portrait segmentation algorithm to obtain the portrait regions in the first image.
[0182] Then, 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 sections will introduce these two parts separately.
[0183] Part 1: Determine the mask image based on the face region in the first image.
[0184] In this embodiment, the mask image serves to protect the original brightness of the face region. For example, the mask image can indicate the degree of brightness adjustment for each first pixel in the first image, with smaller brightness adjustments closer to the center point of the face region and larger adjustments further away from the center point, thereby effectively protecting the original brightness of the face region.
[0185] To better understand the role of mask images, the following will combine... Figure 9 A simple explanation of the principle of masking will be given. Figure 9 This is a schematic diagram of a mask provided for an embodiment of this application.
[0186] like Figure 9 As shown, assuming there exists a 3×3 original graph, in Figure 9The diagram illustrates the pixel values corresponding to the nine pixels in the original image. It also assumes that a 3×3 mask image also exists. Figure 9 The image also shows the pixel values corresponding to the nine pixels in the mask image.
[0187] For example, suppose we perform a bitwise AND operation on each pixel in the original image and the corresponding position in the mask image, then we can obtain the following: Figure 9 The image shown is a rendering. (Refer to the image.) Figure 9 The pixel values of each pixel in the effect diagram shown can be understood as follows: for areas with a pixel value of 0 in the mask image, the corresponding pixel value in the effect diagram is also 0, thus achieving the filtering or protection of a certain area.
[0188] Based on the above, the mask image can be determined, for example, through the following process.
[0189] 1. In the first image, determine the center point of the face region.
[0190] For example, the face region can be represented as a face bounding box, and the center point of the face region can be determined based on the center of the face bounding box. Alternatively, when the face region is represented as an irregular region, the center point of the face region can also be determined based on the outer border of the irregular region. This embodiment does not limit the implementation of determining the center point.
[0191] For example, the center point of a face region can be represented as (centerX, centerY).
[0192] 2. For any first pixel in the first image, determine the first distance between the pixel position and the center point position in the first image.
[0193] In this embodiment, the pixels in the first image are called first pixels, and the same processing is performed on each first pixel in the first image. Therefore, the following description will focus on any one first pixel in the first image.
[0194] In this embodiment, the first pixel point corresponds to a pixel position in the first image, so the first distance between the pixel position of the first pixel point in the first image and the center point position of the face region described above can be determined.
[0195] For example, the pixel position of the first pixel can be represented as (i, j), and the center point position of the face region can be represented as (centerX, centerY). Then, for example, the first distance can be determined based on these two coordinate positions.
[0196] The determination of the first distance can be expressed, for example, as formula one below:
[0197] rTemp = (i-centreX)*(i-centreX) + (j-centreY)*(j-centreY) (Formula 1)
[0198] Where rTemp is the first distance between the pixel position of the first pixel and the center point of the face region.
[0199] Furthermore, for example, one could refer to Figure 10 To understand, Figure 10 A schematic diagram of the first distance provided for an embodiment of this application.
[0200] exist Figure 10 The example shows 16 first pixels in a first image, with each box representing a first pixel. Assuming pixel a corresponds to the center point of the face region, the distance between first pixel b and the center point can be determined by referring to... Figure 10 To understand d1, and the distance between the first pixel c and the center point, refer to... Figure 10 We can understand d2 in this context. The processing method for the first distance of the other first pixels is similar, so it will not be repeated here.
[0201] 3. Determine the mask value corresponding to the first pixel based on the first distance corresponding to the first pixel.
[0202] In the backlit shooting scenario described in this application, because more light enters the outline of the portrait, the portrait area may appear overly bright. Accordingly, the brightness adjustment in this application aims to reduce the brightness of the portrait area to improve image contrast. Meanwhile, in backlit shooting scenarios, the brightness of the face area is usually normal, or at least not overly bright. Therefore, the mask image is used in this embodiment to ensure that the brightness of the face area is minimally affected when brightness reduction processing is applied to the portrait area.
[0203] Furthermore, if the face area is kept at its original brightness, and the brightness is reduced only for the parts of the portrait area excluding the face area, a brightness discontinuity will occur between the face area and the rest of the portrait area. Therefore, to ensure a smooth brightness transition between the face area and the rest of the portrait area, this embodiment determines the mask value corresponding to each first pixel, where the mask value indicates the degree of brightness adjustment for each first pixel.
[0204] In this embodiment, for example, the mask value of the first pixel located closer to the center point of the face region can be set to be larger, and the degree of brightness adjustment can be smaller. Conversely, the mask value of the first pixel located farther away from the center point of the face region can be smaller, and the degree of brightness adjustment can be larger.
[0205] For example in Figure 10 In the example, the first distance d1 corresponding to the first pixel b is less than the first distance d2 corresponding to the first pixel c. Therefore, the mask value corresponding to the first pixel b is greater than the mask value corresponding to the first pixel c, so that the greater the degree of protection of the first pixel b, the smaller the degree of brightness value adjustment.
[0206] The principle behind the negative correlation between the degree of mask value and brightness value adjustment will be explained in detail in the following brightness adjustment embodiments. For now, it is acceptable to temporarily understand that such a negative correlation exists.
[0207] Based on the above description, in this embodiment, the mask value corresponding to the first pixel can be determined according to the first distance corresponding to the first pixel.
[0208] In one implementation, for example, a first distance to the first pixel 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 is far from the center point of the face region. In this case, it can be assumed that there is no need to protect the brightness of the first pixel, so the mask value of the first pixel can be directly determined as the first value, where the first value can be the minimum value of the mask.
[0209] Alternatively, if the first distance is less than or equal to the preset distance, it can be confirmed that the first pixel is not particularly far from the center point of the face region, and a certain degree of brightness protection is still required. Furthermore, based on the above description, it can be determined that this embodiment requires brightness transition processing, which can be achieved, for example, by determining the mask value of the first pixel based on a preset transition coefficient and the first distance.
[0210] For example, in this embodiment, a face mask radius r and a preset transition coefficient coefficien can be set. For instance, 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 can be compared with the square of the face mask radius r to measure the distance of the first distance.
[0211] Furthermore, in this embodiment, the range of mask values can be, for example, 0 to 255, meaning that the minimum mask value is 0 and the maximum mask value is 255.
[0212] Therefore, if it is determined that the first distance rTemp corresponding to the first pixel is greater than r*r, then the mask value corresponding to the first pixel can be determined to be 0. The first pixel with a mask value of 0 will not be subject to brightness protection in subsequent brightness processing; that is, its brightness may be affected by brightness reduction processing.
[0213] If it is determined that the first distance rTemp corresponding to the first pixel is less than or equal to r*r, then the mask value of the first pixel can be determined based on the preset transition coefficient coefficien and the first distance rTemp corresponding to the first pixel.
[0214] In one implementation, for example, a first ratio can be determined based on a first distance and a preset distance. Then, a first difference between the preset value and the first ratio can be determined, and the product of the first difference and the preset transition coefficient can be determined as the target ratio. In this embodiment, the preset value can be set to 1, or it can be set to other values; this embodiment does not limit this.
[0215] Then, the mask value of the first pixel is determined by multiplying the target ratio and the maximum value of the pixel.
[0216] The process of determining the mask value of the first pixel, as described above, can be understood by referring to Formula 2 below.
[0217] ratio=coefficient*(1.0f-(rTemp / (r*r))) Formula 2
[0218] Here, rTemp / (r*r) represents the first ratio described above. In the current example, the preset value could be, for example, 1.0f in Formula 2, where 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.
[0219] Then, for example, the target ratio determined above can be multiplied by the maximum pixel value. Assuming the range of pixel values is 0 to 255, the maximum pixel value can be determined to be 255. Therefore, for example, the target ratio can be multiplied by 255 to obtain the mask value corresponding to the first pixel, which can be expressed as the mask value of the first pixel faceMask = ratio * 255.
[0220] In actual implementation, the method of determining the target ratio or mask value is not limited to Formula 2 mentioned above. Adding coefficients to Formula 2 or performing an identity transformation on Formula 2 can also achieve the purpose of determining the target ratio or mask value.
[0221] Furthermore, referring to Formula 2 above, it can be understood that the larger the first distance of the first pixel, the smaller the corresponding target ratio, and therefore the smaller the mask value corresponding to that first pixel, and the greater the impact of subsequent brightness adjustments. Thus, it can be understood that the first distance and the mask value are inversely proportional. In one implementation, the mask value can be determined according to this principle; the specific determination method can be selected and expanded according to actual needs.
[0222] 4. Determine the mask image based on the mask value corresponding to each first pixel in the first image.
[0223] In this embodiment, the size of the mask image and the size of the first image are the same. For example, if the first image includes W×T pixels, the corresponding mask image also includes W×T pixels. Therefore, it can be understood that each pixel in the mask image corresponds one-to-one with each pixel in the first image. Here, W and T are both integers greater than or equal to 1.
[0224] After determining the mask value for each first pixel, the mask value for each first pixel can be used as the pixel value of the corresponding pixel in the mask image, thus obtaining the mask image. In other words, the image constructed by using the mask value for each first pixel as the pixel value is the mask image in this embodiment.
[0225] Based on the above introduction, for example, you can refer to... Figure 11 Understanding the final mask image, Figure 11 A schematic diagram of the mask image provided in this application.
[0226] Figure 11 The image shown is a mask image. The black parts in the mask image can be understood as having a pixel value of 0 (the pixel value in the mask image is the mask value introduced above, so the corresponding mask value is 0), and the white parts have a pixel value greater than 0 (correspondingly, the mask value is greater than 0).
[0227] For example, the white area corresponds to the face region and the transition area around the face in the first image, and its pixel value is greater than 0. This means that the mask value of the first pixel corresponding to the white area is greater than 0. Accordingly, in the subsequent brightness adjustment stage, the brightness of these first pixels will be protected to a certain extent, which can be understood as reducing the impact of brightness adjustment on the brightness value.
[0228] Furthermore, in the mask image, the pixel value is larger the closer it is to the center point of the face area. This means that the mask value of the first pixel at that position is larger, the degree of brightness adjustment is smaller, and the brightness of the first pixel is protected to a greater extent.
[0229] as well as, Figure 11 The neutralized black portion corresponds to the non-face area in the first image, excluding the face area and transition area. Its pixel value is 0, which means that the mask value of the first pixel corresponding to the black portion is equal to 0. Consequently, 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.
[0230] In this embodiment, by setting a mask image, the mask value corresponding to the first pixel point closer to the center point of the face area is larger, and the mask value corresponding to the first pixel point farther away from the center point of the face area is smaller. This can effectively protect the brightness of the face area, while also realizing the brightness transition processing from the face area to other areas of the portrait.
[0231] The above describes how to determine the mask image; the method for determining the gain image will be explained next.
[0232] Part Two: Determine the gain image based on the human figure region in the first image.
[0233] Based on the above analysis, it can be understood that in backlit shooting scenarios, the edges of the portrait receive the most light, which leads to excessive brightness in the portrait area. This results in a washed-out and hazy effect in the image. Therefore, it is necessary to reduce the brightness of the portrait area to optimize glare and reduce haziness.
[0234] Therefore, the gain image can be determined based on the portrait area in the first image. The function of the gain image is to reduce the brightness of the portrait area, thereby darkening the brightness of the portrait part in the first image. For example, the determination of the gain image can be accomplished through the following steps.
[0235] 1. For any first pixel in the first image that is outside the human figure area, determine the gain value of the first pixel to be the preset maximum gain value.
[0236] In this embodiment, a gain value can be determined for each first pixel in the first image, whereby the gain value is used to maintain or reduce the brightness value of the first pixel.
[0237] In one implementation, the maximum gain value can be preset to 1. In this way, for the first pixel, its gain value is either 1 or the brightness value of the first pixel remains the original brightness value without brightness dimming.
[0238] Alternatively, since the maximum gain value is only 1, the gain value of the first pixel must be less than 1, thus enabling a reduction in the brightness value of the first pixel.
[0239] In this embodiment, it is necessary to darken the brightness of the portrait area. Therefore, for the areas outside the portrait area in the first image, their original brightness can be kept unchanged, 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 outside the portrait area in the first image can be processed separately.
[0240] For example, for any first pixel in the first image outside the portrait area, the gain value of the first pixel can be determined to be the maximum gain value. For instance, the maximum gain value can be 1, thus ensuring that the brightness values of the remaining areas outside the portrait area in the first image remain unchanged.
[0241] 2. For any first pixel within the human image region in the first image, determine the gain value of the first pixel based on the maximum gain value and the preset minimum gain value.
[0242] Secondly, the portrait area in the first image needs to be darkened. In this embodiment, in addition to a preset maximum gain value, a preset minimum gain value (or initial gain value GainInit) can also be set to control the degree of darkening of the portrait area and prevent the portrait area from becoming too dark after the brightness has been darkened.
[0243] For example, the minimum gain value can be set to 0.8, which means that the brightness value of the first pixel in the portrait area will be reduced by a maximum of 20%. The specific setting of the minimum gain value can be selected according to actual needs, and this embodiment does not limit it.
[0244] Therefore, for any first pixel within the portrait region of the first image, the gain value of the first pixel can be determined based on the maximum and minimum gain values. It can be understood that the gain value of the first pixel falls within the range of the maximum and minimum gain values.
[0245] The following describes one possible implementation of determining the gain value of the first pixel based on the maximum and minimum gain values.
[0246] In backlit shooting scenarios, the top of the head in a portrait area typically receives the most light, and the amount of light decreases sequentially downwards, extending down to the body portion of the portrait area. Therefore, in this embodiment, the gain value can be gradually increased from top to bottom for each first pixel in the portrait area of the first image, thereby achieving the goal of maximizing the brightness reduction at the top of the head and decreasing the brightness reduction sequentially downwards from the top of the head.
[0247] In one implementation, the portrait region can be divided into M sub-regions starting from the top of the portrait region and moving downwards along a first vertical direction, where M is an integer greater than or equal to 1, and the first vertical direction is the vertical direction of the first image.
[0248] For example, the "topmost position" described in this embodiment can be understood as the topmost pixel of the portrait area corresponding to the horizontal position in the horizontal direction of the first image. For example, refer to... Figure 12 To understand, Figure 12 This is a schematic diagram illustrating the implementation of determining the gain value of a pixel in an embodiment of this application.
[0249] Figure 12 The image shows the human figure region 1201, and the hypothetical... Figure 12 Pixel 1 in the image is used to indicate the topmost pixel of the portrait area. Therefore, pixel 1 can be mapped to the horizontal position in the horizontal direction of the first image, which is... Figure 12 The horizontal position indicated by the middle line 'a' is determined as the top position of the human figure area.
[0250] And in Figure 12 The image also shows the horizontal and vertical directions of the first image, such as... Figure 12 As shown, starting from the top position 'a' of the portrait area, and moving downwards along the vertical direction of the first image, the portrait area can be divided into... Figure 12 The five sub-regions shown are derived from the division of the human portrait area in this embodiment. Therefore, it is important to understand that... Figure 12 In the example, the human figure area within the horizontal range indicated by each curly brace is the sub-region after division.
[0251] When dividing the region into subregions, the M subregions can be divided according to the first step length. That is to say, the length of the 1st to M-1th subregions in the first vertical direction is the first step length, and the length of the Mth subregion in the first vertical direction is less than or equal to the first step length.
[0252] Alternatively, the lengths of the M sub-regions can be different. For example, each sub-region can be divided into M sub-regions with random lengths, or the lengths can be increased or decreased sequentially. This embodiment does not limit the specific division method of the M sub-regions, and it can be selected according to actual needs.
[0253] Furthermore, in this embodiment, M target values can be sequentially determined within the range of minimum gain value to maximum gain value, wherein the i-th target value among the M target values is less than the (i-1)-th target value, and the value of i ranges from 1 to M. That is, M target values are determined within the range of minimum gain value to maximum gain value in order of increasing numerical value.
[0254] For example, M target values are selected uniformly within the range of minimum gain to maximum gain. The first 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. Uniform selection means that the difference between any two adjacent target values is the same.
[0255] Alternatively, M target values can be randomly selected from the range of minimum gain to maximum gain, as long as the M target values increase sequentially. This embodiment does not impose any restrictions on this.
[0256] For example, you can refer to Figure 12 To understand the target value, such as Figure 12 As shown, assuming the minimum gain is 0.8 and the maximum gain is 1, then M target values need to be selected within the range of 0.8 to 1. In the current example, M equals 5.
[0257] For example, if we select 5 target values evenly within this numerical range, the 5 selected target values could be: Figure 12 The values shown are: 0.8, 0.85, 0.9, 0.95, and 1.
[0258] After determining the M sub-regions and the M target values, for the j-th sub-region, the gain value corresponding to each first pixel in the j-th sub-region can be determined as the j-th target value, where the value of j ranges from 1 to M.
[0259] For example in Figure 12In the example, for the first sub-region, the gain value corresponding to each first pixel in the first sub-region can be determined to be 0.8 (which is the first target value). And for the second sub-region, the gain value corresponding to each first pixel in the second sub-region can be determined to be 0.85 (which is the second target value). The correspondence between the remaining sub-regions and target values is similar.
[0260] Based on the implementation method described above, for the portrait area, the gain value of each first pixel can be increased sequentially from the top of the portrait area downwards along the first vertical direction. This results in the greatest brightness reduction at the top of the head, and the brightness reduction decreasing sequentially downwards. This allows for adaptive adjustments to portrait brightness anomalies in backlit shooting scenarios.
[0261] It should also be noted that the above description is only one implementation method for determining the gain value of each first pixel in the portrait region. However, it is not limited to the above-described method of dividing the region into sub-regions and determining the target value. The ultimate goal of the above technical means is to achieve "for the portrait region, from the top of the portrait region downwards along the first vertical direction, the gain value corresponding to each first pixel increases sequentially". As long as this goal of increasing the gain value from top to bottom can be achieved, any possible implementation method can be extended.
[0262] For example, a function can be preset with the coordinates of a pixel and its corresponding gain value. By inputting the pixel's coordinates into this function, it can output the corresponding gain value. The function's purpose is to transition the gain value of each first pixel in the portrait area from its minimum to its maximum along a first vertical direction downwards.
[0263] 3. Determine the gain image based on the gain value of each first pixel in the first image.
[0264] In this embodiment, the size of the gain image is the same as the size of the first image. For example, the first image includes W×T pixels, and the corresponding gain image also includes W×T pixels. Therefore, it can be understood that each pixel in the gain image corresponds one-to-one with each pixel in the first image in terms of position.
[0265] After determining the gain value for each first pixel, the gain value for each first pixel can be used as the pixel value of the corresponding pixel in the gain image, thus obtaining the gain image. In other words, the image constructed by using the gain value for each first pixel as the pixel value is the gain image in this embodiment.
[0266] Based on the above introduction, for example, you can refer to... Figure 13 Understanding the final gain image Figure 13 A schematic diagram of the gain image provided in this application.
[0267] Figure 13 The image shown is a gain image. In the gain image, the darker the color, the smaller the corresponding pixel value (the pixel value in the gain image is the gain value introduced above, so the smaller the gain value, the larger the corresponding pixel value). The lighter the color, the larger the corresponding pixel value (the corresponding gain value is larger). The pixel value of the lightest color pixel is 1, which means that the maximum gain value is 1.
[0268] For example, the light-colored part corresponds to the part outside the portrait area in the first image, as well as some parts near the bottom of the portrait area. Its gain value can be understood as equal to 1, which means that the brightness of the first pixel corresponding to this part will remain at its original brightness and will not be darkened, thus achieving brightness protection for the part outside the portrait area.
[0269] Furthermore, the dark part corresponds to the portrait area in the first image (or the part of the portrait area excluding the bottom position), and its gain value is less than 1. This means that the brightness of the first pixel corresponding to this part will be reduced, that is, the brightness of this part of the pixel will be darkened, thereby achieving the goal of darkening the brightness of the portrait area.
[0270] and reference Figure 13 Understandably, in the gain image, the portion corresponding to the portrait area gradually lightens in color downwards along the first vertical direction, creating a transition effect. Consequently, when darkening the brightness of the portrait area, the degree of darkening is greater closer to the top of the head, and decreases downwards from the top of the head. This allows for adaptive reduction of the brightness of the portrait area in backlit scenes.
[0271] The above embodiments describe the determination of the gain image by processing the human image region. In another implementation, this application can determine the transition region based on the human image region in the first image, and then determine the gain image based on the transition region.
[0272] For example, for each first pixel in the first image outside the transition region, its gain value is determined as the maximum gain value. And for each first pixel in the transition region of the first image, the gain value is gradually increased from top to bottom, thereby achieving the purpose of the highest degree of brightness reduction in the top part of the portrait, and the degree of brightness reduction decreasing sequentially from the top part of the portrait downwards.
[0273] The following section will first introduce the determination of the transition region:
[0274] In one possible implementation, for example, the length k of the transition region can be preset, where k is a value greater than or equal to 0. Then, starting from the top position of the portrait region and moving downwards along the vertical direction of the first image, the end position of the distance from the top position can be determined as the length k. The portrait region in the first image from the top position to the end position is then defined as the transition region.
[0275] For example, the top position described in this embodiment can be understood as the top pixel of the portrait region corresponding to the horizontal position in the horizontal direction of the first image. Similarly, the end position can be understood as the end pixel that is a vertical distance of length k from the top pixel, corresponding to the horizontal position in the horizontal direction of the first image. Therefore, the portrait region between the top and end positions can be determined based on the top and end positions.
[0276] For example, you can refer to Figure 14 Understanding the transition region Figure 14 This is a schematic diagram of the transition region provided in an embodiment of this application.
[0277] exist Figure 14 The image shown depicts the human figure region 1401 in the first image, and in... Figure 14 The diagram also shows the horizontal and vertical orientations of the first image, which are implemented in a similar manner to the embodiments described above, and will not be repeated here.
[0278] like Figure 14 As shown, assuming pixel 1 is used to indicate the topmost pixel of the portrait area, then pixel 1 can be mapped to the horizontal position in the horizontal direction of the first image, that is... Figure 14 The horizontal position indicated by the middle line 'a' is determined as the top position of the human figure area.
[0279] Furthermore, along the vertical direction downwards of the first image, pixel 2, located at a distance of length k from pixel 1 at the very top of the portrait area, can be determined. Pixel 2 can also be referred to as the ending pixel. Then, pixel 2 is mapped to a horizontal position in the horizontal direction of the first image, which is... Figure 14The horizontal position indicated by the middle line b is determined as the end position of the portrait area. Then, the portrait area between the top position a and the end position b can be defined as the transition area.
[0280] Then, for each first pixel in the transition region, the gain value of each first pixel is determined based on the maximum and minimum gain values. The implementation method is similar to that described in the above embodiment; simply replacing the portrait region in the above embodiment with the transition region described here yields the corresponding implementation method, therefore it will not be elaborated further here. (Refer to...) Figure 14 For example, it is possible to implement, for the transition region, the gain value corresponding to each first pixel point gradually increases from 0.8 to 1 from the top position down along the first vertical direction.
[0281] In this implementation, by determining a transition region of length k vertically downwards from the top of the portrait area based on a pre-set length k, it is possible to achieve brightness reduction processing of the portrait area by progressively decreasing the degree of brightness reduction from top to bottom. This reduction begins at the very top of the portrait area and proceeds downwards within a certain length range, thus reducing the brightness of the portrait area. (Refer to...) Figure 14 It is understandable that some portrait areas may not have been included in the transition zone.
[0282] This avoids situations where the portrait area in the image is too long vertically, causing unnecessary brightness reduction in areas near the bottom of the portrait area that don't actually need it, while areas near the top that do need brightness reduction don't receive the appropriate level of reduction. Therefore, this method of determining the transition region based on a preset length k effectively improves the final brightness reduction effect. Specifically, it allows for a greater degree of brightness reduction near the top of the portrait area, and by controlling the processing range of brightness reduction through length k, it avoids unnecessary brightness reduction in areas near the bottom of the portrait area.
[0283] In actual implementation, whether the gain value of each first pixel is determined based on the transition region described above, or directly based on the portrait region, can be chosen according to actual needs. The various implementation methods in this embodiment are similar; simply interchange the transition region and the portrait region.
[0284] After determining the mask image and gain image described above based on the first image, the brightness of the second image can be adjusted according to the mask image and gain image. In this embodiment, by adjusting the brightness value corresponding to each second pixel, the contrast can be improved; therefore, brightness adjustment can also be understood as contrast adjustment.
[0285] Based on the above description, it can be determined that the purpose of this embodiment is to darken the brightness of the portrait area in the image, thereby optimizing the negative effects of glare and blurring. Therefore, in one possible implementation, when the second image is a YUV format image, the Y channel of the second image can be directly extracted to obtain the brightness map of the second image, and then optimization processing can be performed based on the brightness map of the second image.
[0286] The brightness map of the second image can indicate the initial brightness value of each second pixel in the second image, which is the pixel value corresponding to the Y channel.
[0287] Furthermore, in this embodiment, the second image and the first image have the same size, so the pixels in the second image and the gain image are also in one-to-one correspondence. Therefore, for any second pixel, the target mask value corresponding to the second pixel can be determined in the mask image. In fact, the target mask value is the pixel value of the pixel at the position corresponding to the second pixel in the mask image.
[0288] For example, you can refer to Figure 15 To understand, Figure 15 This is a schematic diagram illustrating the adjustment of the brightness value of the second pixel in an embodiment of this application.
[0289] like Figure 15 As shown, assuming the second image, mask image, and gain image are all 5×5 images, then the pixels in these three images can be matched one-to-one at their pixel locations. Taking the second pixel 'a' in the second image as an example, the pixel at the same position as second pixel 'a' in the mask image is... Figure 15 The pixel value of pixel a1 shown can be determined as the target mask value corresponding to the second pixel a in the mask image.
[0290] Furthermore, the target gain value corresponding to the second pixel can be determined in the gain image. Similarly, the target gain value is the pixel value of the pixel at the position corresponding to the second pixel in the gain image.
[0291] Similarly, you can refer to Figure 15 To understand this, the pixel at the same position as the second pixel a in the gain image is... Figure 15As shown in the image, pixel a2 can be used to determine the target gain value corresponding to the second pixel a.
[0292] Then refer to Figure 15 Therefore, the brightness value of the second pixel can be adjusted based on the target gain value and the target mask value of the second pixel.
[0293] In one implementation, for example, a first adjustment value can be determined by multiplying 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. Then, the second adjustment value is determined by multiplying the initial brightness value and the target mask value. Finally, the sum of the first and second adjustment values can be determined, and the ratio of the sum to the maximum value of the pixel can be used as the adjusted target brightness value for the second pixel.
[0294] For example, you can refer to Formula 3 to understand the above implementation process:
[0295] Y`=(Y*Gain*(255-maskV)+Y*maskV) / 255 Formula 3
[0296] Where Y is the initial brightness value of the second pixel, Gain is the target gain value corresponding to the second pixel, maskV is the target mask value corresponding to the second pixel, and Y' is the target brightness value adjusted for the second pixel.
[0297] The first part of Formula 3 above, “Y*Gain*(255-maskV)”, corresponds to the first adjustment value introduced above.
[0298] The purpose of the “Y*Gain” part is to add the gain value to the initial brightness value of the second pixel, thereby achieving the goal of darkening the brightness.
[0299] Furthermore, the effect of "(255-maskV)" is to apply the opposite effect to the masked portion of the mask image. Specifically, a mask value of 255 will be treated as 0 in the current formula, and a mask value of 0 will be treated as 255. In other words, pixels with larger mask values will experience less luminance suppression, while areas with smaller mask values will experience greater luminance suppression.
[0300] Based on the above, it can be determined that in the mask image, pixels closer to the center of the face region have larger mask values and are less affected by brightness suppression. Conversely, pixels farther from the center of the face region have smaller mask values and are more affected by brightness suppression. This achieves brightness protection for the face region while simultaneously enabling a brightness transition from the face region to other areas of the portrait region.
[0301] Furthermore, regarding the face region and the transition areas near it, because the first part of the formula described above protects these areas, the result of solving the first part of the formula will not reflect the brightness of the face region and the transition areas near it. For example, for the center region of a face image, if its mask value is 255, substituting it into the first part of the formula will result in 0, but the actual brightness of the center region of the face image is not 0.
[0302] Therefore, in addition to protecting the brightness of the face region and the transition area near the face region, it is also necessary to ensure that the final solution can correctly reflect the brightness of the face region and the transition area near the face region. Therefore, the formula also includes the second part "Y*maskV" mentioned above, which corresponds to the second adjustment value described above.
[0303] In the second part here, for pixels with larger mask values, the corresponding solution is closer to the original brightness, and for pixels with smaller mask values, the corresponding solution is closer to 0.
[0304] Since both the first and second parts described above are multiplied by a mask value ranging from 0 to 255, dividing by 255 based on the first and second parts described above will yield the optimized target brightness value of the second pixel.
[0305] It is understandable that in the actual implementation process, Formula 3 described above will be applied to the brightness value of each second pixel in the second image, thereby obtaining the optimized target brightness value for each second pixel in the second image. Then, based on the optimized target brightness value for each second pixel in the second image, the brightness map of the second image after brightness adjustment is obtained. Based on the adjusted brightness map, the optimized second image can be obtained.
[0306] It should be noted that the module names involved in the embodiments of this application can all be defined as other names, as long as they can achieve the function of each module, and no specific restrictions are placed on the module names.
[0307] 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 used for analysis, stored data, displayed data, etc.) involved in the embodiments of this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0308] The image adjustment method according to the embodiments of this application has been described above. The apparatus for performing the above method provided in the embodiments of this application is described below. Those skilled in the art will understand that the methods and apparatus can be combined with and referenced by each other, and the related apparatus provided in the embodiments of this application can perform the steps in the above image adjustment method.
[0309] The image adjustment method provided in this application can be applied to electronic devices with image capture and data processing functions. The electronic device includes a terminal device; the specific device form of the terminal device can be referred to the above-described related features, and will not be repeated here.
[0310] This application provides a terminal device, which includes a processor and a memory; the memory stores computer execution instructions; the processor executes the computer execution instructions stored in the memory, causing the terminal device to perform the above-described method.
[0311] This application provides a chip. The chip includes a processor, which is used to call a computer program in memory to execute the technical solutions in the above embodiments. Its implementation principle and technical effects are similar to those in the related embodiments described above, and will not be repeated here.
[0312] This application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, it implements the methods described above. The methods described in the above embodiments can be implemented wholly or partially by software, hardware, firmware, or any combination thereof. If implemented in software, the functionality can be stored as one or more instructions or code on or transmitted over the computer-readable medium. The computer-readable medium can include computer storage media and communication media, 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.
[0313] In one possible implementation, a computer-readable medium may include RAM, ROM, compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage or other magnetic storage devices, or any other medium targeted to carry or to store the required program code in the form of instructions or data structures, and accessible by a computer. Furthermore, any connection is appropriately referred to as 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, DSL, or wireless technologies such as infrared, radio, and microwave, then coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. As used herein, disks and optical discs include optical discs, laser discs, optical discs, Digital Versatile Discs (DVDs), floppy disks, and Blu-ray discs, where disks typically reproduce data magnetically, while optical discs optically reproduce data using lasers. Combinations of the above should also be included within the scope of computer-readable media.
[0314] This application provides a computer program product, which includes a computer program that, when run, causes a computer to perform the above-described method.
[0315] This application describes embodiments of methods, apparatus (systems), and computer program products according to embodiments of this application with reference to flowchart illustrations and / or block diagrams. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, special-purpose computer, embedded processor, or other programmable device to produce a machine, such that the instructions, which execute via the processing unit of the computer or other programmable data processing device, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0316] The above specific embodiments further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made on the basis of the technical solution of the present invention should be included within the scope of protection of the present invention.
Claims
1. An image adjustment method characterized by, The method comprises: determining a portrait region and a face region in a first image; wherein the first image is one of a preview stream or a reference image; determining a mask image according to the face region in the first image, the mask image being used to indicate a brightness adjustment degree of each first pixel point in the first image; determining a gain image according to the portrait region in the first image, the gain image being used to perform a brightness reduction process on the portrait region; wherein the portrait region is divided into a plurality of sub-regions along a first vertical direction from a topmost position of the portrait region downwards; and different gain values are assigned to each of the sub-regions, and the gain values corresponding to the sub-regions from the topmost sub-region downwards increase in turn; adjusting a respective brightness value of each second pixel point in a second image according to the mask image and the gain image; wherein the second image is an initial fusion image.
2. The method of claim 1, wherein, The method further comprises: determining a center point position of the face region in the first image; for any first pixel point of the first image, determining a pixel position of the first pixel point in the first image and a first distance between the pixel position and the center point position; determining a mask value corresponding to the first pixel point according to the first distance corresponding to the first pixel point; determining the mask image according to the mask value corresponding to each first pixel point in the first image.
3. The method of claim 2, wherein, The method further comprises: if the first distance is greater than a preset distance, determining the mask value of the first pixel point as a first value, the first value being a minimum value of mask values; or if the first distance is less than or equal to the preset distance, determining the mask value of the first pixel point according to a preset transition coefficient and the first distance.
4. The method of claim 3, wherein, The first distance and the mask value are in an inverse proportional relationship.
5. The method according to claim 3 or 4, characterized in that, The method further comprises: determining a first ratio according to the first distance and the preset distance; determining a first difference between a preset value and the first ratio, and determining a product of the first difference and the preset transition coefficient as a target ratio; determining the mask value of the first pixel point according to a product of the target ratio and a maximum value of pixel values.
6. The method according to any one of claims 1 to 4, characterized in that, The method further comprises: for any first pixel point of the first image outside the portrait region, determining a gain value of the first pixel point as a preset maximum gain value; for any first pixel point of the first image in the portrait region, determining a gain value of the first pixel point according to the maximum gain value and a preset minimum gain value; determining the gain image according to the gain value of each first pixel point in the first image.
7. The method of claim 6, wherein, The method further comprises: determining the gain value of the first pixel point according to the maximum gain value and the preset minimum gain value. The portrait region is divided into M sub-regions in a first vertical direction from a topmost position of the portrait region, where M is an integer greater than or equal to 1, and the first vertical direction is a vertical direction of the first image; M target values are determined in a numerical range from the minimum gain value to the maximum gain value, where an i-th target value in the M target values is less than an (i-1)-th target value, and i ranges from 1 to M; For a j-th sub-region in the M sub-regions, a gain value corresponding to each first pixel point in the j-th sub-region is determined as a j-th target value, where j ranges from 1 to M.
8. The method of claim 7, wherein, The M sub-regions are divided according to a first step length, where a length of each of the first M-1 sub-regions in the first vertical direction is the first step length, and a length of the M-th sub-region in the first vertical direction is less than or equal to the first step length. In addition, The M target values are uniformly selected in the numerical range from the minimum gain value to the maximum gain value, a first target value in the M target values is the minimum gain value, and an M-th target value in the M target values is the maximum gain value.
9. The method according to any one of claims 1-4, 7-8, characterized in that, The adjusting of the brightness value corresponding to each second pixel point in the second image according to the mask image and the gain image includes: For any second pixel point in the second image, a target mask value corresponding to the second pixel point is determined in the mask image; A target gain value corresponding to the second pixel point is determined in the gain image; The brightness value of the second pixel point is adjusted according to the target gain value and the target mask value.
10. The method of claim 9, wherein, The adjusting of the brightness value of the second pixel point according to the target gain value and the target mask value includes: An initial brightness value of the second pixel point is obtained; A first adjustment value is determined according to a product of the initial brightness value, the target gain value, and a second difference value corresponding to the target mask value, where the second difference value is a difference between the target mask value and a maximum mask value; A second adjustment value is determined according to a product of the initial brightness value and the target mask value; A sum of the first adjustment value and the second adjustment value is determined, and a ratio of a value obtained by summing to a maximum pixel value is determined as a target brightness value of the second pixel point after adjustment.
11. The method according to any of claims 1-4, 7-8, 10, characterized by, The first image is one of multiple preview images collected by a camera application program; Alternatively, the first image is one of multiple collected images, and the multiple collected images are collected by the camera application program in response to a user operation on a photographing control.
12. The method of claim 11, wherein, The second image is an image fused according to the multiple collected images.
13. An electronic device, comprising: The electronic device 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 electronic device performs the method of any one of claims 1-12.
14. A computer-readable storage medium, the computer-readable storage medium storing a computer program, characterized in that, The computer program, when executed by the processor, implements the method of any one of claims 1-12.
15. A chip system, characterized by A computer program product comprising at least one processor and a communication interface, said communication interface and said at least one processor being interconnected by a line, said at least one processor being adapted to run computer programs or instructions to perform the method according to any one of claims 1 to 12.
16. A computer program product, characterised in that, A computer program, which when run causes a computer to perform the method according to any one of claims 1 to 12.
Citation Information
Patent Citations
Image processing method and device, electronic equipment and computer readable storage medium
CN112085686A
Image processing method and device, electronic equipment and computer readable storage medium
CN113888437A
Image processing method, image processing device, electronic equipment and storage medium
CN115423721A