Image blurring method, apparatus, and storage medium based on progressive Gaussian filtering

By using a progressive Gaussian filtering method, the probability of each pixel is determined by an image segmentation model and a Gaussian filtering algorithm is set, which solves the problem of unnatural pixel changes between the subject and background in existing technologies and achieves a more natural image blurring effect.

CN119904376BActive Publication Date: 2025-11-14ALLWINNER TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411729804.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2025-11-14
Estimated Expiration
2044-11-28

AI Technical Summary

Technical Problem

Existing image blurring methods do not produce natural pixel changes between the subject and the background, and the edges of the subject are not sharp enough.

Method used

A progressive Gaussian filtering method is adopted. The target probability of each pixel is determined by a pre-trained image segmentation model, and the corresponding Gaussian filtering algorithm is set according to the probability to perform Gaussian filtering operation on the pixels. This progressive Gaussian filtering method makes the pixel changes between the subject and the background smoother.

Benefits of technology

This technology achieves smoother pixel transitions between the subject and background during image blurring, resulting in sharper and clearer edges for the subject and a more natural image blurring effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119904376B_ABST
    Figure CN119904376B_ABST
Patent Text Reader

Abstract

This invention discloses an image blurring method, apparatus, and storage medium based on progressive Gaussian filtering, relating to the field of image blurring technology. For each pixel in the image to be blurred, this invention determines the target probability of that pixel being a target object pixel based on a pre-trained image segmentation model; and determines the target Gaussian filtering algorithm corresponding to that pixel. For each pixel in the image to be blurred, a Gaussian filtering operation is performed on that pixel to obtain the corresponding filtered pixel value; based on the filtered pixel values ​​corresponding to each pixel in the image to be blurred, the object blurring image corresponding to the image to be blurred is determined. This invention can set different Gaussian filtering algorithms according to different probability ranges, thereby designing a progressive Gaussian filtering method that makes the pixel changes between the subject and background parts of the image smoother, thus making the image blurring more natural.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image blurring technology, and in particular to an image blurring method, apparatus, and storage medium based on progressive Gaussian filtering. Background Technology

[0002] Image blurring methods are frequently used in the field of image or video processing. Image blurring is an image processing method that highlights the main subject in an image while blurring the parts other than the main subject. For example, the common portrait blurring operation requires that the portrait be displayed clearly, while the parts other than the portrait be blurred.

[0003] Existing image blurring methods primarily rely on multi-camera systems or advanced single-camera systems. In multi-camera systems, two or more cameras capture different perspectives of the same scene. By comparing the phase differences captured by different cameras, the depth information of the scene is calculated to distinguish the subject and background, and software is used to blur the background. Advanced single-camera-based image blurring methods, such as dual-pixel autofocus, acquire scene depth information by capturing multiple light sources from each pixel, and then use software to achieve the blurring effect. Practice shows that these methods often result in unnatural image blurring, mainly due to abrupt pixel changes between the subject and background, and particularly the lack of sharp edges on the subject.

[0004] Therefore, a new image blurring method is proposed to make the pixel changes between the subject and the background in the image smoother and the edges of the subject sharper during image blurring, thus making the image blurring more natural. This has become a technical problem that needs to be solved in the field of image blurring. Summary of the Invention

[0005] This invention provides an image blurring method, apparatus, and storage medium based on progressive Gaussian filtering, so that during image blurring processing, the pixel changes between the main object and the background in the image are smoother, the edges of the main object are clearer and sharper, and thus the image blurring is more natural.

[0006] To address the aforementioned technical problems, the first aspect of this invention discloses an image blurring method based on progressive Gaussian filtering, the method comprising:

[0007] For each pixel in the image to be blurred, the target probability of the pixel being a target object pixel is determined based on the pre-trained image segmentation model; and the target Gaussian filtering algorithm corresponding to the pixel is determined based on the target probability of the pixel.

[0008] For each pixel in the image to be blurred, a Gaussian filtering operation is performed on the pixel based on the target Gaussian filtering algorithm corresponding to the pixel to obtain the filtered pixel value corresponding to the pixel.

[0009] The object blurring image corresponding to the image to be blurred is determined based on the filtered pixel value corresponding to each pixel point on the image to be blurred.

[0010] As an optional implementation, in the first aspect of the present invention, determining the target probability that each pixel in the image to be blurred is a target object pixel based on a pre-trained image segmentation model includes:

[0011] The image to be blurred is input into a pre-trained image segmentation model to obtain the object segmentation probability map output by the image segmentation model;

[0012] For each pixel in the image to be blurred, the target probability of that pixel being a target object pixel is determined according to the object segmentation probability map.

[0013] In the object segmentation probability map, the pixel value of each pixel is used to represent the probability that the pixel is a target object pixel;

[0014] And, for each pixel in the image to be blurred, determining the target Gaussian filtering algorithm corresponding to that pixel based on the target probability includes:

[0015] For each pixel in the image to be blurred, the target algorithm parameters corresponding to the pixel are determined according to the target probability corresponding to the pixel, and the target Gaussian filtering algorithm corresponding to the pixel is determined according to the target algorithm parameters.

[0016] The target algorithm parameters include at least the target filter kernel size (kernel_size) and the target Gaussian function standard deviation (σ).

[0017] As an optional implementation, in the first aspect of the present invention, determining the target Gaussian filtering algorithm corresponding to each pixel in the image to be blurred, based on the target probability corresponding to that pixel, includes:

[0018] For each pixel in the image to be blurred, if the target probability corresponding to the pixel is less than a preset first probability threshold, then the pixel is determined to be a non-target object pixel, and the target algorithm parameter corresponding to the pixel is determined to be a first algorithm parameter; if the target probability corresponding to the pixel is greater than or equal to the first probability threshold and less than a preset second probability threshold, then the pixel is determined to be an object edge pixel, and the target algorithm parameter corresponding to the pixel is determined to be a second algorithm parameter.

[0019] Wherein, the first probability threshold is less than the second probability threshold.

[0020] As an optional implementation, in the first aspect of the present invention, the step of performing a Gaussian filtering operation on each pixel in the image to be blurred, based on the target Gaussian filtering algorithm corresponding to that pixel, to obtain the filtered pixel value corresponding to that pixel, includes:

[0021] A variety of preset Gaussian filtering algorithms are used to perform Gaussian filtering operations on all pixels of the image to be blurred, thereby obtaining multiple pre-filtered pixel values ​​corresponding to each pixel of the image to be blurred; based on all the pre-filtered pixel values ​​corresponding to all pixels of the image to be blurred, a preprocessed image corresponding to each preset Gaussian filtering algorithm is obtained;

[0022] For each pixel in the image to be blurred, a target preset Gaussian filter algorithm matching the target Gaussian filter algorithm corresponding to the pixel is determined according to the target Gaussian filter algorithm corresponding to the pixel. The target preprocessed image corresponding to the pixel is determined from all the preprocessed images according to the target preset Gaussian filter algorithm. The filter pixel value corresponding to the pixel is determined according to the pixel value of the matching pixel in the target preprocessed image.

[0023] As an optional implementation, in the first aspect of the present invention, determining the target algorithm parameters corresponding to each pixel in the image to be blurred, based on the target probability corresponding to that pixel, includes:

[0024] For each pixel in the image to be blurred, the standard deviation σ of the target Gaussian function corresponding to the pixel is determined according to the target probability corresponding to the pixel, and the target filter kernel size kernel_size corresponding to the pixel is determined according to the standard deviation σ of the target Gaussian function corresponding to the pixel.

[0025] Specifically, determining the target filter kernel size (kernel_size) based on the standard deviation σ of the target Gaussian function corresponding to the pixel is achieved through the following formula:

