Image processing method, device, electronic device and storage medium

The target blur kernel matrix processing and image peak signal-to-noise ratio determination is solved, and the problem of inaccurate image defuzzy processing in the prior art is achieved, and a more efficient image defuzzy effect is achieved.

CN115937004BActive Publication Date: 2025-09-02BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110918924.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-11
Publication Date
2025-09-02
Estimated Expiration
2041-08-11

Smart Images

  • Figure CN115937004B_ABST
    Figure CN115937004B_ABST
Patent Text Reader

Abstract

The present disclosure relates to an image processing method, device, electronic identification and storage medium, including: obtaining a blurred image; processing the blurred image based on a blur kernel matrix to obtain a candidate image group, wherein the blur kernel matrix includes multiple different blur kernels, the candidate image group includes multiple different candidate images, the candidate images correspond to the blur kernels one-to-one, and the candidate images are obtained by processing the blurred image based on the corresponding blur kernel; for each candidate image, obtaining a first parameter corresponding to the candidate image based on the candidate image and the blurred image; determining the blur kernel corresponding to the target image as the target blur kernel, wherein the target image is the candidate image corresponding to the minimum value of the first parameter, thereby improving the processing speed and accuracy of deblurring the blurred image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of image processing technology, and in particular to an image processing method, device, electronic device, and storage medium. Background Art

[0002] In recent years, with the rapid development of science and technology, various mobile digital devices have become part of people's lives, making it easier for them to capture the moments of their daily lives. Images, as a medium for information transmission, are closely intertwined with human life and have become a crucial means for people to obtain and transmit information in today's society. However, during the image capture process, various factors, such as subject motion, device quality, and camera shake, often result in blurred images. This information loss can hinder the ability to read important information in images, such as text, faces, and other important features.

[0003] In related technologies, the image deblurring process is mainly based on the characteristics of the image itself, such as using the image gradient method or variance function to analyze the blur degree of each pixel in the blurred image, and then obtaining a clear image by processing each pixel in the blurred image.

[0004] However, in the related art, since the blur type of the image cannot be accurately determined, the subsequent deblurring process often cannot be targeted, resulting in poor deblurring effect. Summary of the Invention

[0005] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides an image processing method, device, electronic device and storage medium.

[0006] In a first aspect, an embodiment of the present disclosure provides an image processing method, comprising:

[0007] Get the blurred image;

[0008] Processing the blurred image based on a blur kernel matrix to obtain a candidate image group, wherein the blur kernel matrix includes a plurality of different blur kernels, the candidate image group includes a plurality of different candidate images, the candidate images correspond one-to-one to the blur kernels, and the candidate images are obtained by processing the blurred image based on the corresponding blur kernels;

[0009] For each candidate image, obtaining a first parameter corresponding to the candidate image according to the candidate image and the blurred image, wherein the first parameter includes an image peak signal-to-noise ratio;

[0010] A blur kernel corresponding to a target image is determined as a target blur kernel, wherein the target image is a candidate image corresponding to a minimum value of the first parameter.

[0011] Optionally, acquiring a first parameter corresponding to the candidate image according to the candidate image and the blurred image includes:

[0012] Obtaining a mean square error between the candidate image and the blurred image;

[0013] A first parameter corresponding to the candidate image is determined according to a mean square error between the candidate image and the blurred image.

[0014] Optionally, obtaining a mean square error between the candidate image and the blurred image includes:

[0015] according to Obtaining a mean square error between the candidate image and the blurred image;

[0016] Among them, MSE x represents the mean square error of the x-th candidate image in the candidate image group, mn represents the pixel of the blurred image m×n, I(i,j) represents the pixel value at the position (i,j) of the blurred image, K x (i, j) represents the pixel value at position (i, j) of the x-th candidate image in the candidate image group.

[0017] Optionally, determining the first parameter corresponding to the candidate image according to a mean square error between the candidate image and the blurred image includes:

[0018] according to Determining a first parameter corresponding to each candidate image in the candidate image group;

[0019] Among them, PSNR x represents the first parameter of the x-th candidate image in the candidate image group, Indicates the maximum pixel value.

[0020] Optionally, after obtaining the first parameter corresponding to the candidate image according to the candidate image and the blurred image, the method further includes:

[0021] The blur degree of the blurred image is determined according to first parameters corresponding to each candidate image in the candidate image group and the blurred image.

[0022] Optionally, determining the blur degree of the blurred image according to the first parameter corresponding to each candidate image in the candidate image group and the blurred image includes:

[0023] averaging the first parameters corresponding to each candidate image in the candidate image group and the blurred image;

[0024] The blur degree of the blurred image is determined according to the average value.

[0025] Optionally, averaging the first parameters corresponding to each candidate image in the candidate image group and the blurred image includes:

