Image processing method, device, electronic device, and computer-readable storage medium

By obtaining gyroscope data to determine the movement trajectory and diffuse circular spot of the image sensor, the motion blur problem of electronic devices during high-magnification shooting is solved, clearer image processing effects are achieved, and hardware costs are reduced.

CN115375566BActive Publication Date: 2025-09-09GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202210956372.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-10
Publication Date
2025-09-09
Estimated Expiration
2042-08-10

AI Technical Summary

Technical Problem

In the existing technology, it is difficult to effectively solve the motion blur caused by hand shaking and low-light environment when shooting at high magnification with electronic devices such as mobile phones, and the image clarity obtained by traditional image processing methods is not high.

Method used

By acquiring gyroscope data, the target movement trajectory and diffuse circular spot of the image sensor are determined. Based on these data, the target blur kernel is determined, and the Patch-wise deconvolution algorithm is used for deblurring.

Benefits of technology

It improves image clarity, reduces hardware costs, and removes motion blur more accurately than traditional OIS methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115375566B_ABST
    Figure CN115375566B_ABST
Patent Text Reader

Abstract

This application relates to an image processing method, apparatus, electronic device, storage medium, and computer program product. The method includes: capturing a first image and obtaining gyroscope data via an image sensor in an electronic device; determining a target movement trajectory of the image sensor based on the gyroscope data; determining a diffuse circular spot on the image sensor's imaging surface based on the target movement trajectory; the diffuse circular spot is generated by the electronic device moving in the target direction; determining a target blur kernel on the image sensor's imaging surface based on the target movement trajectory and the diffuse circular spot; and deblurring the first image using the target blur kernel to obtain a second image. This method can improve image processing accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] With the development of modern optical technology, electronic devices often have micro-magnification functions, which can more conveniently help people observe the microscopic world. Common electronic devices, such as mobile phones, usually do not have zoom functions. Because the magnification and focus distance are fixed, close-up shooting is often required to obtain clear images. During the shooting process, due to the high magnification of the mobile phone, even slight hand shaking can cause the image in the field of view to shift. On the other hand, due to the close shooting distance, the intensity of the external light source is weak, which will lead to an increase in shutter speed. Due to the dual effects of hand shaking and increased exposure time, the captured image is very easy to become blurred. This special motion blur is affected by the hardware itself, is more prone to motion blur than conventional mobile phone lenses, and is difficult to resolve.

[0003] Traditional image processing methods typically use a motion blur kernel estimated from the exposure time to deblur the resulting blurred image. This kernel is then used for image deconvolution to deblur the image. However, these traditional image processing methods still produce images with low clarity. Summary of the Invention

[0004] The embodiments of the present application provide an image processing method, apparatus, electronic device, computer-readable storage medium, and computer program product, which can improve the accuracy of obtaining a blur kernel and thereby obtain a clearer image.

[0005] In a first aspect, the present application provides an image processing method. The method comprises:

[0006] Capturing a first image through an image sensor in an electronic device and obtaining gyroscope data;

[0007] determining a target movement trajectory of the image sensor based on the gyroscope data;

[0008] Determining a diffuse circular spot on the imaging surface of the image sensor according to the target movement trajectory; the diffuse circular spot is generated by the electronic device moving in the target direction;

[0009] Determining a target blur kernel on an imaging surface of the image sensor based on the target movement trajectory and the diffuse circular spot;

[0010] Deblurring the first image using the target blur kernel to obtain a second image.

[0011] In a second aspect, the present application further provides an image processing device. The device comprises:

[0012] an acquisition module, configured to capture a first image through an image sensor in the electronic device and obtain gyroscope data;

[0013] a trajectory determination module, configured to determine a target movement trajectory of the image sensor based on the gyroscope data;

[0014] a diffuse circular spot determination module, configured to determine a diffuse circular spot on the imaging surface of the image sensor according to the target movement trajectory; the diffuse circular spot is generated when the electronic device moves in the target direction;

[0015] a blur kernel determining module, configured to determine a target blur kernel on an imaging surface of the image sensor based on the target movement trajectory and the diffuse circular spot;

[0016] The deblurring processing module is configured to perform deblurring processing on the first image using the target blur kernel to obtain a second image.

[0017] In a third aspect, the present application further provides an electronic device. The electronic device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are performed:

[0018] Capturing a first image through an image sensor in an electronic device and obtaining gyroscope data;

[0019] determining a target movement trajectory of the image sensor based on the gyroscope data;

[0020] Determining a diffuse circular spot on the imaging surface of the image sensor according to the target movement trajectory; the diffuse circular spot is generated by the electronic device moving in the target direction;

[0021] Determining a target blur kernel on an imaging surface of the image sensor based on the target movement trajectory and the diffuse circular spot;

[0022] Deblurring the first image using the target blur kernel to obtain a second image.

[0023] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the following steps:

[0024] Capturing a first image through an image sensor in an electronic device and obtaining gyroscope data;

[0025] determining a target movement trajectory of the image sensor based on the gyroscope data;

[0026] Determining a diffuse circular spot on the imaging surface of the image sensor according to the target movement trajectory; the diffuse circular spot is generated by the electronic device moving in the target direction;

