Image processing method and device

By using a pure quadratic polynomial fuzzy kernel calculation formula, the problem of high computational cost in Gaussian blur algorithm is solved, achieving efficient image blurring processing, reducing computational complexity and maintaining the smoothness of the blurring effect.

CN121169744APending Publication Date: 2025-12-19BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410796624.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2025-12-19

AI Technical Summary

Technical Problem

Existing Gaussian blur algorithms involve a large amount of computation in image processing, especially the calculation of the blur kernel for each pixel, which involves exponential and division calculations, resulting in low efficiency.

Method used

The blur kernel calculation formula adopts a pure quadratic polynomial. The blur kernel is determined by obtaining the blur radius. The weight coefficient of the pixel point whose offset distance is less than the blur radius is calculated, which reduces the repeated calculation for each pixel point. Only one blur kernel is needed to apply to all pixels.

Benefits of technology

It reduces the computational load of image blurring processing, improves processing efficiency, and maintains the smoothness of the blurring effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121169744A_ABST
    Figure CN121169744A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an image processing method and device, and relates to the technical field of image processing. Comprises: obtaining a fuzzy radius; determining a blurring kernel according to the blurring radius; wherein the blurring kernel is obtained by calculating a weight coefficient corresponding to the pixel point of which the offset distance is smaller than the blurring radius according to a blurring kernel calculation formula, and the blurring kernel calculation formula is obtained by substituting the blurring radius and the weight coefficient corresponding to the pixel point of which the offset distance is the blurring radius into a preset calculation formula; based on the blurring kernel, calculating a blurring pixel value corresponding to each pixel point of the initial image; and assigning each pixel point of the initial image as a corresponding fuzzy pixel value to obtain a fuzzy image corresponding to the initial image. The embodiment of the invention is used for reducing the calculation amount in the process of performing fuzzy processing on the image while ensuring the smoothness of the fuzzy effect.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image processing, and in particular to an image processing method and device. BACKGROUND

[0002] Fuzzy processing of an image refers to performing specific processing on color values of pixels in the image, so that details and edges in the image become blurred, thereby achieving effects such as privacy protection, artistic creation, and noise reduction.

[0003] Gaussian blur, also known as Gaussian smoothing, is a classic image blurring algorithm. The basic principle is that a weight coefficient of each pixel point in a blurring range centered on a target pixel point is calculated by using a Gaussian function, and then color values of the pixel points in the blurring range are weighted and averaged according to the weight coefficients, so as to obtain a blurred color value of the target pixel point. Since the weight coefficients of the pixel points in the blurring range are calculated by using the Gaussian function when the Gaussian blur is used to process an image, the spatial distribution of the pixels in the image can be considered, so that the blurring effect is smoother. However, when the Gaussian blur is used to process an image, a blurring kernel needs to be calculated for each pixel point in the image, and the calculation process involves exponential calculation and division calculation, which leads to a problem of large amount of calculation when the Gaussian blur is used to blur an image. SUMMARY

[0004] In view of this, the embodiments of the present application provide an image processing method and device for reducing the amount of calculation in the process of blurring an image.

[0005] To achieve the above object, the embodiments of the present application provide the technical solutions as follows.

[0006] In a first aspect, the embodiments of the present application provide an image processing method, comprising:

[0007] obtaining a blurring radius;

[0008] determining a blurring kernel according to the blurring radius, wherein the blurring kernel is obtained according to a weight coefficient corresponding to a pixel point with an offset distance less than the blurring radius, and the blurring kernel is calculated according to a blurring kernel calculation formula in which the blurring radius and the weight coefficient corresponding to the pixel point with the offset distance equal to the blurring radius are substituted into a pre-designed calculation formula;

[0009] calculating a blurred pixel value corresponding to each pixel point of an initial image based on the blurring kernel;

[0010] assigning each pixel point of the initial image to the corresponding blurred pixel value respectively, to obtain a blurred image corresponding to the initial image.

[0011] As an optional implementation of the embodiment of the present application, the pre-designed formula is a pure quadratic polynomial with the offset distance of a pixel point as the independent variable and the weight coefficient of the pixel point as the dependent variable, and a constant term of the pure quadratic polynomial is a preset value.

[0012] As an optional implementation of the embodiment of the present application,

[0013] The determining the blur kernel according to the blur radius comprises:

[0014] Substituting the weight coefficient corresponding to the pixel point with the offset distance of the blur radius and the blur radius into the pure quadratic polynomial to obtain a target equation;

[0015] Solving a quadratic term coefficient of the pure quadratic polynomial according to the target equation to obtain the blur kernel calculation formula.

[0016] As an optional implementation of the embodiment of the present application, the blur kernel calculation formula is:

[0017]

[0018] wherein, w R is the weight coefficient corresponding to the pixel point with the offset distance of the blur radius, w0 is the preset value, R is the blur radius, x is the offset distance, and f(x) is the weight coefficient corresponding to the pixel point with the offset distance of x.

[0019] As an optional implementation of the embodiment of the present application, the obtaining the blur radius comprises:

[0020] Displaying a blur radius setting interface;

[0021] Obtaining the blur radius according to the input of a user in the blur radius setting interface.

[0022] As an optional implementation of the embodiment of the present application, the calculating the blur pixel value corresponding to each pixel point of the initial image based on the blur kernel comprises:

[0023] For each pixel point in the initial image, performing weighted summation on color values of each pixel point in a first blur range according to the blur kernel to obtain a blur color value corresponding to the pixel point;

[0024] wherein, the first blur range comprises each pixel point with an offset distance less than or equal to the blur radius.

[0025] As an optional implementation of the embodiment of the present application,

[0026] The calculating the blur pixel value corresponding to each pixel point of the initial image based on the blur kernel comprises:

[0027] For each pixel point in the initial image, the color values of each pixel point in a second blur range are weighted and summed according to the blur kernel, to obtain a first blur color value corresponding to the pixel point; the second blur range includes each pixel point with a horizontal offset distance less than or equal to the blur radius.