[0026] according to averaging the first parameters corresponding to each candidate image in the candidate image group and the blurred image;

[0027] in, represents the average value of the first parameter corresponding to each candidate image in the candidate image group, and y represents the number of blur kernels in the blur kernel matrix.

[0028] Optionally, the processing the blurred image based on the blur kernel matrix to obtain the candidate image group includes:

[0029] For each blur kernel, traverse the sub-image blocks of the blurred image, where the size of each sub-image block is the same as the size of the blur kernel. Perform corresponding point multiplication on the pixels of each sub-image block and the elements of the blur kernel to obtain the candidate pixels of the sub-image block. Based on the candidate pixels of all sub-image blocks, obtain all the pixels of the candidate image corresponding to the blur kernel.

[0030] Optionally, the method further includes:

[0031] Deblurring the blurred image based on the target blur kernel.

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

[0033] A blurred image acquisition module, used for acquiring a blurred image;

[0034] a blurred image processing module, configured to process the blurred image based on a blur kernel matrix to obtain a candidate image group, wherein the blur kernel matrix includes a plurality of different blur kernels, the candidate image group includes a plurality of different candidate images, the candidate images correspond one-to-one to the blur kernels, and the candidate images are obtained by processing the blurred image based on the corresponding blur kernels;

[0035] a parameter acquisition module, configured to acquire, for each candidate image, a first parameter corresponding to the candidate image based on the candidate image and the blurred image, wherein the first parameter includes an image peak signal-to-noise ratio;

[0036] The target blur kernel determining module is configured to determine a blur kernel corresponding to a target image as the target blur kernel, wherein the target image is a candidate image corresponding to the minimum value of the first parameter.

[0037] Optionally, the parameter acquisition module includes a first parameter acquisition unit and a first parameter determination unit;

[0038] A first parameter acquisition unit, configured to acquire a mean square error between the candidate image and the blurred image;

[0039] The first parameter determining unit is configured to determine a first parameter corresponding to the candidate image according to a mean square error between the candidate image and the blurred image.

[0040] Optionally, the image processing device further includes a blur degree determination module.

[0041] The blur degree determination module is used to determine the blur degree of the blurred image according to the first parameters corresponding to each candidate image in the candidate image group and the blurred image.

[0042] Optionally, the blur degree determination module includes an average value obtaining unit and a blur degree determination unit;

[0043] an average value calculating unit, configured to calculate an average value of the first parameters corresponding to the blurred image and each candidate image in the candidate image group;

[0044] The blur degree determining unit is used to determine the blur degree of the blurred image according to the average value.

[0045] Optionally, also include:

[0046] An image processing module is configured to perform deblurring processing on the blurred image based on the target blur kernel.

[0047] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:

[0048] one or more processors;

[0049] a storage device for storing one or more programs,

[0050] When the one or more programs are executed by the one or more processors, the one or more processors implement any method as described in the first aspect.

[0051] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any method described in the first aspect.

[0052] The technical solution provided by the embodiments of the present disclosure has the following advantages over the prior art:

[0053] The image processing method, device, electronic device and storage medium provided by the embodiments of the present disclosure obtain a blurred image, process the blurred image based on a blur kernel matrix to obtain a candidate image group, wherein the blur kernel matrix includes multiple different blur kernels, the candidate image group includes multiple different candidate images, the candidate images correspond one-to-one to the blur kernels, and the candidate images are obtained by processing the blurred image based on the corresponding blur kernel; for each candidate image, based on the candidate image and the blurred image, a first parameter corresponding to the candidate image is obtained, wherein the first parameter includes an image peak signal-to-noise ratio; the blur kernel corresponding to the target image is determined as the target blur kernel, wherein the target image is the candidate image corresponding to the minimum value of the first parameter; by performing matrix operations on the blur kernel in the blur kernel matrix and the blurred image, the effects of different blur kernels in the blur kernel matrix on the blurred image are analyzed, the image peak signal-to-noise ratio is used to measure the difference between the candidate image and the blurred image after the blur kernel is applied, the candidate image corresponding to the minimum image peak signal-to-noise ratio is selected, and the target blur kernel is determined. The target blur kernel determined in this way is more reasonable, so that the blur type of the image can be determined more accurately. In an optional embodiment of the present disclosure, further, the blurred image may be deblurred based on the target blur kernel to improve the speed and accuracy of the image deblurring process. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0055] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0056] Figure 1 is a flowchart of an image processing method provided by an embodiment of the present disclosure;

[0057] Figure 2 is a flowchart of another image processing method provided by an embodiment of the present disclosure;

[0058] Figure 3 is a flowchart of another image processing method provided by an embodiment of the present disclosure;

[0059] Figure 4 is a flowchart of another image processing method provided by an embodiment of the present disclosure;

[0060] Figure 5 is a structural diagram of an image processing device provided by an embodiment of the present disclosure;