[0027] Determining a target blur kernel on an imaging surface of the image sensor based on the target movement trajectory and the diffuse circular spot;

[0028] Deblurring the first image using the target blur kernel to obtain a second image.

[0029] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the following steps:

[0030] Capturing a first image through an image sensor in an electronic device and obtaining gyroscope data;

[0031] determining a target movement trajectory of the image sensor based on the gyroscope data;

[0032] Determining a diffuse circular spot on the imaging surface of the image sensor according to the target movement trajectory; the diffuse circular spot is generated by the electronic device moving in the target direction;

[0033] Determining a target blur kernel on an imaging surface of the image sensor based on the target movement trajectory and the diffuse circular spot;

[0034] Deblurring the first image using the target blur kernel to obtain a second image.

[0035] The aforementioned image processing method, apparatus, electronic device, computer-readable storage medium, and computer program product capture a first image and obtain gyroscope data via an image sensor in an electronic device. Based on the gyroscope data, a target movement trajectory of the image sensor can be determined. Furthermore, based on the target movement trajectory, a diffuse circular spot on the image sensor imaging surface generated by the electronic device moving in a target direction can be determined. Therefore, based on the target movement trajectory and the diffuse circular spot generated by movement in the target direction, a target blur kernel on the image sensor imaging surface can be more accurately determined. This target blur kernel can then be used to more accurately deblur the first image, resulting in a clearer second image. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the embodiments of the present application 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, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0037] Figure 1 is a flowchart of an image processing method in one embodiment;

[0038] Figure 2 A schematic diagram of a diffuse circular spot generated by shaking an electronic device in a target direction according to an embodiment;

[0039] Figure 3 FIG. 1 is a schematic diagram of calculating a target blur kernel in one embodiment;

[0040] Figure 4 is a schematic diagram of a division method of an image sensor in one embodiment;

[0041] Figure 5 A schematic diagram of a diffuse circular spot generated by a preset imaging point in an image sensor during movement in one embodiment;

[0042] Figure 6 is a schematic diagram of a rectangular coordinate system centered on a gyroscope in one embodiment;

[0043] Figure 7 is a schematic diagram of a polar coordinate system centered on a gyroscope in one embodiment;

[0044] Figure 8 is a schematic diagram of blur kernels corresponding to various regions of an image in one embodiment;

[0045] Figure 9 is a flowchart of an image processing method in another embodiment;

[0046] Figure 10 is a structural block diagram of an image processing device in one embodiment;

[0047] Figure 11 FIG. 1 is a diagram showing the internal structure of an electronic device in one embodiment. DETAILED DESCRIPTION

[0048] In order to make the purpose, technical solutions and advantages of this application more clearly understood, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0049] In one embodiment, Figure 1As shown, an image processing method is provided. This embodiment uses the method applied to an electronic device as an example. The electronic device can be a terminal or a server. It can be understood that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. Among them, the terminal can be but is not limited to various personal computers, laptops, smart phones, tablets, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server can be implemented as an independent server or a server cluster consisting of multiple servers.

[0050] In this embodiment, the method includes the following steps 102 to 110.

[0051] Step 102: Capture a first image through an image sensor in an electronic device and obtain gyroscope data.

[0052] The electronic device includes a microscopic camera module, which includes an image sensor. The image sensor can convert light signals entering the electronic device into electrical signals and generate images. The microscopic camera module is an imaging system with a magnification of 0.5 times or more.

[0053] The electronic device also includes a gyroscope, through which gyroscope data can be obtained, wherein the gyroscope data includes angular acceleration and linear acceleration.

[0054] Optionally, the electronic device captures the first image through an image sensor and obtains gyroscope data corresponding to the first image.

[0055] Step 104 : Determine the target movement trajectory of the image sensor based on the gyroscope data.

[0056] The target movement trajectory of the image sensor refers to the trajectory generated by the movement of the image sensor during the process of capturing the first image.

[0057] It can be understood that the gyroscope data represents the movement of the gyroscope, and there is a relative spatial position relationship between the gyroscope and the image sensor. According to this relative spatial position relationship, the gyroscope data can be converted to obtain the motion data of the image sensor, and the target movement trajectory of the image sensor can be determined based on the motion data of the image sensor.

[0058] Optionally, based on the gyroscope data, the target movement trajectory of a preset imaging point in the image sensor is determined, wherein the preset imaging point can be the center point, edge point, or any preset point of the image sensor, etc., which is not limited here.

[0059] Step 106 : determining a diffuse circular spot on the imaging surface of the image sensor according to the target movement trajectory; the diffuse circular spot is generated when the electronic device moves in the target direction.

[0060] The intensity distribution of the diffraction image formed by a point light source (i.e., a star point) on different sections before and after the image plane after passing through the optical system is called a diffuse spot. A diffuse circular spot is a circular diffuse spot.

[0061] It is understandable that the depth of field of the microscope camera module is very shallow due to its magnification and focusing distance. Therefore, when the electronic device shakes in the target direction, the ideal imaging point will be diffused into a larger circular spot. Figure 2 As shown in the figure, when an electronic device shakes in the target direction during the shooting process, the relative position of the photographed object moves from point A to point B, resulting in a diffuse circular spot on the imaging surface of the electronic device's image sensor. Although the shaking in the target direction does not cause the blur kernel to move, it does change the size of the blur kernel.