[0028] For each pixel point in the initial image, the first blur color values of each pixel point in a third blur range are weighted and summed according to the blur kernel, to obtain a second blur color value corresponding to the pixel point; the third blur range includes each pixel point with a vertical offset distance less than or equal to the blur radius.

[0029] The second blur color value corresponding to each pixel point of the initial image is determined as the corresponding blur pixel value.

[0030] As an optional implementation of the embodiment of the present application,

[0031] The blur kernel is used to calculate the blur pixel value corresponding to each pixel point of the initial image, including:

[0032] For each pixel point in the initial image, the color values of each pixel point in a third blur range are weighted and summed according to the blur kernel, to obtain a third blur color value corresponding to the pixel point; the third blur range includes each pixel point with a vertical offset distance less than or equal to the blur radius.

[0033] For each pixel point in the initial image, the third blur color values of each pixel point in a second blur range are weighted and summed according to the blur kernel, to obtain a fourth blur color value corresponding to the pixel point; the second blur range includes each pixel point with a horizontal offset distance less than or equal to the blur radius.

[0034] The fourth blur color value corresponding to each pixel point of the initial image is determined as the corresponding blur pixel value.

[0035] As an optional implementation of the embodiment of the present application, the method further includes:

[0036] After the blur kernel is determined according to the blur radius, the weight coefficients of each pixel point in the blur kernel are normalized.

[0037] In a second aspect, the embodiment of the present application provides an image processing device, including:

[0038] An acquisition unit is configured to acquire a blur radius.

[0039] a processing unit, configured to determine a blur kernel according to the blur radius; wherein the blur kernel is obtained according to a blur kernel calculation formula, the blur kernel calculation formula is obtained by substituting the blur radius and a weight coefficient corresponding to a pixel point with an offset distance equal to the blur radius into a pre-designed calculation formula;

[0040] a blurring unit, configured to calculate a blur pixel value corresponding to each pixel point of the initial image based on the blur kernel respectively, and assign each pixel point of the initial image with the corresponding blur pixel value respectively to obtain a blur image corresponding to the initial image.

[0041] As an optional implementation of the embodiment of the present application, the pre-designed calculation formula is a pure quadratic polynomial with the offset distance of a pixel point as the independent variable and the weight coefficient of the pixel point as the dependent variable, and a constant term of the pure quadratic polynomial is a preset value.

[0042] As an optional implementation of the embodiment of the present application, the processing unit is specifically configured to substitute the weight coefficient corresponding to the pixel point with the offset distance equal to the blur radius and the blur radius into the pure quadratic polynomial to obtain a target equation; and solve a quadratic term coefficient of the pure quadratic polynomial according to the target equation to obtain the blur kernel calculation formula.

[0043] As an optional implementation of the embodiment of the present application, the blur kernel calculation formula is:

[0044]

[0045] wherein w R is the weight coefficient corresponding to the pixel point with the offset distance equal to the blur radius, w0 is the preset value, R is the blur radius, x is the offset distance, and f(x) is the weight coefficient corresponding to the pixel point with the offset distance equal to x.

[0046] As an optional implementation of the embodiment of the present application, the obtaining unit is specifically configured to display a blur radius setting interface; and obtain the blur radius according to an input of a user in the blur radius setting interface.

[0047] As an optional implementation of the embodiment of the present application, the blurring unit is specifically configured to, for each pixel point in the initial image, perform weighted summation on color values of each pixel point in a first blur range according to the blur kernel to obtain a blur color value corresponding to the pixel point.

[0048] wherein the first blur range includes each pixel point with an offset distance less than or equal to the blur radius.

[0049] As an optional implementation of the embodiment of the present application, the blurring unit is specifically configured to, for each pixel point in the initial image, perform weighted summation on color values of each pixel point in a second blurring range according to the blurring kernel to obtain a first blurring color value corresponding to the pixel point; the second blurring range includes each pixel point with a horizontal offset distance less than or equal to the blurring radius; for each pixel point in the initial image, perform weighted summation on the first blurring color values of each pixel point in a third blurring range according to the blurring kernel to obtain a second blurring color value corresponding to the pixel point; the third blurring range includes each pixel point with a vertical offset distance less than or equal to the blurring radius; and determine the second blurring color value corresponding to each pixel point of the initial image as a corresponding blurred pixel value.

[0050] As an optional implementation of the embodiment of the present application, the blurring unit is specifically configured to, for each pixel point in the initial image, perform weighted summation on color values of each pixel point in a third blurring range according to the blurring kernel to obtain a third blurring color value corresponding to the pixel point; the third blurring range includes each pixel point with a vertical offset distance less than or equal to the blurring radius; for each pixel point in the initial image, perform weighted summation on the third blurring color values of each pixel point in a second blurring range according to the blurring kernel to obtain a fourth blurring color value corresponding to the pixel point; the second blurring range includes each pixel point with a horizontal offset distance less than or equal to the blurring radius; and determine the fourth blurring color value corresponding to each pixel point of the initial image as a corresponding blurred pixel value.

[0051] As an optional implementation of the embodiment of the present application, the processing unit is further configured to, after determining the blurring kernel according to the blurring radius, perform normalization processing on weight coefficients of each pixel point in the blurring kernel.

[0052] In a third aspect, an electronic device is provided, including a memory and a processor, the memory is configured to store a computer program, and the processor is configured to, when executing the computer program, enable the electronic device to implement the image processing method in any of the above embodiments.

[0053] In a fourth aspect, a computer readable storage medium is provided, when the computer program is executed by a computing device, the computing device is enabled to implement the image processing method in any of the above embodiments.

[0054] In a fifth aspect, a computer program product is provided, when the computer program product is run on a computer, the computer is enabled to implement the image processing method in any of the above embodiments.