[0061] Figure 6 It is a structural diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0062] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features therein can be combined with each other in the absence of conflict.

[0063] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0064] The technical solution disclosed in the present invention can be applied to electronic devices, wherein the electronic devices can be computers, tablets, mobile phones or other intelligent terminal devices, etc. The electronic device has a display screen, wherein the display screen can be a touch screen or a non-touch screen. For electronic devices with a touch screen, users can interact with the electronic device through gestures, fingers or touch tools (for example, a stylus). For electronic devices without a touch screen, interaction with the electronic device can be achieved through external devices (for example, a mouse, keyboard or camera, etc.) or voice recognition or expression recognition. The image processing method disclosed in the present invention is executed by an electronic device.

[0065] The present disclosure does not limit the type of operating system of the electronic device, for example, Android system, Linux system, Windows system, iOS system, etc.

[0066] Figure 1 This is a flowchart of an image processing method provided by an embodiment of the present disclosure. This embodiment is applicable to image processing. The method of this embodiment can be executed by an image processing device. This device can be implemented using hardware or software and can be configured in an electronic device to implement the image processing method described in any embodiment of this application.

[0067] The prior art generally uses an alternating solution method to estimate the blur kernel and the clear image separately. This involves first roughly estimating the image's blur kernel k, then performing non-blind deconvolution on the image using the initially estimated blur kernel k to estimate the intermediate clear image x. Repeatedly iterating and alternating the estimation of the blur kernel and the clear image ultimately yields an approximate solution that approximates the true clear image. However, when the input image contains or has dark pixels, these dark pixels can affect the speed and accuracy of deblurring the image. To ensure both speed and accuracy in image deblurring, the present disclosure provides an image processing method.

[0068] like Figure 1 As shown, the method specifically includes the following:

[0069] S10: Obtain a blurred image.

[0070] During image capture, image quality often degrades, resulting in blurred images due to various unavoidable factors, such as subject motion, equipment quality, and camera shake. This information loss can severely hinder the ability to read important information in the image, such as text and faces. The image processing method provided in the present embodiment first captures blurred images caused by these unavoidable factors.

[0071] S20. Process the blurred image based on the blur kernel matrix to obtain a candidate image group.

[0072] The blur kernel matrix includes multiple different blur kernels, the candidate image group includes multiple different candidate images, the candidate images correspond to the blur kernels one by one, and the candidate images are obtained by processing the blurred images based on the corresponding blur kernels.

[0073] Specifically, common blur kernels include: Gaussian blur kernel B1, box blur kernel B2, double blur kernel B3, bokeh blur kernel B4, motion blur kernel B5, focus blur kernel B6, radial blur kernel B7 and motion blur kernel B8. The blur kernel matrix B = {B1, B2, ..., B8} composed of different blur kernels.

[0074] For example, Gaussian blur kernel

[0075] Box Blur Kernel

[0076] After constructing the blur kernel matrix, in the specific process of processing the blurred image based on the blur kernel matrix to obtain a candidate image group, the blur kernel in the blur kernel matrix is ​​used to process the blurred image to obtain a candidate image corresponding to the blur kernel. For example, the candidate image processed by Gaussian blur kernel B1 is A1, the candidate image processed by Gaussian blur kernel B2 is A2, the candidate image processed by Gaussian blur kernel B3 is A3, the candidate image processed by Gaussian blur kernel B4 is A4, the candidate image processed by Gaussian blur kernel B5 is A5, the candidate image processed by Gaussian blur kernel B6 is A6, the candidate image processed by Gaussian blur kernel B7 is A7, and the candidate image processed by Gaussian blur kernel B8 is A8, then the candidate image group A = {A1, A2, ..., A8}.

[0077] S30 . For each candidate image, obtain a first parameter corresponding to the candidate image according to the candidate image and the blurred image.

[0078] The first parameter includes the image peak signal-to-noise ratio (PSNR).

[0079] After the blurred image is processed based on the blur kernel matrix to obtain a candidate image group, for each candidate image, according to the candidate image and the blurred image, the specific process of obtaining the first parameter corresponding to the candidate image is as follows: the candidate image after processing by the Gaussian blur kernel B1 is A1. At this time, the pixel value at the position (i, j) in the candidate image A1 is represented by K1(i, j), and the pixel value at the position (i, j) in the blurred image corresponding to the candidate image A1 is represented by I(i, j). The first parameter PSNR1 corresponding to the candidate image A1 and the blurred image is obtained through matrix operation. Similarly, the candidate image after being processed by the Gaussian blur kernel B2 is A2. At this time, the pixel value at the position (i, j) in the candidate image A2 is represented by K2(i, j), and the pixel value at the position (i, j) in the blurred image corresponding to the candidate image A2 is represented by I(i, j). The first parameter PSNR2 corresponding to the candidate image A2 and the blurred image is obtained through matrix operation. Similarly, the first parameter PSNR3 corresponding to the candidate image A3 processed by the blur kernel B3 and the blurred image is obtained, the first parameter PSNR4 corresponding to the candidate image A4 processed by the blur kernel B4 and the blurred image is obtained, the first parameter PSNR5 corresponding to the candidate image A5 processed by the blur kernel B5 and the blurred image is obtained, the first parameter PSNR6 corresponding to the candidate image A6 processed by the blur kernel B6 and the blurred image is obtained, the first parameter PSNR7 corresponding to the candidate image A7 processed by the blur kernel B7 and the first parameter PSNR8 corresponding to the candidate image A8 processed by the blur kernel B8 are obtained.