[0026]

[0027] kernel_size = 2 * radius + 1

[0028] In the above formula, For the floor function, radius is an intermediate parameter.

[0029] As an optional implementation, in the first aspect of the present invention, the step of performing a Gaussian filtering operation on each pixel in the image to be blurred, based on the target Gaussian filtering algorithm corresponding to that pixel, to obtain the filtered pixel value corresponding to that pixel, includes:

[0030] For each pixel in the image to be blurred, the pixel is determined as the target pixel. The target pixel is used as the origin of the coordinate system, and the target filter kernel size kernel_siz corresponding to the target pixel is used as the side length. A target filter kernel of size kernel_size*kernel_size is constructed for the target pixel. The filter kernel weight matrix corresponding to the target filter kernel is determined according to the standard deviation σ of the target Gaussian function corresponding to the target pixel.

[0031] For each target pixel in the image to be blurred, all pixels in the image to be blurred that are located within the target filter kernel corresponding to that target pixel are convolved with the filter kernel weight matrix to obtain the filter pixel value corresponding to that target pixel.

[0032] Specifically, for each target pixel in the image to be blurred, the filter kernel weight matrix corresponding to the target filter kernel is determined based on the standard deviation σ of the target Gaussian function corresponding to that target pixel. This is achieved through the following formula:

[0033]

[0034] In the above formula, x is the horizontal coordinate of any pixel within the target filtering kernel, where the value of x ranges from [-radius, radius]; y is the vertical coordinate of any pixel within the target filtering kernel, where the value of y also ranges from [-radius, radius]; the coordinates of the target pixel are (0,0); and f(x,y) is the weight parameter of the pixel at (x,y).

[0035] As an optional implementation, in the first aspect of the present invention, the step of inputting the image to be blurred into a pre-trained image segmentation model to obtain an object segmentation probability map output by the image segmentation model includes:

[0036] Obtain an image to be blurred with a resolution of ih*iw, and preprocess the image to be blurred to obtain a preprocessed image;

[0037] The preprocessed image is scaled up to an intermediate image with a resolution of nh*nw;

[0038] The intermediate image is input into a pre-trained image segmentation model to obtain an initial probability map with a resolution of nh*nw output by the image segmentation model;

[0039] After performing bilinear interpolation upsampling on the initial probability map, an object segmentation probability map with a resolution of ih*iw is obtained;

[0040] Specifically, the preprocessing of the image to be blurred to obtain a preprocessed image includes:

[0041] Calculate the pixel mean and pixel variance of all pixels in the image to be blurred;

[0042] For each pixel in the image to be blurred, the pixel value is subtracted from the pixel mean and then divided by the pixel variance to obtain the standardized pixel value of the pixel.

[0043] A normalization operation is performed on the standardized pixel values ​​of all pixels in the image to be blurred to obtain the preprocessed pixel value of each pixel in the image to be blurred.

[0044] A preprocessed image is obtained based on the preprocessed pixel values ​​of all the pixels in the image to be blurred.

[0045] A second aspect of the present invention discloses an image blurring device based on progressive Gaussian filtering, the device comprising:

[0046] The image segmentation module is used to determine the target probability of each pixel in the image to be blurred, based on a pre-trained image segmentation model; and to determine the target Gaussian filtering algorithm corresponding to the pixel based on the target probability.

[0047] The Gaussian filtering module is used to perform a Gaussian filtering operation on each pixel in the image to be blurred, based on the target Gaussian filtering algorithm corresponding to the pixel, to obtain the filtered pixel value corresponding to the pixel.

[0048] The image blurring module is used to determine the object blurring image corresponding to the image to be blurred based on the filtered pixel value corresponding to each pixel point on the image to be blurred.

[0049] As an optional implementation, in the second aspect of the present invention, the image segmentation module determines the target probability of each pixel in the image to be blurred as a target object pixel based on a pre-trained image segmentation model, including:

[0050] The image to be blurred is input into a pre-trained image segmentation model to obtain the object segmentation probability map output by the image segmentation model;

[0051] For each pixel in the image to be blurred, the target probability of that pixel being a target object pixel is determined according to the object segmentation probability map.

[0052] In the object segmentation probability map, the pixel value of each pixel is used to represent the probability that the pixel is a target object pixel;

[0053] And, for each pixel in the image to be blurred, determining the target Gaussian filtering algorithm corresponding to that pixel based on the target probability includes:

[0054] For each pixel in the image to be blurred, the target algorithm parameters corresponding to the pixel are determined according to the target probability corresponding to the pixel, and the target Gaussian filtering algorithm corresponding to the pixel is determined according to the target algorithm parameters.

[0055] The target algorithm parameters include at least the target filter kernel size (kernel_size) and the target Gaussian function standard deviation (σ).

[0056] As an optional implementation, in the second aspect of the present invention, the image segmentation module determines the specific method of the target Gaussian filtering algorithm corresponding to each pixel in the image to be blurred, based on the target probability corresponding to that pixel, including:

[0057] For each pixel in the image to be blurred, if the target probability corresponding to the pixel is less than a preset first probability threshold, then the pixel is determined to be a non-target object pixel, and the target algorithm parameter corresponding to the pixel is determined to be a first algorithm parameter; if the target probability corresponding to the pixel is greater than or equal to the first probability threshold and less than a preset second probability threshold, then the pixel is determined to be an object edge pixel, and the target algorithm parameter corresponding to the pixel is determined to be a second algorithm parameter.

[0058] Wherein, the first probability threshold is less than the second probability threshold.

[0059] As an optional implementation, in the second aspect of the present invention, the specific method by which the Gaussian filtering module performs a Gaussian filtering operation on each pixel in the image to be blurred, based on the target Gaussian filtering algorithm corresponding to that pixel, to obtain the filtered pixel value corresponding to that pixel, includes:

[0060] A variety of preset Gaussian filtering algorithms are used to perform Gaussian filtering operations on all pixels of the image to be blurred, thereby obtaining multiple pre-filtered pixel values ​​corresponding to each pixel of the image to be blurred; based on all the pre-filtered pixel values ​​corresponding to all pixels of the image to be blurred, a preprocessed image corresponding to each preset Gaussian filtering algorithm is obtained;

[0061] For each pixel in the image to be blurred, a target preset Gaussian filter algorithm matching the target Gaussian filter algorithm corresponding to the pixel is determined according to the target Gaussian filter algorithm corresponding to the pixel. The target preprocessed image corresponding to the pixel is determined from all the preprocessed images according to the target preset Gaussian filter algorithm. The filter pixel value corresponding to the pixel is determined according to the pixel value of the matching pixel in the target preprocessed image.

[0062] As an optional implementation, in the second aspect of the present invention, the image segmentation module determines the target algorithm parameters corresponding to each pixel in the image to be blurred according to the target probability corresponding to that pixel in a specific way, including:

[0063] For each pixel in the image to be blurred, the standard deviation σ of the target Gaussian function corresponding to the pixel is determined according to the target probability corresponding to the pixel, and the target filter kernel size kernel_size corresponding to the pixel is determined according to the standard deviation σ of the target Gaussian function corresponding to the pixel.

[0064] Specifically, determining the target filter kernel size (kernel_size) based on the standard deviation σ of the target Gaussian function corresponding to the pixel is achieved through the following formula:

[0065]

[0066] kernel_size = 2 * radius + 1

[0067] In the above formula, For the floor function, radius is an intermediate parameter.

[0068] As an optional implementation, in the second aspect of the present invention, the specific method by which the Gaussian filtering module performs a Gaussian filtering operation on each pixel in the image to be blurred, based on the target Gaussian filtering algorithm corresponding to that pixel, to obtain the filtered pixel value corresponding to that pixel, includes:

[0069] For each pixel in the image to be blurred, the pixel is determined as the target pixel. The target pixel is used as the origin of the coordinate system, and the target filter kernel size kernel_siz corresponding to the target pixel is used as the side length. A target filter kernel of size kernel_size*kernel_size is constructed for the target pixel. The filter kernel weight matrix corresponding to the target filter kernel is determined according to the standard deviation σ of the target Gaussian function corresponding to the target pixel.

[0070] For each target pixel in the image to be blurred, all pixels in the image to be blurred that are located within the target filter kernel corresponding to that target pixel are convolved with the filter kernel weight matrix to obtain the filter pixel value corresponding to that target pixel.

[0071] Specifically, for each target pixel in the image to be blurred, the filter kernel weight matrix corresponding to the target filter kernel is determined based on the standard deviation σ of the target Gaussian function corresponding to that target pixel. This is achieved through the following formula:

[0072]

[0073] In the above formula, x is the horizontal coordinate of any pixel within the target filtering kernel, where the value of x ranges from [-radius, radius]; y is the vertical coordinate of any pixel within the target filtering kernel, where the value of y also ranges from [-radius, radius]; the coordinates of the target pixel are (0,0); and f(x,y) is the weight parameter of the pixel at (x,y).

[0074] As an optional implementation, in the second aspect of the present invention, the specific method by which the image segmentation module inputs the image to be blurred into a pre-trained image segmentation model to obtain the object segmentation probability map output by the image segmentation model includes:

[0075] Obtain an image to be blurred with a resolution of ih*iw, and preprocess the image to be blurred to obtain a preprocessed image;

[0076] The preprocessed image is scaled up to an intermediate image with a resolution of nh*nw;

[0077] The intermediate image is input into a pre-trained image segmentation model to obtain an initial probability map with a resolution of nh*nw output by the image segmentation model;

[0078] After performing bilinear interpolation upsampling on the initial probability map, an object segmentation probability map with a resolution of ih*iw is obtained;

[0079] The image segmentation module preprocesses the image to be blurred to obtain a preprocessed image, specifically including:

[0080] Calculate the pixel mean and pixel variance of all pixels in the image to be blurred;

[0081] For each pixel in the image to be blurred, the pixel value is subtracted from the pixel mean and then divided by the pixel variance to obtain the standardized pixel value of the pixel.

[0082] A normalization operation is performed on the standardized pixel values ​​of all pixels in the image to be blurred to obtain the preprocessed pixel value of each pixel in the image to be blurred.

[0083] A preprocessed image is obtained based on the preprocessed pixel values ​​of all the pixels in the image to be blurred.

[0084] A third aspect of the present invention discloses another image blurring device based on progressive Gaussian filtering, the device comprising:

[0085] Memory containing executable program code;

[0086] A processor coupled to the memory;

[0087] The processor calls the executable program code stored in the memory to execute the image blurring method based on progressive Gaussian filtering disclosed in the first aspect of the present invention.

[0088] The fourth aspect of the present invention discloses a computer storage medium storing computer instructions, which, when invoked, are used to execute the image blurring method based on progressive Gaussian filtering disclosed in the first aspect of the present invention.

[0089] Compared with the prior art, the present invention has the following beneficial effects:

[0090] This invention, for each pixel in the image to be blurred, determines the target probability that the pixel is a target object pixel based on a pre-trained image segmentation model; based on the target probability corresponding to the pixel, it determines the target Gaussian filtering algorithm corresponding to the pixel; for each pixel in the image to be blurred, it performs a Gaussian filtering operation on the pixel based on the target Gaussian filtering algorithm corresponding to the pixel to obtain the filtered pixel value corresponding to the pixel; based on the filtered pixel value corresponding to each pixel in the image to be blurred, it determines the object blurred image corresponding to the image to be blurred. It can be seen that the image blurring method based on progressive Gaussian filtering of this invention can set different Gaussian filtering algorithms according to different probability ranges, thereby designing a progressive Gaussian filtering method that makes the pixel changes between the subject and background parts of the image smoother, thus making the image blurring more natural. Attached Figure Description

[0091] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0092] Figure 1 This is a flowchart illustrating an image blurring method based on progressive Gaussian filtering disclosed in an embodiment of the present invention.

[0093] Figure 2 This is a flowchart illustrating another image blurring method based on progressive Gaussian filtering disclosed in an embodiment of the present invention;

[0094] Figure 3 This is a schematic diagram of a Gaussian filtering operation disclosed in an embodiment of the present invention;

[0095] Figure 4 This is a schematic diagram of another Gaussian filtering operation disclosed in an embodiment of the present invention;

[0096] Figure 5 This is a schematic diagram of the structure of an image blurring device based on progressive Gaussian filtering disclosed in an embodiment of the present invention;

[0097] Figure 6 This is a schematic diagram of another image blurring device based on progressive Gaussian filtering disclosed in an embodiment of the present invention. Detailed Implementation

[0098] To enable those skilled in the art to better understand the present invention, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0099] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, apparatus, product, or end that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or ends.

[0100] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0101] This invention discloses an image blurring method, apparatus, and storage medium based on progressive Gaussian filtering, which makes the pixel changes between the subject and background in the image smoother and the edges of the subject sharper during image blurring, thus making the image blurring more natural.

[0102] Example 1

[0103] Please see Figure 1 , Figure 1 This is a flowchart illustrating an image blurring method based on progressive Gaussian filtering disclosed in an embodiment of the present invention. Figure 1 The described image blurring method based on progressive Gaussian filtering can be applied to an image blurring device based on progressive Gaussian filtering. This device can be integrated into a cloud server or a local server; the embodiments of this invention are not limited thereto. Figure 1 As shown, this image blurring method based on progressive Gaussian filtering can include the following operations:

[0104] Step 101: For each pixel in the image to be blurred, determine the target probability of the pixel as a target object pixel based on the pre-trained image segmentation model; determine the target Gaussian filtering algorithm corresponding to the pixel based on the target probability of the pixel.

[0105] In this embodiment of the invention, image blurring is an image processing method that highlights the main subject in an image while blurring the parts other than the main subject. For example, a common portrait blurring operation requires the portrait to be displayed clearly, while the parts other than the portrait are blurred. In a blurred image, the main subject that needs to be highlighted in the image is the target object. For example, if the image to be blurred can be an image containing a human body, then the target object is the human body.

[0106] In this embodiment of the invention, image segmentation means separating target objects and non-target objects in an image. This embodiment uses a trained image segmentation model to achieve this separation. The image segmentation model analyzes the input image and outputs the probability that each pixel is a target object. For example, in an image containing a human body, after processing by the image segmentation model, pixels identified as human parts have a high probability, non-human pixels have a low probability, and pixels with a probability in between have a moderate probability. In this embodiment, the probability of a pixel being a target pixel is used to determine which Gaussian filtering algorithm should be applied to that pixel, thereby highlighting the subject while blurring the background.

[0107] In an optional embodiment, the image to be blurred is a human portrait, and the image segmentation model is a human portrait segmentation model. The human portrait segmentation model can be obtained by the following method:

[0108] S1. Collect training image data: Combine with the actual scene, collect data of the actual scene, mainly considering the collection of data such as the size and posture of the human figure under different indoor and outdoor lighting and scenes;

[0109] S2. Image annotation: Annotate the human and non-human parts of the image. Human segmentation data needs to be detailed down to each pixel, otherwise it will cause classification errors.

[0110] S3. Image preprocessing: Online image enhancement is performed on the selected high-quality public portrait dataset and the collected training data, including cropping, rotation, color gamut conversion, mean subtraction and variance division, etc.