[0055] The image processing method provided by the embodiments of the present application, when performing blur processing on an initial image, first acquires a blur radius, then determines a blur kernel calculation formula according to the blur radius, and then respectively calculates blur pixel values corresponding to each pixel point of the initial image based on the blur kernel, and respectively assigns each pixel point of the initial image with the corresponding blur pixel value to obtain a blur image corresponding to the initial image. Since the blur kernel in the embodiments of the present application is obtained by calculating the weight coefficient of each pixel point with a displacement distance less than the blur radius according to the blur kernel calculation formula, the blur kernel calculation formula is obtained by substituting the weight coefficient of the pixel point with the displacement distance equal to the blur radius into a pre-designed calculation formula, and the blur kernel determined according to the blur radius can be used to calculate the blur pixel values corresponding to all pixel points of the initial image, therefore the image processing method provided by the embodiments of the present application does not need to calculate the blur kernel for each pixel point of the initial image, but only needs to calculate the blur kernel once to be applicable to all pixel points of the initial image, therefore the image processing method provided by the embodiments of the present application can reduce the calculation amount in the process of performing blur processing on the image. BRIEF DESCRIPTION OF DRAWINGS

[0056] The accompanying drawings, which are incorporated herein and form part of the specification, illustrate embodiments consistent with the present application and, together with the description, further serve to explain the principles of the application.

[0057] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings to be invoked in the embodiments or the prior art description will be briefly introduced as follows, and obviously, other drawings can also be obtained by those skilled in the art without any creative effort on the basis of these drawings.

[0058] Figure 1 The step flowchart of the image processing method provided by the embodiments of the present application;

[0059] Figure 2 The interface diagram of the blur radius setting interface provided by the embodiments of the present application;

[0060] Figure 3 The comparison diagram of the blur kernel calculation formula and the Gaussian function provided by the embodiments of the present application;

[0061] Figure 4 The step flowchart of the image processing method provided by the embodiments of the present application;

[0062] Figure 5 The step flowchart of the image processing method provided by the embodiments of the present application; Figure 4 The flowchart of the image processing method provided by the embodiments of the present application;

[0063] Figure 6Another step flow chart of an image processing method provided by an embodiment of the present application is shown in FIG. 6.

[0064] Figure 7 A flow chart of the image processing method provided by an embodiment of the present application is shown in FIG. 5. Figure 6 A flow chart of the image processing method provided by an embodiment of the present application is shown in FIG. 5.

[0065] Figure 8 Another step flow chart of an image processing method provided by an embodiment of the present application is shown in FIG. 6.

[0066] Figure 9 A flow chart of the image processing method provided by an embodiment of the present application is shown in FIG. 5. Figure 8 A flow chart of the image processing method provided by an embodiment of the present application is shown in FIG. 5.

[0067] Figure 10 A structure schematic diagram of an image processing device provided by an embodiment of the present application is shown in FIG. 7.

[0068] Figure 11 A hardware structure schematic diagram of an electronic device provided by an embodiment of the present application is shown in FIG. 8. DETAILED DESCRIPTION

[0069] In order to enable a person skilled in the art to more clearly understand the above-mentioned purposes, features and advantages of the present application, the solutions of the present application will be further described below. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.

[0070] In the following description, many specific details are set forth in order to provide a thorough understanding of the present application. However, it will be apparent to one skilled in the art that the present application can be practiced in other ways different from those described herein. It should be noted that the embodiments in the specification are only some embodiments of the present application, not all the embodiments.

[0071] In the embodiments of the present application, the words such as "exemplary" or "for example" are used to mean serving as an example, instance, or illustration. Any embodiment or design presented as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or advantageous than other embodiments or design solutions. Rather, the use of the words such as "exemplary" or "for example" is intended to present concepts in a concrete manner. In addition, in the description of the embodiments of the present application, the meaning of "plurality" is two or more, unless otherwise specified.

[0072] The embodiments of the present application provide an image processing method, referring to FIG. 1, the image processing method comprises the following steps: Figure 1

[0073] S101, acquiring a blur radius (Radius).

[0074] ​The blur radius in the embodiments of the present application refers to a pixel radius range used for blur processing. The blur radius determines the range of pixels for parameter blur calculation. When the blur radius is large, the number of pixels for parameter blur calculation is large, the blur degree is also increased accordingly, and the image becomes more blurred. Conversely, when the blur radius is small, the number of pixels for parameter blur calculation is small, the blur degree is reduced, and the image becomes clearer.

[0075] In some embodiments, the blur radius is obtained, including: obtaining a preset blur radius. That is, a blur radius is preconfigured, and the image is processed by default based on the preset blur radius.

[0076] In some embodiments, the blur radius is obtained, including: displaying a blur radius setting interface; and obtaining the blur radius according to user input in the blur radius setting interface. That is, the blur radius can be set according to the requirement of the blur degree, and when the requirement of the blur degree is high, the blur radius can be set to be large, and when the requirement of the blur degree is low, the blur radius can be set to be small.

[0077] When the implementation manner of obtaining the blur radius is receiving the blur radius input by the user, the user can set the blur radius according to the actual requirement, so as to obtain a blur image that meets the requirement.

[0078] For example, referring to FIG. 2, Figure 2 As shown in FIG. 2, the blur radius setting interface 200 includes a blur radius input control 21, and the user can drag in the blur radius input control 21 to set the blur radius.

[0079] S102, determining a blur kernel according to the blur radius.

[0080] The blur kernel is obtained according to a blur kernel calculation formula, and the blur kernel calculation formula is obtained by substituting the blur radius and the weight coefficient corresponding to the pixel point with the offset distance of the blur radius into a pre-designed calculation formula.

[0081] In some embodiments, the pre-designed calculation formula is a pure quadratic polynomial with the offset distance of the pixel point as the independent variable and the weight coefficient of the pixel point as the dependent variable, and the constant term of the pure quadratic polynomial is a preset value.