[0080] It should be noted that the pixel value at the position (i, j) in the candidate image A1 refers to the pixel value of the pixel point corresponding to the i-th row and j-th column in the candidate image A1.

[0081] S40: Determine the blur kernel corresponding to the target image as the target blur kernel.

[0082] In an embodiment of the present application, the blur kernel can be used to indicate the blur type. Through the method of the embodiment of the present application, the blur type of the image can be determined more accurately, thereby facilitating targeted processing according to the blur type, such as deblurring processing or changing the blur type, etc. This application does not limit the subsequent processing.

[0083] The target image is the candidate image corresponding to the minimum value of the first parameter.

[0084] After obtaining the first parameters corresponding to each candidate image and the blurred image in the candidate image group, the candidate image corresponding to the minimum value of the first parameters is selected as the target image, and the blur kernel corresponding to the target image is selected as the target blur kernel. The specific process is as follows: if the first parameter PSNR1 corresponding to the blurred image of candidate image A1, the first parameter PSNR2 corresponding to the blurred image of candidate image A2, the first parameter PSNR3 corresponding to the blurred image of candidate image A3, the first parameter PSNR4 corresponding to the blurred image of candidate image A4, the first parameter PSNR5 corresponding to the blurred image of candidate image A5, the first parameter PSNR6 corresponding to the blurred image of candidate image A6, the first parameter PSNR7 corresponding to the blurred image of candidate image A7, and the first parameter PSNR8 corresponding to the blurred image of candidate image A8 are obtained, by analyzing and calculating the sizes of the first parameters corresponding to the obtained candidate images and the blurred images, the candidate image corresponding to the minimum value of the first parameters is selected as the target image, and the blur kernel corresponding to the target image is used as the target blur kernel.

[0085] For example, if among the first parameter PSNR1 corresponding to the candidate image A1 and the blurred image, the first parameter PSNR2 corresponding to the candidate image A2 and the blurred image, the first parameter PSNR3 corresponding to the candidate image A3 and the blurred image, the first parameter PSNR4 corresponding to the candidate image A4 and the blurred image, the first parameter PSNR5 corresponding to the candidate image A5 and the blurred image, the first parameter PSNR6 corresponding to the candidate image A6 and the blurred image, the first parameter PSNR7 corresponding to the candidate image A7 and the blurred image, and the first parameter PSNR8 corresponding to the candidate image A8 and the blurred image, the first parameter PSNR2 value is the smallest, so the target image is candidate image A2, and the blur kernel B2 corresponding to candidate image A2 is selected as the target blur kernel.

[0086] Optionally, the method further includes: performing deblurring processing on the blurred image based on a target blur kernel.

[0087] The mathematical model of image deblurring can be expressed as: y = k*x + n, where y represents the input blurred image, x represents the clear image to be restored (original image), n represents random Gaussian noise, k represents the blur kernel, also known as the point spread function, which represents the diffusion process of a pixel along a certain motion trajectory, and * represents the convolution operation.

[0088] Based on the mathematical model of image deblurring, after determining the target blur kernel, the blurred image is deblurred by the target blur kernel to obtain the target image, that is, to obtain x.

[0089] It should be noted that the above embodiment exemplifies that the blur kernel matrix includes 8 blur kernels, and the candidate image group obtained after the blur kernel matrix processing includes 8 candidate images. In other possible implementation modes, the number of blur kernels in the blur kernel matrix is ​​not limited, and therefore the number of candidate images in the candidate image group after the blur kernel matrix processing is also not limited, that is, the number of candidate images in the candidate image group corresponds to the number of blur kernels in the blur kernel matrix.