[0111] S4. Human Image Segmentation Model Training: Forward propagation calculates the loss function, backpropagation calculates the parameter gradients, and the parameters are updated using the gradients. This process is repeated until the model converges or reaches the maximum number of iterations. Training is then stopped, and the trained model is output. After a fixed number of training iterations, the model's performance is tested using real-world scene data not found in the training set until the segmentation criteria are met, at which point the model is output.

[0112] As can be seen, this optional embodiment better combines the actual scene and the size and pose of the human face to enhance the segmentation performance of the model during the training stage, thereby obtaining a human face segmentation model with better performance.

[0113] Step 102: For each pixel in the image to be blurred, perform a Gaussian filtering operation on the pixel based on the target Gaussian filtering algorithm corresponding to that pixel to obtain the filtered pixel value corresponding to that pixel.

[0114] In this embodiment of the invention, different pixels correspond to different Gaussian filtering algorithms. Optionally, different Gaussian filtering algorithms can be set according to different probability ranges. Taking a portrait as an example: for the portrait part, a first Gaussian filtering algorithm is set; for the non-portrait part, a second Gaussian filtering algorithm is set; and for the portrait edge part, a third Gaussian filtering algorithm is set. This results in a progressive Gaussian filtering method that makes the transition between the portrait edge and the background area more natural, achieving the effect of portrait blurring without relying on dual cameras or other hardware costs.

[0115] Step 103: Determine the object blurring image corresponding to the image to be blurred based on the filtered pixel value corresponding to each pixel on the image to be blurred.

[0116] As can be seen, the image blurring method based on progressive Gaussian filtering in this embodiment of the invention can set different Gaussian filtering algorithms according to different probability ranges, thereby designing a progressive Gaussian filtering method that makes the pixel changes between the main object and the background in the image smoother, thus making the image blurring more natural.

[0117] It should be noted that the embodiments of the present invention can be applied to any image or video application that needs to highlight the subject, such as the portrait mode of a camera, beauty algorithm apps, etc.

[0118] In an optional embodiment, for each pixel in the image to be blurred, the probability of that pixel being a target pixel of the target object is determined based on a pre-trained image segmentation model, which may include:

[0119] Input the image to be blurred into a pre-trained image segmentation model to obtain the object segmentation probability map output by the image segmentation model;

[0120] For each pixel in the image to be blurred, the target probability of that pixel being a target object pixel is determined according to the object segmentation probability map;

[0121] Furthermore, for each pixel in the image to be blurred, the target Gaussian filtering algorithm corresponding to that pixel is determined based on the target probability, which may include:

[0122] For each pixel in the image to be blurred, the target algorithm parameters corresponding to the pixel are determined based on the target probability of the pixel, and the target Gaussian filtering algorithm corresponding to the pixel is determined based on the target algorithm parameters.

[0123] In this optional embodiment, the pixel value of each pixel in the object segmentation probability map is used to represent the probability that the pixel is the target object pixel; the target algorithm parameters may include at least the target filter kernel size kernel_size and the target Gaussian function standard deviation σ.

[0124] In this optional embodiment, the blurring of a human portrait is used as an example, as illustrated below:

[0125] Input a portrait image into a pre-trained image segmentation model to obtain an object segmentation probability map output by the image segmentation model. In the object segmentation probability map, the pixel value of each pixel is used to represent the probability that the pixel is a portrait pixel.

[0126] For each pixel in the portrait image, the probability of that pixel being a target of the portrait is determined based on the object segmentation probability map;

[0127] For each pixel in the portrait image, the kernel size and standard deviation σ of the target Gaussian function are determined based on the target probability corresponding to the pixel. The target Gaussian filtering algorithm corresponding to the pixel is then determined based on the kernel size and standard deviation σ.

[0128] As can be seen, this optional embodiment can input the image to be blurred into a pre-trained image segmentation model to obtain an object segmentation probability map output by the image segmentation model. The pixel value of each pixel in the object segmentation probability map is used to represent the probability that the pixel is a target object pixel. Thus, a single object segmentation probability map can store the probability that all pixels in the image to be blurred are target object pixels, which is beneficial for the computer system to process the image to be blurred quickly. Based on the object segmentation probability map, the target filtering kernel size kernel_size and the target Gaussian function standard deviation σ corresponding to the pixel can be quickly determined, thereby efficiently determining the corresponding Gaussian filtering algorithm.

[0129] In another optional embodiment, for each pixel in the image to be blurred, determining the target Gaussian filtering algorithm corresponding to that pixel based on the target probability of that pixel may include:

[0130] For each pixel in the image to be blurred, if the target probability corresponding to the pixel is less than a preset first probability threshold, then the pixel is determined to be a non-target object pixel, and the target algorithm parameter corresponding to the pixel is determined to be the first algorithm parameter; if the target probability corresponding to the pixel is greater than or equal to the first probability threshold and less than a preset second probability threshold, then the pixel is determined to be an object edge pixel, and the target algorithm parameter corresponding to the pixel is determined to be the second algorithm parameter.

[0131] In this optional embodiment, if each pixel corresponds to a different Gaussian filtering algorithm, the computational burden on tens of thousands of pixels in the entire image would be enormous. To address this issue, this optional embodiment groups pixels within certain probability ranges into one category, and then assigns each category of pixels the same Gaussian filtering algorithm. Thus, the tens of thousands of pixels in the entire image only need to be divided into two categories: pixels with a target probability less than a preset first probability threshold are non-target object pixels, and pixels with a target probability greater than or equal to the first probability threshold and less than a preset second probability threshold are object edge pixels. By setting corresponding Gaussian filtering algorithms for these two categories of pixels, the computational burden is greatly reduced, and the efficiency of image blurring is improved.

[0132] In this optional embodiment, the first probability threshold is less than the second probability threshold. The first probability value can be set to 0.9 and the second probability value can be set to 0.95. Taking a human portrait as an example, that is: pixels with a target probability of less than 0.9 are non-human portrait pixels, pixels with a target probability greater than or equal to 0.9 and less than 0.95 are human portrait edge pixels, and pixels with a target probability greater than or equal to 0.95 are human portrait pixels.

[0133] As can be seen, in this optional embodiment, the pixels in the image to be blurred are divided into two categories: pixels with a target probability less than a preset first probability threshold are non-target object pixels, and pixels with a target probability greater than or equal to the first probability threshold and less than a preset second probability threshold are object edge pixels. Corresponding Gaussian filtering algorithms are then applied to these two categories of pixels, significantly reducing computational load and improving the efficiency of image blurring.

[0134] In another optional embodiment, for each pixel in the image to be blurred, performing a Gaussian filtering operation on the pixel based on the target Gaussian filtering algorithm corresponding to that pixel to obtain the filtered pixel value corresponding to that pixel may include:

[0135] Gaussian filtering operations are performed on all pixels of the image to be blurred using various preset Gaussian filtering algorithms to obtain multiple pre-filtered pixel values ​​corresponding to each pixel of the image to be blurred; based on all the pre-filtered pixel values ​​corresponding to all pixels of the image to be blurred, the preprocessed image corresponding to each preset Gaussian filtering algorithm is obtained.

[0136] For each pixel in the image to be blurred, a target preset Gaussian filter algorithm that matches the target Gaussian filter algorithm corresponding to the pixel is determined according to the target Gaussian filter algorithm corresponding to the pixel. Based on the target preset Gaussian filter algorithm, the target preprocessed image corresponding to the pixel is determined from all preprocessed images. Based on the pixel value of the matching pixel in the target preprocessed image, the filter pixel value corresponding to the pixel is determined.