[0082] The pure quadratic polynomial in the embodiments of the present application refers to a polynomial with the highest order term being quadratic and the coefficient of the first order term being 0. For example, when the value of the coefficient B of the first order term of the quadratic polynomial Ax 2 +BX+C is 0, the quadratic polynomial can be rewritten as Ax 2 +C, and Ax 2 +C is a pure quadratic polynomial.

[0083] Since the pre-designed formula is a pure quadratic polynomial with the offset distance of the pixel point as the independent variable and the weight coefficient of the pixel point as the dependent variable, the blur kernel calculation formula is a pure quadratic polynomial with the offset distance as the independent variable, and thus the embodiments of the present application can consider the spatial distribution of the pixel points in the image, thereby making the blur effect smoother.

[0084] S103, respectively calculating blur pixel values corresponding to each pixel point of the initial image based on the blur kernel.

[0085] That is, the blur kernel determined through step S102 calculates the blur pixel values corresponding to each pixel point of the initial image.

[0086] S104, respectively assigning the blur pixel values corresponding to each pixel point of the initial image to obtain a blur image corresponding to the initial image.

[0087] The image processing method provided by the embodiments of the present application first acquires a blur radius when performing blur processing on an initial image, then determines a blur kernel calculation formula according to the blur radius, respectively calculates blur pixel values corresponding to each pixel point of the initial image based on the blur kernel, and respectively assigns the blur pixel values corresponding to each pixel point of the initial image to obtain a blur image corresponding to the initial image. Since the weight coefficients of each pixel point with an offset distance less than the blur radius in the blur kernel are obtained according to the blur kernel calculation formula in the embodiments of the present application, the blur kernel calculation formula is obtained by substituting the weight coefficient of the pixel point with the offset distance equal to the blur radius and the blur radius into the pre-designed formula, and the blur kernel determined according to the blur radius can be used to calculate the blur pixel values corresponding to all pixel points of the initial image, thus the image processing method provided by the embodiments of the present application does not need to calculate the blur kernel for each pixel point of the initial image, but only needs to calculate the blur kernel once to be applicable to all pixel points of the initial image, and thus the image processing method provided by the embodiments of the present application can reduce the calculation amount in the process of performing blur processing on the image.

[0088] In some embodiments, the step of determining the blur kernel according to the blur radius includes the following steps a and b:

[0089] Step a, substituting the weight coefficient of the pixel point with the offset distance equal to the blur radius and the blur radius into the pure quadratic polynomial to obtain a target equation.

[0090] Suppose that the quadratic term coefficient of the pure quadratic polynomial is -a 2 , and the constant term of the pure quadratic polynomial is w0, then the pure quadratic polynomial is as follows:

[0091] f(x) = w0-(ax)2

[0092] The first weighting coefficient w R Substituting the fuzzy radius R into the above pure quadratic polynomial, the objective equation is as follows:

[0093] w R =w0-(aR) 2

[0094] Step b: Solve for the quadratic coefficients of the pure quadratic polynomial according to the objective equation to obtain the fuzzy kernel calculation formula.

[0095] Since the objective equation contains only one unknown quantity—the coefficient of the quadratic term—of a pure quadratic polynomial, while the other parameters are only known quantities, the coefficient of the quadratic term of the pure quadratic polynomial can be calculated as follows:

[0096]

[0097] Therefore, the fuzzy kernel calculation formula is:

[0098]

[0099] Among them, w R The weight coefficient is the pixel point whose offset distance is the blur radius, w0 is the preset value (the value of the constant term of the pure quadratic polynomial), R is the blur radius, x is the offset distance, and f(x) is the weight coefficient corresponding to the pixel point whose offset distance is x.

[0100] The following compares the computational complexity of the fuzzy kernel calculation formula provided in this application embodiment with that of the Gaussian function. The comparison of the number of operators between the fuzzy kernel calculation formula and the Gaussian function provided in this application embodiment is shown in Table 1 below:

[0101] Table 1

[0102]

[0103] As shown in Table 1 above, the number of multiplication operators, division operators, and exponentiation operators in the fuzzy kernel calculation formula provided in this application embodiment are all less than those in the Gaussian function. Furthermore, since the order of computational complexity of a single operator is: exponentiation operator > division operator > multiplication operator > addition and subtraction operator, the computational complexity of the fuzzy kernel calculation formula provided in this application embodiment is much less than that of the Gaussian function.

[0104] Furthermore, refer to Figure 3 As shown, Figure 3 This includes curve 31, representing the offset distance and weighting coefficients of the Gaussian function, and curve 32, representing the offset distance and weighting coefficients of the fuzzy kernel calculation formula provided in the embodiments of this application. Because... Figure 3It can be seen that the curve 31 of the offset distance and the weight coefficient of the Gaussian function is very close to the curve 32 of the offset distance and the weight coefficient of the blur kernel calculation formula provided in the embodiments of the present application, and thus the blur effect obtained by the blur kernel calculation formula is similar to the blur effect obtained by the Gaussian blur.

[0105] As shown above, compared with the Gaussian function involving exponential calculation and division calculation, the blur kernel calculation formula provided in the embodiments of the present application does not involve exponential calculation and division calculation, and thus the calculation amount in the process of performing the blur processing on the image by the embodiments of the present application is much smaller than that of the Gaussian blur.

[0106] As an extension and refinement of the above embodiments, the embodiments of the present application further provide an image processing method, which, as shown in Figure 4 The image processing method comprises the following steps:

[0107] S401, acquiring a blur radius.

[0108] S402, substituting a weight coefficient corresponding to a pixel point with an offset distance of the blur radius and the blur radius into a pure quadratic polynomial to obtain a target equation.

[0109] The preset calculation formula is a pure quadratic polynomial with the offset distance of the pixel point as the independent variable and the weight coefficient of the pixel point as the dependent variable, and a constant term of the pure quadratic polynomial is a preset value.

[0110] S403, solving a quadratic term coefficient of the pure quadratic polynomial according to the target equation to obtain the blur kernel calculation formula.

[0111] S404, calculating the weight coefficient of each pixel point with an offset distance smaller than the blur radius according to the blur kernel calculation formula to obtain a blur kernel.

