Image processing method and electronic device

By using unexposed images in the linear domain space for filtering in night scene photography, the problem of poor bokeh effect caused by brightness truncation in bright areas of clear sRGB images is solved. This achieves a bokeh effect with the number and brightness of bokeh spots consistent with the actual light source, thus improving image quality.

CN123185447APending Publication Date: 2026-11-27HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510694893.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-27
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

In night scene photography, existing technologies suffer from poor bokeh effects in the blurred image because the brightness of the bright areas in the clear sRGB image is truncated, which affects the user experience.

Method used

By acquiring an unexposed image in the linear domain space, filtering is applied to the image in the nonlinear domain space to enhance the bokeh effect. This includes steps such as bokeh enhancement, linear transformation, weighted filtering, and nonlinear transformation in the bokeh region, ensuring that the number and brightness of the bokeh are consistent with the actual light source.

Benefits of technology

It improves the bokeh effect of the image, enhances the brightness levels and overlay relationships of the bokeh, and improves image quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123185447A_ABST
    Figure CN123185447A_ABST
Patent Text Reader

Abstract

The application provides an image processing method and an electronic device. In the method, the electronic device acquires a first image and a second image; the first image is an image in a nonlinear domain space, and the second image is an un-overexposed image in a linear domain space; the first image is subjected to speckle enhancement, linear transformation and weighted filtering according to the second image to obtain an image consistent with the speckle number and brightness of the second image; the image is mapped to the nonlinear domain through nonlinear transformation to ensure the contrast of the dark area of the image, and then fused with the first image to generate a target bokeh image, thereby enhancing the effect of the bokeh speckle in the target bokeh image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of terminal technology, and in particular to an image processing method and an electronic device. Background Technology

[0002] When taking photos with electronic devices, users increasingly seek professional-grade image quality, especially the bokeh effect of a large aperture from a DSLR camera. The basic process involves obtaining a sharp image with the sRGB domain distribution and then filtering it according to the desired blur level to obtain the blurred image. However, in most scenarios, especially night scene photography, the brightness of the bright areas in the sharp image with the sRGB domain distribution is truncated, resulting in poor bokeh effects in the blurred image and negatively impacting the user experience. Summary of the Invention

[0003] To address the aforementioned technical problems, this application provides an image processing method and an electronic device. In this method, an unexposed image in the linear domain space is used to filter an image in the nonlinear domain space, thereby enhancing the effect of blurring light spots and improving the user experience.

[0004] In a first aspect, embodiments of this application provide an image processing method. This method is applied to an electronic device and includes:

[0005] In response to a photo-taking operation, a first image and a second image are acquired; wherein the first image is an image in a non-linear domain space, and the second image is an unexposed image in a linear domain space;

[0006] Based on the second image, the spot area of ​​the first image is enhanced to generate a third image;

[0007] Perform a linear transformation on the third image to generate a fourth image corresponding to the third image;

[0008] The fourth image is weighted and filtered to generate the fifth image;

[0009] A nonlinear transformation is performed on the fifth image to generate a sixth image corresponding to the fifth image;

[0010] The sixth image is fused with the first image to generate the target image;

[0011] Display the target image.

[0012] For example, the first image is a normally exposed image in a non-linear domain space, which includes, but is not limited to, sRGB, Adobe RGB, ProPhoto RGB, Display P3, etc. This application uses an image in the sRGB domain (sRGB clear image) as an example for illustration.

[0013] For example, the second image is an unexposed image in the linear domain space. The light source brightness distribution of the second image is linearly related to the actual light source brightness distribution. This application uses a short-exposure image captured by a camera as an example for illustration.

[0014] For example, the third image may be an enhanced image; the fourth image may be a clear image in the pseudo-linear domain; and the fifth image may be... Figure 10 The first pseudo-linear domain global virtualized diagram shown, or Figure 12 The second pseudo-linear domain global blurring diagram is shown; the sixth image can be... Figure 10 The first bokeh image shown, or Figure 12 The second bokeh effect is shown; the target image can be... Figure 10 The first target blurred image shown, or Figure 12 The second target blurred image is shown.

[0015] For example, a light spot area is a specific type of bright area, specifically referring to a localized light spot area formed by reflection or scattering.

[0016] Thus, the second image is an unexposed linear domain image. Based on the second image, the spot area of ​​the first image is enhanced to generate the third image. Then, the third image is sequentially subjected to linear transformation and weighted filtering to obtain the fifth image. The number and brightness of the spots in the fifth image are also consistent with the linear domain image. The fifth image is mapped to the nonlinear domain through nonlinear transformation to ensure the contrast of the dark areas. Then, it is fused with the first image to generate the target image, enhancing the effect of the blurred spots in the target image. That is, the brightness level, overlay relationship and number of spots in the spot effect of the target image are consistent with the actual light source.

[0017] According to the first aspect, the linear transformation includes at least one of the following: inverse gamma transformation, inverse tone mapping;

[0018] Perform a linear transformation on the third image to generate a fourth image corresponding to the third image, including:

[0019] Perform an inverse gamma transform on the third image to generate the seventh image;

[0020] Perform inverse tone mapping on the seventh image to generate the fourth image.

[0021] For example, the seventh image may be a reverse-enhanced image.

[0022] In this way, by using the second image with unexposed brightness in the linear domain space, the first image is linearly transformed to the pseudo-linear domain for blur filtering, which optimizes the brightness of the spot area in the image and the overlay level of adjacent spots, and makes the number of spots consistent with the actual light source.

[0023] According to the first aspect, or any implementation of the first aspect above, the fourth image is weighted and filtered to generate the fifth image, including:

[0024] Generate the eighth image based on the second and seventh images;

[0025] The fourth image is filtered to generate the ninth image;

[0026] Using the eighth image as a weight, the tenth image is generated by sequentially applying weighted filtering to the spot regions of the fourth image based on the first data.

[0027] The tenth image is superimposed on the ninth image to generate the fifth image.

[0028] For example, the eighth image can be a pseudo-mapping gain image; the ninth image can be a preliminary blurring image; and the tenth image is an image obtained by using the eighth image as a weight and sequentially performing weighted filtering on the spot area of ​​the fourth image according to the first data.

[0029] For example, the first data is a mask for the distribution of connected components of the light spot.

[0030] In this way, a global brightness map (i.e., the eighth image) is constructed using the second image, and used as a weight for weighted filtering during spot blur filtering. The brightness of the spots, the overlay levels of adjacent spots, and the number of spots in the filtered image are consistent with the actual light source.

[0031] According to the first aspect, or any implementation of the first aspect above, it also includes:

[0032] Second data is obtained by performing spot detection on the second image;

[0033] The first data is obtained by performing connected component detection on the second data.

[0034] For example, the second data is a mask for the bright spot region.

[0035] In this way, by using the first data to perform weighted filtering on the spot area of ​​the fourth image, the edge information in the image can be better preserved, the edge blurring or loss can be reduced, and the overall image quality can be improved.

[0036] According to the first aspect, or any implementation of the first aspect above, the fourth image is weighted and filtered to generate the fifth image, including:

[0037] Generate the eighth image based on the second and seventh images;

[0038] The fourth image is then weighted and filtered using the eighth image to generate the fifth image.

[0039] In this way, a global brightness map (i.e., the eighth image) is constructed using the second image, and used as a weight for weighted filtering during spot blur filtering. The brightness of the spots, the overlay levels of adjacent spots, and the number of spots in the filtered image are consistent with the actual light source.

[0040] According to the first aspect, or any implementation of the first aspect above, based on the second image, the spot enhancement of the spot region of the first image is performed to generate the third image, including:

[0041] Based on the third data and the second image, the spot area of ​​the first image is enhanced to generate the third image; wherein, the third data is the depth data corresponding to the first image.

[0042] In this way, the light source brightness distribution of the second image is linearly related to the actual light source brightness distribution. The light spot area of ​​the first image is enhanced to optimize the brightness of the light spot area in the image and the overlay layer of adjacent light spots.

[0043] According to the first aspect, or any implementation of the first aspect above, the sixth image is fused with the first image to generate the target image, including:

[0044] Based on the third data, the sixth image is fused with the first image to generate the target image.

[0045] For example, the sixth image is fused with the first image to generate the target image based on the mask of the region within the depth of field.

[0046] In this way, by using the mask of the depth-of-field region for image fusion, the clear regions within the depth of field in different images can be identified and fused into the final image, which can improve the overall image clarity while preserving the image's details and texture information.

[0047] According to the first aspect, or any implementation of the first aspect above, it also includes:

[0048] Based on the third data, determine the filtering parameters for weighted filtering of the fourth image.

[0049] For example, the filtering parameters for weighted filtering of the fourth image are determined based on the blur filtering radius of the region outside the depth of field, that is, the blur filtering radius of the region outside the depth of field is the size of the blur kernel of the filtering function (such as the blur filtering function).

[0050] This allows for precise control over the blur range, balancing detail preservation with the blur effect, and improving image quality.

[0051] According to the first aspect, or any implementation of the first aspect above, it also includes:

[0052] Depth calculation is performed on the first image to generate the eleventh image;

[0053] The third data was obtained based on the eleventh image and shooting parameters;

[0054] The third data includes at least one of the following: the mask of the area within the depth of field, and the blurring filter radius of the area outside the depth of field.

[0055] For example, the eleventh image may be a depth distribution map.

[0056] For example, deep learning models can be categorized into monocular depth models and multi-view depth models (such as binocular depth models) based on the number of lenses. For instance, if there is only one lens, the eleventh image is generated by performing depth calculations on a first image using a monocular depth model; if there are two lenses, the eleventh image is generated by performing depth calculations on two first images (the first image corresponding to the main lens and the second image corresponding to the auxiliary lens) using a binocular depth model.

[0057] For example, the shooting parameters include at least one of the following: focus point position, aperture size, and focal length.

[0058] It should be noted that depth calculation can be performed on multiple first images. For example, in addition to the first image corresponding to the main lens, there may be first images corresponding to other lenses (such as auxiliary lenses), which can capture images of the same scene from different perspectives, providing efficient and accurate 3D information. In the steps of generating a third image by enhancing the light spot area of ​​the first image based on the second image, and fusing the sixth image with the first image to generate the target image, the number of first images is one. The first image can be a clear sRGB image generated by fusing multiple first images, or it can be a clear sRGB image corresponding to the main lens.

