Image blurring method, electronic device and computer-readable storage medium
By acquiring pixel depth information and depth-of-field range parameters in the image, the filtering coefficients of the pixels are determined for blurring processing, which solves the problem of blurring the boundaries between the subject and the foreground and background, and achieves a more natural image blurring effect.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- SANECHIPS TECH CO LTD
- Filing Date
- 2025-09-05
- Publication Date
- 2026-05-07
AI Technical Summary
In existing technologies, digital image blurring methods often result in the subject and background blurring together, leading to insufficient sharpness of the subject's edges and ignoring the rendering hierarchy of the distance from the shooting device in real optical imaging.
By acquiring the pixel depth information of each pixel in the image to be blurred and the depth range parameters of the main area, the first filtering coefficient of each pixel is determined, and pixel blurring is performed based on the coefficient to ensure clear segmentation of the main subject within the depth of field and the foreground and background outside the depth of field, as well as reasonable coverage layers.
It achieves clear separation and reasonable coverage of the subject within the depth of field and the foreground and background outside the depth of field, avoiding blurring of the boundary between the subject and the foreground and background, and improving the naturalness and aesthetics of the image blurring effect.
Smart Images

Figure CN2025119466_07052026_PF_FP_ABST
Abstract
Description
Image blurring method, electronic device and computer readable storage medium
[0001] Cross-reference to related applications
[0002] The present application claims priority to the Chinese patent application No. 202411522383.9, filed on October 29, 2024, and entitled "Image blurring method, electronic device and computer readable storage medium", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD
[0003] The present application relates to the technical field of image processing, and in particular to an image blurring method, an electronic device and a computer readable storage medium. BACKGROUND
[0004] Background blurring refers to blurring the background part of an image while clearly displaying the foreground part, and is a widely used shooting method that can well highlight the subject and express visual aesthetics. Some professional cameras can directly capture an image after background blurring, but the requirements for the aperture and zoom ratio of the camera lens are relatively high. For the camera of an electronic device such as a mobile phone or a tablet computer, due to the limitations of the device size, thickness and other factors, the lens performance cannot match that of a professional camera, so it cannot directly capture an image after background blurring. Therefore, image processing software needs to be used to achieve background blurring of an image.
[0005] Some digital image blurring processing methods have been proposed in the related art, for example, real-time rendering based on an image signal processor (ISP) system to obtain online image blurring function. However, this digital image blurring method is prone to bleeding of the subject in the depth of field and the front and back backgrounds after blurring, resulting in insufficient edge definition of the subject, and usually ignores the rendering level relationship of the front and back layers in real optical imaging.
[0006] That is, the image after blurring in the related art is prone to the problems of blurred boundaries and unnatural transitions of the subject in the depth of field and the front and back backgrounds, such as color leakage and discontinuous blurring of the front and back backgrounds. SUMMARY
[0007] The main purpose of the present application is to provide an image blurring method, an electronic device and a computer readable storage medium.
[0008] This application provides an image blurring method, comprising: acquiring pixel depth information of each pixel in an image to be blurred, and determining a depth-of-field range parameter of the main subject region in the image to be blurred; determining a first filtering coefficient corresponding to each pixel in the image to be blurred based on the pixel depth information and the depth-of-field range parameter, wherein the farther the pixel is from the focal plane of the main subject region, the larger the first filtering coefficient corresponding to the pixel; and performing pixel blurring processing on each pixel in the image to be blurred based on the first filtering coefficient corresponding to each pixel, wherein the first filtering coefficient is positively correlated with the degree of pixel blurring.
[0009] This application also provides an electronic device, comprising: a memory, a processor, and an image blurring program stored in the memory and executable on the processor, wherein the image blurring program, when executed by the processor, implements the steps of the image blurring method described above. This application also provides a computer-readable storage medium storing an image blurring program, wherein the image blurring program, when executed by a processor, implements the steps of the image blurring method described above.
[0010] This application also provides a computer program product, which includes an image blurring program, which, when executed by a processor, implements the steps of the image blurring method described above. Attached Figure Description
[0011] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0012] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on the structures shown in these drawings without creative effort.
[0013] Figure 1 is a flowchart of the image blurring method provided in Embodiment 1 of this application;
[0014] Figure 2 is a flowchart of the image blurring method provided in Embodiment 2 of this application;
[0015] Figure 3 is a flowchart of the image blurring method provided in Embodiment 3 of this application;
[0016] Figure 4 is a flowchart provided in a specific embodiment of this application;
[0017] Figure 5 is a schematic diagram of DC4 image blurring provided in a specific embodiment of this application;
[0018] Fig. 6 is a schematic diagram of DC16 image blurring provided by an embodiment of the present application;
[0019] Fig. 7 is a schematic diagram of a first image blurring effect provided by an embodiment of the present application;
[0020] Fig. 8 is a schematic diagram of a second image blurring effect provided by an embodiment of the present application;
[0021] Fig. 9 is a schematic diagram of a device structure of a hardware running environment involved in an image blurring method in an embodiment of the present application.
[0022] The purposes, functional features and advantages of the present application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION
[0023] The exemplary embodiments will be described in detail herein with reference to the accompanying drawings. The following description is with reference to the drawings, in which like numerals indicate like elements, unless otherwise described in detail. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the present application as detailed in the appended claims.
[0024] It should be understood that the specific embodiments described herein merely serve to explain the technical solutions of the present application, and are not intended to limit the present application.
[0025] At present, the digital image blurring technology in the related art adopts consistent standards for blurring when blurring an image. Such consistency cannot perform different degrees of blurring according to different depths when processing an image with a complex depth distribution, lacks a sense of hierarchy, and leads to the technical problem that the blurred image has a blurred boundary and an unnatural transition between the subject and the front and back backgrounds.
[0026] The main solution of the embodiments of the present application is: obtaining pixel depth information of each pixel point in a to-be-blurred image, and determining a depth-of-field range parameter of a subject region in the to-be-blurred image; determining a first filter coefficient corresponding to each pixel point in the to-be-blurred image according to the pixel depth information and the depth-of-field range parameter, wherein the farther the pixel point is from a focal plane of the subject region, the larger the first filter coefficient corresponding to the pixel point is; and performing pixel blurring processing on each pixel point in the to-be-blurred image based on the first filter coefficient corresponding to each pixel point, wherein the first filter coefficient is positively correlated with the degree of pixel blurring.
[0027] The embodiment of the present application aims at the boundary definition of the depth-of-field subject and the front and back blurred background, and the overlay level of the foreground and the background, and proposes an image blurring scheme based on depth guidance (Depth Guided), which effectively ensures the clear division and reasonable overlay level of the subject in the depth of field and the front and back background out of the depth of field by using relative depth information, has a good effect of highlighting the subject in the depth of field, and realizes that the subject in the depth of field needs to have a clear boundary with the objects out of the depth of field (including the foreground and the background), especially in the case that the subject in the depth of field and the front and back background have a relatively large depth difference, so as to highlight the definition of the subject in the depth of field, thereby solving the technical problem that the blurred image is prone to have a blurred boundary between the subject in the depth of field and the front and back background and an unnatural transition in the related art.
[0028] The execution subject of the embodiment of the present application is an electronic device, which can include but is not limited to a mobile terminal such as a mobile phone (i.e. a cell phone), a notebook computer, a digital broadcast receiver, a PDA (Personal Digital Assistant), a PAD (Portable Application Description), a PMP (Portable Media Player), a vehicle-mounted terminal (such as a vehicle-mounted navigation terminal), and the like, and a fixed terminal such as a digital TV (Television), a desktop computer, and the like, or any electronic device capable of realizing the above functions, and the present application is not specifically limited thereto. The following describes each embodiment of the present application by taking an electronic device as an execution subject.
[0029] In order to better understand the technical solutions of the present application, the following will be described in detail in combination with the drawings of the specification and specific embodiments.
[0030] Embodiment One
[0031] Please refer to FIG. 1, which is a flowchart provided by the image blurring method of the embodiment one of the present application.
[0032] In the present embodiment, the image blurring method includes steps S100-S300:
[0033] Step S100, obtaining the pixel depth information of each pixel point in the image to be blurred, and determining the depth-of-field range parameter of the subject region in the image to be blurred.
[0034] As is known to those skilled in the art, depth of field is an important concept in photography and filmmaking, referring to the range of distances in a scene that appear acceptably sharp in a photograph or video. In simpler terms, it is the depth interval from the nearest to the farthest objects in sharp focus in a photograph or video. When photographing a scene, a camera will only focus on a specific distance, and the objects at that distance will be the sharpest. However, within a certain range before and after this distance, other objects will also appear relatively sharp, and this range is called the depth of field. The depth of field can be very shallow, only a few centimeters, or very deep, reaching several meters or even infinity, depending on the equipment and technical parameters used during shooting.
[0035] In this embodiment, the depth of field range parameter is a parameter for representing the depth of field, and the objects within the depth of field range parameter are the main objects of the depth of field, i.e., the main objects in the image that the user wants to keep sharp, and the corresponding regions in the image to be blurred correspond to the main object region. The depth of field range parameter can be a depth interval, which is also converted into a parallax interval to represent it, i.e., the depth of field range parameter can also be a parallax interval.
[0036] It should be noted that in this embodiment, the image to be blurred refers to an image that needs to be processed for background blurring, which includes the main object region that needs to be highlighted within the depth of field, and the front and back backgrounds that need to be blurred outside the depth of field. The main object region refers to the part of the image to be blurred that needs to be kept sharp and not blurred, i.e., the object or region that the user wants to emphasize. The pixel depth information refers to the depth information of the pixel points, i.e., the distance information from the pixel points in the image to the camera lens.
[0037] It is not difficult to understand that the depth of field range parameter can reflect the depth interval in which the main object region is located, i.e., the pixel depth interval in which each pixel point in the main object region is located. That is, the depth of field range parameter can be represented by the depth interval in which the main object region is located, or by the pixel depth interval in which each pixel point in the main object region is located.
[0038] It is worth mentioning that in this embodiment, the pixel depth information can be represented by the parallax intensity value of the parallax image pixel, or by the depth value of the pixel in the depth map, or by the layering information to which the pixel belongs in the layering map, and in addition, the pixel depth information of each pixel point can be determined based on at least two of the parallax map, the depth map, and the layering map.
[0039] That is, in the first feasible implementation, the step of obtaining the pixel depth information of each pixel point in the image to be blurred in step S100 can be step A10: obtaining a parallax map of the image to be blurred, and determining the pixel depth information of each pixel point in the image to be blurred according to the parallax intensity value of each pixel point in the parallax map.
[0040] It should be noted that the parallax intensity value is used to represent the position offset between the images of a point at different angles, the greater the offset, the greater the parallax intensity value, which means that the point is closer to the camera lens of the electronic device.
[0041] The depth information of each pixel point in the image can be accurately determined by the parallax intensity value in the embodiment, thereby providing accurate data basis for subsequent blurring processing. Meanwhile, the parallax intensity value can better simulate the real optical blurring effect, ensure that different depth regions have different blurring degrees, and achieve a more natural blurring effect.
[0042] In a second possible implementation, the step of obtaining the pixel depth information of each pixel point in the image to be blurred in step S100 can also be step A20: obtaining a depth map of the image to be blurred, and determining the pixel depth information of each pixel point in the image to be blurred according to the depth value of each pixel point in the depth map.
[0043] The depth value of each pixel point is directly provided by the depth map in the embodiment, without additional calculation or estimation, thereby simplifying the processing flow. In addition, the depth map usually has high precision and can provide detailed depth information, thereby ensuring a more natural blurring effect.
[0044] In a third possible implementation, the step of obtaining the pixel depth information of each pixel point in the image to blurred in step S100 can also be step A30: obtaining a layered image of the image to be blurred, and determining the pixel depth information of each pixel point in the blurred image according to the layered information of each pixel point in the layered image.
[0045] It should be noted that the layered image is an image in which different regions in the image are classified according to depth levels. The layered information refers to information indicating the depth level to which each pixel point in the image belongs in the layered image.
[0046] In the embodiment, the layered image classifies the pixel points in the image to be blurred according to depth levels, can intuitively display different depth regions in the image to be blurred, and is convenient for understanding and debugging. In addition, the layered information can simplify the processing of depth information, and the blurring of different depth regions can be realized through simple layering.
[0047] In addition, in a fourth possible implementation, the step of obtaining the pixel depth information of each pixel point in the image to blur in step S100 can also be step A40: fusing and determining the pixel depth information of each pixel point in the image to be blurred based on at least two of the parallax map, the depth map and the layered image of the image to be blurred.
[0048] The embodiment fuses multiple depth information sources, supplements respective deficiencies, improves the accuracy of depth information, and even if the depth information obtained by a certain method fails, other methods can still provide reliable depth information, so that the most suitable combination mode can be selected according to actual conditions, different application scenarios can be flexibly coped with, and the robustness of the system is enhanced.
[0049] Through any one of the embodiments of steps A10 to A40, the pixel depth information of each pixel point in the image to be blurred can be accurately obtained, the blurring process is ensured to be more accurate and natural, and the robustness and flexibility are high.
[0050] In addition, in the embodiment, the step of determining the depth-of-field range parameter of the subject region in the image to be blurred in step S100 includes step A50 or step A60:
[0051] Step A50: Obtain a focus region in the image to be blurred, and determine the depth-of-field range parameter of the subject region in the image to be blurred according to the depth information of each pixel point in the focus region.
[0052] It should be noted that the focus region refers to a region in the image that is selected as a focus point by an automatic focusing function or manually by a user, and generally includes a main object or a point of interest in the image. It is not difficult to understand that, in general, the focus region is the subject region.
[0053] In the embodiment, the focus region in the image to be blurred can be obtained by manually framing the focus region by the user through the interactive interface of the related camera function in the electronic device, or the focus region in the image to be blurred can be obtained by recognizing the main object region (i.e., the subject region) in the image to be blurred by using the automatic focusing function provided by the electronic device, so as to obtain the depth information (i.e., the pixel depth information) of each pixel point in the focus region according to the pixel depth information of each pixel point in the image to be blurred obtained according to any one of steps A10 to A40, and then determine the depth-of-field range parameter of the subject region in the image to be blurred according to depth information of each pixel point in the focus region.
[0054] In the embodiment, the automatic focusing function can accurately recognize the main object in the image to determine the depth-of-field range parameter, and the user manually frames the focus region, so as to flexibly select the key region according to actual needs and improve the flexibility of processing. According to the depth information of each pixel point in the focus region, the embodiment can accurately determine the depth-of-field range parameter to ensure the clarity of the subject region after the image is blurred.
[0055] Step A60: Obtain a subject region corresponding to an input depth-of-field subject, and determine the depth-of-field range parameter of the subject region in the image to be blurred, according to the depth information of each pixel point in the subject region.
[0056] It should be noted that the depth-of-field subject refers to a main object or area in the image that the user wants to keep clear, and the corresponding area in the image to be blurred is the subject area. The parameter corresponding to the depth-of-field subject is used to determine the subject area from the image to be blurred.
[0057] In this embodiment, the parameter corresponding to the depth-of-field subject can be manually input by the user through the interactive interface of the related camera function in the electronic device, and the subject area is determined from the image to be blurred. Thus, the depth information of each pixel point in the image to be blurred obtained according to any one of the embodiments of steps A10 to A40 is obtained, the depth information of each pixel point in the subject area is obtained, and then the depth-of-field range parameter of the subject area in the image to be blurred is determined according to the depth information of each pixel point in the subject area.
[0058] In this embodiment, the subject area is determined by manually inputting the parameter corresponding to the depth-of-field subject by the user, so that the part that needs to be kept clear can be accurately determined. According to the depth information of each pixel point in the subject area, the depth-of-field range parameter can be accurately determined in this embodiment, so as to ensure the clarity of the subject area after the image is blurred.
[0059] In addition, the depth-of-field range parameter can also be directly obtained by manually inputting the depth-of-field range parameter by the user.
[0060] In step S200, the first filter coefficient corresponding to each pixel point in the image to be blurred is determined according to the pixel depth information and the depth-of-field range parameter, wherein the farther the pixel point is from the focal plane of the subject area, the greater the first filter coefficient corresponding to the pixel point is.
[0061] It should be noted that in this embodiment, the focal plane of the subject area refers to the plane that the lens of the electronic device is aligned with the subject area and focuses most clearly during the shooting process. The first filter coefficient is a coefficient for determining the blurring degree of the pixel point. In the case where other conditions are the same, the greater the first filter coefficient, the higher the blurring procedure of the pixel point, that is, the first filter coefficient is positively correlated with the blurring degree of the pixel.
[0062] In the embodiment, for each pixel point in the image to be blurred, according to the relationship between the pixel depth information and the depth of field range parameter, the distance relationship of the pixel point to the focus plane of the subject region is determined, so that a smaller first filter coefficient is given to the pixel point closer to the focus plane, and a larger first filter coefficient is given to the pixel point farther from the focus plane, so that the first filter coefficient of the pixel point farther from the focus plane is larger in the image to be blurred, and the farther the pixel point from the focus plane, the higher the degree of blurring when the pixel points in the image to be blurred are processed, so that the pixel points of different depths have different degrees of blurring, the level of image blurring is enhanced, a more natural and smooth blurring effect is achieved, and the boundary between the front and back backgrounds and the subject region is blurred.
[0063] It is not difficult to understand that the first filter coefficient of the pixel point in the subject region can be set to 0, that is, the pixel blurring processing is not performed, and the imaging of the subject region is clear and prominent.
[0064] In step S300, based on the first filter coefficient corresponding to each pixel point, the pixel blurring processing is performed on each pixel point in the image to be blurred, wherein the first filter coefficient is positively correlated with the pixel blurring degree.
[0065] It should be noted that the pixel blurring processing refers to blurring processing of the pixel point, so that the pixel point is blurred. The pixel blurring degree refers to the blurring degree of the pixel point.
[0066] In the embodiment, the first filter coefficient is applied to each pixel point in the image to be blurred, so that the pixel points of different depths have different pixel blurring degrees, the level of image blurring is enhanced, the blurring effect is more natural, the boundary between the subject region in the depth of field and the front and back backgrounds outside the depth of field is clear, the phenomenon of halo is avoided, and the final image blurring processing result is more natural, beautiful and practical.
[0067] The embodiment obtains pixel depth information of each pixel point in the image to be blurred, and determines a depth-of-field range parameter of a subject region in the image to be blurred. According to the pixel depth information and the depth-of-field range parameter, a first filter coefficient corresponding to each pixel point in the image to be blurred is determined, wherein the farther the pixel point is from the focal plane of the subject region, the greater the first filter coefficient corresponding to the pixel point is. Then, pixel blurring processing is performed on each pixel point in the image to be blurred based on the first filter coefficient corresponding to each pixel point, wherein the first filter coefficient is positively correlated with the pixel blurring degree, so that the embodiment proposes an image blurring scheme based on depth guidance, which effectively ensures clear segmentation and reasonable coverage level of the subject in the depth of field and the front and rear background out of the depth of field by using relative depth information, has a beneficial effect of highlighting the subject in the depth of field, and realizes clear demarcation between the subject in the depth of field and objects out of the depth of field (including the foreground and the background), especially in the case that the subject in the depth of field and the front and rear background have a relatively large depth difference, to highlight the clarity of the subject in the depth of field, thereby solving the technical problem that the blurred image in the related art is prone to have blurred boundaries and unnatural transitions between the subject in the depth of field and the front and rear background.
[0068] Further, in a feasible implementation manner, before the step of obtaining the pixel depth information of each pixel point in the image to be blurred in step S100, the method further includes step A70:
[0069] In step A70, an initial image is obtained, and image preprocessing is performed on the initial image to obtain the image to be blurred.
[0070] The image preprocessing includes at least one of image smoothing processing, image noise reduction processing, up-sampling processing, and down-sampling processing.
[0071] It should be noted that in the present embodiment, the initial image refers to an original image without any processing. It can be obtained by shooting through the lens of an electronic device, or can be obtained by loading through the storage device of the electronic device.
[0072] As known by those skilled in the art, image smoothing processing is used to reduce image noise and make the image smoother, image noise reduction processing is used to remove random noise in the image and retain the main features of the image, up-sampling processing is used to improve the resolution of the image and make the image clearer, and down-sampling processing is used to reduce the resolution of the image and reduce processing time and resource consumption.
[0073] The embodiment obtains a to-be-blurred image with higher image quality by performing image preprocessing on the initial image, thereby providing better conditions for subsequent depth information acquisition and blurring processing, ensuring that the subsequent blurring processing is more accurate and natural, and thus achieving the expected blurring effect. As for the specific selection of which or which image preprocessing method, it depends on the characteristics of the initial image and the application scenario of image blurring, and is flexibly set by the user according to actual needs, and the embodiment does not make specific limitations in this regard.
[0074] Embodiment Two
[0075] Please refer to FIG. 2, which is a flowchart provided by the image blurring method of embodiment two of the present application.
[0076] In this embodiment, the same or similar contents as the above embodiments can be referred to the above introduction, and will not be described in detail hereinafter.
[0077] In this embodiment, the first filter coefficient corresponding to each pixel point includes a first blurring coefficient of each pixel point in the foreground region and a second blurring coefficient of each pixel point in the background region.
[0078] The step of determining the first filter coefficient corresponding to each pixel point in the to-be-blurred image according to the pixel depth information and the depth range parameter in step S200 can include steps S210-S220.
[0079] In step S210, the foreground region and the background region in the to-be-blurred image are determined according to the pixel depth information and the depth range parameter.
[0080] In this embodiment, the foreground region refers to a region in the to-be-blurred image that is closer to the lens of the electronic device than the subject region, that is, a region with a depth less than the depth range parameter, that is, a foreground outside the depth of field. The background region refers to a region in the to-be-blurred image that is farther from the lens of the electronic device than the subject region, that is, a region with a depth greater than the depth range parameter, that is, a background outside the depth of field.
[0081] It should be noted that the blurring coefficient refers to the first filter coefficient, which is used to determine the blurring degree of the pixel point, the first blurring coefficient refers to the blurring coefficient of the pixel point in the foreground region, which is used to determine the blurring degree of the pixel point in the foreground region, and the second blurring coefficient refers to the blurring coefficient of the pixel point in the background region, which is used to determine the blurring degree of the pixel point in the background region. For the pixel point in the foreground region, under the condition that other conditions are the same, the greater the first blurring coefficient, the higher the blurring degree, that is, the first blurring coefficient is positively correlated with the blurring degree of the pixel. For the pixel point in the background region, under the condition that other conditions are the same, the greater the second blurring coefficient, the higher the blurring degree, that is, the second blurring coefficient is positively correlated with the blurring degree of the pixel.
[0082] According to the pixel depth information of each pixel point in the to-be-virtualized image and the depth-of-field range parameter of the subject region, it can be determined which pixel points in the to-be-virtualized image are closer to the lens of the electronic device than the subject region and which pixel points in the to-be-virtualized image are farther from the lens of the electronic device than the subject region, so that the pixel points closer to the lens of the electronic device than the subject region are regarded as the pixel points in the foreground region, and the pixel points farther from the lens of the electronic device than the subject region are regarded as the pixel points in the background region, and then the foreground region and the background region in the to-be-virtualized image are determined, so that the edge of the subject region is clear and there is no boundary blur in subsequent virtualization processing.
[0083] In step S220, a first virtualization coefficient of each pixel point in the foreground region is determined based on a first preset lookup table function, and a second virtualization coefficient of each pixel point in the background region is determined based on a second preset lookup table function, where the first virtualization coefficient is positively correlated with the pixel virtualization degree, and the second virtualization coefficient is positively correlated with the pixel virtualization degree.
[0084] As known by those skilled in the art, a lookup table function generally refers to a function in a programming or calculation tool, which mainly functions to find and return the required data from a predefined data set (such as an array, a list, a table, etc.). The lookup table function can map the input data to another value, return different preset results based on different input values, or perform interpolation calculation between known data points to estimate the value of unknown data points.
[0085] In this embodiment, the first preset lookup table function and the second preset lookup table function are both preset lookup table functions, which are used to determine the virtualization coefficient of a pixel point according to the depth information (i.e., pixel depth information) of the pixel point. The first preset lookup table function is used to determine the virtualization coefficient (i.e., the first virtualization coefficient) of a pixel point in the foreground region according to the depth information of the pixel point, and the second preset lookup table function is used to determine the virtualization coefficient (i.e., the second virtualization coefficient) of a pixel point in the background region according to the depth information of the pixel point.
[0086] It should be noted that in this embodiment, the first preset lookup table function is different from the second preset lookup table function, that is, for a pixel point with the same depth, the first virtualization coefficient determined by the first preset lookup table function when the pixel point belongs to the foreground region is different from the second virtualization coefficient determined by the second preset lookup table function when the pixel point belongs to the background region.
[0087] The embodiment sets the first preset lookup table function and the second preset lookup table function, adopts different blurring standards for the foreground region and the background region, more accurately controls the blurring degree of different regions, ensures that the transition between the foreground region, the main body region and the background region is more natural, avoids the sense of abruptness, makes the boundary between the main body region and the foreground region or the background region more clear, improves the overall visual effect and the blurring level of the blurred image, and better simulates the physical characteristics and visual perception requirements in natural optical imaging.
[0088] Further, in a possible implementation, the step of performing image blurring processing on each pixel point in the to-be-blurred image based on the first filter coefficient corresponding to each pixel point in step S300 can include steps S310-S330.
[0089] In step S310, perform pixel blurring processing on each pixel point in the foreground region based on the first blurring coefficient to obtain a foreground region image after pixel blurring processing.
[0090] It should be noted that the foreground region image refers to an image corresponding to the foreground region in the to-be-blurred image.
[0091] After determining the first blurring coefficient of each pixel point in the foreground region by the lookup table function in the embodiment, the image corresponding to the foreground region, i.e., the foreground region image, is extracted from the to-be-blurred image, and then the corresponding first blurring coefficient of each pixel point in the foreground region image is applied to perform pixel blurring processing on the pixel point by pixel to obtain the foreground region image after pixel blurring processing.
[0092] In step S320, perform pixel blurring processing on each pixel point in the background region based on the second blurring coefficient to obtain a background region image after pixel blurring processing.
[0093] It should be noted that the background region image refers to an image corresponding to the foreground region in the to-be-blurred image. The background region image refers to an image corresponding to the foreground region in the to-be-blurred image. The background region image refers to an image corresponding to the foreground region in the to-be-blurred image, and the background region image refers to an image corresponding to the foreground region in the to-be-blurred
[0094] After determining the second blurring coefficient of each pixel point in the background region by the lookup table function in the embodiment, the image corresponding to the background region, i.e., the background region image, is extracted from the to-be-blurred image, and then the corresponding second blurring coefficient of each pixel point in the background region image is applied to perform pixel blurring processing on the pixel point by pixel to obtain the background region image after pixel blurring processing.
[0095] In step S330, obtain a main body region image of the main body region in the to-be-blurred image, fuse the main body region image with the foreground region image and the background region image after pixel blurring processing to obtain a target blurred image.
[0096] It should be noted that the subject region image refers to an image corresponding to the subject region in the image to be blurred, and the target blurred image refers to an image obtained by performing pixel blurring processing on each pixel point in the image to be blurred.
[0097] After obtaining the foreground region image and the background region image after the pixel blurring processing, the embodiment extracts the image corresponding to the subject region, i.e., the subject region image, from the image to be blurred, and fuses the image with the foreground region image and the background region image after the pixel blurring processing through image fusion technologies such as a mask layer and multi-channel synthesis, to finally obtain the target blurred image.
[0098] It should be noted that when the subject region image is fused with the foreground region image and the background region image after the pixel blurring processing in step S330, the foreground region image and the background region image after the pixel blurring processing can be preliminarily fused first to ensure that the blurring effect of the foreground region and the background region outside the depth of field is more natural and to avoid a jarring feeling between the background region and the foreground region. Then, the preliminarily fused image and the subject region image are finally fused to ensure the clarity and details of the subject region. Alternatively, the background region image after the pixel blurring processing and the subject region image can be preliminarily fused first to ensure the clarity and details of the subject region, to preferentially ensure the visual effect of the subject region, to reduce the boundary blur between the subject region and the background region, to ensure the clear boundary between the subject region and the background region, to better guide the audience to focus on the subject region, and to avoid the interference of the foreground region on the vision. Then, the preliminarily fused image and the foreground region image after the pixel blurring processing are fused. Alternatively, the foreground region image after the pixel blurring processing and the subject region image can be preliminarily fused first to ensure the clarity and details of the subject region, to preferentially ensure the visual effect of the subject region, to reduce the boundary blur between the subject region and the foreground region, to ensure the clear boundary between the subject region and the foreground region, to avoid the visual discontinuity, and then the preliminarily fused image and the background region image after the pixel blurring processing are fused. Alternatively, the three images can be fused together without any sequence.
[0099] It should be noted that in addition to the above embodiments, the embodiment can directly perform pixel blurring processing on each pixel point in the image to be blurred after determining the first filter coefficient of each pixel point in the image to be blurred, to directly obtain the target blurred image.
[0100] Embodiment Three
[0101] Please refer to FIG. 3, which is a flowchart of the image blurring method provided by Embodiment Three of the present application.
[0102] In this embodiment, the same or similar contents as the above embodiments can be referred to the above description, and will not be described hereinafter.
[0103] In the embodiment, the step of performing the pixel blurring processing on each pixel in the to-be-blurred image based on the first filter coefficient corresponding to each pixel in step S300 can further include steps S340-S360.
[0104] In step S340, each pixel in the to-be-blurred image is taken as a center pixel, and the neighborhood pixels corresponding to the center pixel are determined.
[0105] As known by those skilled in the art, in image processing, when a certain pixel is selected as a core for processing, the pixel is a center pixel, the pixels around the center pixel are neighborhood pixels, and the pixel block composed of the center pixel and the neighborhood pixels can be a 3*3 pixel block or a 4*4 pixel block, which is not specifically limited in the embodiment.
[0106] In the embodiment, the size of the pixel block can be set according to actual requirements, then the pixels in the to-be-blurred image are taken as center pixels in sequence to construct the pixel block, and the pixels other than the center pixel in the pixel block are determined as the neighborhood pixels corresponding to the center pixel, so as to implement step S340.
[0107] In step S350, the second filter coefficient corresponding to each pixel in the to-be-blurred image is determined according to the pixel depth difference information between each center pixel and the corresponding neighborhood pixels.
[0108] It should be noted that the pixel depth difference information reflects the pixel depth difference between the pixel and the neighborhood pixels, that is, the depth relationship between the pixel and the neighborhood pixels. The pixel depth difference information can be determined by the pixel depth information of the pixel as the center pixel and the pixel depth information of the neighborhood pixels.
[0109] For example, when the pixel depth information is represented by a depth value, the pixel depth difference information reflects the depth value difference between the pixel and the neighborhood pixels, and is determined by the depth value of the pixel as the center pixel and the depth value of the neighborhood pixels.
[0110] In addition, it should be further noted that the second filter coefficient is similar to the first filter coefficient, and is also used to determine the blurring degree of the pixel, and the difference lies in that the first filter coefficient depends on the depth relationship between the pixel and the focal plane, while the second filter coefficient depends on the depth relationship between the pixel and the neighborhood pixels.
[0111] In the embodiment, the blurring degree of the pixel point depends on the size of the first filter coefficient and the second filter coefficient, that is, the pixel blurring degree is determined by the first filter coefficient and the second filter coefficient. For the pixel point in the image to be blurred, the greater the first filter coefficient is, the higher the pixel blurring degree is when the second filter coefficient is unchanged, and the greater the second filter coefficient is, the higher the pixel blurring degree is when the first filter coefficient is unchanged. That is, the first filter coefficient is positively correlated with the pixel blurring degree when the second filter coefficient is unchanged, and the second filter coefficient is positively correlated with the pixel blurring degree when the first filter coefficient is unchanged.
[0112] Exemplarily, in a feasible implementation, the step S350 can include steps S351-S353.
[0113] In step S351, the size between the first depth value of the center pixel and the second depth value of the corresponding neighborhood pixel is compared based on the pixel depth difference information.
[0114] In the embodiment, the first depth value refers to the depth value of the center pixel, which is determined by the pixel depth information of the center pixel. The second depth value is used to reflect the depth of the corresponding neighborhood pixel of the center pixel.
[0115] In the embodiment, the depth value of each neighborhood pixel can be determined by the pixel depth information of each neighborhood pixel corresponding to the center pixel, and then the average or weighted average of the depth values of the neighborhood pixels is taken as the second depth value of the neighborhood pixel corresponding to the center pixel, or the neighborhood pixel with a depth value less than the first depth value is taken as an effective neighborhood pixel, and the average or weighted average of the depth values of the effective neighborhood pixels is taken as the second depth value of the neighborhood pixel corresponding to the center pixel.
[0116] In the embodiment, after the step S340 takes each pixel point in the image to be blurred as a center pixel and determines the neighborhood pixel corresponding to each center pixel, the depth values of the center pixel and the corresponding neighborhood pixel are determined by the pixel depth information of the center pixel and the corresponding neighborhood pixel, and then the first depth value of the center pixel and the second depth value of the corresponding neighborhood pixel are calculated, and then the pixel depth difference information between the center pixel and the corresponding neighborhood pixel is determined according to the first depth value of the center pixel and the second depth value of the corresponding neighborhood pixel, and finally the size between the first depth value of the center pixel and the second depth value of the corresponding neighborhood pixel is compared based on the pixel depth difference information, and the depth relationship between the center pixel and the corresponding neighborhood pixel is determined.
[0117] Step S352, in the case that the first depth value is less than the second depth value, then based on the first depth value, the second filter coefficient corresponding to each pixel point in the to-be-virtualized image is determined from the first preset lookup table function.
[0118] Step S353, in the case that the first depth value is greater than or equal to the second depth value, then based on the first depth value and the second depth value, the second filter coefficient corresponding to each pixel point in the to-be-virtualized image is determined from the second preset lookup table function.
[0119] It should be noted that in the present embodiment, the first preset lookup table function and the second preset lookup table function are both preset lookup table functions for determining the second filter coefficient of the pixel point as the center pixel. Among them, the first preset lookup table function is used to directly determine the second filter coefficient of the pixel point as the center pixel according to the first depth value of the center pixel in the case that the first depth value of the center pixel is less than the second depth value of the corresponding neighborhood pixel. And the second preset lookup table function is used to comprehensively determine the second filter coefficient of the pixel point as the center pixel according to the first depth value of the center pixel and the second depth value of the corresponding neighborhood pixel in the case that the first depth value of the center pixel is greater than or equal to the second depth value of the corresponding neighborhood pixel.
[0120] It is not difficult to understand that in the present embodiment, when the first depth value is less than the second depth value, the pixel point as the center pixel is located at a relatively close distance from the lens of the electronic device in the corresponding pixel block, at this time, the second filter coefficient of the pixel point is directly determined from the first threshold lookup table function based on the first depth value of the pixel point, the interference of the neighborhood pixels located at a relatively far distance from the lens of the electronic device is reduced, and it is ensured that the neighborhood pixels (pixels corresponding to objects located at a relatively far distance from the lens of the electronic device) will not blur into the center pixel (pixels corresponding to objects located at a relatively close distance from the lens of the electronic device), so as to truly simulate the single reflex optical virtualization imaging effect. When the first depth value is greater than or equal to the second depth value, the pixel point as the center pixel is located at a relatively far distance from the lens of the electronic device in the corresponding pixel block, at this time, the second filter coefficient of the pixel point is comprehensively determined from the second threshold lookup table function based on the first depth value of the pixel point and the second depth value of the neighborhood pixel, it is ensured that the center pixel located at a relatively far distance from the lens of the electronic device can comprehensively consider the depth information of the surrounding neighborhood pixels, avoid excessive virtualization leading to loss of details, and maintain the natural feeling of the image.
[0121] The embodiment sets the first preset lookup table function and the second preset lookup table function, adopts different blurring standards for the center pixel in the corresponding pixel block at different distances from the lens of the electronic device, avoids blurring the object far from the imaging device into the object close to the imaging device, truly simulates the single reflex optical blurring imaging effect, avoids excessive blurring to cause loss of details, ensures that the pixel blurring processing is more natural and accurate, can highlight the subject area, and realizes a high-quality background blurring effect.
[0122] In step S360, the pixel blurring processing is performed on each pixel point in the to-be-blurred image based on the first filter coefficient and the second filter coefficient corresponding to the pixel point.
[0123] In the case where the second filter coefficient is unchanged, the first filter coefficient is positively correlated with the pixel blurring degree; in the case where the first filter coefficient is unchanged, the second filter coefficient is positively correlated with the pixel blurring degree.
[0124] In the embodiment, step S360 can be that the pixel points in the to-be-blurred image are subjected to preliminary pixel blurring processing by applying the corresponding first filter coefficient pixel by pixel using the blurring algorithm, a preliminarily blurred to-be-blurred image is obtained, then the pixel points in the preliminarily blurred to-be-blurred image are subjected to final pixel blurring processing by applying the corresponding second filter coefficient pixel by pixel using the blurring algorithm, and a finally blurred target blurred image is obtained. Alternatively, the pixel points can be subjected to preliminary pixel blurring processing by applying the corresponding second filter coefficient pixel by pixel, and then subjected to final pixel blurring processing by applying the corresponding first filter coefficient pixel by pixel. Alternatively, the final filter coefficient of each pixel point is calculated by integrating the first filter coefficient and the second filter coefficient, and the pixel blurring processing is performed pixel by pixel using the final filter coefficient.
[0125] In addition, it is worth mentioning that when the pixel blurring processing is performed pixel by pixel by applying the first filter coefficient corresponding to the pixel point, the pixel blurring processing can be performed pixel by pixel on the foreground area by applying the first blurring coefficient and pixel by pixel on the background area by applying the second blurring coefficient according to the technical solution in Embodiment 2.
[0126] The embodiment determines the depth relationship between each pixel point and the neighborhood pixels thereof according to the pixel depth difference information between the center pixel and the neighborhood pixels corresponding to the center pixel, thereby adopting different blurring standards for the center pixel in the corresponding pixel block at different distances from the lens of the electronic device, avoiding blurring the object far from the imaging device into the object close to the imaging device, truly simulating the single reflex optical blurring imaging effect, avoiding excessive blurring to cause loss of details, and further ensuring that the pixel blurring processing is more natural and accurate, can highlight the subject area, and realizes a high-quality blurring effect.
[0127] To facilitate understanding of the technical concept or technical principle of the above-mentioned embodiments of the image blurring method of the present application, a specific embodiment is listed:
[0128] In this specific embodiment, an 8-bit RBG (Red-Blue-Green, a color space representation method) image is taken as an example of the image to be blurred, and a pixel point with pixel coordinates (i, j) is defined, whose RGB three-channel values are (p r,i,j ,p g,i,j ,p b,i,j ), and the parallax intensity value is D i,j , where i = 0, 1, …, h, j = 0, 1, …, w, represents the pixel space position index, h represents the image height of the image to be blurred, w represents the image width of the image to be blurred, p r,i,j represents the pixel value (i.e., the brightness value) of the pixel point in the R channel, p g,i,j represents the pixel value of the pixel point in the G channel, and p b,i,j represents the pixel value of the pixel point in the B channel.
[0129] Please refer to FIG. 4, and the flow steps of this specific embodiment are as follows:
[0130] Step S1, set the depth of field range, and pre-process the parallax map (or depth map, or segmentation map) of the image to be blurred.
[0131] In this specific embodiment, first, the parallax map (or depth map, or segmentation map, where the segmentation map is also called a layered map) of the image to be blurred is subjected to a filtering operation, for example, a bilateral filter can be used, to perform a filtering operation on the parallax image, so as to smooth the image and compensate for the insufficient estimation accuracy of the layer.
[0132] In this specific embodiment, the depth of field range (i.e., the depth of field range parameter) is set as (focal s ,focal e ), where focal s is the lower limit of the interval of the depth of field range, and focal e is the upper limit of the interval of the depth of field range. The interval represents the depth of field range of the expected output clear subject (i.e., the depth of field subject), and the interval is the parallax interval, i.e., the parallax intensity value interval. It is not difficult to understand that (0, focal s ) corresponds to the background area, (focal e , 255) corresponds to the foreground area, and (focal s ,focal e ) corresponds to the subject area.
[0133] In this specific embodiment, (focal sfocal e ) can be obtained by the user selecting in real time in a preview frame in the interaction interface of the electronic device about the camera shooting, or by the automatic focusing function of the electronic device. That is, the in-focus area in the image to be blurred is obtained, and the depth range parameter of the subject area in the image to be blurred is determined according to the depth information of each pixel point in the in-focus area; or, the subject area in the image to be blurred is determined according to the input parameter corresponding to the depth subject, and the depth range parameter of the subject area in the image to be blurred is determined according to the depth information of each pixel point in the subject area.
[0134] In the embodiment, for a pixel point with pixel coordinates (i, j) (hereinafter referred to as pixel point (i, j)), the difference D between the disparity intensity value and the depth range of the pixel point (i, j) can be calculated diff,i,j , and the calculation formula is as follows:
[0135] In the embodiment, the in-depth flag value FlagInFocal i,j of the pixel point (i, j) can be calculated, and whether the pixel point (i, j) is in the depth range is determined, and the calculation formula is as follows:
[0136] It is not difficult to understand that when FlagInFocal i,j is 1, it indicates that the pixel point is in the depth range and is located in the subject area, and when FlagInFocal i,j is 0, it indicates that the pixel point is out of the depth range and is located in the front and background areas (including the foreground area and the background area).
[0137] In the embodiment, the out-of-depth flag value FlagFront i,j of the pixel point (i, j) can be calculated, and whether the pixel point (i, j) is out of the depth range is determined, and the calculation formula is as follows:
[0138] It is not difficult to understand that when FlagFront i,j is 1, it indicates that the pixel point is out of the depth range and is located in the foreground area, and when FlagFront i,j is 0, it indicates that the pixel point is out of the depth range and is located in the background area.
[0139] By the two marking values, the present embodiment can divide the pixel points in the image to be blurred into the pixel points in the subject region within the depth of field, the pixel points in the foreground region outside the depth of field, and the pixel points in the background region outside the depth of field, so as to assign different first filter coefficients to the pixel points in different regions. That is, according to the pixel depth information and the depth of field range parameter, the first filter coefficient corresponding to each pixel point in the image to be blurred is determined, wherein the farther the pixel point is from the focal plane of the subject region, the greater the first filter coefficient corresponding to the pixel point is.
[0140] In step S2, the highlight light source is detected.
[0141] In the present embodiment, after the image corresponding to the subject region within the depth of field (i.e., the subject region image) and the image corresponding to the foreground and background regions outside the depth of field (including the foreground region image and the background region image) are distinguished from the image to be blurred, the image corresponding to the foreground and background regions outside the depth of field is further detected and processed for the highlight light source.
[0142] It should be noted that in the present embodiment, the image to be blurred is an RGB image, so the detection of the highlight light source is to detect the highlight light source for the R, G and B channels respectively. When the image to be blurred is a YUV image or an HSV image, the detection of the highlight light source is to detect the highlight light source for the Y channel or the V channel.
[0143] Taking the R channel as an example, the local brightness value bright of the pixel point (i, j) can be calculated as follows: i,j
[0144] wherein region represents the pixel coordinate set of the neighborhood pixels of the pixel point (i, j), and (m, n) represents the pixel coordinate of the neighborhood pixel of the pixel point (i, j).
[0145] The present embodiment can set certain conditions to determine whether the pixel point (i, j) is a point light source.
[0146] For example, five conditions a to e can be set to determine whether the pixel point (i, j) is a point light source.
[0147] Wherein, cond a represents condition a, cond b represents condition b, cond c represents condition c, cond d represents condition d, cond e represents condition e, scale1 represents a configurable multiplicative parameter threshold, th1, th2 and th3 represent different configurable additive thresholds respectively.
[0148] It should be noted that the above is only one feasible implementation of judging point light sources, and users can add other conditions or delete part of the conditions according to actual needs to form new feasible implementations.
[0149] In the embodiment, if the above five preset conditions are met at the same time, it is determined that the pixel point (i, j) is saturated in the current channel, that is, it is determined to be a point light source. If the pixel point (i, j) is determined to be a point light source, the p r,i,j is boosted in brightness to obtain the pixel value pr,boost,i,j of the pixel point (i, j) after brightness boosting in the R channel, and the calculation formula is as follows: pr,boost,i,j = p r,i,j × scale2.
[0150] Wherein, scale2 represents a configurable multiplicative threshold.
[0151] It is worth mentioning that, in order to facilitate the formation of light spots by blurring operation in subsequent steps, the embodiment can use a higher bit width to represent pr,boost,i,j. For example, the image to be blurred is 8 bits, and the maximum value of pr,boost,i,j is 255. After brightness boosting, pr,boost,i,j can be represented by 10 bits, and the maximum value is 1023.
[0152] The embodiment can determine whether the pixel point located outside the depth of field and belonging to the front and back backgrounds is a point light source in the R, G and B three channels by the above method, and if so, the brightness of the channel is boosted to form light spots of different colors in the final target blurred image.
[0153] It should be noted that when the pixel point is determined to be a point light source in a certain channel and the brightness of the channel is boosted, the brightness of other channels can also be boosted to prevent the formation of light spots with too high saturation, or the brightness of other channels can be suppressed to form light spots with higher saturation. For example, for the RGB 3 channels, if the R channel is determined to be a point light source, the brightness of the other G and B channels can also be boosted to prevent the formation of a red light spot with too high saturation, or the brightness of the other G and B channels can be suppressed to form a red light spot with higher saturation.
[0154] Step S3, fuse the enhanced point light source and the image to be blurred.
[0155] In this specific embodiment, after the brightness of the pixels belonging to point light sources outside the main area in the image to be blurred is increased, they also need to be fused with the image to be blurred to obtain a new image to be blurred.
[0156] Taking the R channel as an example, pixel (i,j) is the light source point on the R channel. After pixel (i,j) is enhanced in the R channel and merged with the image to be blurred, the pixel value of pixel (i,j) on the R channel in the new image to be blurred is pr,merge,i,j. The merging formula is as follows: pr,merge,i,j=p r,i,j +α1×pr,boost,i,j;
[0157] Where α1 represents the configurable fusion coefficient.
[0158] In this specific embodiment, pr,merge,i,j can also be represented using the high bit width.
[0159] Step S4, foreground and background blurring scheme based on depth guidance.
[0160] In this specific embodiment, after fusing and enhancing the point light source, it is also necessary to perform blurring processing on the new image to be blurred based on depth guidance, so as to obtain the blurred image.
[0161] Taking the R channel as an example, first calculate the blur radius r of pixel (i,j). i,j , where r i,j It can be obtained through direct calculation, or by dividing the disparity map into different levels and then looking up the table according to the level.
[0162] In one example, r i,j The calculation formula is as follows: r i,j =MAX((D diff,i,j / 255)×sizekernel,max,sizekernel,max);
[0163] Where MAX(a,b) represents taking the larger value between a and b, and sizekernel,max represents the configurable maximum allowed blur radius.
[0164] In another example, the disparity map with disparity intensity values in the range of (0, 255) can be divided into, for example, N = 5 levels, with different levels corresponding to different sizes of blur radius. In this example, the blur filter generated by the blur radius can be preset.
[0165] In this specific embodiment, the blur radius r of pixel point (i,j) is obtained. i,j After that, the corresponding blur filter can be obtained. For example, the radius of the blur filter can be set to r. i,jThe filter coefficients of the blur filter are constants.
[0166] In the embodiment, the new pixel value of the pixel point (i, j) in the R channel of the blurred image obtained by performing the blur operation (i.e., the pixel blurring process) on the new to-be-blurred image based on the depth is pr, blur, i, j.
[0167] In an example, the first calculation formula of pr, blur, i, j is as follows:
[0168] wherein f d represents the first filter coefficient obtained by the disparity map, f euclid represents the second filter coefficient obtained by the blur filter, f s represents the third filter coefficient defined by the user, sum weight represents the filter coefficient weight sum, f d,m,n is the first filter coefficient of the pixel point (m, n), feuclid, m, n is the second filter coefficient of the pixel point (m, n), and f s,m,n is the third filter coefficient of the pixel point (m, n).
[0169] In the example, the calculation formula of f d,m,n is as follows:
[0170] wherein D m,n is the disparity intensity value of the pixel point (m, n), and σ d represents a configurable parameter.
[0171] It should be noted that, in order to ensure that objects far from the imaging device cannot be blurred into objects close to the imaging device, and to truly simulate the single reflex optical blurring imaging effect, after the first filter coefficient f d,m,n of each neighborhood pixel point is calculated, the depth relationship between the center pixel and the neighborhood pixel is determined according to the positive and negative relationship of D m,n -D i,j , for D m,n -D i,j ≥ 0, i.e., the disparity intensity value of the center pixel (i, j) is less than or equal to the pixel point (m, n) of the neighborhood pixel, the center pixel (i, j) position can be fused using the neighborhood pixel, i.e., the first filter coefficient f d,m,n of the neighborhood pixel is unchanged, and for D m,n -D i,j < 0, i.e., the disparity intensity value of the center pixel (i, j) is greater than the pixel point (m, n) of the neighborhood pixel, the first filter coefficient f d,m,nThe value is set to 0, meaning that neighboring pixels whose depth value is less than the first depth value (the larger the disparity intensity value, the smaller the depth value) are considered valid neighboring pixels (i.e., neighboring pixels whose second filter coefficient value is not 0).
[0172] In this example, f s,m,n The calculation formula is as follows:
[0173] Among them, LUT s (.) represents a monotonically increasing function.
[0174] The above f s The physical meaning is: the farther the relative distance between the pixel and the focal plane, the greater the f. s The larger the value, the greater the first filter coefficient corresponding to the pixel. That is, the farther the pixel is from the focal plane of the main body region, the larger the first filter coefficient corresponding to that pixel.
[0175] The above feuclid,m,n can be used in the fuzzy radius r i,j The internal configuration can be set to a constant or other custom function shape to create different shaped light spot effects.
[0176] In this example, the first filter coefficient is the same as the second filter coefficient, and the third filter coefficient is the same as the first filter coefficient. The above f d,m,n The calculation formula and corresponding steps are as follows: Based on the pixel depth difference information between each center pixel and its corresponding neighboring pixels, determine the second filter coefficient corresponding to each pixel in the image to be blurred. The above f s,m,n The calculation formula and corresponding steps are as follows: Based on the pixel depth information and depth range parameters, determine the first filtering coefficient corresponding to each pixel in the image to be blurred.
[0177] In another example, the second calculation formula for pr,blur,i,j is as follows: pr,blur,i,j=pr,merge,i,j×f d,i,j ×feuclid,i,j×f s,i,j ;
[0178] Among them, f d,i,j Here, f represents the first filter coefficient for pixel (i,j), and feuclid,i,j represents the second filter coefficient for pixel (i,j). s,i,j Let be the third filter coefficient for pixel (i,j).
[0179] In this example, f d,i,j =LUT d (D i,j LUT d (.) is a pre-defined lookup function that is monotonically decreasing.
[0180] In this example, the depth-of-field marker value FlagFront can be used. i,j Configure the first filter coefficients for pixels belonging to the foreground and background regions respectively.
[0181] Taking pixel (i,j) as an example, f d,i,j The calculation formula is as follows:
[0182] Among them, LUT d,front (.) represents the lookup function for the foreground region (i.e., the first preset lookup function), LUT d,back (.) is the lookup function for the background area (i.e., the second preset lookup function).
[0183] In this example, feuclid,i,j and f s,i,j The calculation method is similar to that in the previous example, and will not be repeated here. Please refer to the previous example for f. s,m,n The calculation formula, and the settings for feuclid, m, and n.
[0184] In this example, the product of the first filter coefficient and the second filter coefficient is the first filter coefficient. The product of the first filter coefficient and the second filter coefficient, determined by a lookup function for the foreground region, is the first blurring coefficient. The product of the first filter coefficient and the second filter coefficient, determined by a lookup function for the background region, is the second blurring coefficient. The corresponding steps in this example are: determining the foreground and background regions in the image to be blurred based on pixel depth information and depth-of-field parameters; determining the first blurring coefficient for each pixel in the foreground region based on the first preset lookup function; and determining the second blurring coefficient for each pixel in the background region based on the second preset lookup function.
[0185] It should be noted that this specific embodiment can also use a dynamic fusion weighting scheme, where the fusion coefficients can be obtained by, for example, depth and brightness.
[0186] Step S5 yields the output result.
[0187] In this specific embodiment, after performing a blurring operation (i.e. pixel blurring processing) on the new image to be blurred to obtain a blurred image, the new pixel values of each pixel in the blurred image need to be fused with the pixel values in the image to be blurred in order to obtain the pixel values on the final target blurred image.
[0188] Taking the fusion of pixel values in the R channel with those in the image to be blurred as an example, in the R channel, the new pixel value of pixel (i,j) in the blurred image is pr,blur,i,j, and the pixel value in the target blurred image is p. r,out,i,j p r,out,i,jThe calculation formula is as follows: p r,out,i,j =pr,blur,i,j×α2+p r,i,j ×(1-α2);
[0189] Where α2 represents a configurable coefficient.
[0190] In this specific embodiment, after obtaining the target blurred image, artificial noise can be added to the target blurred image, which is a common operation in the blurring process.
[0191] It should be noted that this specific embodiment supports multi-scale image blurring.
[0192] In one example, as shown in Figure 5, this specific embodiment can perform image blurring by downsampling by 4 times.
[0193] This example, from input to output, first takes the image to be blurred, its disparity map (or depth map, or segmentation map), and a 4x downsampled image obtained by downsampling the image to be blurred. Then, based on the disparity map (or depth map, or segmentation map), the image to be blurred is blurred to obtain a blurred image. Simultaneously, bright point light sources are detected from the 4x downsampled image and their brightness is enhanced to obtain enhanced point light sources. These enhanced point light sources are then fused into the 4x downsampled image to obtain an enhanced point light source map. Next, the blurred image is rendered into the enhanced point light source map to obtain a rendered image. This rendered image is then upsampled by 2x to obtain a 2x upsampled image. Finally, the 2x upsampled image is fused with the image to be blurred to obtain the target blurred image. Noise is then removed from this image, resulting in a high-quality blurred image output.
[0194] In another example, as shown in Figure 6, this specific embodiment can perform image blurring by downsampling by 16 times.
[0195] This example, from input to output, first takes the image to be blurred, its disparity map (or depth map, or segmentation map), and a 16x downsampled image obtained by downsampling the image to be blurred. Then, based on the disparity map (or depth map, or segmentation map), the image to be blurred is blurred to obtain a blurred image. Simultaneously, bright point light sources are detected from the 16x downsampled image and their brightness is enhanced to obtain enhanced point light sources. These enhanced point light sources are then merged into the 16x downsampled image to obtain an enhanced point light source map. Next, the blurred image is rendered into the enhanced point light source map to obtain a rendered image, which is then upsampled by 4x to obtain a 4x upsampled image. Finally, the 4x upsampled image is merged with the image to be blurred to obtain the target blurred image, and noise is removed to achieve a high-quality blurred image output.
[0196] The image blurring effect of this specific embodiment is shown in Figures 7 and 8.
[0197] In Figure 7, the top left corner is the image to be blurred, the top right corner is the target blurred image obtained after image blurring (i.e. pixel blurring) of the top left corner image to be blurred, the bottom left corner is the flawed image where the edges between different objects in the background area are not sufficiently blurred when image blurring is performed on the top left corner image to be blurred, and the top right corner is the flawed image where the edges between the background area and the subject area are blurred when image blurring is performed on the top left corner image to be blurred.
[0198] This specific embodiment utilizes the first filter coefficient f d It can preserve the edges of objects at similar depths, meaning that the subject within the depth of field and the background at different depths outside the depth of field are less likely to blur each other during the blurring process. This solves the problem of the sharpness of the boundaries between the subject within the depth of field and the objects outside the depth of field, achieving the effect shown in the lower left corner of Figure 7. Furthermore, it can be effectively combined with the second filter coefficient f. s This can provide a higher blur intensity to the background that is far from the depth of field of the subject, thus achieving the effect shown in the upper right corner of Figure 7, which maintains the sharpness of the inner and outer edges of the depth of field while ensuring the blur intensity of the blurred background.
[0199] In Figure 8, the top left corner is the image to be blurred; the top right corner is the target blurred image where the brightness of the point light source is enhanced to create a large spot effect during the image blurring process of the top left corner image; the bottom left corner is the target blurred image where the brightness of the point light source is enhanced to create a small spot effect during the image blurring process of the top left corner image; and the bottom right corner is the target blurred image where the brightness of the point light source is enhanced to create a colored spot effect during the image blurring process of the top left corner image.
[0200] It should be noted that the above examples are only for the purpose of assisting in understanding this application and do not constitute a limitation on the image blurring method of this application. Any simple transformations based on this technical concept are all within the protection scope of this application.
[0201] In addition, please refer to Figure 9, which is a schematic diagram of the device structure of the hardware operating environment involved in the image blurring method in the embodiments of this application.
[0202] This application also provides an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the steps of the image blurring method in the above embodiments.
[0203] Referring now to Figure 9, a schematic diagram of an electronic device suitable for implementing embodiments of this application is shown. The electronic device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs (Televisions), desktop computers, or any electronic device capable of performing the above functions. The electronic device shown in Figure 9 is merely an example and should not impose any limitations on the functions and scope of use of the embodiments of this application.
[0204] As shown in Figure 9, the electronic device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the electronic device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. While electronic devices with various systems are shown in the figures, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.
[0205] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0206] The electronic device provided in this application, employing the image blurring method described in the above embodiments, can solve the technical problem in related technologies where blurred images easily exhibit blurred boundaries between the subject and the foreground / background, resulting in unnatural transitions. Compared with the prior art, the beneficial effects of the electronic device provided in this application are the same as those of the image blurring method provided in the above embodiments, and other technical features of this electronic device are the same as those disclosed in the methods of the above embodiments, and will not be elaborated upon here.
[0207] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0208] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of protection of the above claims.
[0209] In addition, this application also provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to perform the steps of the image blurring method in the above embodiments.
[0210] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0211] The aforementioned computer-readable storage medium may be included in an electronic device or may exist independently without being assembled into an electronic device.
[0212] The aforementioned computer-readable storage medium carries one or more programs that, when executed by an electronic device, cause the electronic device to: acquire pixel depth information of each pixel in the image to be blurred, and determine the depth-of-field range parameter of the main subject region in the image to be blurred; determine a first filtering coefficient corresponding to each pixel in the image to be blurred based on the pixel depth information and the depth-of-field range parameter, wherein the farther the pixel is from the focal plane of the main subject region, the larger the first filtering coefficient corresponding to the pixel; and perform pixel blurring processing on each pixel in the image to be blurred based on the first filtering coefficient corresponding to each pixel, wherein the first filtering coefficient is positively correlated with the degree of pixel blurring.
[0213] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0214] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0215] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0216] The computer-readable storage medium provided in this application stores computer-readable program instructions (i.e., a computer program) for performing the steps of the above-described image blurring method, which can solve the technical problem in related technologies that blurred images easily exhibit blurred boundaries between the subject and the foreground / background, and unnatural transitions. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the image blurring method provided in the above embodiments, and will not be repeated here.
[0217] Furthermore, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the image blurring method as described in the above embodiments.
[0218] The computer program product provided in this application can solve the technical problem in related technologies that blurred images easily exhibit blurred boundaries and unnatural transitions between the subject and the foreground / background. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the image blurring method provided in the above embodiments, and will not be repeated here.
[0219] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
Claims
1. An image blurring method, comprising: Obtain pixel depth information of each pixel in the image to be blurred, and determine the depth range parameters of the main area in the image to be blurred; Based on the pixel depth information and the depth of field range parameters, the first filtering coefficient corresponding to each pixel in the image to be blurred is determined, wherein the farther the pixel is from the focal plane of the main body region, the larger the first filtering coefficient corresponding to the pixel is. Based on the first filtering coefficient corresponding to each pixel, pixel blurring processing is performed on each pixel in the image to be blurred, wherein the first filtering coefficient is positively correlated with the degree of pixel blurring.
2. The image blurring method of claim 1, wherein, Based on the first filtering coefficients corresponding to each pixel, pixel blurring processing is performed on each pixel in the image to be blurred, including: Each pixel in the image to be blurred is taken as the center pixel, and the neighboring pixels corresponding to each center pixel are determined. Based on the pixel depth difference information between each center pixel and its corresponding neighboring pixels, the second filtering coefficients corresponding to each pixel in the image to be blurred are determined. Based on the first and second filtering coefficients corresponding to each pixel, pixel blurring processing is performed on each pixel in the image to be blurred. Wherein, when the second filter coefficient remains unchanged, the first filter coefficient is positively correlated with the degree of pixel blurring; when the first filter coefficient remains unchanged, the second filter coefficient is positively correlated with the degree of pixel blurring.
3. The image blurring method of claim 2, wherein, Based on the pixel depth difference information between each center pixel and its corresponding neighboring pixels, the second filtering coefficients corresponding to each pixel in the image to be blurred are determined, including: Based on the pixel depth difference information, the magnitude of the first depth value of the center pixel and the second depth value of its corresponding neighboring pixels are compared. If the first depth value is less than the second depth value, then based on the first depth value and the second depth value, the second filtering coefficients corresponding to each pixel in the image to be blurred are determined from the first preset lookup table function. If the first depth value is greater than or equal to the second depth value, then based on the first depth value, the second filtering coefficients corresponding to each pixel in the image to be blurred are determined from the second preset lookup table function.
4. The image blurring method of claim 1, wherein, The first filtering coefficients corresponding to each pixel include: the first blurring coefficient of each pixel in the foreground region, and the second blurring coefficient of each pixel in the background region; Based on the pixel depth information and the depth-of-field range parameters, the first filtering coefficients corresponding to each pixel in the image to be blurred are determined, including: Based on the pixel depth information and the depth-of-field range parameters, the foreground region and background region in the image to be blurred are determined; Based on a first preset lookup table function, a first blur coefficient for each pixel in the foreground region is determined, and based on a second preset lookup table function, a second blur coefficient for each pixel in the background region is determined. The first blur coefficient is positively correlated with the degree of pixel blur, and the second blur coefficient is positively correlated with the degree of pixel blur.
5. The image blurring method as described in claim 4, wherein, Based on the first filtering coefficients corresponding to each pixel, image blurring processing is performed on each pixel in the image to be blurred, including: Based on the first blurring coefficient, pixel blurring processing is performed on each pixel in the foreground region to obtain a pixel-blurred foreground region image; and... Based on the second blurring coefficient, pixel blurring processing is performed on each pixel in the background region to obtain a background region image after pixel blurring processing; Obtain the main region image of the main area in the image to be blurred, and fuse the main region image with the foreground region image and background region image after pixel blurring to obtain the target blurred image.
6. The image blurring method as described in claim 1, wherein, Before obtaining the pixel depth information of each pixel in the image to be blurred, the following steps are included: Acquire an initial image, perform image preprocessing on the initial image to obtain the image to be blurred; The image preprocessing includes at least one of image smoothing, image noise reduction, upsampling, and downsampling.
7. The image blurring method according to any one of claims 1 to 6, wherein, Determining the depth-of-field range parameters of the subject region in the image to be blurred includes: Obtain the focus area in the image to be blurred, and determine the depth-of-field range parameters of the main subject area in the image to be blurred based on the depth information of each pixel within the focus area; or, Based on the parameters corresponding to the input depth subject, the subject region in the image to be blurred is determined, and based on the depth information of each pixel in the subject region, the depth range parameters of the subject region in the image to be blurred are determined.
8. An electronic device, comprising: The image blurring program stored in the memory and executable on the processor, wherein when executed by the processor, the image blurring program implements the steps of the image blurring method as described in any one of claims 1 to 7.
9. A computer-readable storage medium storing an image blurring program, which, when executed by a processor, implements the steps of the image blurring method as described in any one of claims 1 to 7.
10. A computer program product comprising an image blurring program, wherein the image blurring program, when executed by a processor, implements the steps of the image blurring method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Image-processing method and terminal
CN105592271A
Image blurring method, image blurring device, mobile terminal and storage medium
CN108076286A
Image processing method and device, electronic equipment and computer readable storage medium
CN116071222A
Multiview synthesis and processing systems and methods
US20140098100A1
Virtual viewpoint depth map processing method, device, and apparatus, and storage medium
WO2022116397A1