[0112] In some embodiments, the step S404 (calculating the weight coefficient of each pixel point with an offset distance smaller than the blur radius according to the blur kernel calculation formula to obtain a blur kernel) comprises: substituting the offset distance of each pixel point with an offset distance smaller than the blur radius into the blur kernel calculation formula to obtain the weight coefficient of each pixel point with an offset distance smaller than the blur radius, and assigning the weight coefficient of each pixel point with an offset distance smaller than the blur radius to each pixel point with an offset distance smaller than the blur radius to obtain the blur kernel.

[0113] In some embodiments, after obtaining the blur kernel, the method further comprises: performing normalization processing on the weight coefficient of each pixel point in the blur kernel.

[0114] That is, the sum of the weight coefficients of each pixel point in the blur kernel is 1, and the ratio of the weight coefficients of each pixel point in the blur kernel is unchanged.

[0115] S405, for each pixel point in the initial image, the color values of each pixel point in the first blur range are weighted and summed according to the blur kernel to obtain the blur color value corresponding to the pixel point.

[0116] Wherein, the first blur range includes each pixel point with an offset distance less than or equal to the blur radius.

[0117] For example, when the blur radius is 5, the first blur range includes 5*5 pixel points, and the above step S405 needs to respectively take each pixel point in the initial image as the blur center, and the color values of the 5*5 pixel points in the first blur range are weighted and summed to obtain the blur color value corresponding to each pixel point.

[0118] In some embodiments, the color values of each pixel point in the first blur range are weighted and summed according to the blur kernel to obtain the blur color value corresponding to the pixel point, including: calculating the product of the weight coefficient and the color value of each pixel point in the first blur range to obtain the weight value of each pixel point in the first blur range, and summing the weight values of each pixel point in the first blur range to obtain the blur color value of the pixel point. That is,

[0119]

[0120] Wherein, I B is the blur color value corresponding to the pixel point, I i is the color value of the i-th pixel point in the first blur range, w i is the weight coefficient of the i-th sampling pixel point in the first blur range, and N is the total number of pixel points in the first blur range.

[0121] In other embodiments, the color values of each pixel point in the first blur range are weighted and summed according to the blur kernel to obtain the blur color value corresponding to the pixel point, including: calculating the product of the weight coefficient and the color value of each pixel point in the first blur range to obtain the weight value of each pixel point in the first blur range, and summing the weight values of each pixel point in the first blur range to obtain the first calculation value, summing the weight coefficients of each pixel point in the first blur range to obtain the second calculation value, and calculating the ratio of the first calculation value and the second calculation value to obtain the blur color value of the pixel point. That is,

[0122]

[0123] Wherein, I BI represents the blurred color value of a pixel. i w represents the color value of the i-th pixel within the first blur range. i is the weight coefficient of the i-th pixel within the first fuzzy range, and N is the total number of pixels within the first fuzzy range.

[0124] Compared to directly using the color values ​​of each pixel within the first blur range and the weighted sum as the blurred color value of the pixel located at the blur center, the above embodiment also calculates the ratio of the weighted sum of each pixel within the first blur range to the sum of the weight coefficients of each pixel. Therefore, the above embodiment can normalize the weight coefficients of each pixel to avoid the brightness of the blurred image being too high or too low.

[0125] S406. Assign each pixel of the initial image to the corresponding blurred pixel value to obtain the blurred image corresponding to the initial image.

[0126] For example, refer to Figure 5 As shown, Figure 5 The image processing method provided in the above embodiment will be explained using a blur radius of 5 as an example. (Refer to...) Figure 5 As shown, the steps of this image processing method include: first, obtaining the weight coefficients 52 of each pixel within the blur kernel based on the blur kernel calculation formula and the offset distance 51 of each pixel within the blur kernel; then, for each pixel in the initial image 53, sampling is performed on the pixels within the first blur range to obtain the color values ​​54 of each pixel within the first blur range; finally, based on the color values ​​54 of each pixel within the first blur range and the weight coefficients 52 of each pixel within the first blur range, the blur value I of each pixel is calculated. B 55. Finally, the color values ​​of each pixel in the initial image 53 are assigned to the corresponding blurred color values ​​to generate the blurred image corresponding to the initial image 53.

[0127] In the above embodiments, each pixel to be blurred requires R*R sampling and calculations. For an initial image of size W*H, if the blur radius is 5, a total of 25*W*H sampling and calculations are required, which is still a large computational load. To further reduce the computational load of image blurring, this application also provides another image processing method, referred to... Figure 6 As shown, the image processing method includes the following steps:

[0128] S601, Obtain the fuzzy radius.

[0129] S602. Substitute the weight coefficients corresponding to the pixels with an offset distance equal to the blur radius and the blur radius into a pure quadratic polynomial to obtain the target equation.

[0130] wherein the pre-designed formula is a pure quadratic polynomial with the offset distance of the pixel point as the independent variable and the weight coefficient of the pixel point as the dependent variable, and a constant term of the pure quadratic polynomial is a preset value.

[0131] S603, solving a quadratic term coefficient of the pure quadratic polynomial according to the target formula to obtain the blur kernel calculation formula.

[0132] wherein the second blur range includes each pixel point with an offset distance less than or equal to the blur radius in the horizontal direction.

[0133] S604, calculating the weight coefficient of each pixel point with an offset distance less than the blur radius according to the blur kernel calculation formula to obtain a blur kernel.

[0134] S605, for each pixel point in the initial image, performing weighted summation on color values of each pixel point in the second blur range according to the blur kernel to obtain a first blur color value corresponding to the pixel point.

[0135] wherein the second blur range includes each pixel point with an offset distance less than or equal to the blur radius in the horizontal direction.

[0136] In some embodiments, the above step S605 includes: calculating a product of the weight coefficient and the color value of each pixel point in the second blur range to obtain a weight value of each pixel point in the second blur range, and summing the weight values of each pixel point in the second blur range to obtain the first blur color value of the pixel point. That is,