[0062] The target direction is perpendicular to the imaging surface of the image sensor. For example, if the imaging surface of the image sensor is in the X direction and the Y direction, the target direction is the Z direction.

[0063] Step 108 : Determine the target blur kernel on the imaging surface of the image sensor based on the target movement trajectory and the diffuse circular spot.

[0064] A blur kernel is actually a matrix. Convolving a sharp image with the blur kernel results in a blurred image, hence the name blur kernel. A blur kernel is a type of convolution kernel, and image convolution is essentially a matrix convolution. In other words, image blurring can be viewed as the process of convolving a sharp image with the blur kernel to produce a blurred image.

[0065] Optionally, the electronic device determines a blur kernel of each track point in the target movement track based on the target movement track and the diffuse circular spot, and determines a target blur kernel on the imaging surface of the image sensor based on the blur kernel of each track point.

[0066] It can be understood that the target blur kernel not only takes into account the target movement trajectory of the image sensor, but also takes into account the diffuse circular spot on the imaging surface of the image sensor generated by the electronic device moving in the target direction, which can more accurately characterize the blur kernel generated by the electronic device moving in the target direction.

[0067] Step 110 : Deblurring the first image using a target blur kernel to obtain a second image.

[0068] Optionally, the electronic device may use a patch-wise deconvolution algorithm to deconvolve the first image using a target blur kernel to obtain a second image, wherein the second image has a higher definition than the first image.

[0069] The above-described image processing method uses an image sensor in an electronic device to capture a first image and obtain gyroscope data. This gyroscope data is used to estimate the target movement trajectory of the image sensor. Based on the target movement trajectory, the diffuse circular spot on the image sensor's imaging surface, generated by the electronic device moving in the target direction, is determined. Therefore, based on the target movement trajectory and the diffuse circular spot generated by movement in the target direction, a target blur kernel on the image sensor's imaging surface can be more accurately determined. This target blur kernel can then be used to more accurately deblur the first image, resulting in a clearer second image.

[0070] Furthermore, electronic devices can use existing gyroscopes to assist in image deblurring, which can save hardware costs compared to traditional OIS (Optical Image Stabilizer).

[0071] In one embodiment, Figure 3 As shown, the electronic device integrates the target's movement trajectory and diffuse circular spot during the exposure time to determine the target blur kernel on the image sensor imaging plane, i.e., the point spread function of the image sensor imaging plane. Exemplarily, the electronic device obtains the target's movement trajectory and diffuse circular spot from time t1, time t2, time t3, and time tn during the exposure time, and integrates them over time to obtain the target blur kernel on the image sensor imaging plane.

[0072] from Figure 3 It can be seen that directional movement on the image sensor's imaging surface causes the blur kernel's position to change, while movement in the target direction causes the blur kernel's size to change. Therefore, if the electronic device moves in the target direction, the target blur kernel can be used to determine the blur kernel distribution on the image sensor's imaging surface.

[0073] In one embodiment, a target blur kernel on an imaging surface of an image sensor is determined based on a target movement trajectory and a diffuse circular spot, including: determining a blur kernel for each trajectory point in the target movement trajectory based on the target movement trajectory and the diffuse circular spot; and determining a target blur kernel on the imaging surface of the image sensor based on the blur kernels of each trajectory point.

[0074] A trajectory point is a point in the target movement trajectory, and the lines between the trajectory points can generate the target movement trajectory.

[0075] Optionally, the electronic device determines each trajectory point and a diffuse circular spot corresponding to each trajectory point from the target movement trajectory; and adjusts each trajectory point to a size of the corresponding diffuse circular spot to obtain a blur kernel for each trajectory point.

[0076] The size of the diffuse spot includes information such as its diameter, radius, circumference, and area. The size of the diffuse spot reflects the size of the blur kernel. The size of the diffuse spot corresponding to each trajectory point can be the same or different.

[0077] Optionally, the electronic device integrates the blur kernels of each trajectory point within the exposure time to determine a target blur kernel on the imaging surface of the image sensor. Furthermore, the electronic device sums the blur kernels of each trajectory point and calculates the average value to obtain the target blur kernel on the imaging surface of the image sensor.

[0078] In this embodiment, the electronic device determines the blur kernel for each point in the target's trajectory based on the target's trajectory and the diffuse circular spot. This blur kernel, based on each point, more accurately determines the target blur kernel on the image sensor's imaging plane, avoiding errors introduced by the blur kernel of a single data point. Furthermore, the electronic device adjusts each point to the size of the corresponding diffuse circular spot, further accurately determining the blur kernel for each point and, consequently, a more accurate target blur kernel.

[0079] In one embodiment, the imaging surface of the image sensor is divided into at least one preset area; and the target movement trajectory of the image sensor is determined based on the gyroscope data, including: for each preset area, determining the target movement trajectory of the preset area on the imaging surface of the image sensor based on the gyroscope data.