[0090] The image processing method provided by the embodiment of the present disclosure obtains a blurred image, processes the blurred image based on a blur kernel matrix to obtain a candidate image group, wherein the blur kernel matrix includes multiple different blur kernels, the candidate image group includes multiple different candidate images, the candidate images correspond to the blur kernels one-to-one, and the candidate images are obtained by processing the blurred image based on the corresponding blur kernel; for each candidate image, based on the candidate image and the blurred image, obtains a first parameter corresponding to the candidate image, wherein the first parameter includes an image peak signal-to-noise ratio; determines the blur kernel corresponding to the target image as the target blur kernel, wherein the target image is the candidate image corresponding to the minimum value of the first parameter; by performing matrix operations on the blur kernel in the blur kernel matrix and the blurred image, analyzing the effects of different blur kernels in the blur kernel matrix on the blurred image, using the image peak signal-to-noise ratio to measure the difference between the candidate image and the blurred image after the blur kernel is applied, selecting the candidate image corresponding to the minimum image peak signal-to-noise ratio, and determining the target blur kernel, wherein the target blur kernel determined in this way is more reasonable; further, deblurring the blurred image based on the target blur kernel, thereby improving the speed and accuracy of the image deblurring process.

[0091] Figure 2 This is a flow chart of another image processing method provided by an embodiment of the present disclosure. This embodiment is based on the above embodiment, wherein one possible implementation of step S30 is as follows: Figure 2 As shown:

[0092] S31. Obtain the mean square error between the candidate image and the blurred image.

[0093] Specifically, according to Obtain the mean square error between the candidate image and the blurred image;

[0094] Among them, MSE x represents the mean square error of the x-th candidate image in the candidate image group, mn represents the pixel of the blurred image m×n, I(i,j) represents the pixel value at the position (i,j) of the blurred image, K x (i, j) represents the pixel value at position (i, j) of the x-th candidate image in the candidate image group.

[0095] The blurred image is processed using the blur kernel in the blur kernel matrix to obtain a candidate image corresponding to the blur kernel. For example, the candidate image processed by Gaussian blur kernel B1 is A1, the candidate image processed by Gaussian blur kernel B2 is A2, the candidate image processed by Gaussian blur kernel B3 is A3, the candidate image processed by Gaussian blur kernel B4 is A4, the candidate image processed by Gaussian blur kernel B5 is A5, the candidate image processed by Gaussian blur kernel B6 is A6, the candidate image processed by Gaussian blur kernel B7 is A7, and the candidate image processed by Gaussian blur kernel B8 is A8. Then the candidate image group A = {A1, A2, ..., A8}.

[0096] Then, the above formula is used to calculate the mean square error MSE1 corresponding to the candidate image A1 and the blurred image, the mean square error MSE2 corresponding to the candidate image A2 and the blurred image, the mean square error MSE3 corresponding to the candidate image A3 and the blurred image, the mean square error MSE4 corresponding to the candidate image A4 and the blurred image, the mean square error MSE5 corresponding to the candidate image A5 and the blurred image, the mean square error MSE6 corresponding to the candidate image A6 and the blurred image, the mean square error MSE7 corresponding to the candidate image A7 and the blurred image, and the mean square error MSE8 corresponding to the candidate image A8 and the blurred image.

[0097] S32. Determine a first parameter corresponding to the candidate image according to a mean square error between the candidate image and the blurred image.

[0098] Specifically, according to Determining a first parameter corresponding to each candidate image in the candidate image group;

[0099] Among them, PSNR x represents the first parameter of the x-th candidate image in the candidate image group, Indicates the maximum pixel value.

[0100] When the blurred image has 8-bit sampling points, The value of is 255, and the blurred image corresponds to different numbers of sampling points. The values ​​represented are different.

[0101] The first parameter corresponding to each candidate image in the candidate image group is calculated by the above formula, that is, the first parameter PSNR1 corresponding to the candidate image A1 processed by the blur kernel B1 and the blurred image, the first parameter PSNR2 corresponding to the candidate image A2 processed by the blur kernel B2 and the blurred image, the first parameter PSNR3 corresponding to the candidate image A3 processed by the blur kernel B3 and the blurred image are calculated in sequence by the formula, the first parameter PSNR4 corresponding to the candidate image A4 processed by the blur kernel B4 and the blurred image are obtained, the first parameter PSNR5 corresponding to the candidate image A5 processed by the blur kernel B5 and the blurred image are obtained, the first parameter PSNR6 corresponding to the candidate image A6 processed by the blur kernel B6 and the blurred image are obtained, the first parameter PSNR7 corresponding to the candidate image A7 processed by the blur kernel B7 and the first parameter PSNR8 corresponding to the candidate image A8 processed by the blur kernel B8 and the blurred image are obtained.

[0102] The image processing method provided by the embodiment of the present disclosure obtains the mean square error corresponding to each candidate image in the candidate image group and the blurred image, determines the first parameter corresponding to each candidate image in the candidate image group based on the mean square error corresponding to each candidate image and the blurred image, and then determines the target blur kernel based on the first parameter corresponding to each candidate image in the candidate image group to perform blurring processing on the blurred image, thereby improving the speed of image deblurring.