[0137]

[0138] wherein I1 is the first blur color value of the pixel point, I i is a color value of an i-th pixel point in the second blur range, w i is a weight coefficient of the i-th pixel point in the second blur range, and N is a total number of pixel points in the second blur range.

[0139] In some other embodiments, the above step S605 includes: calculating a product of the weight coefficient and the color value of each pixel point in the second blur range to obtain a weight value of each pixel point in the second blur range, summing the weight values of each pixel point in the second blur range to obtain a first calculation value, summing the weight coefficients of each pixel point in the second blur range to obtain a second calculation value, and calculating a ratio of the first calculation value to the second calculation value to obtain the first blur color value of the pixel point. That is,

[0140]

[0141] wherein, I1 is a first blur color value of the pixel point, I i is a color value of an i-th pixel point in the second blur range, w i is a weight coefficient of the i-th pixel point in the second blur range, and N is a total number of pixel points in the second blur range.

[0142] S606, for each pixel point in the initial image, a first blur color value of each pixel point in a third blur range is weighted and summed according to the blur kernel to obtain a second blur color value corresponding to the pixel point.

[0143] wherein, the third blur range includes each pixel point with a vertical direction offset distance less than or equal to the blur radius.

[0144] The implementation manner of step S606 is similar to the implementation manner of step S605 described above, and thus will not be repeated here.

[0145] S607, a second blur color value corresponding to each pixel point of the initial image is determined as a corresponding blur pixel value.

[0146] S608, each pixel point of the initial image is respectively assigned as a corresponding blur pixel value to obtain a blur image corresponding to the initial image.

[0147] For example, referring to Figure 7 For example, Figure 7 The image processing method provided in the above embodiment is described with the blur radius of 5 as an example. Referring to Figure 7As shown in the image processing method, the step flow includes: step 1, obtaining the weight coefficient 72 of each pixel point in the blur kernel according to the blur kernel calculation formula and the offset distance 71 of each pixel point in the blur kernel; step 2, for each pixel point in the initial image 73, sampling the pixel points in the second blur range to obtain the color value 74 of each pixel point in the second blur range; step 3, calculating the first blur value I1 76 of each pixel point according to the color value 74 of each pixel point in the second blur range and the weight value 75 of each pixel point in the second blur range; step 4, assigning the color value of each pixel point of the initial image 73 to the corresponding first blur color value I1 to generate the pre-processed blur image 77 corresponding to the initial image 73; step 5, for each pixel point in the pre-processed blur image 77, sampling the pixel points in the third blur range to obtain the color value 78 of each pixel point in the third blur range; step 6, calculating the second blur value I2 710 of each pixel point according to the color value 78 of each pixel point in the third blur range and the weight value 79 of each pixel point in the third blur range; step 7, assigning the color value of each pixel point of the initial image 73 or the pre-processed blur image 76 to the corresponding second blur color value I2 to generate the blur image 711 corresponding to the initial image 73.

[0148] Compared with Figure 4 As shown in the embodiment, the initial image with a size of W*H needs R*R*W*H times of sampling and calculation, Figure 6 In the embodiment, the initial image with a size of W*H only needs 2*R*W*H times of sampling and calculation, so Figure 6 As shown in the embodiment, the sampling and calculation times can be reduced, and the calculation amount of image blur can be further reduced.

[0149] The embodiment of the present application also provides another image processing method, referring to Figure 8 As shown in the image processing method, the image processing method includes the following steps:

[0150] S801, obtaining a blur radius.

[0151] S802, substituting the weight coefficient corresponding to the pixel point with an offset distance of the blur radius and the blur radius into a pure quadratic polynomial to obtain a target equation.

[0152] Wherein, wherein, the pre-designed calculation formula is a pure quadratic polynomial with the offset distance of the pixel point as the independent variable and the weight coefficient of the pixel point as the dependent variable, and the constant term of the pure quadratic polynomial is a preset value.

[0153] S803, solving the quadratic term coefficient of the pure quadratic polynomial according to the target equation to obtain the blur kernel calculation formula.

[0154] The second blur range includes each pixel point with a horizontal offset distance less than or equal to the blur radius.

[0155] S804, calculating a weight coefficient of each pixel point with an offset distance less than the blur radius according to the blur kernel formula, to obtain a blur kernel.

[0156] S805, for each pixel point in the initial image, performing weighted summation on color values of each pixel point in a third blur range according to the blur kernel, to obtain a third blur color value corresponding to the pixel point.

[0157] The third blur range includes each pixel point with a vertical offset distance less than or equal to the blur radius.

[0158] S806, for each pixel point in the initial image, performing weighted summation on third blur color values of each pixel point in a second blur range according to the blur kernel, to obtain a fourth blur color value corresponding to the pixel point.

[0159] The second blur range includes each pixel point with a horizontal offset distance less than or equal to the blur radius.

[0160] S807, determining the fourth blur color value corresponding to each pixel point of the initial image as a corresponding blur pixel value.

[0161] S808, respectively assigning each pixel point of the initial image with a corresponding blur pixel value, to obtain a blur image corresponding to the initial image.

[0162] For example, referring to Figure 9 For example, Figure 9 The image processing method provided in the above embodiment is described with a blur radius of 5. For example, referring to Figure 9As shown in the figure, the step flow of the image processing method includes: step 1, obtaining the weight coefficient 92 of each pixel point in the blur kernel according to the blur kernel calculation formula and the offset distance 91 of each pixel point in the blur kernel; step 2, for each pixel point in the initial image 93, sampling the pixel points in the third blur range to obtain the color value 94 of each pixel point in the third blur range; step 3, calculating the third blur value I3 96 of each pixel point according to the color value 94 of each pixel point in the third blur range and the weight coefficient 95 of each pixel point in the third blur range; step 4, assigning the color value of each pixel point of the initial image 93 to the corresponding third blur color value I3 to generate the pre-processed blur image 97 corresponding to the initial image 93; step 5, for each pixel point in the pre-processed blur image 97, sampling the pixel points in the second blur range to obtain the color value 98 of each pixel point in the second blur range; step 6, calculating the fourth blur value I4 910 of each pixel point according to the color value 98 of each pixel point in the second blur range and the weight coefficient 99 of each pixel point in the second blur range; step 7, assigning the color value of each pixel point of the initial image 93 or the pre-processed blur image 96 to the corresponding fourth blur color value I4 to generate the blur image 911 corresponding to the initial image 93.