[0080] The division method of the image sensor can be set as needed. Figure 4 As shown, if the aspect ratio of the image sensor is 4:3, the image sensor is divided into 16*12 preset areas.

[0081] It can be understood that the preset area in each image sensor is used for spatially non-uniform deconvolution. The target motion trajectory of the preset area of ​​each image sensor is different, and the corresponding target blur kernel is also different. Therefore, the corresponding target blur kernel is used to perform deblurring processing on each area in the first image to improve the clarity of the image.

[0082] Each preset area includes at least one preset imaging point. Optionally, for each preset imaging point in each preset area, a movement trajectory of each preset imaging point is determined based on gyroscope data; and based on the movement trajectory of each preset imaging point, a target movement trajectory of the preset area on the imaging surface of the image sensor is determined.

[0083] The position and number of the preset imaging points in each preset area can be set as needed. For example, the preset imaging point in the preset area can be the center point or edge point of the preset area.

[0084] If the preset area includes one preset imaging point, the electronic device may use the movement trajectory of the preset imaging point as the target movement trajectory for the area. If the preset area includes at least two preset imaging points, the electronic device may calculate the average of the movement trajectories of the preset imaging points and use the average as the target movement trajectory for the preset area.

[0085] It should be noted that if the preset area includes at least two preset imaging points, other methods may be used to determine the target movement trajectory of the preset area, such as weighted averaging, screening processing, etc., which are not limited here.

[0086] It can be understood that, for each preset area, based on the gyroscope data, the target movement trajectory of the preset area on the imaging surface of the image sensor is determined; according to the target movement trajectory of each preset area, the diffuse circular spot of each preset area on the imaging surface of the image sensor is determined; according to the target movement trajectory and the diffuse circular spot of each preset area, the target blur kernel of each preset area on the imaging surface of the image sensor is determined; and the target blur kernel of each preset area is used to deblur the corresponding area in the first image to obtain the second image.

[0087] In this embodiment, for each preset area, based on the gyroscope data, the target movement trajectory of the preset area on the imaging surface of the image sensor can be determined. Then, based on the target movement trajectory and the diffuse circular spot of each preset area, the target blur kernel of each preset area can be determined, so that the corresponding area in the first image can be deblurred to obtain a clearer second image for each area.

[0088] In one embodiment, determining the diffuse circular spot on the imaging surface of the image sensor according to the target movement trajectory includes: obtaining the movement distance of the image sensor in the target direction according to the target movement trajectory; and determining the diffuse circular spot on the imaging surface of the image sensor based on the movement distance.

[0089] Optionally, the electronic device obtains coordinate values ​​in the target direction from the target movement trajectory, and subtracts the coordinate values ​​to obtain the movement distance of the image sensor in the target direction.

[0090] Optionally, the electronic device obtains the coordinate value of each track point in the target direction from the target movement track, and subtracts the coordinate values ​​of two adjacent track points in the target direction to obtain the movement distance of each track point of the image sensor in the target direction.

[0091] Optionally, determining the diffuse circular spot on the imaging surface of the image sensor based on the moving distance includes: acquiring shooting parameters; determining the size of the diffuse circular spot based on the moving distance and the shooting parameters, and obtaining the diffuse circular spot on the imaging surface of the image sensor based on the size of the diffuse circular spot.

[0092] Shooting parameters are parameters used when shooting an image, including focal length, lens diameter, distance from the position of the object to the lens, image distance, etc.

[0093] Optionally, the electronic device determines the size of the diffuse circular spot, and the diffuse circular spot on the imaging surface of the image sensor can be obtained according to the size of the diffuse circular spot.

[0094] In one embodiment, combined with Figure 2 When the electronic device shakes in the target direction during the shooting process, the relative position of the object moves from point A to point B. A diffuse circular spot is generated on the imaging surface of the image sensor in the electronic device. The size of the diffuse circular spot is calculated using the following formula:

[0095]

[0096] μ B =μ A +Δz

[0097] Where δ is the diameter of the diffuse spot, μ B is the distance from point B to the lens, μ A is the distance from point A to the lens, f is the focal length, D is the diameter of the lens, and Δz is the distance the image sensor moves in the target direction. A The parameters are known, and the moving distance Δz of the image sensor in the target direction is obtained, then μ can be calculated. B Parameters, and then obtain the focal length and lens diameter, the diameter of the diffuse spot can be calculated.

[0098] For each preset imaging point in a preset area of ​​the image sensor, the blur kernel can be obtained using the above method. Figure 5 As shown, at time t0 within the exposure time, the coordinates of a preset imaging point in a preset area are (x, y, z), and the resulting diffuse circular spot has a diameter of 1 pixel. At time t1, the coordinates of the preset imaging point are (x1, y1, z1), meaning the preset imaging point moves by a distance x1-x in the x-direction and a distance y1-y in the y-direction. Based on the image sensor's movement distance (z1-z) in the target direction, the diameter of the diffuse circular spot on the image sensor's imaging surface is determined. At time t2, the coordinates of the preset imaging point are (x2, y2, z2), meaning the preset imaging point moves by a distance x2-x1 in the x-direction and a distance y2-y1 in the y-direction. Based on the image sensor's movement distance (z2-z1) in the target direction, the diameter of the diffuse circular spot on the image sensor's imaging surface is determined. It will be understood that the coordinates of the preset imaging point within the exposure time can form a movement trajectory of the preset imaging point, with each coordinate being a point in the trajectory.