[0103] Figure 3 is a flowchart of another image processing method provided by an embodiment of the present disclosure. Figure 3 Based on the above embodiments, Figure 3 As shown, after step S30, the following steps are further included:

[0104] S301 : Determine the blur degree of the blurred image according to a first parameter corresponding to each candidate image in the candidate image group and the blurred image.

[0105] Specifically, determining the blur degree of the blurred image according to the first parameter corresponding to each candidate image in the candidate image group and the blurred image includes:

[0106] according to An average value is calculated for the first parameters corresponding to each candidate image in the candidate image group and the blurred image.

[0107] The candidate image processed by Gaussian blur kernel B1 is A1, the candidate image processed by Gaussian blur kernel B2 is A2, the candidate image processed by Gaussian blur kernel B3 is A3, the candidate image processed by Gaussian blur kernel B4 is A4, the candidate image processed by Gaussian blur kernel B5 is A5, the candidate image processed by Gaussian blur kernel B6 is A6, the candidate image processed by Gaussian blur kernel B7 is A7, and the candidate image processed by Gaussian blur kernel B8 is A8, then the candidate image group A = {A1, A2, ..., A8}. In the candidate image group A = {A1, A2, ..., A8}, the first parameter corresponding to the blurred image of candidate image A1 is PSNR1, the first parameter corresponding to the blurred image of candidate image A2 is PSNR2, the first parameter corresponding to the blurred image of candidate image A3 is PSNR3, the first parameter corresponding to the blurred image of candidate image A4 is PSNR4, the first parameter corresponding to the blurred image of candidate image A5 is PSNR5, the first parameter corresponding to the blurred image of candidate image A6 is PSNR6, the first parameter corresponding to the blurred image of candidate image A7 is PSNR7, and the first parameter corresponding to the blurred image of candidate image A8 is PSNR8.

[0108] According to the formula It can be seen that:

[0109]

[0110] in, represents the average value of the first parameter corresponding to each candidate image in the candidate image group, and y represents the number of blur kernels in the blur kernel matrix.

[0111] Determines how much to blur the blurred image based on the average value.

[0112] In getting After that, The blur degree of the blurred image.

[0113] The image processing method provided by the embodiment of the present disclosure determines the blur degree of the blurred image based on the first parameter corresponding to each candidate image in the candidate image group and the blurred image, and determines the blur degree of the blurred image through the blur kernel matrix. Compared with the existing technology of evaluating the blur degree of the image based on the image gradient or variance function, the image processing method provided by the embodiment of the present disclosure is simpler in determining the blur degree of the image.

[0114] Figure 4 This is a flow chart of another image processing method provided by an embodiment of the present disclosure. This embodiment is based on the above embodiment. Figure 4 Said, one possible implementation of step S20 is:

[0115] S21. For each blur kernel, traverse the sub-image blocks of the blurred image. The size of each sub-image block is the same as the size of the blur kernel. Perform corresponding point multiplication on the pixel points of each sub-image block and the elements of the blur kernel to obtain the candidate pixel points of the sub-image block. Based on the candidate pixel points of all sub-image blocks, all pixel points of the candidate image corresponding to the blur kernel are obtained.

[0116] Specifically, the specific process of using the Gaussian blur kernel to process the blurred image is as follows: if the blurred image is 100×100 pixels and the Gaussian blur kernel is a 5×5 matrix, the blurred image is divided into 20 sub-image blocks of the same size as the blur kernel, and each sub-image block includes 5×5 pixels. The candidate pixels of the sub-image block are obtained by performing corresponding dot multiplication of the pixels of each sub-image block with the elements of the Gaussian blur kernel B1, that is, 20 sub-image blocks after dot multiplication with the elements of the Gaussian blur kernel B1 are obtained, and all pixels of the candidate image corresponding to the Gaussian blur kernel B1 are obtained according to the candidate pixels in the 20 sub-image blocks.

[0117] It should be noted that the above embodiment exemplarily indicates that the blurred image is 100×100 pixels and the Gaussian blur kernel is a 5×5 matrix. At this time, the blurred image is divided into 20 sub-image blocks of the same size as the blur kernel. When the blurred image is 100×100 pixels and the Gaussian blur kernel is a 5×5 matrix, the blurred image is divided into 20 sub-image blocks of the same size as the blur kernel. When the blurred image is 101×101 pixels and the Gaussian blur kernel is a 5×5 matrix, the blurred image is divided into 20 sub-image blocks of the same size as the blur kernel. In addition, the number of the remaining 1 row of pixels and 1 column of pixels cannot meet the dot product with the blur kernel. At this time, by supplementing 4 rows and 4 columns of pixels, and the pixel values ​​of these 4 rows and 4 columns of pixels are 0, the remaining 1 row of pixels and 1 column of pixels are combined with the supplemented pixels to form a pixel matrix to achieve dot product with the blur kernel.