[0059] In this way, by determining the depth data based on the depth distribution map and shooting parameters, more accurate, natural, and efficient depth-of-field blurring can be achieved, greatly improving the quality of photography, rendering, and visual expression.

[0060] According to the first aspect, or any implementation of the first aspect above, the nonlinear transformation includes at least one of the following: gamma transformation, tone mapping; the parameters of the nonlinear transformation are the same as those of the linear transformation.

[0061] In this way, the contrast of the dark area of ​​the image is guaranteed by nonlinear transformation to nonlinear domain, and then fused with the first image to generate the target image, which enhances the effect of the blurred light spots in the target image. That is, the brightness level, overlay relationship and number of light spots in the light spot effect of the target image are consistent with the actual light source.

[0062] Secondly, embodiments of this application provide an electronic device. The electronic device includes: one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, and when executed by the one or more processors, the electronic device performs the image processing method of the first aspect and any one thereof.

[0063] The second aspect and any implementation thereof correspond to the first aspect and any implementation thereof, respectively. The technical effects of the second aspect and any implementation thereof are similar to those of the first aspect and any implementation thereof, and will not be repeated here.

[0064] Thirdly, embodiments of this application provide a computer-readable storage medium. This computer-readable storage medium includes a computer program that, when run on an electronic device, causes the electronic device to perform the image processing method of the first aspect and any one thereof.

[0065] The third aspect and any implementation thereof correspond to the first aspect and any implementation thereof, respectively. The technical effects of the third aspect and any implementation thereof are similar to those of the first aspect and any implementation thereof, and will not be repeated here.

[0066] Fourthly, embodiments of this application provide a computer program product, including a computer program that, when run, causes a computer to perform an image processing method as described in the first aspect or any one of the first aspects.

[0067] The fourth aspect and any implementation thereof correspond to the first aspect and any implementation thereof, respectively. The technical effects of the fourth aspect and any implementation thereof can be found in the technical effects of the first aspect and any implementation thereof, as described above, and will not be repeated here.

[0068] Fifthly, this application provides a chip including a processing circuit and transceiver pins. The transceiver pins and the processing circuit communicate with each other via an internal connection path. The processing circuit executes an image processing method as described in the first aspect or any one thereof, to control the receiving pin to receive signals and to control the transmitting pin to transmit signals.

[0069] The fifth aspect and any implementation thereof correspond to the first aspect and any implementation thereof, respectively. The technical effects of the fifth aspect and any implementation thereof are similar to those of the first aspect and any implementation thereof, and will not be repeated here. Attached Figure Description

[0070] Figure 1 This is a schematic diagram of a scenario as an example.

[0071] Figure 2 This is a schematic diagram illustrating the structure of an electronic device as an example.

[0072] Figure 3 A schematic diagram illustrating the software structure of an electronic device as an example;

[0073] Figure 4 This is a schematic diagram illustrating an image processing method as an example.

[0074] Figure 5 This is a schematic diagram illustrating a short-exposure image, a sharp sRGB image, and a blurred target image, as exemplarily shown.

[0075] Figure 6 This is a schematic diagram of an image processing apparatus as an example.

[0076] Figure 7 This is a schematic diagram illustrating an exemplary method for generating depth-of-field inner masks and blurring filter radii.

[0077] Figure 8 This is a schematic diagram illustrating a method for generating a clear map of a pseudo-linear domain, as exemplarily shown.

[0078] Figure 9 This is a schematic diagram illustrating an exemplary method for generating a pseudo-mapping gain map;

[0079] Figure 10 This is an example of a target blurring image generation schematic diagram;

[0080] Figure 11 This is a schematic diagram of yet another image processing apparatus, as exemplarily shown.

[0081] Figure 12 This is an example of another target blurring image generation schematic diagram;

[0082] Figure 13 This is a schematic diagram of the structure of an exemplary device. Detailed Implementation

[0083] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0084] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.

[0085] The terms "first" and "second," etc., used in the specification and claims of this application are used to distinguish different objects, not to describe a specific order of objects. For example, "first target object" and "second target object," etc., are used to distinguish different target objects, not to describe a specific order of target objects.

[0086] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0087] In the description of the embodiments in this application, unless otherwise stated, "multiple" means two or more. For example, multiple processing units means two or more processing units; multiple systems means two or more systems.

[0088] When taking photos with electronic devices, users are increasingly pursuing professional-grade image quality, especially the bokeh effect of large apertures reminiscent of DSLR cameras. Whether day or night, users want to capture photos with depth and atmosphere. Currently, the basic process for simulating the bokeh effect of large apertures in mobile phone photography involves inputting a clear sRGB image (i.e., a clear image with a sRGB domain distribution), then applying a blur filter to the clear sRGB image according to the appropriate degree of bokeh, ultimately outputting a clear sRGB image with a simulated bokeh effect.

[0089] However, in most scenarios, especially night scene photography, electronic devices tend to have relatively high exposure levels to capture details in dark areas. This can cause bright areas to exceed the maximum brightness range that the electronic device can record. Compressing and truncating the maximum brightness value of the sRGB sharp image to 255, and then applying a blur filter to the truncated sRGB sharp image, can lead to problems such as similar brightness levels in the sRGB sharp image with simulated bokeh, indistinguishable layering when bokeh overlaps, and uncontrollable bokeh quantity. The following example of night scene photography will illustrate this in detail.

[0090] In night scene photography, the dynamic range of a scene is typically very high. Illuminated subjects (such as streetlights and car headlights) are in bright areas with high brightness, while non-illuminated subjects (such as buildings and people) are in dark areas with low brightness. Responding to the user's shooting action, the electronic device captures multiple images of the same scene at different exposures (such as short exposure, normal exposure, and overexposed images) using sensors. The electronic device then merges these multiple images into a single high dynamic range (HDR) image (e.g., in 32-bit floating-point format). During this process, information from dark areas is fully integrated, thereby brightening the non-illuminated subjects in those dark areas. Images with different exposures can capture details in different brightness areas of the scene; for example, underexposed images clearly record details in bright areas, while overexposed images capture more information from dark areas. Dynamic range describes the range of brightness levels in a scene, that is, the difference between the brightest and darkest areas. High dynamic range means being able to identify both very bright and very dark areas in a scene.

[0091] Because electronic devices need to capture details in dark areas, the exposure is relatively large, which may cause bright areas to exceed the maximum brightness range that the electronic device can record. The electronic device uses methods such as non-linear brightness mapping to map the brightness range of the HDR image to the 8-bit range of the sRGB domain. Simultaneously, it maps the lower values ​​representing dark areas in the HDR image to relatively higher values ​​within the 8-bit range (i.e., brightening the non-emitting elements in dark areas to the point where the human eye can distinguish details), resulting in a clear sRGB image. The clear sRGB image is a low dynamic range image, meaning the level from brightest to lowest is 255.

[0092] In the sRGB clear image, the three color channels are red (R), green (G), and blue (B), each using 8 bits to represent the brightness value, ranging from 0 to 255. For example, the brightness range of an HDR image is 5000 units, which maps to a brightness value of 255 in the sRGB domain; the brightness of the second luminous element is 900 units, which maps to a brightness value of 150 in the sRGB domain.

[0093] However, this results in a difference between the final sRGB clear image brightness and the actual brightness of different objects in the real scene. For example, the original brightness value of a non-emitting subject in a dark area might be very low (e.g., 0.5), making it difficult for the human eye to distinguish details. The method described above increases the brightness value of the non-emitting subject from near 0 (e.g., 0.5) to a range that the human eye can distinguish (e.g., 50). Meanwhile, the original brightness value of an emitting subject in a bright area might be much greater than 255 (e.g., 300). The method described above truncates the original brightness value of the emitting subject to 255, meaning that brightness values ​​exceeding 255 are forcibly set to 255. Ultimately, this results in the brightness comparison between the emitting and non-emitting subjects in the sRGB clear image being less than 255, or even only a few times. For example, the original brightness comparison between the emitting and non-emitting subjects might be 300:0.5, but in the sRGB clear image, it might be 255:50.

[0094] Blur filtering is an image processing technique commonly used to simulate the "blurring" effect in camera lenses (such as background blur or bokeh). This blur filtering generates bokeh effects in bright areas based on the brightness distribution of the image, simulating the halo effect produced by a real lens outside the focus area. The brightness and shape of the bokeh are usually related to the brightness of the bright areas in the image. Ideally, blur filtering should generate bokeh based on the real brightness distribution of the scene: brighter light sources should produce brighter, more prominent bokeh; darker light sources should produce darker, weaker bokeh. In this way, when multiple bokeh overlap, the brightness differences create a visual sense of hierarchy (overlay hierarchy), allowing the human eye to distinguish the distance or intensity of different light sources.

[0095] However, if a blur filter is directly applied to the sRGB clear image after brightness truncation, the resulting brightness reflects the brightness distribution of the truncation image. This can lead to all the blurred spots having similar brightness levels and overlapping, making it impossible to distinguish layers. In other words, if the brightness values ​​of bright areas in the sRGB clear image are all close to 255 with little difference, the corresponding blurred spots will also have the same brightness because the image brightness values ​​are essentially the same. For example, if the first emitting element has a brightness of 10,000 units and the second emitting element has a brightness of 5,000 units, and the brightness values ​​of both the first and second emitting elements mapped to the sRGB domain are close to 255 (e.g., between 250 and 255), after blur filtering, these emitting elements will all become "bright spots" of the same brightness, lacking any gradient or difference in brightness.

[0096] Furthermore, when multiple light spots have the same brightness and their positions overlap, they become indistinguishable, resulting in a lack of visual overlay and layering. For example, when a user takes a portrait of a city night scene on a neon-lit street, multiple luminous subjects (such as signs and streetlights) are adjacent, and the brightness values ​​of these subjects mapped to the sRGB domain are all close to 255. The areas corresponding to these subjects are also indistinguishable, causing the light spots to overlap and have similar brightness. The human eye cannot distinguish which is brighter, farther, or closer, nor can it tell which "outshines" which. Compared to images taken directly with a large aperture from a DSLR, this lacks the effect of bokeh and layering.

[0097] Specifically, if there are white areas within a non-luminous subject (such as a white wall or white clothing), their brightness values ​​will be amplified significantly, meaning their RGB values ​​will approach [255, 255, 255], reaching or near the maximum value of 255. Although in real-world scenes, the actual brightness of white areas (reflected light) is far lower than that of luminous subjects (self-illuminating), because the RGB values ​​of white areas are [255, 255, 255], the filtering algorithm cannot distinguish whether these white areas are truly luminous subjects (such as streetlights) or simply bright non-luminous subjects (such as white walls or white clothing). These white areas are treated as luminous subjects and subjected to the same spotting process. Real spots (spots corresponding to luminous subjects) and false spots (spots not corresponding to luminous subjects) are mixed together in the image, resulting in an uncontrollable number of spots and ruining the image's blurring effect.