[0099] In this embodiment, the distance the image sensor has moved in the target direction is obtained based on the target's movement trajectory. Based on this distance, the diffuse circular spot on the image sensor's imaging plane can be accurately determined. Furthermore, based on the movement distance and the obtained shooting parameters, the size of the diffuse circular spot can be more accurately determined, and the diffuse circular spot on the image sensor's imaging plane can be obtained based on the size of the diffuse circular spot.

[0100] In one embodiment, determining a target movement trajectory of an image sensor based on gyroscope data includes: determining the movement amount and rotation angle of the gyroscope within a preset time period based on the gyroscope data; determining target coordinates obtained by the image sensor at each preset time interval based on the spatial position relationship between the gyroscope and the image sensor, as well as the movement amount and rotation angle; and generating a target movement trajectory of the image sensor based on the target coordinates obtained by the image sensor at each preset time interval.

[0101] The preset duration can be set as needed.

[0102] Optionally, the gyroscope data includes angular acceleration and linear acceleration at each preset time interval; the electronic device integrates the angular acceleration twice to obtain the rotation angle of the gyroscope, and integrates the linear acceleration twice to obtain the movement amount of the gyroscope.

[0103] Optionally, the target coordinates obtained by the image sensor at each preset time interval are determined based on the spatial position relationship between the gyroscope and the image sensor, as well as the movement amount and the rotation angle, including: determining the initial coordinates of the image sensor based on the spatial position relationship between the gyroscope and the image sensor; determining the first coordinates obtained by the image sensor at each preset time interval based on the movement amount and the initial coordinates; determining the second coordinates obtained by the image sensor at each preset time interval based on the rotation angle and the initial coordinates; and determining the target coordinates obtained by the image sensor at each preset time interval based on the first coordinates and the second coordinates.

[0104] The initial coordinates are the coordinates of the image sensor before the electronic device is moved.

[0105] Optionally, the electronic device obtains the spatial position relationship between the gyroscope and the image sensor, establishes a coordinate system centered on the gyroscope based on the spatial position relationship, determines the initial coordinates of the image sensor in the coordinate system, converts the gyroscope's rotation angle into the image sensor's rotation angle, and converts the gyroscope's movement into the image sensor's movement; multiplies the image sensor's initial coordinates by the image sensor's movement to obtain a first coordinate obtained by the image sensor at each preset time interval; multiplies the image sensor's initial coordinates by the image sensor's rotation angle to obtain a second coordinate obtained by the image sensor at each preset time interval; and adds the first and second coordinates obtained at the same time to obtain the target coordinate obtained by the image sensor at each preset time interval. The coordinate system includes a rectangular coordinate system and a polar coordinate system.

[0106] like Figure 6 The figure shows a rectangular coordinate system centered on the gyroscope. The coordinates of the gyroscope are (0, 0, 0). The initial coordinates of the center point of the image sensor in the rectangular coordinate system are (x0, y0, z0). The coordinates of the edge points of the image sensor are (x i 、y i 、z i ).

[0107] During the shutter duration, or exposure duration T, the electronic device collects gyroscope data at intervals of a preset duration Δt, with the number of sampling times n = T / Δt. The gyroscope data obtained at each preset duration is time-integrated twice to obtain the gyroscope's movement and rotation angle in the X, Y, and Z directions. The gyroscope's movement and rotation angle in the X, Y, and Z directions are then converted into the image sensor's movement and rotation angle in the X, Y, and Z directions.

[0108] The electronic device uses the following formula to add the movement amount of the image sensor in each direction and the coordinate value of the initial coordinate in that direction to obtain the coordinate value of the image sensor in each direction. Formula 1:

[0109]

[0110]

[0111]

[0112] Where x0, y0, and z0 are the coordinate values ​​of the initial coordinates of the image sensor in the X, Y, and Z directions, respectively. Δx, Δy, and Δz are the movement amounts of the image sensor in the X, Y, and Z directions within a preset time period, respectively. and They are the coordinate values ​​obtained by the image sensor in the X, Y and Z directions after a preset time. is the first coordinate.

[0113] The rotation angle on the axis can be mapped to the movement amount in the rectangular coordinate system through the polar coordinate system transformation, such as Figure 7 The polar coordinate system is shown with the gyroscope as the center. The coordinates of the gyroscope are (0, 0, 0) and the image sensor rotates Δω on the Z axis. z The initial coordinates of the center point of the image sensor in the polar coordinate system are (x0, y0, z0), and the coordinates obtained after rotation are (x0, y0, z0).

[0114] During the exposure time, when the Z axis rotates, its projection on the XY plane will change position. After polar coordinate transformation, it can be calculated by the following formula 2:

[0115]

[0116]

[0117] Among them, Δω z is the rotation angle on the Z axis. It can be understood that when the image sensor rotates on the Z axis, the coordinate in the Z direction remains unchanged. is the second coordinate.

[0118] It should be noted that the above formulas 1 and 2 are both affine matrices between the image sensor and the gyroscope.