[0163] Compared with Figure 4 In the embodiment shown, the initial image with a size of W*H needs R*R*W*H times of sampling and calculation, Figure 8 In the embodiment shown, the initial image with a size of W*H also only needs 2*R*W*H times of sampling and calculation, so Figure 8 As shown in the figure, the image processing method can also reduce the number of sampling and calculation, and further reduce the calculation amount of image blur.

[0164] Based on the same inventive concept, as an implementation of the above method, the embodiment of the application also provides an image processing device, which corresponds to the above-mentioned method embodiment. For easy reading, the details of the above-mentioned method embodiment will not be described one by one, but it should be clear that the image processing device in the embodiment can correspondingly implement all the contents in the above-mentioned method embodiment.

[0165] The embodiment of the application provides an image processing device, Figure 10 The structural schematic diagram of the image processing device is shown in the figure, which includes: Figure 10 As shown in the figure, the image processing device 100 includes:

[0166] The acquisition unit 101 is configured to acquire the blur radius;

[0167] The processing unit 102 is configured to determine a blur kernel according to the blur radius; wherein the blur kernel is obtained by substituting the blur radius and the weight coefficient corresponding to the pixel point with the offset distance of the blur radius into a pre-designed calculation formula.

[0168] The blurring unit 103 is configured to calculate a blur pixel value corresponding to each pixel point of the initial image based on the blur kernel respectively, and assign each pixel point of the initial image with the corresponding blur pixel value respectively to obtain a blur image corresponding to the initial image.

[0169] As an optional implementation of the embodiment of the present application, the pre-designed calculation formula is a pure quadratic polynomial with the offset distance of the pixel point as the independent variable and the weight coefficient of the pixel point as the dependent variable, and the constant term of the pure quadratic polynomial is a preset value.

[0170] As an optional implementation of the embodiment of the present application, the processing unit 102 is specifically configured to substitute the weight coefficient corresponding to the pixel point with the offset distance of the blur radius and the blur radius into the pure quadratic polynomial to obtain a target equation; and solve the quadratic term coefficient of the pure quadratic polynomial according to the target equation to obtain the blur kernel calculation formula.

[0171] As an optional implementation of the embodiment of the present application, the blur kernel calculation formula is:

[0172]

[0173] wherein w R is the weight coefficient corresponding to the pixel point with the offset distance of the blur radius, w0 is the preset value, R is the blur radius, x is the offset distance, and f(x) is the weight coefficient corresponding to the pixel point with the offset distance of x.

[0174] As an optional implementation of the embodiment of the present application, the obtaining unit 101 is specifically configured to display a blur radius setting interface; and obtain the blur radius according to the input of a user in the blur radius setting interface.

[0175] As an optional implementation of the embodiment of the present application, the blurring unit 103 is specifically configured to, for each pixel point in the initial image, perform weighted summation on color values of each pixel point in a first blur range according to the blur kernel to obtain a blur color value corresponding to the pixel point.

[0176] wherein the first blur range includes each pixel point with the offset distance less than or equal to the blur radius.

[0177] As an optional implementation of the embodiment of the present application, the blurring unit 103 is specifically configured to, for each pixel point in the initial image, perform weighted summation on color values of each pixel point in a second blurring range according to the blurring kernel to obtain a first blurring color value corresponding to the pixel point; the second blurring range includes each pixel point with a horizontal offset distance less than or equal to the blurring radius; for each pixel point in the initial image, perform weighted summation on the first blurring color values of each pixel point in a third blurring range according to the blurring kernel to obtain a second blurring color value corresponding to the pixel point; the third blurring range includes each pixel point with a vertical offset distance less than or equal to the blurring radius; and determine the second blurring color value corresponding to each pixel point of the initial image as a corresponding blurred pixel value.

[0178] As an optional implementation of the embodiment of the present application, the blurring unit 103 is specifically configured to, for each pixel point in the initial image, perform weighted summation on color values of each pixel point in a third blurring range according to the blurring kernel to obtain a third blurring color value corresponding to the pixel point; the third blurring range includes each pixel point with a vertical offset distance less than or equal to the blurring radius; for each pixel point in the initial image, perform weighted summation on the third blurring color values of each pixel point in a second blurring range according to the blurring kernel to obtain a fourth blurring color value corresponding to the pixel point; the second blurring range includes each pixel point with a horizontal offset distance less than or equal to the blurring radius; and determine the fourth blurring color value corresponding to each pixel point of the initial image as a corresponding blurred pixel value.

[0179] As an optional implementation of the embodiment of the present application, the processing unit 102 is further configured to, after determining the blurring kernel according to the blurring radius, perform normalization processing on weight coefficients of each pixel point in the blurring kernel.

[0180] The image processing apparatus provided by the embodiment of the present application can execute the image processing method provided by any of the above embodiments, and has similar implementation principles and technical effects, which will not be described here.

[0181] Based on the same inventive concept, the embodiment of the present application further provides an electronic device. Figure 11 The structural schematic diagram of the electronic device provided by the embodiment of the present application is shown in Figure 11 The electronic device provided by the embodiment of the present application includes a memory 111 and a processor 112, the memory 111 is used to store a computer program, and the processor 112 is used to execute the image processing method provided by the above embodiment when executing the computer program.

[0182] Based on the same inventive concept, the embodiment of the present application further provides a computer readable storage medium, which stores a computer program. When the computer program is executed by a processor, the computer program enables a computing device to implement the image processing method provided by the above embodiment.