[0137] In this optional embodiment, if the corresponding Gaussian filtering algorithm is only executed after the target probability range of a pixel in the image to be blurred is determined, a calculation operation follows each determination, resulting in insufficient computational efficiency. To further improve computational efficiency, in this embodiment, all points in the image to be blurred are pre-filtered using different Gaussian filtering algorithms to obtain a pre-processed image. When the target probability range of a pixel in the image to be blurred is determined, it is only necessary to match the target pre-processed image and then determine the filtered pixel value corresponding to the pixel based on the pixel value of the matching pixel in the target pre-processed image.

[0138] Taking portrait blurring as an example, the optional implementation is illustrated below:

[0139] Four filter kernels are set up. The first three have a size of kernel_size, and their center point values ​​are normalized after being replaced with 0, 0.2, and 0.4 respectively. The last kernel has a size of kernel_size / 4, and its center point value is normalized after being replaced with 0.92. The original image is subjected to four Gaussian filters using these filter kernels. Then, according to the weight information, pixels with weights in [0, 0.1) are replaced with the corresponding pixels of the filter kernel 1 result; pixels with weights in [0.1, 0.5) are replaced with the corresponding pixels of the filter kernel 2 result; pixels with weights in [0.5, 0.9) are replaced with the corresponding pixels of the filter kernel 3 result; pixels with weights in [0.9, 0.95) are replaced with the corresponding pixels of the filter kernel 4 result; and pixels with weights in [0.95, 1) are replaced with the corresponding pixels in the original image. By setting different filter kernels to filter the image multiple times and then fusing them according to the portrait segmentation weight information, the algorithm efficiency is improved.

[0140] As can be seen, in this optional embodiment, the image to be blurred is preprocessed according to different Gaussian filtering algorithms to obtain several preprocessed images. After the target probability range of the pixel point on the image to be blurred is determined, it is only necessary to match the target preprocessed image and then determine the filter pixel value corresponding to the pixel point according to the pixel value of the matching pixel point in the target preprocessed image, thereby further improving the calculation efficiency of image blurring.

[0141] Example 2

[0142] Please see Figure 2 , Figure 2 This is a flowchart illustrating another image blurring method based on progressive Gaussian filtering disclosed in an embodiment of the present invention. This image blurring method based on progressive Gaussian filtering may include the following operations:

[0143] Step 201: Input the image to be blurred into the pre-trained image segmentation model to obtain the object segmentation probability map output by the image segmentation model; for each pixel in the image to be blurred, determine the target probability of the pixel being the target object pixel according to the object segmentation probability map.

[0144] Step 202: For each pixel in the image to be blurred, determine the standard deviation σ of the target Gaussian function corresponding to the pixel based on the target probability corresponding to the pixel, determine the kernel size of the target filter kernel corresponding to the pixel based on the standard deviation σ of the target Gaussian function corresponding to the pixel, and determine the target Gaussian filter algorithm corresponding to the pixel based on the target algorithm parameters.

[0145] In this embodiment of the invention, the target algorithm parameters may include at least the target filter kernel size (kernel_size) and the target Gaussian function standard deviation (σ). Optionally, the target filter kernel size (kernel_size) corresponding to the pixel can be determined based on the target Gaussian function standard deviation (σ) corresponding to the pixel, which can be achieved by the following formula:

[0146]

[0147] kernel_size = 2 * radius + 1

[0148] In the above formula, For the rounding operation, radius is an intermediate parameter. Using the above formula, a Gaussian filtering algorithm that is more suitable for image blurring can be constructed.

[0149] Step 203: For each pixel in the image to be blurred, perform a Gaussian filtering operation on the pixel based on the target Gaussian filtering algorithm corresponding to that pixel to obtain the filtered pixel value corresponding to that pixel.

[0150] Step 204: Determine the object blurring image corresponding to the image to be blurred based on the filtered pixel value corresponding to each pixel on the image to be blurred.

[0151] For a detailed description of steps 203 and 204, please refer to the descriptions in steps 102 and 103. These will not be repeated in this embodiment of the invention.

[0152] As can be seen, the image blurring method based on progressive Gaussian filtering in this embodiment of the invention can input the image to be blurred into a pre-trained image segmentation model to obtain an object segmentation probability map output by the image segmentation model. The pixel value of each pixel in the object segmentation probability map represents the probability that the pixel is a target object pixel. Thus, a single object segmentation probability map can store the probability that all pixels in the image to be blurred are target object pixels, which is beneficial for the computer system to process the image to be blurred quickly. Based on the target probability corresponding to the pixel, the standard deviation σ of the target Gaussian function corresponding to the pixel is determined. Based on the standard deviation σ of the target Gaussian function corresponding to the pixel, the kernel size of the target filtering kernel corresponding to the pixel is determined, which can construct a Gaussian filtering algorithm more suitable for image blurring. In summary, this embodiment of the invention can further improve the efficiency of the image blurring method.

[0153] In an optional embodiment, for each pixel in the image to be blurred, performing a Gaussian filtering operation on the pixel based on the target Gaussian filtering algorithm corresponding to that pixel to obtain the filtered pixel value can include:

[0154] For each pixel in the image to be blurred, determine that pixel as the target pixel. With the target pixel as the origin and the target filter kernel size kernel_siz as the side length, construct the target filter kernel of size kernel_size*kernel_size corresponding to the target pixel. Determine the filter kernel weight matrix corresponding to the target filter kernel based on the standard deviation σ of the target Gaussian function corresponding to the target pixel.

[0155] For each target pixel in the image to be blurred, all pixels in the image to be blurred that are located in the target filter kernel corresponding to that target pixel are convolved with the filter kernel weight matrix to obtain the filter pixel value corresponding to that target pixel.

[0156] Specifically, for each target pixel in the image to be blurred, the filter kernel weight matrix corresponding to the target filter kernel is determined based on the standard deviation σ of the target Gaussian function corresponding to that target pixel. This is achieved through the following formula:

[0157]

[0158] In this optional embodiment, x is the abscissa of any pixel within the target filtering kernel, where the value of x ranges from [-radius, radius]; y is the ordinate of any pixel within the target filtering kernel, where the value of y also ranges from [-radius, radius]; the coordinates of the target pixel are (0,0); f(x,y) is the weight parameter of the pixel at (x,y). In the above formula, σ 2 It is variance, which represents the average fluctuation of the sample. σ determines the steepness of the curve. A curve with σ=1 is relatively smooth, so the fuzziness will also be relatively smooth.

[0159] Taking portrait blurring as an example, the image blurring method based on progressive Gaussian filtering in this optional embodiment is illustrated as follows:

[0160] For an RGB image, progressive Gaussian filtering divides each pixel into three regions: background non-human image region, human image edge region, and human image interior region, channel by channel. It also presets the segmentation thresholds for different regions, processes the filtering kernels corresponding to the pixels in different regions with different schemes, and then convolves them with the original image region of the corresponding size to obtain the filtering result for that pixel.

[0161] For non-human areas in the background, such as Figure 3 As shown, the probability value of the current pixel is less than 0.9. For this optional embodiment, it is desirable that the edges of the subject and background are very clear and sharp. Based on experimental verification, the background segmentation threshold is set to 0.9. For the pixel value that meets the above requirements, the corresponding filter kernel is set according to Scheme 1: the point is used as the center point of the filter kernel with size [kernel_size, kernel_size], and then the modified filter kernel is renormalized; the corresponding input image region is selected with the current pixel as the center and kernel_size as the width. The pixels in the edge region are padded with 0 for the area exceeding the image size, that is, the original image is padded with kernel_size / 2 on the top, bottom, left and right sides. Then, the filter kernel and the selected input image region are convolved: the corresponding pixels are multiplied and then added together to obtain the filtering result of the current pixel.