[0119] Similarly, for rotation on the X-axis or Y-axis, the corresponding spatial coordinates can also be calculated, which will not be described in detail here.

[0120] The electronic device converts the first coordinate and the second coordinate Add the first coordinate and the second coordinate Add the first coordinate and the second coordinate Add together to get the target coordinates

[0121] For non-axis rotation, the electronic device determines the first coordinate obtained by the image sensor at each preset time interval based on the movement amount and the initial coordinate; determines the second coordinate obtained by the image sensor at each preset time interval based on the rotation angle and the initial coordinate; and adds the first coordinate and the second coordinate to obtain the target coordinate obtained by the image sensor at each preset time interval.

[0122] Optionally, the electronic device combines the target coordinates obtained by the image sensor at each preset time interval to obtain the target movement trajectory of the image sensor. For example, the initial coordinates of the image sensor are (x0, y0, z0) and the target coordinates obtained by the image sensor at each preset time interval are (x0, y0, z0). Where n is an integer greater than or equal to 1; the target movement trajectory of the image sensor is

[0123] After superimposing the movement and rotation angle of each axis, we obtain the target movement trajectory of the center point of the image sensor within the exposure time T. Similarly, the target motion trajectory at other positions on the image sensor can also be calculated using the same method as above, which will not be described in detail here.

[0124] In this embodiment, the electronic device determines the movement amount and rotation angle of the gyroscope within a preset time period based on the gyroscope data; according to the spatial position relationship between the gyroscope and the image sensor, as well as the movement amount and rotation angle, the movement amount and rotation angle of the gyroscope can be converted into image sensor data, thereby determining the target coordinates obtained by the image sensor at each preset time interval, and thus accurately generating the target movement trajectory of the image sensor based on the target coordinates obtained by the image sensor at each preset time interval.

[0125] In one embodiment, a target blur kernel is used to deblur a first image to obtain a second image, including: dividing the first image into multiple first sub-images; for each first sub-image, using a target blur kernel at a corresponding position of the first sub-image to perform deblurring processing to obtain a second sub-image; and obtaining a second image based on each second sub-image.

[0126] It is understandable that the division method of the first image can be set as needed. Exemplarily, the first image is divided into 16*12 first sub-images.

[0127] For each first sub-image, the electronic device obtains a target blur kernel at a corresponding position of the first sub-image, deblurs the first sub-image using the target blur kernel to obtain a second sub-image, and then splices the second sub-images to obtain a deblurred second image.

[0128] It is understandable that due to the large magnification of the microscope module in the electronic device and the close imaging distance, the blur kernel generated by the jitter of the electronic device is not consistent across the entire field of view, such as Figure 8As shown, the blur kernels for each region of the image captured by the electronic device during shaking are inconsistent. This blur is related to the shaking trajectory of the electronic device, the distance to the subject, and the position in the field of view. Therefore, due to the spatially non-uniform blur, the electronic device deblurs the first sub-image in different regions of the first image using the target blur kernel at the corresponding position, resulting in a clearer second sub-image.

[0129] In one embodiment, Figure 9 As shown, the electronic device presses the shutter to expose, obtains a blurred first image, and simultaneously collects gyroscope data; performs motion estimation based on the gyroscope data to determine the motion data of the gyroscope; obtains the positions (xy, z) of the image sensor and the gyroscope for coordinate calibration, that is, obtains the spatial position relationship between the gyroscope and the image sensor, and establishes a coordinate system centered on the gyroscope; based on the coordinate position of the image sensor in the coordinate system, obtains the affine transformation matrix between the gyroscope and the image sensor, and converts the motion data of the gyroscope into motion data of the image sensor based on the affine transformation matrix; based on the motion data, determines the target coordinates obtained by the image sensor at each preset time interval, and generates a target movement trajectory of the image sensor based on the target coordinates obtained by the image sensor at each preset time interval; determines a diffuse circular spot on the imaging surface of the image sensor according to the target movement trajectory; the diffuse circular spot is generated by the electronic device moving in the target direction; based on the target movement trajectory and the diffuse circular spot, determines the target blur kernel on the imaging surface of the image sensor; uses a patch-wise deconvolution algorithm and the target blur kernel to deblur the first image to obtain a clear second image.

[0130] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.

[0131] Based on the same inventive concept, embodiments of the present application also provide an image processing device for implementing the aforementioned image processing method. The solution provided by this device is similar to the solution described in the aforementioned method. Therefore, the specific limitations in one or more of the following image processing device embodiments can be found in the above-described limitations on the image processing method and will not be further elaborated here.

[0132] In one embodiment, Figure 10 As shown, an image processing device is provided, including: an acquisition module 1002, a trajectory determination module 1004, a diffuse spot determination module 1006, a blur kernel determination module 1008 and a deblurring processing module 1010, wherein:

[0133] The acquisition module 1002 is configured to capture a first image through an image sensor in the electronic device and acquire gyroscope data.

[0134] The trajectory determination module 1004 is configured to determine the target movement trajectory of the image sensor based on the gyroscope data.