[0183] Based on the same inventive concept, the embodiment of the present application further provides a computer program product, which enables a computing device to implement the image processing method provided by the above embodiment when the computer program product is run on the computer.

[0184] Those skilled in the art will appreciate that embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media having computer-usable program code embodied in the medium.

[0185] The processor can be a central processing unit (CPU), and can also be other general-purpose processors, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.

[0186] The memory can include non-persistent memory in computer readable medium, random access memory (RAM), and / or non-volatile memory, etc. in the form of read only memory (ROM) or flash memory (flash RAM), etc. The memory is an example of the computer readable medium.

[0187] Computer-readable media includes permanent and non-permanent, movable and non-movable storage media. Storage media can be implemented by any method or technology to store information, which can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible by a computing device. According to the definition herein, computer-readable media does not include transitory media such as modulated data signals and carriers.

[0188] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and are not limited to them. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent substitutions for part or all of the technical features, without departing from the scope of the technical solutions of the embodiments of the present application.

Claims

1. An image processing method, characterized by, The method comprises: obtaining a blur radius; determining a blur kernel according to the blur radius; wherein the blur kernel is obtained according to a blur kernel calculation formula, the blur kernel calculation formula being a formula in which the blur radius and a weight coefficient corresponding to a pixel point with an offset distance equal to the blur radius are substituted into a pre-designed calculation formula; calculating a blur pixel value corresponding to each pixel point of an initial image based on the blur kernel; assigning each pixel point of the initial image to a corresponding blur pixel value to obtain a blurred image corresponding to the initial image.

2. The method of claim 1, wherein, The pre-designed calculation formula is a pure quadratic polynomial with the offset distance of a pixel point as the independent variable and the weight coefficient of the pixel point as the dependent variable, and the constant term of the pure quadratic polynomial is a preset value.

3. The method of claim 2, wherein, The determining of the blur kernel according to the blur radius comprises: substituting the weight coefficient corresponding to the pixel point with the offset distance equal to the blur radius and the blur radius into the pure quadratic polynomial to obtain a target equation; solving the quadratic term coefficient of the pure quadratic polynomial according to the target equation to obtain the blur kernel calculation formula.

4. The method of claim 3, wherein, The blur kernel calculation formula is: wherein w R is a weight coefficient corresponding to a pixel point with an offset distance of the blur radius, w0 is the preset value, R is the blur radius, x is the offset distance, and f(x0 is a weight coefficient corresponding to a pixel point with an offset distance of x.

5. The method of claim 1, wherein, The obtaining of the blur radius comprises: displaying a blur radius setting interface; obtaining the blur radius according to the input of a user in the blur radius setting interface.

6. The method of claim 1, wherein, The calculating of the blur pixel value corresponding to each pixel point of the initial image based on the blur kernel comprises: for each pixel point in the initial image, performing weighted summation on the color values of each pixel point in a first blur range according to the blur kernel to obtain a blur color value corresponding to the pixel point; wherein the first blur range comprises each pixel point with an offset distance less than or equal to the blur radius. The calculating of the blur pixel value corresponding to each pixel point of the initial image based on the blur kernel comprises:

7. The method of claim 1, wherein, for each pixel point in the initial image, performing weighted summation on the color values of each pixel point in a second blur range according to the blur kernel to obtain a first blur color value corresponding to the pixel point; the second blur range comprises each pixel point with an offset distance less than or equal to the blur radius in the horizontal direction; for each pixel point in the initial image, performing weighted summation on the first blur color values of each pixel point in a third blur range according to the blur kernel to obtain a second blur color value corresponding to the pixel point; the third blur range comprises each pixel point with an offset distance less than or equal to the blur radius in the vertical direction; determining the second blur color value corresponding to each pixel point of the initial image as the corresponding blur pixel value. The calculating of the blur pixel value corresponding to each pixel point of the initial image based on the blur kernel comprises:

8. The method of claim 1, wherein, for each pixel point in the initial image, performing weighted summation on the color values of each pixel point in a third blur range according to the blur kernel to obtain a third blur color value corresponding to the pixel point; the third blur range comprises each pixel point with an offset distance less than or equal to the blur radius in the vertical direction; ​ For each pixel point in the initial image, a third blur color value of each pixel point in a second blur range according to the blur kernel is weighted and summed to obtain a fourth blur color value corresponding to the pixel point; the second blur range includes each pixel point with a horizontal offset distance less than or equal to the blur radius. The fourth blur color value corresponding to each pixel point of the initial image is determined as the corresponding blur pixel value.

9. The method of claim 1, wherein, The method further comprises: After determining the blur kernel according to the blur radius, the weight coefficients of each pixel point in the blur kernel are normalized.

10. An image processing apparatus characterized by comprising: Comprise: An acquisition unit is configured to acquire a blur radius; A processing unit is configured to determine a blur kernel according to the blur radius; wherein the blur kernel is obtained by calculating the weight coefficients of the pixel points with an offset distance less than the blur radius according to a blur kernel calculation formula; the blur kernel calculation formula is obtained by substituting the weight coefficients of the pixel points with an offset distance equal to the blur radius into a pre-designed calculation formula; A blurring unit is configured to calculate the blur pixel values corresponding to each pixel point of an initial image respectively based on the blur kernel, and assign each pixel point of the initial image with the corresponding blur pixel value respectively to obtain a blur image corresponding to the initial image.

11. An electronic device, comprising: Comprise: A memory and a processor, the memory is configured to store a computer program, and the processor is configured to execute the computer program, so that the electronic device implements the image processing method in any one of claims 1-9.

12. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and when the computer program is executed by a computing device, the computing device implements the image processing method in any one of claims 1-9.

13. A computer program product, characterised in that, When the computer program product runs on the computer, the computer implements the image processing method in any one of claims 1-9. When the computer program product runs on the computer, the computer implements the image processing method in any one of claims 1-9.