[0098] For example, in an HDR image, a luminous subject (such as a street lamp) has a brightness of 10,000 units, while a non-luminous subject (such as a white building) has a brightness of 500 units for reflected light. The luminous subject emits light through its own light source, resulting in extremely high brightness and typically sharp edges, while reflected light depends on ambient light, exhibiting lower brightness and softer edges. However, in a clear sRGB image, the luminous subject's brightness value is compressed to 255, while the non-luminous subject's brightness value may be increased to 255 (because the algorithm might consider reflected light as a dark area requiring enhancement). Since the luminous and non-luminous subjects have the same brightness value, blurring filters cannot differentiate them based on brightness difference; they are blurred only because the brightness values ​​are equal, generating light spots for both subjects. This results in two light spots in the final clear sRGB image, whereas in a real scene there is only one luminous subject.

[0099] In the above embodiments, the brightness of the blurred image depends on the brightness distribution of the sRGB clear image. However, the brightness of the sRGB clear image is truncated in the bright areas. In addition, some bright areas in the sRGB clear image are actually non-light source areas. This results in the blurred image generated by the final filtering having unclear brightness levels of the light spots, poor superposition of brightness levels between adjacent light spots, and light spots or halos appearing in areas that are not bright areas.

[0100] To address the aforementioned issues, this application provides an image processing method. The short-exposure image is an unexposed linear domain image. Based on the short-exposure image, the sRGB clear image undergoes spot enhancement, linear transformation, and weighted filtering to obtain an image with the same number and brightness of spots as the linear domain image. This image is then mapped to the nonlinear domain through a nonlinear transformation to ensure contrast in dark areas. Finally, it is fused with the sRGB clear image to generate a target blurred image, enhancing the effect of blurred spots in the target blurred image and improving image quality.

[0101] Before introducing the embodiments of this application, firstly based on Figure 1 The application scenarios of the embodiments of this application will be described. Figure 1 In the corresponding embodiments, a mobile phone is used as an example for illustration. This example does not constitute a limitation on the embodiments of this application.

[0102] In response to the user launching the camera application on the electronic device, the electronic device displays the shooting interface 101, such as Figure 1 As shown in (1) in the image; the shooting interface 101 may include a preview image 102, which is an image after being blurred based on the large aperture function.

[0103] The shooting interface 101 may also include: a gallery control 103, a shooting control 104, a shooting mode option area 105, and a focus point box 106.

[0104] Gallery control 103 is a control used in camera applications to display and manage images.

[0105] The shooting control 104 is a functional component used for shooting in the camera application.

[0106] The shooting mode option area 105 can display one or more shooting mode options. These shooting mode options may include: large aperture mode option, night scene mode option, portrait mode option, photo mode option, video mode option, professional option mode, and more options. If the electronic device responds to the user's selection of large aperture mode option, night scene mode option, portrait mode, etc., and takes a picture, the electronic device applies image processing methods to obtain a blurred image.

[0107] The focus point frame 106 can be automatically generated by the electronic device based on the content displayed in the preview image 102, or it can be generated in response to a user's trigger operation on the shooting interface 101.

[0108] In response to the user clicking the shooting control 104, the electronic device can acquire a captured image using the camera, and through image processing steps such as blurring the captured image, obtain an image like... Figure 1 The image shown in (2) is the blurred image.

[0109] This application provides an image processing method. This method can be applied to electronic devices with camera functionality. The electronic device optimizes the brightness of light spots in an image and the overlay levels of adjacent light spots, and makes the number of light spots in the image consistent with the actual light source, thereby enhancing the blurred light spot effect of the image.

[0110] Therefore, in order to better understand the embodiments of this application, the electronic devices of the embodiments of this application will be described below with reference to the accompanying drawings. Figure 2 This is a schematic diagram of the structure of an electronic device 200 provided in an embodiment of this application.

[0111] The electronic device can be a mobile phone, smart screen, tablet computer, wearable device, television, in-vehicle electronic device, augmented reality (AR) / virtual reality (VR) device, laptop computer, ultra-mobile personal computer (UMPC), netbook, personal digital assistant (PDA), projector, etc., or it can be other devices or apparatuses capable of scene recognition. This application does not impose any restrictions on the specific type of electronic device.

[0112] It should be understood that, Figure 2 The electronic device 200 shown is only one example of an electronic device, and the electronic device 200 may have more or fewer components than shown in the figure, may combine two or more components, or may have different component configurations. Figure 2 The various components shown can be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application-specific integrated circuits.

[0113] Electronic device 200 may include: processor 210, external memory interface 220, internal memory 221, universal serial bus (USB) interface 230, charging management module 240, power management module 241, battery 242, antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, audio module 270, speaker 270A, receiver 270B, microphone 270C, headphone jack 270D, sensor module 280, button 290, motor 291, indicator 292, camera 293, display screen 294, and subscriber identification module (SIM) card interface 295, etc. The sensor module 280 may include pressure sensors, gyroscope sensors, barometric pressure sensors, magnetic sensors, accelerometers, distance sensors, proximity sensors, fingerprint sensors, temperature sensors, touch sensors, ambient light sensors, bone conduction sensors, etc.

[0114] Processor 210 may include one or more processing units, such as application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU). Different processing units may be independent devices or integrated into one or more processors.

[0115] The controller can be the nerve center and command center of the electronic device 200. The controller can generate operation control signals based on the instruction opcode and timing signals to control the fetching and execution of instructions.

[0116] The processor 210 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 210 is a cache memory. This memory can store instructions or data that the processor 210 has just used or that are used repeatedly. If the processor 210 needs to use the instruction or data again, it can directly retrieve it from the memory. This avoids repeated accesses, reduces the waiting time of the processor 210, and thus improves the efficiency of the system.

[0117] 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 electronic device 200. In other embodiments of this application, the electronic device 200 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.

[0118] The wireless communication function of electronic device 200 can be implemented through antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, modem processor, and baseband processor. Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals.

[0119] The mobile communication module 250 can provide wireless communication solutions, including 2G / 3G / 4G / 5G, for use on electronic devices 200.

[0120] In some embodiments, antenna 1 of electronic device 200 is coupled to mobile communication module 250, and antenna 2 is coupled to wireless communication module 260, enabling electronic device 200 to communicate with networks and other devices via wireless communication technology.

[0121] Electronic device 200 implements display functions through a GPU, a display screen 294, and an application processor. The GPU is a microprocessor for image processing, connecting the display screen 294 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 210 may include one or more GPUs, which execute program instructions to generate or modify display information.

[0122] Display screen 294 is used to display images, videos, etc. Display screen 294 includes a display panel. In some embodiments, electronic device 200 may include two or N displays screens 294, where N is a positive integer greater than 2. For example, display screen 294 is used to display the target blurred image after blurring processing as described in the embodiments of this application.

[0123] Electronic device 200 can perform shooting functions through ISP, camera 293, video codec, GPU, display screen 294 and application processor.

[0124] Camera 293 is used to capture still images or videos, for example, camera 293 is used to acquire raw images containing light spots.

[0125] The external storage interface 220 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 200. The external memory card communicates with the processor 210 through the external storage interface 220 to perform data storage functions. For example, files such as music, videos, and blurred images of targets acquired based on camera applications can be stored on the external memory card.

[0126] Internal memory 221 can be used to store computer executable program code, which includes instructions. Processor 210 executes various functional applications and data processing of electronic device 200 by running the instructions stored in internal memory 221. Internal memory 221 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 200 (such as audio data, phonebook, etc.). Furthermore, internal memory 221 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.

[0127] Electronic device 200 can implement audio functions such as music playback and recording through audio module 270, speaker 270A, receiver 270B, microphone 270C, headphone jack 270D, and application processor.

[0128] A pressure sensor is used to sense pressure signals and can convert these signals into electrical signals. In some embodiments, the pressure sensor may be located on the display screen 294.

[0129] An ambient light sensor is used to detect ambient light levels. Electronic device 200 can adaptively adjust the brightness of its display screen 294 based on the detected ambient light level. The ambient light sensor can also be used to automatically adjust the white balance when taking a picture. Furthermore, the ambient light sensor can work in conjunction with a proximity sensor to detect whether electronic device 200 is in a pocket, preventing accidental touches.

[0130] A fingerprint sensor is used to collect fingerprints. Electronic device 200 can utilize the characteristics of the collected fingerprints to achieve fingerprint unlocking, accessing application locks, taking photos with fingerprints, answering calls with fingerprints, etc.

[0131] The display screen 294 in this embodiment can be a touch screen. A touch sensor can be integrated into the display screen 294. This touch sensor can also be called a "touch panel." That is, the display screen 294 can include a display panel and a touch panel; the touch sensor and the display screen 294 together form a touch screen, also called a "touchscreen." The touch sensor is used to detect touch operations applied to or near it. After the touch sensor detects a touch operation, it can be passed to the upper layer by a kernel layer driver (such as a TP driver) to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 294. In other embodiments, the touch sensor can also be disposed on the surface of the electronic device 200, in a different location than the display screen 294.

[0132] In this embodiment, the touch sensor detects the user's touch operation. For example, when the user touches the display screen 294, the touch sensor detects the user's touch operation and passes it to the upper layer by the kernel layer driver (such as the TP driver) to determine the touch event type, such as a click on the camera control event. Similarly, when the user stops touching the display screen 294, the touch sensor detects that the user has lifted their finger, and passes it to the upper layer by the kernel layer driver (such as the TP driver) to determine the touch event type. In response to the user's touch operation, the processor 210 provides visual output related to the touch operation through the display screen 294, such as displaying a camera interface on the display screen 294, which includes a preview image, gallery controls, and camera controls, etc.

[0133] The software system of electronic device 200 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses the layered architecture Android system as an example to exemplify the software structure of electronic device 200.

[0134] Figure 3 This is a software structure block diagram of an electronic device 100 according to an embodiment of this application.

[0135] The layered architecture of the electronic device 200 divides the software into several layers, each with a clear role and division of labor. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android Runtime and system libraries, and the kernel layer.

[0136] The application layer can include a series of application packages.