[0135] The diffuse circular spot determining module 1006 is used to determine the diffuse circular spot on the imaging surface of the image sensor according to the target movement trajectory; the diffuse circular spot is generated when the electronic device moves in the target direction.

[0136] The blur kernel determination module 1008 is configured to determine the blur kernel of the target on the imaging surface of the image sensor based on the target movement trajectory and the diffuse circular spot.

[0137] The deblurring processing module 1010 is configured to perform deblurring processing on the first image using a target blur kernel to obtain a second image.

[0138] The image processing device captures a first image using an image sensor in an electronic device and obtains gyroscope data. Based on the gyroscope data, the device can determine a target movement trajectory of the image sensor and, based on the target movement trajectory, determine a diffuse circular spot on the image sensor's imaging surface caused by movement of the electronic device in the target direction. Therefore, based on the target movement trajectory and the diffuse circular spot caused by movement in the target direction, a target blur kernel on the image sensor's imaging surface can be more accurately determined. This target blur kernel can then be used to more accurately deblur the first image, resulting in a clearer second image.

[0139] In one embodiment, the blur kernel determination module 1008 is further configured to determine the blur kernel of each trajectory point in the target movement trajectory based on the target movement trajectory and the diffuse circular spot; and determine the target blur kernel on the imaging surface of the image sensor based on the blur kernel of each trajectory point.

[0140] In one embodiment, the blur kernel determination module 1008 is further configured to determine each trajectory point and the diffuse circular spot corresponding to each trajectory point from the target movement trajectory; and adjust each trajectory point to the size of the corresponding diffuse circular spot to obtain the blur kernel of each trajectory point.

[0141] In one embodiment, the imaging surface of the image sensor is divided into at least one preset area; the trajectory determination module 1004 is further configured to determine, for each preset area, a target movement trajectory of the preset area on the imaging surface of the image sensor based on gyroscope data.

[0142] In one embodiment, each preset area includes at least one preset imaging point; the above-mentioned trajectory determination module 1004 is further used to determine, for each preset imaging point in each preset area, an imaging point movement trajectory of each preset imaging point based on gyroscope data; and determine the target movement trajectory of the preset area on the imaging surface of the image sensor based on the movement trajectory of each imaging point.

[0143] In one embodiment, the diffuse circular spot determining module 1006 is further configured to obtain a moving distance of the image sensor in the target direction according to the target moving trajectory; and determine the diffuse circular spot on the imaging surface of the image sensor based on the moving distance.

[0144] In one embodiment, the diffuse spot determining module 1006 is further configured to obtain shooting parameters; determine the size of the diffuse spot based on the moving distance and the shooting parameters, and obtain the diffuse spot on the imaging surface of the image sensor based on the size of the diffuse spot.

[0145] In one embodiment, the trajectory determination module 1004 is further configured to determine the amount of movement and the rotation angle of the gyroscope within a preset time period based on the gyroscope data; determine the target coordinates obtained by the image sensor at each interval of the preset time period based on the spatial position relationship between the gyroscope and the image sensor, as well as the amount of movement and the rotation angle; and generate a target movement trajectory of the image sensor based on the target coordinates obtained by the image sensor at each interval of the preset time period.

[0146] In one embodiment, the trajectory determination module 1004 is further configured to determine the initial coordinates of the image sensor based on the spatial positional relationship between the gyroscope and the image sensor; determine the first coordinates obtained by the image sensor at each preset time interval based on the movement amount and the initial coordinates; determine the second coordinates obtained by the image sensor at each preset time interval based on the rotation angle and the initial coordinates; and determine the target coordinates obtained by the image sensor at each preset time interval based on the first coordinates and the second coordinates.

[0147] In one embodiment, the deblurring module 1010 is further configured to divide the first image into a plurality of first sub-images; for each first sub-image, deblurring is performed using a target blur kernel at a corresponding position of the sub-image to obtain a second sub-image; and based on each second sub-image, a second image is obtained.

[0148] In one embodiment, the target direction is perpendicular to the imaging plane of the image sensor.

[0149] Each module in the above-mentioned image processing device can be implemented in whole or in part through software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in an electronic device in the form of hardware, or can be stored in a memory in the electronic device in the form of software, so that the processor can call and execute the corresponding operations of each module.

[0150] In one embodiment, an electronic device is provided. The electronic device may be a terminal, and its internal structure diagram may be as follows: Figure 11 As shown. The electronic device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface, the display unit and the input device are connected to the system bus via the input / output interface. The processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the electronic device is used to exchange information between the processor and an external device. The communication interface of the electronic device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, an image processing method is implemented. The display unit of the electronic device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the electronic device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the electronic device casing, or an external keyboard, touchpad or mouse.

[0151] Those skilled in the art will understand that Figure 11 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the electronic device to which the solution of the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0152] The present application also provides a computer-readable storage medium, one or more non-volatile computer-readable storage media containing computer-executable instructions, which, when executed by one or more processors, cause the processors to perform the steps of the image processing method.

[0153] An embodiment of the present application further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the image processing method.

[0154] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions.

[0155] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processor involved in the various embodiments provided herein may be, but are not limited to, a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, and the like.

[0156] The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0157] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.

Claims