[0162] For the edge areas of the portrait, such as Figure 4As shown, segment_weights has a probability value between [0.9, 0.95] for the current pixel. Since the probability value of human image segmentation increases rapidly in the edge region, after filtering the non-human image region of the background, it is also necessary to ensure that the blurring degree of the edge connection region is smooth and gradual. Therefore, this point is used as the center point of the filter kernel with a size of [kernel_size / 4, kernel_size / 4], and then the modified filter kernel is renormalized. The corresponding input image region is selected with the current pixel as the center and kernel_size / 4 as the width. The pixels in the edge region are padded with 0 for the area exceeding the image size, that is, the original image is padded with kernel_size / 8 on the top, bottom, left and right sides. Then, the filter kernel and the selected input image region are convolved: the corresponding pixels are multiplied and then added together to get the filtering result of the current pixel.

[0163] For the region inside the human image, i.e., the current pixel probability value is greater than 0.95, in this optional embodiment, the goal of portrait blurring is to maintain the sharpness of the human image while blurring the rest of the background, thus highlighting the main subject. The region inside the human image is the pixel area strongly identified as human by the portrait segmentation network. Therefore, after filtering the non-human image areas of the background and performing transition filtering on the edge areas of the human image, the pixels in this region use the original image pixels as the output for that pixel. This completes the progressive Gaussian filtering portrait blurring algorithm for the entire image.

[0164] As can be seen, in this optional embodiment, each pixel that needs to be filtered is reassigned using a "weighted average of neighboring pixels", thereby filtering the pixel based on the distribution of the pixels around it, and thus blurring the background of the entire image.

[0165] In another optional embodiment, inputting the image to be blurred into a pre-trained image segmentation model to obtain an object segmentation probability map output by the image segmentation model may include:

[0166] Obtain the image to be blurred with a resolution of ih*iw, preprocess the image to be blurred, and obtain the preprocessed image;

[0167] Scale the preprocessed image to an intermediate image with a resolution of nh*nw;

[0168] Input the intermediate image into the pre-trained image segmentation model to obtain the initial probability map with a resolution of nh*nw output by the image segmentation model;

[0169] After bilinear interpolation upsampling of the initial probability map, an object segmentation probability map with resolution ih*iw is obtained;

[0170] The process of preprocessing the image to be blurred to obtain a preprocessed image may specifically include:

[0171] Calculate the pixel mean and pixel variance of all pixels in the image to be blurred;

[0172] For each pixel in the image to be blurred, subtract the pixel mean from the pixel value and then divide by the pixel variance to obtain the standardized pixel value of the pixel.

[0173] Perform a normalization operation on the standardized pixel values ​​of all pixels in the image to be blurred to obtain the preprocessed pixel value of each pixel in the image to be blurred.

[0174] A preprocessed image is obtained based on the preprocessed pixel values ​​of all pixels in the image to be blurred.

[0175] In this optional embodiment, after the image segmentation model is trained, it is used to analyze images of a specific size. However, the actual image size is often very large, so it needs to be scaled up to a size suitable for the image segmentation model. After the image segmentation model has finished its analysis, the scaled image is upsampled and "enlarged" back.

[0176] Taking portrait blurring as an example, the optional implementation is illustrated below:

[0177] The original resolution image (ih*iw) is input. The image is then normalized by subtracting the mean and dividing by the variance according to the training strategy. The image is then scaled to the input size (nh*nw) of the human image segmentation network. The human image segmentation algorithm is then used to obtain a segmentation probability map, which has a resolution of (nh*nw). The probability value of each pixel between 0 and 1 represents the probability that the pixel is identified as a human. The probability map is then upsampled to the resolution (ih*iww) using bilinear interpolation.

[0178] As can be seen, this optional embodiment can adjust the image to be blurred to a size suitable for use by the image segmentation model through image scaling, upsampling, and preprocessing techniques, thereby facilitating the efficient use of the image segmentation model and improving the efficiency of the image blurring method.

[0179] Example 3

[0180] Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of an image blurring device based on progressive Gaussian filtering disclosed in an embodiment of the present invention. Figure 5 As shown, the image blurring device based on progressive Gaussian filtering may include:

[0181] The image segmentation module 301 is used to determine the target probability of each pixel in the image to be blurred as a target object pixel based on a pre-trained image segmentation model; and to determine the target Gaussian filtering algorithm corresponding to the pixel based on the target probability corresponding to the pixel.

[0182] The Gaussian filtering module 302 is used to perform a Gaussian filtering operation on each pixel in the image to be blurred, based on the target Gaussian filtering algorithm corresponding to that pixel, to obtain the filtered pixel value corresponding to that pixel.

[0183] The image blurring module 303 is used to determine the object blurring image corresponding to the image to be blurred based on the filtered pixel value corresponding to each pixel point on the image to be blurred.

[0184] As can be seen, the image blurring device based on progressive Gaussian filtering in this embodiment of the invention can set different Gaussian filtering algorithms according to different probability ranges, thereby designing a progressive Gaussian filtering method, making the pixel changes between the main object and the background in the image smoother, and thus making the image blurring more natural.

[0185] In an optional embodiment, the image segmentation module 301 determines the target probability of each pixel in the image to be blurred as a target object pixel based on a pre-trained image segmentation model, which may include:

[0186] Input the image to be blurred into a pre-trained image segmentation model to obtain the object segmentation probability map output by the image segmentation model;

[0187] For each pixel in the image to be blurred, the target probability of that pixel being a target object pixel is determined according to the object segmentation probability map;

[0188] In the object segmentation probability map, the pixel value of each pixel is used to represent the probability that the pixel is a pixel of the target object.

[0189] Furthermore, for each pixel in the image to be blurred, the target Gaussian filtering algorithm corresponding to that pixel is determined based on the target probability, which may include:

[0190] For each pixel in the image to be blurred, the target algorithm parameters corresponding to the pixel are determined according to the target probability corresponding to the pixel, and the target Gaussian filtering algorithm corresponding to the pixel is determined according to the target algorithm parameters.

[0191] The target algorithm parameters may include at least the target filter kernel size (kernel_size) and the target Gaussian function standard deviation (σ).

[0192] As can be seen, this optional embodiment can input the image to be blurred into a pre-trained image segmentation model to obtain an object segmentation probability map output by the image segmentation model. The pixel value of each pixel in the object segmentation probability map is used to represent the probability that the pixel is a target object pixel. Thus, a single object segmentation probability map can store the probability that all pixels in the image to be blurred are target object pixels, which is beneficial for the computer system to process the image to be blurred quickly. Based on the object segmentation probability map, the target filtering kernel size kernel_size and the target Gaussian function standard deviation σ corresponding to the pixel can be quickly determined, thereby efficiently determining the corresponding Gaussian filtering algorithm.

[0193] In another optional embodiment, for each pixel in the image to be blurred, the image segmentation module 301 determines the specific method of the target Gaussian filtering algorithm corresponding to that pixel based on the target probability of that pixel, which may include:

[0194] For each pixel in the image to be blurred, if the target probability corresponding to the pixel is less than a preset first probability threshold, then the pixel is determined to be a non-target object pixel, and the target algorithm parameter corresponding to the pixel is determined to be the first algorithm parameter; if the target probability corresponding to the pixel is greater than or equal to the first probability threshold and less than a preset second probability threshold, then the pixel is determined to be an object edge pixel, and the target algorithm parameter corresponding to the pixel is determined to be the second algorithm parameter.

[0195] The first probability threshold is less than the second probability threshold.