[0137] like Figure 3 As shown, the application package can include applications such as camera, gallery, Bluetooth, call, calendar, map, navigation, music, and video.

[0138] The camera application is used to generate and send shooting requests, and to display the blurred image of the target after blurring.

[0139] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.

[0140] like Figure 6 As shown, the application framework layer may include a window manager, content provider, view system, phone manager, resource manager, notification manager, activity manager, camera service module, etc.

[0141] The camera service module is a module that processes image data at the application framework layer. It is used to transmit image data, such as returning the target blurred image data transmitted from the underlying layer to the camera application.

[0142] The window manager is used to manage windowed applications. It can retrieve screen size, determine the presence of a status bar, lock the screen, and capture screenshots, among other things.

[0143] The Activity Manager Service (AMS) is responsible for managing Activities, including starting, switching, and scheduling various components in the system, as well as managing and scheduling applications.

[0144] Content providers store and retrieve data, making that data accessible to applications. This data may include videos, images, audio, made and received phone calls, browsing history and bookmarks, phone books, etc.

[0145] A view system includes visual controls, such as controls for displaying text and controls for displaying images. View systems can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text notification icon could include views for displaying text and views for displaying images.

[0146] The phone manager is used to provide communication functions for electronic device 100. For example, it manages call status (including connection and disconnection).

[0147] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.

[0148] The notification manager allows applications to display notifications in the status bar. These notifications can be used to deliver informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager can be used to notify users of completed downloads or message alerts. The notification manager can also display notifications as icons or scrolling text in the top status bar, such as notifications from background applications, or as dialog boxes on the screen. Examples include displaying text messages in the status bar, emitting sounds, vibrating electronic devices, and flashing indicator lights.

[0149] The Android Runtime consists of core libraries and a virtual machine. The Android Runtime is responsible for the scheduling and management of the Android system.

[0150] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.

[0151] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

[0152] System libraries can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.

[0153] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.

[0154] The media library supports playback and recording of various common audio and video formats, as well as still image files. It supports multiple audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.

[0155] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

[0156] A 2D graphics engine is a graphics engine for 2D drawing.

[0157] The Hardware Abstraction Layer (HAL) is an interface layer located between the application framework layer and the kernel layer, providing a virtual hardware platform for the operating system. The HAL can include the Audio HAL, Camera HAL, and Storage HAL, among others. The Camera HAL processes short-exposure images and sharp sRGB images to generate blurred target images. For example, the Camera HAL performs spot enhancement, linear transformation, and weighted filtering on the sharp sRGB image based on the short-exposure image to obtain an image with the same number and brightness of spots as the linear domain image; this image is then mapped to the nonlinear domain through a nonlinear transformation to ensure contrast in dark areas, and finally fused with the sharp sRGB image to generate the blurred target image.

[0158] The kernel layer is the layer between hardware and software. It includes at least display drivers, audio drivers, Wi-Fi drivers, and camera drivers. The hardware includes at least a processor, a display screen, a Wi-Fi module, and a camera. For example, the camera driver uses the camera to acquire raw images and sharp sRGB images, and then transmits the image data to the camera's HAL (Hardware Allocation Layer).

[0159] Understandable Figure 6The layers in the illustrated software structure and the components contained in each layer do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer layers than illustrated, and each layer may include more or fewer components; this application does not impose any limitations.

[0160] It is understood that, in order to implement the image processing methods in the embodiments of this application, electronic devices include hardware and / or software modules that perform various functions. Based on the algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementation should not be considered beyond the scope of this application.

[0161] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be implemented independently or in combination with each other. The same or similar concepts or processes may not be described again in some embodiments.

[0162] For example, Figure 4 This is a schematic flowchart illustrating an image processing method provided in an embodiment of this application. Figure 4 In a corresponding embodiment, the electronic device may include: a camera application, a camera service module, a camera HAL, and a camera driver. For example... Figure 4 As shown, the image processing method may include the following steps:

[0163] S401. In response to the user's trigger shooting operation, the camera application sends a first image shooting request to the camera service module.

[0164] For example, the shooting operation is used to indicate the start of shooting; the shooting operation can be a photo-taking operation. Figure 1 As shown in (1), the shooting operation can be a click operation on the shooting control. The shooting operation can also be a shooting operation instructed by voice; or, the shooting operation can also be a shooting operation instructed by face recognition; or, the shooting operation can also be a shooting operation instructed by gesture recognition; or, the shooting operation can also be a shooting operation instructed by pressing a physical button (such as a volume button), etc.; this application does not limit it in any way.

[0165] It is worth noting that, in the embodiments of this application, when the shooting operation is a click operation, the shooting operation can be divided into clicking the shooting control and taking off the hand operation. Typically, when the camera application detects a click on the shooting control, it starts shooting; when the camera application detects a take-off operation, it ends shooting.

[0166] For example, the first image capture request includes, but is not limited to, parameter settings, shooting mode, etc.; parameter settings include, but are not limited to, resolution, frame rate, exposure, ISO, aperture, white balance, etc.

[0167] S402, The camera service module captures the first image capture request and sends the first image capture request to the camera HAL module.

[0168] S403, the camera HAL module parses the first image capture request and converts it into a second image capture request.

[0169] It should be noted that the first image capture request is in a format recognizable by the application layer and application framework layer, while the second image capture request is in a format recognizable by the camera driver.

[0170] S404, the camera HAL module sends the second image capture request to the camera driver.

[0171] S405, the camera driver captures a second image capture request and sends the second image capture request to the camera.

[0172] S406, The camera captures a second image shooting request and acquires the original image (such as a short exposure image, a normal exposure image, an overexposed image, etc.).

[0173] For example, a camera includes, but is not limited to, a lens, an image sensor, and an image signal processor. The camera can be a front-facing camera or a rear-facing camera; no limitation is made.

[0174] For example, an image sensor converts light signals (light from the lens) into electrical signals and digitizes them to generate at least one raw image.

[0175] For example, the original image can be an image of the same scene with different exposures, such as a short exposure image, a normal exposure image, an overexposed image, etc.

[0176] Short exposure images retain details in bright areas (but dark areas may be too dark).

[0177] Normal exposure image: balanced exposure, but may lose details in extremely bright and dark areas.

[0178] Overexposed image: Preserves details in dark areas (but bright areas may be overexposed).

[0179] It should be noted that the original image can be in raw RAW format (containing linear data from the image sensor), JPEG format, TIFF format, etc., and there are no restrictions on the comparison.

[0180] S407 The camera processes the original image to generate at least one clear sRGB image.

[0181] For example, the image signal processor processes the original image to generate at least one sRGB sharp image.

[0182] For example, if the electronic device is a monocular electronic device, that is, it has only one lens and one image sensor (such as a main lens and a main image sensor), the electronic device acquires at least one original image through the main lens and the main image sensor, and sends the original image to the image signal processor. The image signal processor maps the brightness range of the original image to the 8-bit range of the sRGB domain through nonlinear brightness mapping and other methods. At the same time, it maps the lower values ​​representing dark areas in the original image to relatively higher values ​​in the 8-bit range to obtain a clear sRGB image.

[0183] For example, if the original image consists of multiple images of the same scene with different exposures, the image signal processor merges these images into a single high dynamic range (HDR) image (e.g., in 32-bit floating-point format). During this process, information from dark areas is fully integrated, thereby brightening the non-illuminating subjects in the dark areas. Images with different exposures can capture details in different brightness areas of the scene; for example, underexposed images can clearly record details in bright areas, while overexposed images can capture more information from dark areas. Normally exposed images reflect the true brightness and color of most areas in the scene. The image signal processor uses methods such as nonlinear brightness mapping to map the brightness range of the HDR image to an 8-bit range in the sRGB domain. Simultaneously, it maps lower values ​​representing dark areas in the HDR image to relatively higher values ​​within the 8-bit range, resulting in a clear sRGB image.

[0184] It's important to note that HDR images use floating-point numbers to store the brightness or color value of each pixel. Each pixel value represents the true linear brightness of the scene (potentially reaching 32 bits or higher), capable of simultaneously rendering details in extremely bright and extremely dark areas. sRGB clear images, on the other hand, are low dynamic range images (8-bit range). Their brightness values ​​are generally limited to integers between 0 and 255, meaning the brightest to lowest level is 255. They can only express the brightness range that the display device can reproduce (limited dynamic range) and cannot directly store details in extremely bright or extremely dark scenes.

[0185] It should be noted that nonlinear brightness mapping includes, but is not limited to, tone mapping and gamma transform. Tone mapping includes, but is not limited to, global tone mapping and local tone mapping. Global tone mapping applies a uniform nonlinear transformation (such as logarithmic mapping curves, sigmoid mapping curves, linear piecewise mapping curves, rational function mapping curves, etc.) to the entire image, which may make the overall image appear darker or brighter, but retains a large range of contrast. Local tone mapping dynamically adjusts the nonlinear mapping according to the brightness distribution of image regions (such as the Reinhard algorithm, Durand algorithm, etc.) to enhance local contrast while avoiding overexposure of highlights or underexposure of shadows.

[0186] Specifically, the image signal processor aligns multiple images with different exposures to ensure consistent viewing angles and eliminate displacement caused by electronic device movement or jitter. Using the corresponding pixel values ​​from the different exposure images, the image sensor's response function (typically a non-linear function, such as a logarithmic or polynomial curve) is estimated, mapping the pixel values ​​to true linear brightness values. Based on the response function and weight assignment, the images with different exposures are fused into an HDR image. Weights are typically based on the saturation or signal-to-noise ratio of each pixel in the original image. A non-linear function is used to adjust the brightness contribution of different exposure layers to avoid detail loss or artifacts caused by simple linear averaging.

[0187] Specifically, the image signal processor maps the brightness range of the HDR image to the 8-bit range of the sRGB domain through tone mapping, and maps the lower values ​​representing the dark areas in the HDR image to relatively higher values ​​in the 8-bit range. The image signal processor uses gamma curves to process the tone-mapped image to obtain the sRGB clear image, thereby enhancing the contrast of the dark areas of the sRGB clear image, while avoiding overexposure of highlights or distortion of midtones, and making the overall contrast more in line with human eye perception.

[0188] For example, if the original image is a normally exposed image, the image signal processor maps the brightness range of the normally exposed image to an 8-bit range in the sRGB domain through tone mapping, and maps the lower values ​​representing dark areas in the normally exposed image to relatively higher values ​​in the 8-bit range; the image signal processor then uses a gamma curve to process the tone-mapped image to obtain a clear sRGB image. For details, please refer to the above embodiments; further comparisons are not provided.