[0118] Figure 5 is a structural diagram of an image processing device provided by an embodiment of the present disclosure, such as Figure 5 As shown, the image processing device includes:

[0119] A blurred image acquisition module 410 is used to acquire a blurred image;

[0120] a blurred image processing module 420 configured to process the blurred image based on a blur kernel matrix to obtain a candidate image group, wherein the blur kernel matrix includes a plurality of different blur kernels, the candidate image group includes a plurality of different candidate images, and the candidate images correspond one-to-one to the blur kernels. The candidate images are obtained by processing the blurred image based on the corresponding blur kernels;

[0121] The parameter acquisition module 430 is configured to acquire, for each candidate image, a first parameter corresponding to the candidate image based on the candidate image and the blurred image, wherein the first parameter includes an image peak signal-to-noise ratio;

[0122] The target blur kernel determining module 440 is configured to determine a blur kernel corresponding to a target image as the target blur kernel, wherein the target image is the candidate image corresponding to the minimum value of the first parameter.

[0123] The image processing device provided by the embodiment of the present disclosure comprises: a blurred image acquisition module acquiring a blurred image; a blurred image processing module processing the blurred image based on a blur kernel matrix to obtain a candidate image group, wherein the blur kernel matrix includes a plurality of different blur kernels, the candidate image group includes a plurality of different candidate images, the candidate images correspond one-to-one to the blur kernels, and the candidate images are obtained by processing the blurred images based on the corresponding blur kernels; a parameter acquisition module acquiring, for each candidate image, a first parameter corresponding to the candidate image based on the candidate image and the blurred image, wherein the first parameter includes an image peak signal-to-noise ratio; a target blur kernel determination module determining the blur kernel corresponding to the target image as the target blur kernel, wherein the target image is the candidate image corresponding to the minimum value of the first parameter; by performing matrix operations on the blur kernel in the blur kernel matrix and the blurred image, analyzing the effects of different blur kernels in the blur kernel matrix on the blurred image, using the image peak signal-to-noise ratio to measure the difference between the candidate image and the blurred image after the blur kernel is applied, selecting the candidate image corresponding to the minimum image peak signal-to-noise ratio, and determining the target blur kernel, the target blur kernel determined in this manner is more reasonable.

[0124] Optionally, the parameter acquisition module includes a first parameter acquisition unit and a first parameter determination unit.

[0125] A first parameter acquisition unit is used to obtain the mean square error corresponding to the candidate image and the blurred image;

[0126] The first parameter determination unit is configured to determine a first parameter corresponding to each candidate image according to a mean square error between each candidate image and the blurred image.

[0127] Optionally, the image processing device further includes a blur degree determination module.

[0128] The blur degree determination module is used to determine the blur degree of the blurred image according to the first parameters corresponding to the blurred images of each candidate image in the candidate image group.

[0129] Optionally, the blur level determination module includes an average value obtaining unit and a blur level determination unit.

[0130] an average value calculating unit, configured to calculate an average value of the first parameters corresponding to each candidate image in the candidate image group and the blurred image;

[0131] The blur degree determining unit is used to determine the blur degree of the blurred image according to the average value.

[0132] Optionally, also include:

[0133] The target image acquisition module is used to deblur the blurred image based on the target blur kernel.

[0134] The device provided by the embodiment of the present invention can execute the method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0135] Figure 6 is a structural diagram of an electronic device provided by an embodiment of the present disclosure, such as Figure 6 As shown, the electronic device includes a processor 610, a memory 620, an input device 630, and an output device 640; the number of processors 610 in the computer device can be one or more. Figure 6 In the figure, a processor 610 is used as an example; the processor 610, memory 620, input device 630 and output device 640 in the electronic device can be connected via a bus or other means. Figure 6 The bus connection is taken as an example.

[0136] Memory 620, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as program instructions / modules corresponding to the methods in the embodiments of the present invention. Processor 610 executes the software programs, instructions, and modules stored in memory 620 to perform various functional applications and data processing of the computer device, thereby implementing the methods provided in the embodiments of the present invention.

[0137] The memory 620 may primarily include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function; the data storage area may store data created based on the use of the terminal, etc. Furthermore, the memory 620 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state memory device. In some instances, the memory 620 may further include memory remotely located relative to the processor 610, and these remote memories may be connected to the computer device via a network. Examples of the aforementioned networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0138] The input device 630 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the electronic device, and may include a keyboard, a mouse, etc. The output device 640 may include a display device such as a display screen.

[0139] The embodiments of the present disclosure further provide a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to implement the method provided by the embodiments of the present disclosure.

[0140] Of course, the computer executable instructions of a storage medium containing computer executable instructions provided by an embodiment of the present invention are not limited to the operations of the method described above, and can also execute related operations in the method provided by any embodiment of the present invention.