[0196] As can be seen, in this optional embodiment, the pixels in the image to be blurred are divided into two categories: pixels with a target probability less than a preset first probability threshold are non-target object pixels, and pixels with a target probability greater than or equal to the first probability threshold and less than a preset second probability threshold are object edge pixels. Corresponding Gaussian filtering algorithms are then applied to these two categories of pixels, significantly reducing computational load and improving the efficiency of image blurring.

[0197] In another optional embodiment, the Gaussian filtering module 302 performs a Gaussian filtering operation on each pixel in the image to be blurred, based on the target Gaussian filtering algorithm corresponding to that pixel, to obtain the filtered pixel value corresponding to that pixel. The specific method may include:

[0198] Gaussian filtering operations are performed on all pixels of the image to be blurred using various preset Gaussian filtering algorithms to obtain multiple pre-filtered pixel values ​​corresponding to each pixel of the image to be blurred; based on all the pre-filtered pixel values ​​corresponding to all pixels of the image to be blurred, the preprocessed image corresponding to each preset Gaussian filtering algorithm is obtained.

[0199] For each pixel in the image to be blurred, a target preset Gaussian filter algorithm that matches the target Gaussian filter algorithm corresponding to the pixel is determined according to the target Gaussian filter algorithm corresponding to the pixel. Based on the target preset Gaussian filter algorithm, the target preprocessed image corresponding to the pixel is determined from all preprocessed images. Based on the pixel value of the matching pixel in the target preprocessed image, the filter pixel value corresponding to the pixel is determined.

[0200] As can be seen, in this optional embodiment, the image to be blurred is preprocessed according to different Gaussian filtering algorithms to obtain several preprocessed images. After the target probability range of the pixel point on the image to be blurred is determined, it is only necessary to match the target preprocessed image and then determine the filter pixel value corresponding to the pixel point according to the pixel value of the matching pixel point in the target preprocessed image, thereby further improving the calculation efficiency of image blurring.

[0201] In another optional embodiment, the image segmentation module 301 determines the specific method of the target algorithm parameters corresponding to each pixel in the image to be blurred, based on the target probability corresponding to that pixel, which may include:

[0202] For each pixel in the image to be blurred, the standard deviation σ of the target Gaussian function corresponding to the pixel is determined according to the target probability corresponding to the pixel, and the target filter kernel size kernel_size corresponding to the pixel is determined according to the standard deviation σ of the target Gaussian function corresponding to the pixel.

[0203] Specifically, the target filter kernel size (kernel_size) for a given pixel is determined based on the standard deviation σ of the target Gaussian function, and is implemented using the following formula:

[0204]

[0205] kernel_size = 2 * radius + 1

[0206] In the above formula, For the floor function, radius is an intermediate parameter.

[0207] As can be seen, the image blurring device based on progressive Gaussian filtering in this embodiment of the invention can determine the target filter kernel size (kernel_size) corresponding to a pixel based on the standard deviation σ of the target Gaussian function corresponding to that pixel, and can construct a Gaussian filtering algorithm that is more suitable for image blurring. In summary, this embodiment of the invention can further improve the efficiency of image blurring methods.

[0208] In another optional embodiment, the Gaussian filtering module 302 performs a Gaussian filtering operation on each pixel in the image to be blurred, based on the target Gaussian filtering algorithm corresponding to that pixel, to obtain the filtered pixel value corresponding to that pixel. The specific method may include:

[0209] For each pixel in the image to be blurred, determine that pixel as the target pixel. With the target pixel as the origin and the target filter kernel size kernel_siz as the side length, construct the target filter kernel of size kernel_size*kernel_size corresponding to the target pixel. Determine the filter kernel weight matrix corresponding to the target filter kernel based on the standard deviation σ of the target Gaussian function corresponding to the target pixel.

[0210] For each target pixel in the image to be blurred, all pixels in the image to be blurred that are located in the target filter kernel corresponding to that target pixel are convolved with the filter kernel weight matrix to obtain the filter pixel value corresponding to that target pixel.

[0211] Specifically, for each target pixel in the image to be blurred, the filter kernel weight matrix corresponding to the target filter kernel is determined based on the standard deviation σ of the target Gaussian function corresponding to that target pixel. This is achieved through the following formula:

[0212]

[0213] In the above formula, x is the horizontal coordinate of any pixel within the target filtering kernel, where the value of x ranges from [-radius, radius]; y is the vertical coordinate of any pixel within the target filtering kernel, where the value of y also ranges from [-radius, radius]; the coordinate of the target pixel is (0,0); f(x,y) is the weight parameter of the pixel at (x,y).

[0214] As can be seen, in this optional embodiment, each pixel that needs to be filtered is reassigned using a "weighted average of neighboring pixels", thereby filtering the pixel based on the distribution of the pixels around it, and thus blurring the background of the entire image.

[0215] In another optional embodiment, the specific method by which the image segmentation module 301 inputs the image to be blurred into a pre-trained image segmentation model to obtain the object segmentation probability map output by the image segmentation model may include:

[0216] Obtain the image to be blurred with a resolution of ih*iw, preprocess the image to be blurred, and obtain the preprocessed image;

[0217] Scale the preprocessed image to an intermediate image with a resolution of nh*nw;

[0218] Input the intermediate image into the pre-trained image segmentation model to obtain the initial probability map with a resolution of nh*nw output by the image segmentation model;

[0219] After bilinear interpolation upsampling of the initial probability map, an object segmentation probability map with resolution ih*iw is obtained;

[0220] The image segmentation module 301 preprocesses the image to be blurred to obtain a preprocessed image, which may specifically include:

[0221] Calculate the pixel mean and pixel variance of all pixels in the image to be blurred;

[0222] For each pixel in the image to be blurred, subtract the pixel mean from the pixel value and then divide by the pixel variance to obtain the standardized pixel value of the pixel.

[0223] Perform a normalization operation on the standardized pixel values ​​of all pixels in the image to be blurred to obtain the preprocessed pixel value of each pixel in the image to be blurred.

[0224] A preprocessed image is obtained based on the preprocessed pixel values ​​of all pixels in the image to be blurred.

[0225] As can be seen, this optional embodiment can adjust the image to be blurred to a size suitable for use by the image segmentation model through image scaling, upsampling, and preprocessing techniques, thereby facilitating the efficient use of the image segmentation model and improving the efficiency of the image blurring method.

[0226] Example 4

[0227] Please see Figure 6 , Figure 6 This is a schematic diagram of another image blurring device based on progressive Gaussian filtering disclosed in an embodiment of the present invention. Figure 6 As shown, the image blurring device based on progressive Gaussian filtering may include:

[0228] Memory 401 storing executable program code;

[0229] Processor 402 coupled to memory 401;

[0230] The processor 402 calls the executable program code stored in the memory 401 to execute the steps in the image blurring method based on progressive Gaussian filtering described in Embodiment 1 or Embodiment 2 of the present invention.

[0231] Example 5

[0232] This invention discloses a computer storage medium storing computer instructions. When these computer instructions are invoked, they are used to execute the steps in the image blurring method based on progressive Gaussian filtering described in Embodiment 1 or Embodiment 2 of this invention.

[0233] Example 6

[0234] This invention discloses a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to perform the steps in the image blurring method based on progressive Gaussian filtering described in Embodiment 1 or Embodiment 2.

[0235] The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0236] Through the detailed description of the above embodiments, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, including read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-Erasable Programmable Read-Only Memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.