[0189] For example, if the electronic device is a binocular electronic device, that is, it has two lenses and two corresponding image sensors (such as a main lens and a main image sensor, and an auxiliary lens and an auxiliary image sensor), the electronic device acquires at least one original image (i.e., a first original image) through the main lens and the main image sensor, and the electronic device acquires at least one original image (i.e., a second original image) through the auxiliary lens and the auxiliary image sensor, and sends the first original image and the second original image to an image signal processor. The image signal processor processes the first original image using the above method to obtain a first sRGB clear image, and the image signal processor processes the second original image using the above method to obtain a second sRGB clear image.

[0190] For example, if the electronic device is a binocular electronic device, it can acquire short-exposure images and normal-exposure images of the same scene through the main lens and main image sensor, and acquire a normal-exposure image through the auxiliary lens and auxiliary image sensor. The image signal processor processes the short-exposure images and normal-exposure images of the same scene using the above method to obtain a first sRGB clear image, and processes the normal-exposure image using the above method to obtain a second sRGB clear image. Specific details can be found in the above embodiments, which will not be elaborated further.

[0191] It should be noted that the above embodiments are described with one image information processor in the binocular electronic device. The binocular electronic device may be equipped with two image information processors to process the first original image and the second original image respectively. The comparison is not limited.

[0192] It's important to note that the main lens is typically the core camera of an electronic device, usually located in the center or main position on the back. It's responsible for capturing the primary image information, ensuring the core quality and detail clarity of photos or videos. The main image sensor, being larger and with higher resolution, is responsible for capturing most of the main image information to ensure image quality and detail reproduction. Secondary lenses are distributed around the main lens or in other more remote locations, providing different perspectives, focal lengths, or special effects. Secondary image sensors are usually smaller or have lower resolution but possess special functions, such as enhanced focusing and depth information acquisition.

[0193] S408: The camera sends the short-exposure image and the clear sRGB image to the camera driver.

[0194] For example, the sRGB clear image corresponding to the main lens, or the sRGB clear image obtained by fusing multiple sRGB clear images, can be used in subsequent image processing such as depth calculation, spot enhancement, linear transformation, weighted filtering, and fusion. The sRGB clear images corresponding to other lenses (such as the sRGB clear image corresponding to the auxiliary lens) can be used only for subsequent depth calculation.

[0195] S409: The camera driver receives short-exposure images and clear sRGB images, and sends short-exposure images and clear sRGB images to the camera HAL.

[0196] The S410 camera's HAL module obtains a blurred image of the target based on the short-exposure image and the sharp sRGB image.

[0197] It's important to note that short exposure refers to a short shutter speed (e.g., 1 / 1000 of a second) in electronic devices, allowing less light to enter the image sensor. A short exposure image is the raw image obtained using this technique. Short exposure images have a high dynamic range and, due to the short exposure time, there is no overexposure. The brightness values ​​of a short exposure image are consistent with the true brightness values ​​of the real scene, satisfying a linear relationship. For example, in a real scene, there might be a non-luminous object and a luminous object. The luminous object emits its own light, while the non-luminous object only reflects light from the environment; that is, the luminous object is in the bright area, and the non-luminous object is in the dark area. The brightness value of the luminous object may be much higher than that of the non-luminous object, yet the image sensor can still linearly record these brightness differences, accurately reflecting the brightness ratio of the real scene because the light intensity received by the image sensor has not reached the saturation point.

[0198] It should be noted that sRGB clear images are low dynamic range images (8-bit range), and their brightness values ​​are generally limited to the integer range of 0-255, that is, the brightest to the lowest level is 255. They can only express the brightness range that the display device can present (limited dynamic range) and cannot directly store the details of extremely bright or extremely dark scenes.

[0199] The target blurred image is obtained by: using a short-exposure image with brightness distribution in the linear domain, an electronic device converts the sharp sRGB image in sRGB space to a pseudo-linear domain space to obtain a sharp pseudo-linear domain image; weighted filtering is applied to the sharp pseudo-linear domain image to obtain a pseudo-linear domain overall blurred image; the pseudo-linear domain overall blurred image is then converted back from the pseudo-linear domain space to sRGB space to obtain a bokeh blurred image; finally, the blurred image is obtained by combining the sharp sRGB image and the bokeh blurred image according to the depth-of-field inner mask. The target blurred image includes, but is not limited to: a first target blurred image, a second target blurred image, etc.

[0200] For example, the camera HAL performs depth calculations on at least one sRGB sharp image to obtain a depth distribution map, and obtains the in-field mask and the blur filtering radius of the out-of-field region based on the depth distribution map and shooting parameters. Based on the short-exposure image and the in-field mask, the camera HAL performs spot enhancement on the sRGB sharp image to obtain an enhancement map, performs an inverse gamma transform on the enhancement map to obtain an inverse enhancement map, and performs inverse tone mapping on the inverse enhancement map to obtain a pseudo-linear domain sharp image. The camera HAL performs spot detection on the short-exposure image to obtain a bright spot region mask, performs connected component detection on the bright spot region mask to obtain a spot connected component distribution mask; the camera HAL obtains a pseudo-mapping gain map based on the short-exposure image and the inverse enhancement map. The camera's HAL (Hyper-Aspect Ratio) performs blur filtering on the background region of the pseudo-linear domain sharp image based on the blur filtering radius outside the depth of field, obtaining a preliminary blurred image. The camera HAL then uses the pseudo-mapping gain map as weights and sequentially applies weighted filtering to the spot regions of the pseudo-linear domain sharp image according to the spot connectivity distribution mask, superimposing this onto the preliminary blurred image to obtain the first pseudo-linear domain overall blurred image. The camera HAL performs positive tone mapping and positive gamma transformation on the first pseudo-linear domain overall blurred image to obtain the first bokeh blurred image. Finally, the camera HAL fuses the sRGB sharp image with the first bokeh blurred image according to the depth-of-field mask to obtain the final first target blurred image.

[0201] For example, the camera HAL performs depth calculations on at least one sRGB sharp image to obtain a depth distribution map, and obtains the depth-of-field mask and the blur filtering radius of the out-of-field region based on the depth distribution map and shooting parameters. The camera HAL performs spot enhancement on the sRGB sharp image based on the short-exposure image and the depth-of-field mask to obtain an enhanced image. An inverse gamma transform is then performed on the enhanced image to obtain an inverse enhanced image, and an inverse tone mapping is performed on the inverse enhanced image to obtain a pseudo-linear domain sharp image. The camera HAL obtains a pseudo-mapping gain map based on the short-exposure image and the inverse enhanced image. The camera HAL uses the pseudo-mapping gain map as weights to perform weighted filtering on the pseudo-linear domain sharp image based on the out-of-field blur filtering radius, obtaining a second pseudo-linear domain overall blur image. The camera HAL performs forward tone mapping and forward gamma transform on the second pseudo-linear domain overall blur image to obtain a second bokeh blur image; the camera HAL then fuses the sRGB sharp image and the second bokeh blur image based on the depth-of-field mask to obtain the final second target blurred image.

[0202] like Figure 5As shown, (1) Figure is the sRGB clear image generated by the camera processing the original image. (2) Figure is the short exposure image acquired by the camera. (3) Figure is the target blurred image obtained by the electronic device using the above image processing method. That is, (3) Figure is the image obtained by the electronic device using the short exposure image with brightness distribution in the linear domain, converting the sRGB clear image in the sRGB space to the pseudo-linear domain space to obtain the pseudo-linear domain clear image, performing weighted filtering on the pseudo-linear domain clear image to obtain the pseudo-linear domain overall blurred image, then converting the pseudo-linear domain overall blurred image back from the pseudo-linear domain space to the sRGB space to obtain the bokeh blurred image, and then fusing the sRGB clear image and the bokeh blurred image according to the depth-of-field inner mask.

[0203] Figure 5 In the target blurred image shown in (3), the brightness levels of the light spots are distinct, and adjacent light spots have overlapping layers. The number of light spots is consistent with the actual light source. It can be seen that the above image processing method enhances the blurred light spot effect of the image.

[0204] S411, the camera HAL sends the blurred image of the target to the camera service module.

[0205] S412, The camera service module receives the target blurred image and sends the target blurred image to the camera application.

[0206] S413, The camera application receives the blurred image of the target and displays the blurred image of the target on the display screen.

[0207] It should be noted that the camera can obtain a blurred target image based on the image sensor, using a short-exposure image and a sharp sRGB image. The camera's HAL can also send the short-exposure image and the sharp sRGB image to the camera service module or camera application; the camera service module or camera application then obtains the blurred target image based on the short-exposure image and the sharp sRGB image. The following embodiment uses the camera HAL obtaining the blurred target image based on the short-exposure image and the sharp sRGB image as an example for specific illustration.

[0208] In this way, by performing spot enhancement, linear transformation, and weighted filtering on the sRGB clear image based on the short exposure image, an image with the same number and brightness of spots as the linear domain image is obtained. This image is then mapped to the nonlinear domain through a nonlinear transformation to ensure the contrast of the dark areas. Finally, it is fused with the sRGB clear image to generate the target blurred image, which enhances the effect of the blurred spots in the target blurred image. That is, the brightness distribution and number of spots are the same as the brightness and number of the actual light source, and the overlapping relationship between the spots is clear and distinguishable, thus improving the user experience.

[0209] Figure 6 This is a schematic diagram of an image processing apparatus provided in an embodiment of this application. Figure 6In a corresponding embodiment, the camera HAL may include: a first processing module, a second processing module, a third processing module, and a fourth processing module, etc.

[0210] like Figure 6 As shown, the first processing module receives at least one sRGB clear image sent by the camera driver, performs depth calculation on the at least one sRGB clear image to obtain a depth distribution map, and obtains the depth-of-field mask and the blur filtering radius of the outer depth-of-field region based on the depth distribution map and shooting parameters.

[0211] The second processing module performs spot enhancement on the sRGB clear image based on the short exposure image and depth-of-field mask to obtain an enhanced image. It then performs an inverse gamma transform on the enhanced image to obtain an inverse enhanced image, and finally performs inverse tone mapping on the inverse enhanced image to obtain a pseudo-linear domain clear image.