1. An image processing method, characterized in that: include: Capturing a first image through an image sensor in an electronic device and obtaining gyroscope data; determining a target movement trajectory of the image sensor based on the gyroscope data; According to the target movement trajectory, the movement distance of the image sensor in the target direction is obtained; shooting parameters are obtained; based on the movement distance and the shooting parameters, the size of the diffuse circular spot is determined, and the diffuse circular spot on the imaging surface of the image sensor is obtained based on the size of the diffuse circular spot; The diffuse circular spot is generated when the electronic device moves in a target direction; the target direction is perpendicular to the imaging surface of the image sensor; Determining a blur kernel for each track point in the target movement track based on the target movement track and the diffuse circular spot; integrating the blur kernels of each track point within the exposure time to determine the target blur kernel on the imaging surface of the image sensor; Deblurring the first image using the target blur kernel to obtain a second image.

2. The method according to claim 1, characterized in that The step of obtaining a moving distance of the image sensor in a target direction according to the target moving trajectory includes: The coordinate value of each track point in the target direction is obtained from the target movement track, and the coordinate values ​​of two adjacent track points in the target direction are subtracted to obtain the movement distance of each track point of the image sensor in the target direction.

3. The method according to claim 1, characterized in that The step of determining a blur kernel for each track point in the target movement track based on the target movement track and the diffuse circular spot includes: Determining each trajectory point and the diffuse circular spot corresponding to each trajectory point from the target movement trajectory; Each trajectory point is adjusted to the size of the corresponding diffuse circular spot to obtain the blur kernel of each trajectory point.

4. The method according to claim 1, wherein The imaging surface of the image sensor is divided into at least one preset area; and determining the target movement trajectory of the image sensor based on the gyroscope data includes: For each preset area, a target movement trajectory of the preset area on the imaging surface of the image sensor is determined based on the gyroscope data.

5. The method according to claim 4, characterized in that Each of the preset areas includes at least one preset imaging point; The step of determining, for each preset area, a target movement trajectory of the preset area on the imaging surface of the image sensor based on the gyroscope data includes: For each preset imaging point in each preset area, determining an imaging point movement trajectory of each preset imaging point based on the gyroscope data; Based on the movement trajectories of the respective imaging points, a target movement trajectory of the preset area on the imaging surface of the image sensor is determined.

6. The method according to claim 1, characterized in that The determining the target movement trajectory of the image sensor based on the gyroscope data includes: Determining the movement and rotation angle of the gyroscope within a preset time period based on the gyroscope data; Determining target coordinates obtained by the image sensor at intervals of a preset time length based on a spatial positional relationship between the gyroscope and the image sensor, the movement amount, and the rotation angle; A target movement trajectory of the image sensor is generated based on the target coordinates obtained by the image sensor at intervals of a preset time length.

7. The method according to claim 6, characterized in that The determining, based on the spatial position relationship between the gyroscope and the image sensor, the movement amount, and the rotation angle, of the target coordinates obtained by the image sensor at intervals of a preset time length includes: determining the initial coordinates of the image sensor according to the spatial position relationship between the gyroscope and the image sensor; Determining, based on the movement amount and the initial coordinate, a first coordinate obtained by the image sensor at intervals of a preset time length; Determining, based on the rotation angle and the initial coordinate, a second coordinate obtained by the image sensor at intervals of a preset time length; Based on the first coordinate and the second coordinate, a target coordinate obtained by the image sensor at intervals of a preset time length is determined.

8. The method according to claim 1, characterized in that The deblurring the first image using the target blur kernel to obtain a second image includes: dividing the first image into a plurality of first sub-images; For each first sub-image, deblurring is performed using the target blur kernel at the corresponding position of the first sub-image to obtain a second sub-image; A second image is obtained based on each of the second sub-images.

9. An image processing device, characterized in that: include: an acquisition module, configured to capture a first image through an image sensor in the electronic device and obtain gyroscope data; a trajectory determination module, configured to determine a target movement trajectory of the image sensor based on the gyroscope data; a diffuse circular spot determination module, configured to obtain a movement distance of the image sensor in a target direction according to the target movement trajectory; obtain shooting parameters; determine a size of the diffuse circular spot based on the movement distance and the shooting parameters, and obtain a diffuse circular spot on the imaging surface of the image sensor based on the size of the diffuse circular spot; The diffuse circular spot is generated when the electronic device moves in a target direction; the target direction is perpendicular to the imaging surface of the image sensor; a blur kernel determining module, configured to determine a blur kernel for each track point in the target track based on the target track and the diffuse circular spot; Integrating the blur kernel of each trajectory point within the exposure time to determine the target blur kernel on the imaging surface of the image sensor; The deblurring processing module is configured to perform deblurring processing on the first image using the target blur kernel to obtain a second image.

10. An electronic device comprising a memory and a processor, wherein a computer program is stored in the memory, wherein: When the computer program is executed by the processor, the processor is caused to perform the steps of the image processing 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 computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.

12. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Image data processing method and device

    CN108322642A

  • A method of remote sensing image deblurring based on dark channel

    CN109300092A

  • Image deblurring method based on camera positioning

    CN110677556A

  • Image definition restoration method and device and image shooting method and device

    CN111835968A