[0237] Finally, it should be noted that the image blurring method, apparatus, and storage medium based on progressive Gaussian filtering disclosed in the embodiments of the present invention are merely preferred embodiments of the present invention and are only used to illustrate the technical solutions of the present invention, not to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. An image blurring method based on progressive Gaussian filtering, characterized in that, The method includes: The image to be blurred is input into a pre-trained image segmentation model to obtain the object segmentation probability map output by the image segmentation model; For each pixel in the image to be blurred, the target probability of that pixel being a target object pixel is determined according to the object segmentation probability map. In the object segmentation probability map, the pixel value of each pixel is used to represent the probability that the pixel is a target object pixel; For each pixel in the image to be blurred, the standard deviation σ of the target Gaussian function corresponding to the pixel is determined according to the target probability corresponding to the pixel. The kernel size of the target filter kernel corresponding to the pixel is determined according to the standard deviation σ of the target Gaussian function corresponding to the pixel. The target Gaussian filter algorithm corresponding to the pixel is determined according to the target algorithm parameters. The target algorithm parameters include at least the target filter kernel size and the target Gaussian function standard deviation σ; For each pixel in the image to be blurred, a Gaussian filtering operation is performed on the pixel based on the target Gaussian filtering algorithm corresponding to the pixel to obtain the filtered pixel value corresponding to the pixel. Based on the filtered pixel value corresponding to each pixel point on the image to be blurred, determine the object blurred image corresponding to the image to be blurred; Specifically, determining the target filter kernel size (kernel_size) based on the standard deviation σ of the target Gaussian function corresponding to the pixel is achieved through the following formula: In the above formula, For floor operations, These are intermediate parameters.

2. The image blurring method based on progressive Gaussian filtering according to claim 1, characterized in that, For each pixel in the image to be blurred, the method for determining the target Gaussian filtering algorithm corresponding to that pixel based on the target probability includes: For each pixel in the image to be blurred, if the target probability corresponding to the pixel is less than a preset first probability threshold, then the pixel is determined to be a non-target object pixel, and the target algorithm parameter corresponding to the pixel is determined to be a first algorithm parameter; if the target probability corresponding to the pixel is greater than or equal to the first probability threshold and less than a preset second probability threshold, then the pixel is determined to be an object edge pixel, and the target algorithm parameter corresponding to the pixel is determined to be a second algorithm parameter. Wherein, the first probability threshold is less than the second probability threshold.

3. The image blurring method based on progressive Gaussian filtering according to claim 1, characterized in that, For each pixel in the image to be blurred, performing a Gaussian filtering operation on that pixel based on the target Gaussian filtering algorithm to obtain the filtered pixel value includes: A variety of preset Gaussian filtering algorithms are used to perform Gaussian filtering operations on all pixels of the image to be blurred, thereby obtaining multiple pre-filtered pixel values ​​corresponding to each pixel of the image to be blurred; based on all the pre-filtered pixel values ​​corresponding to all pixels of the image to be blurred, a preprocessed image corresponding to each preset Gaussian filtering algorithm is obtained; For each pixel in the image to be blurred, a target preset Gaussian filter algorithm matching the target Gaussian filter algorithm corresponding to the pixel is determined according to the target Gaussian filter algorithm corresponding to the pixel. The target preprocessed image corresponding to the pixel is determined from all the preprocessed images according to the target preset Gaussian filter algorithm. The filter pixel value corresponding to the pixel is determined according to the pixel value of the matching pixel in the target preprocessed image.

4. The image blurring method based on progressive Gaussian filtering according to claim 1, characterized in that, For each pixel in the image to be blurred, performing a Gaussian filtering operation on that pixel based on the target Gaussian filtering algorithm to obtain the filtered pixel value includes: For each pixel in the image to be blurred, this pixel is determined as a target pixel. Using this target pixel as the origin and the target filter kernel size (kernel_siz) corresponding to this target pixel as the side length, a kernel of size [missing information] is constructed for this target pixel. The target filter kernel; the filter kernel weight matrix corresponding to the target filter kernel is determined based on the standard deviation σ of the target Gaussian function corresponding to the target pixel. For each target pixel in the image to be blurred, all pixels in the image to be blurred that are located within the target filter kernel corresponding to that target pixel are convolved with the filter kernel weight matrix to obtain the filter pixel value corresponding to that target pixel. Specifically, for each target pixel in the image to be blurred, the filter kernel weight matrix corresponding to the target filter kernel is determined based on the standard deviation σ of the target Gaussian function corresponding to that target pixel. This is achieved through the following formula: In the above formula, x is the horizontal coordinate of any pixel within the target filtering kernel, where the value of x ranges from [-radius, radius]; y is the vertical coordinate of any pixel within the target filtering kernel, where the value of y also ranges from [-radius, radius]; the coordinates of the target pixel are (0,0); and f(x,y) is the weight parameter of the pixel at (x,y).

5. The image blurring method based on progressive Gaussian filtering according to claim 1, characterized in that, The process of inputting the image to be blurred into a pre-trained image segmentation model to obtain an object segmentation probability map output by the image segmentation model includes: Obtain an image to be blurred with a resolution of ih*iw, and preprocess the image to be blurred to obtain a preprocessed image; The preprocessed image is scaled up to an intermediate image with a resolution of nh*nw; The intermediate image is input into a pre-trained image segmentation model to obtain an initial probability map with a resolution of nh*nw output by the image segmentation model; After performing bilinear interpolation upsampling on the initial probability map, an object segmentation probability map with a resolution of ih*iw is obtained; Specifically, the preprocessing of the image to be blurred to obtain a preprocessed image includes: Calculate the pixel mean and pixel variance of all pixels in the image to be blurred; For each pixel in the image to be blurred, the pixel value is subtracted from the pixel mean and then divided by the pixel variance to obtain the standardized pixel value of the pixel. A normalization operation is performed on the standardized pixel values ​​of all pixels in the image to be blurred to obtain the preprocessed pixel value of each pixel in the image to be blurred. A preprocessed image is obtained based on the preprocessed pixel values ​​of all the pixels in the image to be blurred.

6. An image blurring device based on progressive Gaussian filtering, characterized in that, The device includes: An image segmentation module is used to input the image to be blurred into a pre-trained image segmentation model to obtain an object segmentation probability map output by the image segmentation model. For each pixel in the image to be blurred, the target probability of the pixel being a target object pixel is determined according to the object segmentation probability map. The pixel value of each pixel in the object segmentation probability map represents the probability that the pixel is a target object pixel. For each pixel in the image to be blurred, the target Gaussian function standard deviation σ corresponding to the pixel is determined according to the target probability. Based on the target Gaussian function standard deviation σ, the target filter kernel size kernel_size corresponding to the pixel is determined. Finally, the target Gaussian filtering algorithm corresponding to the pixel is determined according to the target algorithm parameters. The target algorithm parameters include at least the target filter kernel size kernel_size and the target Gaussian function standard deviation σ. The Gaussian filtering module is used to perform a Gaussian filtering operation on each pixel in the image to be blurred, based on the target Gaussian filtering algorithm corresponding to the pixel, to obtain the filtered pixel value corresponding to the pixel. An image blurring module is used to determine the object blurring image corresponding to the image to be blurred based on the filtered pixel value corresponding to each pixel point on the image to be blurred; Specifically, determining the target filter kernel size (kernel_size) based on the standard deviation σ of the target Gaussian function corresponding to the pixel is achieved through the following formula: In the above formula, For floor operations, These are intermediate parameters.

7. An image blurring device based on progressive Gaussian filtering, characterized in that, The apparatus includes: a memory storing executable program code; a processor coupled to the memory; the processor calling the executable program code stored in the memory to execute the image blurring method based on progressive Gaussian filtering as described in any one of claims 1-5.

8. A computer storage medium, characterized in that, The computer storage medium stores computer instructions, which, when invoked, are used to execute the image blurring method based on progressive Gaussian filtering as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Foreground recognition method and device, electronic equipment and storage medium

    CN109784164A

  • Image blurring method, terminal, storage medium and processor

    CN111127328A