[0212] The third processing module performs spot detection on the short exposure image to obtain a mask of the bright spot region, and performs connected component detection on the mask of the bright spot region to obtain a mask of the connected component distribution of the spot; the third processing module obtains a pseudo-mapping gain map based on the short exposure image and the inverse enhancement map.

[0213] The fourth processing module performs blur filtering on the background region of the pseudo-linear domain sharp image based on the blur filtering radius outside the depth of field to obtain a preliminary blur image. Using the pseudo-mapping gain image as weight, the module sequentially performs weighted filtering on the spot region of the pseudo-linear domain sharp image according to the spot connected domain distribution mask, and then superimposes it onto the preliminary blur image to obtain the first pseudo-linear domain overall blur image. Based on the depth-of-field mask, the sRGB sharp image and the first bokeh blur image are fused to obtain the final first target blur image.

[0214] It should be noted that the sRGB clear image in the second, third, and fourth processing modules can be an sRGB clear image generated by fusing multiple sRGB clear images, or it can be the sRGB clear image corresponding to the main lens.

[0215] In this way, by performing spot enhancement, linear transformation, and weighted filtering on the sRGB clear image based on the short exposure image, an image with the same number and brightness of spots as the linear domain image is obtained. This image is then mapped to the nonlinear domain through a nonlinear transformation to ensure the contrast of the dark areas. Finally, it is fused with the sRGB clear image to generate the target blurred image, which enhances the effect of the blurred spots in the target blurred image. That is, the brightness distribution and number of spots are the same as the brightness and number of the actual light source, and the overlapping relationship between the spots is clear and distinguishable, thus improving the user experience.

[0216] The following is combined Figures 7 to 10 The image processing methods are explained in detail.

[0217] Figure 7This is a schematic diagram illustrating a method for generating depth-of-field inner masks and blurring filter radii, provided in an embodiment of this application. Figure 7 In a corresponding embodiment, the first processing module may include: a depth estimation module, a depth calculation module, etc. Figure 6 and Figure 7 As shown, the method for generating the depth-of-field mask and blurring filter radius includes the following steps:

[0218] S701, the depth estimation module receives at least one clear sRGB image sent by the camera driver.

[0219] S702, The depth estimation module performs depth calculations on at least one sRGB clear image to obtain a depth distribution map.

[0220] It should be noted that the value of each pixel in the depth distribution map represents the depth information of that point (distance from the electronic device).

[0221] For example, the depth estimation module can use traditional stereo vision calculation methods, deep learning model calculation methods, image segmentation methods, etc., to obtain the true depth distribution map of the image.

[0222] For example, the deep learning model calculation method is as follows: Deep learning models can be divided into monocular depth models and multi-view depth models (such as binocular depth models) according to the number of lenses used for shooting. That is, when the input image is only a single clear sRGB image, the monocular depth model is used; if the input image is two clear sRGB images, namely the clear sRGB image corresponding to the main lens and the clear sRGB image corresponding to the auxiliary lens, then the binocular depth model is used.

[0223] For example, monocular depth models include, but are not limited to, MiDaS, DPT-Hybrid, etc. Binocular depth models include, but are not limited to, PSMNet, RAFT-Stereo, etc. This application does not limit the network structure of the depth models.

[0224] For example, the stereo vision calculation method is as follows: obtain the sRGB clear image corresponding to the main lens and the sRGB clear image corresponding to the auxiliary lens; find the pixel position of the same scene point in the two images through feature detection (such as SIFT, ORB, SURF, etc.) or dense matching (such as block matching) methods, and calculate the three-dimensional position of these points using the triangulation principle based on the intrinsic parameters (mainly focal length f) and extrinsic parameters (mainly baseline distance B) of the electronic device, thereby obtaining the depth distribution map.

[0225] For example, an image segmentation method is used to determine the main body of the image, and a specific depth value is set for other regions outside the main body. This depth value can be a default value or a value that can be adjusted by the user. The depth values ​​of the main body and the depth values ​​of the regions outside the main body are integrated to generate the final depth distribution map.