[0141] Through the above description of the implementation methods, those skilled in the art can clearly understand that the present invention can be implemented with the help of software and necessary general-purpose hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0142] It is worth noting that in the embodiment of the above-mentioned protection device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.

[0143] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.

[0144] The foregoing description is intended only to provide specific embodiments of the present disclosure, intended to enable those skilled in the art to understand and implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the embodiments described herein, but rather to be construed in the broadest manner consistent with the principles and novel features disclosed herein.

Claims

1. An image processing method, characterized in that: include: Get the blurred image; Processing the blurred image based on a blur kernel matrix to obtain a candidate image group, wherein the blur kernel matrix includes a plurality of different blur kernels, each of which is used to indicate a blur type, and the candidate image group includes a plurality of different candidate images, each of which corresponds to the blur kernel in a one-to-one manner, and each candidate image is obtained by processing the blurred image based on the corresponding blur kernel; For each candidate image, obtaining a first parameter corresponding to the candidate image according to the candidate image and the blurred image, wherein the first parameter includes an image peak signal-to-noise ratio; Determine a blur kernel corresponding to a target image as a target blur kernel, wherein the target image is a candidate image corresponding to a minimum value of the first parameter; Deblurring the blurred image based on the target blur kernel.

2. The method according to claim 1, characterized in that The acquiring, according to the candidate image and the blurred image, a first parameter corresponding to the candidate image includes: Obtaining a mean square error between the candidate image and the blurred image; A first parameter corresponding to the candidate image is determined according to a mean square error between the candidate image and the blurred image.

3. The method according to claim 2, characterized in that The obtaining the mean square error between the candidate image and the blurred image includes: according to , obtaining the mean square error corresponding to the candidate image and the blurred image; in, Indicates the first The mean square error of candidate images, The blurred image is represented by pixels, Represents a blurred image The pixel value at position, Indicates the first candidate images The pixel value at location.

4. The method according to claim 3, characterized in that The determining the first parameter corresponding to the candidate image according to the mean square error between the candidate image and the blurred image includes: according to , determining a first parameter corresponding to each candidate image in the candidate image group; in, Indicates the first The first parameter of the candidate image, Indicates the maximum pixel value.

5. The method according to claim 1, wherein After obtaining the first parameter corresponding to the candidate image according to the candidate image and the blurred image, the method further includes: The blur degree of the blurred image is determined according to first parameters corresponding to each candidate image in the candidate image group and the blurred image.

6. The method according to claim 5, characterized in that The determining the blur degree of the blurred image according to the first parameters corresponding to each candidate image in the candidate image group and the blurred image respectively includes: averaging the first parameters corresponding to each candidate image in the candidate image group and the blurred image; The blur degree of the blurred image is determined according to the average value.

7. The method according to claim 6, characterized in that The averaging of the first parameters corresponding to each candidate image in the candidate image group and the blurred image includes: according to , calculating an average value of the first parameters corresponding to each candidate image in the candidate image group and the blurred image; in, represents the average value of the first parameter corresponding to each candidate image in the candidate image group, and y represents the number of blur kernels in the blur kernel matrix.

8. The method according to any one of claims 1 to 7, characterized in that The step of processing the blurred image based on the blur kernel matrix to obtain a candidate image group includes: For each blur kernel, traverse the sub-image blocks of the blurred image, where the size of each sub-image block is the same as the size of the blur kernel. Perform corresponding point multiplication on the pixels of each sub-image block and the elements of the blur kernel to obtain the candidate pixels of the sub-image block. Based on the candidate pixels of all sub-image blocks, obtain all the pixels of the candidate image corresponding to the blur kernel.

9. An image processing device, characterized in that: include: A blurred image acquisition module, used for acquiring a blurred image; a blurred image processing module, configured to process the blurred image based on a blur kernel matrix to obtain a candidate image group, wherein the blur kernel matrix includes a plurality of different blur kernels, each of which is used to indicate a blur type, and the candidate image group includes a plurality of different candidate images, each of which corresponds to the blur kernel in a one-to-one manner, and each candidate image is obtained by processing the blurred image based on the corresponding blur kernel; a parameter acquisition module, configured to acquire, for each candidate image, a first parameter corresponding to the candidate image based on the candidate image and the blurred image, wherein the first parameter includes an image peak signal-to-noise ratio; a target blur kernel determining module, configured to determine a blur kernel corresponding to a target image as a target blur kernel, wherein the target image is a candidate image corresponding to a minimum value of the first parameter; The target image acquisition module is used to deblur the blurred image based on the target blur kernel.

10. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 8.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Method and device for removing motion blur of image

    CN110490822A

  • Image deblurring method and device and electronic equipment

    CN111275625A