[0226] For example, image segmentation methods include, but are not limited to, automatic segmentation methods and interactive segmentation. For instance, the main subject of an image can be determined using a model corresponding to an automatic segmentation method. Users provide interactive prompts such as coordinates through clicking, selecting boxes, etc.; the interactive segmentation model converts these prompt coordinates into prompt features in the feature space, extracts image features, and determines the main subject based on the prompt features and image features. Interactive prompt coordinates include, but are not limited to, points (foreground or background points), boxes (boundary boxes surrounding the target), boundaries (pixel coordinates of the target's edge), and text (such as "segment animal"). For example, a user outlines the main subject they want to segment with a rectangle, i.e., the main subject of the image (such as an animal). The interactive segmentation model converts the boundary coordinates of the rectangle (such as top left (100, 50), bottom right (300, 400)) into prompt features in the feature space, and determines the main subject based on these prompt features and image features.

[0227] S703, The depth estimation module sends the depth distribution map to the depth calculation module.

[0228] S704, the depth-of-field calculation module obtains the depth-of-field mask and the blurring filter radius of the outer depth-of-field region based on the depth distribution map and shooting parameters.

[0229] For example, shooting parameters include, but are not limited to, focus point position, aperture size, and focal length. The focus point position refers to the specific location of the focus point within the frame. The focus point can be determined by the user's trigger operation on the shooting interface before the user takes a picture, or it can be determined by the electronic device based on the content displayed on the screen when responding to the user's photo-taking operation, or it can be determined based on a preset focus point. This embodiment of the application does not limit this. Figure 1 The focus point box 106 in the image is a visual marker (such as a small square, dot, or area) displayed on the screen to indicate the physical location of the focus point.

[0230] For example, the depth-of-field calculation module determines the depth-of-field range based on the depth distribution map and shooting parameters. The depth-of-field range includes the foreground depth-of-field threshold Z. near and back depth of field threshold Z far Foreground depth threshold Z near The lower limit of the distance range from which the foreground remains sharp, based on the focus point position; the back depth-of-field threshold Z. far This refers to the upper limit of the distance range from which the background remains sharp after the focal point.

[0231] Foreground depth threshold Z near The calculation formula is as follows:

[0232]

[0233] Back depth of field threshold Z far The calculation formula is as follows:

[0234]

[0235] Where f is the focal length;

[0236] Z f The depth (focusing distance) corresponding to the focus point position is the actual distance from the focused object to the image sensor.

[0237] δ is the minimum allowable circle of confusion size, i.e., the pixel size of the image sensor;

[0238] F represents the aperture size.

[0239] For example, the minimum permissible circle of confusion for an electronic device is approximately 0.029 mm.

[0240] For example, the depth-of-field calculation module calculates the depth-of-field range (foreground depth-of-field threshold Z) based on the depth-of-field range. near and back depth of field threshold Z far Determine the depth-of-field mask. Dof Specifically, the depth is less than the foreground depth threshold Z. near The area is the out-of-focus region in front of the depth of field, with a depth greater than the rear depth-of-field threshold Z. far The two out-of-focus areas (the out-of-focus area before and the out-of-focus area after the out-of-focus area) are the areas that need to be enhanced with blur filtering to improve the bokeh effect.

[0241] Depth greater than the foreground depth threshold Z near Less than the back depth of field threshold Z far For areas within the depth of field, the corresponding mask is the in-depth-of-field mask. Dof It should be noted that the blurring filter radius within the depth of field is 0.

[0242] The blur filtering radius r(x,y) of the out-of-focus area, i.e. the blur range of the out-of-focus area (the out-of-focus area before and after the out-of-focus area), is calculated using the following formula:

[0243]

[0244] Where Z(x,y) is the depth distribution map, and x,y are the image coordinates;

[0245] Z fThe depth corresponding to the focus point position;

[0246] f is the focal length;

[0247] F represents the aperture size.

[0248] S705, the depth calculation module sends the depth mask to the second module.

[0249] S706, the depth-of-field calculation module sends the depth-of-field mask and the blurring filter radius of the outer depth-of-field region to the fourth processing module.

[0250] For example, the depth-of-field calculation module sends the depth-of-field mask to the second module, which then performs spot enhancement on the bright areas of the sRGB clear image based on the short-exposure image and the depth-of-field mask to generate an enhanced image.

[0251] For example, the depth-of-field calculation module sends the depth-of-field mask and the blur filtering radius of the outer depth-of-field region to the fourth processing module to generate the final target blurred image.

[0252] In this way, by generating the final target blurred image based on the depth-of-field mask and the blur filtering radius of the outer depth-of-field region, more accurate, natural and efficient depth-of-field blur processing can be achieved, greatly improving the quality of photography, rendering and visual performance.

[0253] Figure 8 This is a schematic diagram illustrating a method for generating a clear map of a pseudo-linear domain, as provided in an embodiment of this application. Figure 8 In a corresponding embodiment, the second processing module may include: a brightness area enhancement module, a pseudo-linear mapping module, etc. Figure 6 and Figure 8 As shown, the method for generating a clear map of the pseudo-linear domain includes the following steps:

[0254] S801, the bright area enhancement module receives short-exposure images and sRGB clear images sent by the camera driver.

[0255] S802, the bright area enhancement module receives the depth-of-field inner mask sent by the first processing module.

[0256] S803, the bright area enhancement module enhances the bright areas of the sRGB clear image by performing spot enhancement based on the short exposure image and the depth-of-field mask, thus obtaining an enhanced image.

[0257] For example, enhanced Figure I enhance The calculation formula is as follows:

[0258]

[0259] Among them, I sRGB A clear sRGB image;

[0260] Ishort This is a short exposure image;

[0261] The coefficient CoefShort is a constant greater than 1 used to control the enhanced bright spot;

[0262] Mask Dof This is the depth-of-field mask.

[0263] It should be noted that the sRGB clear image I sRGB and short exposure image I short The grayscale value range (x,y) needs to be adjusted to between 0 and 255.

[0264] It should be noted that the smaller the CoefShort, the greater the enhancement of the light spot, and the brighter the final blurred image light spot; conversely, the smaller the CoefShort, the less bright the final light spot. Based on experience, CoefShort is generally taken as a number between 4 and 8.

[0265] In this way, the light source brightness distribution of the short exposure image is linearly related to the actual light source brightness distribution. The light spot area of ​​the sRGB clear image is enhanced, and the brightness of the light spot area in the image and the overlay level of adjacent light spots are optimized.

[0266] S804, the bright area enhancement module sends the enhancement map to the pseudo-linear mapping module.

[0267] S805, the pseudo-linear mapping module performs an inverse gamma transform on the enhancement map to obtain an inverse enhancement map.

[0268] S806, the pseudo-linear mapping module performs inverse tone mapping on the inverse enhancement map to obtain a pseudo-linear domain sharp map.

[0269] For example, the inverse mapping method includes, but is not limited to, inverse tone mapping, inverse gamma transform, etc., as can be referred to in the tone mapping and gamma transform in the above embodiments. Through inverse gamma transform and inverse tone mapping, the enhanced image in the sRGB domain is inversely mapped to the pseudo-linear domain space. It should be noted that, as can be seen from the above embodiments, when the original RAW format image is converted to a clear sRGB image, the brightness is compressed and truncated, and it cannot be completely converted to the original linear domain space; therefore, it is called a pseudo-linear domain space.

[0270] For example, the pseudo-linear mapping module first performs an inverse gamma transform on the enhancement map to obtain the inverse enhancement map I. gamma Then, the reverse enhancement graph I gamma Performing inverse tone mapping yields a pseudo-linear domain sharpness map I. LRGB The calculation formula is as follows:

[0271] I gamma =I enhance g (5)

[0272] Where g is a parameter of the gamma transform, which is generally a value between 2 and 5. The larger the value, the greater the difference in brightness between the spot area and the non-spot area in the final blurred image.

[0273] I enhance To enhance the graph.

[0274] I LRGB =ToneMapping -1 (I gamma (6)

[0275] Among them, I gamma This is a reverse enhancement graph;

[0276] ToneMapping -1 () is the inverse function of the global tone mapping function. Generally, the distribution of the global tone mapping function can be a logarithmic mapping curve, a sigmoid mapping curve, a linear piecewise mapping curve, a rational function mapping curve, etc.

[0277] For example, the formula for calculating the inverse function of a rational function is as follows:

[0278]

[0279] Where I is the input image before tone mapping;

[0280] α is a scaling factor less than 1. The larger the scaling factor, the more severe the highlight compression of the image after tone mapping, while the bright areas are stretched and contrasted more after inverse tone mapping.

[0281] S807, the pseudo-linear mapping module sends the inverse enhancement graph to the third processing module.

[0282] S808, the pseudo-linear mapping module sends the pseudo-linear domain clear map to the fourth processing module.

[0283] For example, the pseudo-linear mapping module sends the inverse enhancement map to the third processing module, which then obtains the pseudo-mapping gain map based on the short exposure image and the inverse enhancement map.

[0284] For example, the pseudo-linear mapping module sends the pseudo-linear domain clear map to the fourth processing module for generating the final target blurred image.

[0285] In this way, by using the short-exposure image with brightness in the linear domain space, the sRGB clear image is linearly transformed to the pseudo-linear domain for blur filtering, which optimizes the brightness of the spot area in the image and the superposition level of adjacent spots, and makes the number of spots consistent with the actual light source.

[0286] Figure 9This is a schematic diagram of a pseudo-mapping gain map generation method provided in an embodiment of this application. Figure 9 In a corresponding embodiment, the third processing module may include: a spot detection module, a pseudo-mapping gain module, etc. Figure 6 and Figure 9 As shown, the pseudo-mapping gain map generation method includes the following steps:

[0287] S901, the spot detection module receives short-exposure images sent by the camera driver.

[0288] S902, the spot detection module performs spot detection on the short exposure image to obtain the mask of the bright spot area.

[0289] For example, based on the brightness distribution characteristics of short-exposure images, namely that the brightness of the light source area is significantly greater than that of the non-light source area, the brightness is directly subjected to binarized threshold detection to obtain the mask of the bright spot area, that is, the spot mask of the bright area.

[0290] The formula for calculating the SpotMask (high-brightness spot mask) is as follows:

[0291]

[0292] Among them, I short This is a short exposure image;

[0293] V() represents the brightness distribution of the V channel in the HSV color space of the image. Areas with brightness greater than the threshold thr are considered light spots. The threshold thr is selected based on experience.

[0294] It should be noted that a bright area refers to a region in an image or scene with relatively high brightness (or intensity). A spot area is a specific type of bright area, specifically referring to a localized spot area formed by reflection or scattering.

[0295] S903, the spot detection module performs connected component detection on the mask of the high-brightness spot region to obtain the spot connected component distribution mask.

[0296] For example, connected component detection includes, but is not limited to, degree-first search (DFS) or breadth-first search (BFS). Specifically, the spot detection module performs connected component detection on the mask of the bright spot region, resulting in multiple independent connected regions. Each connected region represents a spot, and a unique label value is assigned to each connected region. Spot connected component distribution mask: SpotMask i Let represent the distribution mask of the connected components of the i-th spot. It is a binary image of the same size as the original mask, in which only the pixel value in the i-th connected component is i, and the value of the other pixels is 0.

[0297] S904, the pseudo-mapping gain module receives short-exposure images sent by the camera driver.

[0298] S905, the pseudo-mapping gain module receives the inverse enhancement map sent by the second module.

[0299] S906, the pseudo-mapping gain module obtains the pseudo-mapping gain map based on the short exposure image and the inverse enhancement map.

[0300] For example, the formula for calculating the pseudo-map gain map is as follows:

[0301]

[0302] Where V() represents the luminance V channel distribution in the HSV color space of the image.

[0303] I short This is a short exposure image;

[0304] I gamma This is a reverse enhancement graph.

[0305] S907, the pseudo-mapping gain module sends the pseudo-mapping gain map to the fourth processing module to generate the final target bokeh image.

[0306] In this way, by using the short-exposure image of brightness in the linear domain space, the first image is linearly transformed to the pseudo-linear domain for blur filtering, which optimizes the brightness of the spot area in the image and the superposition level of adjacent spots, and makes the number of spots consistent with the actual light source. Figure 10 This is a schematic diagram illustrating a method for generating a target blurred image according to an embodiment of this application. Figure 10 In a corresponding embodiment, the fourth processing module may include: a bokeh processing module, a forward mapping module, a bokeh fusion module, etc. For example... Figure 6 and Figure 10 As shown, the method for generating a blurred target image includes the following steps:

[0307] S1001, The blurring processing module receives the pseudo-linear domain clear image sent by the second processing module.

[0308] S1002, The blurring processing module receives the filtering radius of the outer depth region sent by the first processing module.

[0309] S1003, the blurring processing module performs blurring filtering on the background area of ​​the pseudo-linear domain sharp image based on the blurring filtering radius outside the depth of field to obtain a preliminary blurred image.

[0310] For example, the initial blurring of image B LRGB1 The calculation formula is as follows:

[0311] B LRGB1 =Blur(I LRGB (10)

[0312] Blur() is the blur filtering function;

[0313] I LRGB This is a clear diagram of the pseudo-linear domain.

[0314] It should be noted that the blur kernel size is the blur filtering radius of each pixel in the background region obtained from depth estimation. The shape of the blur kernel can be a simple disk distribution, a polygonal distribution simulating the shape of an aperture, or a cat's eye etched shape distribution obtained by the intersection of two disks, etc., without any limitations.

[0315] S1004. The blurring processing module receives the pseudo-mapping gain map and the spot connected domain distribution mask sent by the third processing module.

[0316] S1005. The blurring processing module uses the pseudo-mapping gain map as weights, and performs weighted filtering on the spot regions of the pseudo-linear domain clear map according to the spot connected domain distribution mask, and superimposes it on the preliminary blurring map to obtain the first pseudo-linear domain overall blurring map.

[0317] For example, the first pseudo-linear domain global virtual graph B LRGB The calculation formula is as follows:

[0318]

[0319] SpotMask i The mask representing the distribution of the connected components of the i-th spot;

[0320] B LRGB1 This is a preliminary blurred image;

[0321] Blur() is a blur filtering function, and the size of the blur kernel is the blur filtering radius of each pixel in the background region obtained by depth estimation.

[0322] I LRGB Clear diagram of pseudolinear domain

[0323] GainMap is a pseudo-mapped gain map.

[0324] In this way, the pseudo-mapping gain map is used as the weight, and the spot regions of the pseudo-linear domain clear map are sequentially weighted and filtered according to the spot connected domain distribution mask. The spot brightness, the overlay level of adjacent spots, and the number of spots in the filtered image are consistent with the actual light source.

[0325] S1006, The blurring processing module sends the overall blurring graph of the first pseudo-linear domain to the forward mapping module.

[0326] S1007. The forward mapping module performs forward nonlinear brightness mapping on the overall bokeh image of the first pseudo-linear domain to obtain the first bokeh image.

[0327] For example, nonlinear brightness mapping includes, but is not limited to, tone mapping, gamma transformation, etc.

[0328] For example, the first bokeh image B sRGB The calculation formula is as follows:

[0329] B tone =ToneMapping(B LRGB (12)

[0330]

[0331] Among them, B LRGB This is the overall virtualized graph of the first pseudolinear domain;

[0332] ToneMapping() is a global tone mapping function;

[0333] B tone This is the blurred image after tone mapping;

[0334] g is a parameter of the gamma transform, which is generally taken as a value between 2 and 5.

[0335] It should be noted that the forward mapping module transforms the overall bokeh image of the first pseudo-linear domain from the pseudo-linear domain space to the sRGB space, resulting in the first bokeh image B with blurred background outside the depth of field. sRGB This process is the reverse of the transformation of a clear sRGB image from sRGB space to pseudo-linear domain space, using the same parameters.

[0336] S1008, the forward mapping module sends the first bokeh image to the bokeh fusion module.

[0337] S1009, the bokeh blending module receives the sRGB clear image sent by the camera driver.

[0338] S1010, the bokeh blending module receives the depth-of-field inner mask sent by the first processing module.

[0339] S1011 The bokeh fusion module fuses the sRGB clear image with the first bokeh image according to the depth-of-field inner mask to obtain the final first target bokeh image.

[0340] For example, based on the depth-of-field mask obtained from depth estimation, the sharp subject within the depth of field in the sRGB sharp image is fused with the first bokeh image to obtain the first target bokeh image.

[0341] For example, the first target blurred image B Final The calculation formula is as follows:

[0342] B Final =B sRGB *(1-MaskDof )+I sRGB *Mask Dof (14)

[0343] Among them, Mask Dof For depth-of-field masking;

[0344] B sRGB This is the first bokeh effect image;

[0345] I sRGB This is a clear sRGB image.

[0346] For example, in order to make the blended edges more natural, it is necessary to adjust the mask. Dof To create a small radius Gaussian blur, the blur radius can be customized, such as setting it to 5.

[0347] In this way, by using the mask of the depth-of-field region for image fusion, the clear regions within the depth of field in different images can be identified and fused into the final image, which can improve the overall image clarity while preserving the image's details and texture information.

[0348] Figure 11 This is a schematic diagram of yet another image processing apparatus provided in an embodiment of this application. Figure 11 In a corresponding embodiment, the camera HAL may include: a first processing module, a second processing module, a third processing module, and a fourth processing module.

[0349] like Figure 11 As shown, the first processing module receives at least one sRGB clear image sent by the camera driver, performs depth calculation on the at least one sRGB clear image to obtain a depth distribution map, and obtains the depth-of-field mask and the blur filtering radius of the outer depth-of-field region based on the depth distribution map and shooting parameters.

[0350] The second processing module performs spot enhancement on the sRGB clear image based on the short exposure image and depth-of-field mask to obtain an enhanced image. It then performs an inverse gamma transform on the enhanced image to obtain an inverse enhanced image, and finally performs inverse tone mapping on the inverse enhanced image to obtain a pseudo-linear domain clear image.

[0351] The third processing module obtains the pseudo-mapping gain map based on the short-exposure image and the inverse enhancement map.

[0352] The fourth processing module uses the pseudo-mapping gain map as a weight to perform weighted filtering on the pseudo-linear domain sharp image based on the blur filtering radius outside the depth of field, thereby obtaining the second pseudo-linear domain overall blur image; based on the depth-of-field mask, the sRGB sharp image and the second bokeh blur image are fused to obtain the final second target blur image.

[0353] The first, second, and third processing modules can be referenced. Figures 7-9I will not go into details about that.

[0354] In this way, by performing spot enhancement, linear transformation, and weighted filtering on the sRGB clear image based on the short exposure image, an image with the same number and brightness of spots as the linear domain image is obtained. This image is then mapped to the nonlinear domain through a nonlinear transformation to ensure the contrast of the dark areas. Finally, it is fused with the sRGB clear image to generate the target blurred image, which enhances the effect of the blurred spots in the target blurred image. That is, the brightness distribution and number of spots are the same as the brightness and number of the actual light source, and the overlapping relationship between the spots is clear and distinguishable, thus improving the user experience.

[0355] Figure 12 This is a schematic diagram illustrating another method for generating a target blurred image provided in an embodiment of this application. Figure 12 In a corresponding embodiment, the fourth processing module may include: a bokeh processing module, a forward mapping module, a bokeh fusion module, etc. For example... Figure 11 and Figure 12 As shown, the method for generating a blurred target image includes the following steps:

[0356] S1201, The blurring processing module receives the pseudo-linear domain clear image sent by the second processing module.

[0357] S1202, The blurring processing module receives the filtering radius of the outer region of the depth of field sent by the first processing module.

[0358] S1203, The virtualization processing module receives the pseudo-mapping gain map sent by the third processing module.

[0359] S1204. The blurring processing module uses the pseudo-mapping gain map as a weight to perform weighted filtering on the pseudo-linear domain sharp map based on the blurring filtering radius outside the depth of field, and obtains the second pseudo-linear domain overall blurring map.

[0360] For example, the global virtual graph B of the second pseudolinear domain LRGB The calculation formula is as follows:

[0361]

[0362] Where Blur() is the blur filtering function, and the size of the blur kernel is the blur filtering radius of each pixel in the background region obtained by depth estimation;

[0363] I LRGB A clear map of the pseudo-linear domain;

[0364] GainMap is a pseudo-mapped gain map.

[0365] In this way, a global brightness map (i.e., a pseudo-mapped gain map) is constructed using the short-exposure image, and used as a weight for weighted filtering during spot blur filtering. The brightness of the spot, the overlay level of adjacent spots, and the number of spots in the filtered image are consistent with the actual light source.

[0366] S1205, The blurring processing module sends the overall blurring graph of the second pseudo-linear domain to the forward mapping module.

[0367] S1206. The forward mapping module performs forward nonlinear brightness mapping on the overall bokeh image of the second pseudo-linear domain to obtain the second bokeh image.

[0368] S1207. The forward mapping module sends the second bokeh image to the bokeh fusion module.

[0369] S1208, the bokeh blending module receives the sRGB clear image sent by the camera driver.

[0370] S1209, The blur blending module receives the depth-of-field inner mask sent by the first processing module.

[0371] S1210 The bokeh fusion module fuses the sRGB clear image with the second bokeh image according to the depth-of-field inner mask to obtain the final second target bokeh image.

[0372] In this way, by using the mask of the depth-of-field region for image fusion, the clear regions within the depth of field in different images can be identified and fused into the final image, which can improve the overall image clarity while preserving the image's details and texture information.

[0373] It should be noted that S1201 to S1210 can be referred to Figure 10 The corresponding implementation examples are not described in detail here.

[0374] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0375] Figure 13A schematic block diagram illustrating an embodiment of the present application shows an apparatus 1300. The apparatus 1300 may include a processor 1301 and a transceiver / transceiver pin 1302, and optionally, a memory 1303.

[0376] The various components of device 1300 are coupled together via bus 1304, which includes a data bus, a power bus, a control bus, and a status signal bus. However, for clarity, all buses are referred to as bus 1304 in the figure.

[0377] Optionally, the memory 1303 can be used for the instructions in the foregoing method embodiments. The processor 201 can be used to execute the instructions in the memory 203, control the receive pin to receive signals, and control the transmit pin to transmit signals.

[0378] Device 1300 may be the call application or the chip of the call application in the above method embodiments.

[0379] All relevant content of each step involved in the above method embodiments can be referenced from the functional description of the corresponding functional module, and will not be repeated here.

[0380] This embodiment also provides a computer storage medium storing computer instructions. When the computer instructions are executed on a call application, the call application performs the aforementioned related method steps to implement the control method in the above embodiment.

[0381] This embodiment also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned related steps to implement the control method described in the above embodiment.

[0382] In addition, embodiments of this application also provide an apparatus, which may specifically be a chip, component or module. The apparatus may include a connected processor and a memory. The memory is used to store computer execution instructions. When the apparatus is running, the processor can execute the computer execution instructions stored in the memory to cause the chip to execute the control methods in the above-described method embodiments.

[0383] In this embodiment, the call application, computer storage medium, computer program product or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here.

[0384] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0385] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0386] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0387] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0388] Any content in the various embodiments of this application, as well as any content in the same embodiment, can be freely combined. Any combination of the above content is within the scope of this application.

[0389] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0390] The steps of the methods or algorithms described in conjunction with the embodiments of this application can be implemented in hardware or by a processor executing software instructions. The software instructions can consist of corresponding software modules, which can be stored in random access memory (RAM), flash memory, read-only memory (ROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, portable hard disks, CD-ROMs, or any other form of storage medium well known in the art. An exemplary storage medium is coupled to a processor, enabling the processor to read information from and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and storage medium can reside in an ASIC. Additionally, the ASIC can reside in a network device. Alternatively, the processor and storage medium can exist as discrete components in the network device.

[0391] Those skilled in the art will recognize that, in one or more of the examples above, the functions described in the embodiments of this application can be implemented using hardware, software, firmware, or any combination thereof. Whether a function is implemented in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementation should not be considered beyond the scope of this application.

[0392] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

Claims

1. An image processing method, characterized in that, Applied to electronic devices, the method includes: In response to a photo-taking operation, a first image and a second image are acquired; wherein the first image is an image in a non-linear domain space, and the second image is an unexposed image in a linear domain space; Based on the second image, a third image is generated by enhancing the light spot area of ​​the first image. A linear transformation is performed on the third image to generate a fourth image corresponding to the third image; The fourth image is weighted and filtered to generate the fifth image; A nonlinear transformation is performed on the fifth image to generate a sixth image corresponding to the fifth image; The sixth image is fused with the first image to generate the target image; Display the target image.

2. The method according to claim 1, characterized in that, The linear transformation includes at least one of the following: inverse gamma transform, inverse tone mapping; The step of performing a linear transformation on the third image to generate a fourth image corresponding to the third image includes: Perform the inverse gamma transform on the third image to generate the seventh image; The inverse tone mapping is performed on the seventh image to generate the fourth image.

3. The method according to claim 2, characterized in that, The step of weighted filtering the fourth image to generate the fifth image includes: Generate an eighth image based on the second image and the seventh image; The fourth image is filtered to generate the ninth image; Using the eighth image as a weight, the tenth image is generated by sequentially performing weighted filtering on the spot regions of the fourth image based on the first data. The tenth image is superimposed on the ninth image to generate the fifth image.

4. The method according to claim 3, characterized in that, The method further includes: The second image is subjected to spot detection to obtain the second data; The first data is obtained by performing connected component detection on the second data.

5. The method according to claim 2, characterized in that, The step of weighted filtering the fourth image to generate the fifth image includes: Generate an eighth image based on the second image and the seventh image; The eighth image is used as a weight to perform weighted filtering on the fourth image, thereby generating the fifth image.

6. The method according to claim 1, characterized in that, The step of enhancing the light spot region of the first image based on the second image to generate a third image includes: Based on the third data and the second image, the spot area of ​​the first image is enhanced to generate the third image; wherein, the third data is the depth data corresponding to the first image.

7. The method according to claim 1, characterized in that, The step of fusing the sixth image with the first image to generate the target image includes: Based on the third data, the sixth image is fused with the first image to generate the target image.

8. The method according to claim 1, characterized in that, The method further includes: Based on the third data, the filtering parameters for weighted filtering of the fourth image are determined.

9. The method according to any one of claims 6-8, characterized in that, The method further includes: Depth calculation is performed on the first image to generate the eleventh image; The third data is obtained based on the eleventh image and the shooting parameters; The third data includes at least one of the following: the mask of the depth-of-field region and the blurring filter radius of the outer depth-of-field region.

10. The method according to claim 1, characterized in that, The nonlinear transformation includes at least one of the following: gamma transformation, tone mapping; the parameters of the nonlinear transformation are consistent with those of the linear transformation.

11. An electronic device, characterized in that, include: A memory and a processor, wherein the memory and the processor are coupled; The memory stores program instructions that, when executed by the processor, cause the electronic device to perform the image processing method as described in any one of claims 1-10.

12. A computer-readable storage medium comprising a computer program, characterized in that, When the computer program is run on an electronic device, it causes the electronic device to perform the image processing method as described in any one of claims 1-10.