Image processing method

Through parallax estimation and machine learning processing of QPD images, combined with morphological transformation, the problem of poor background blur in defocused images is solved, and effective background blur and foreground edge recognition in defocused and focused images are achieved.

CN118587121APending Publication Date: 2024-09-03HOWAY TECH (WUHAN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410754093.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-12
Publication Date
2024-09-03

AI Technical Summary

Technical Problem

Existing background blur technology is difficult to achieve effective background blur in defocused images, especially because the boundaries of the foreground ROI area are blurred and cannot effectively distinguish the foreground and background.

Method used

QPD images are used for background blurring, and disparity information is predicted through a pre-trained disparity estimation model. Machine learning and morphological transformation are combined to obtain the foreground target mask, which is then weighted and fused with the deblurred image to output a background blurred image.

Benefits of technology

It achieves effective background blurring in both defocused and focused images, and improves foreground edge recognition. Compared with traditional single-frame RGB images, the effect is better and does not depend on image clarity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118587121A
    Figure CN118587121A
Patent Text Reader

Abstract

The invention provides an image processing method comprising the following steps: obtaining a QPD image which is a defocused image or a focused image; using a pre-training parallax estimation model to predict parallax information of the QPD image, and outputting a parallax image; carrying out machine learning-based adaptive multi-parallax layering and morphological transformation on the parallax image to obtain a foreground target mask; training the QPD image by adopting a pre-training deblurring model to obtain a deblurred image; and carrying out weighted fusion on the foreground target mask and the deblurred image, and outputting a background blurred image. According to the method, the background blurring effect can be realized by using the QPD image (single-frame image), and the background blurring effect is better than that of a traditional single-frame RGB image; the background blurring effect of the defocused image and the focused image can be realized without depending on the definition degree of the image; post-processing is carried out based on a machine learning method and morphological transformation, and the foreground edge identification degree is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of image processing, and in particular relates to an image processing method. Background Art

[0002] Bokeh means blurring the background while keeping the main subject in the image clear. This technique simulates the effect of a large aperture and shallow depth of field, which makes the main part of the image stand out and looks more beautiful. Common software-based background blur techniques include the following:

[0003] The first type: In portrait scenes, face frames, head frames, and human frames are used to correct the intensity of background blur. This method has the following defects: it can only be used for portrait scenes; the size of the face, head, and human body is not completely proportional to the distance to the camera, but is related to the individual's body shape; the size of the frame of the same person will be unstable in profile, sideways, back, and complex postures; the frame size is unstable when blocked. The second type: methods based on deep learning, including image segmentation algorithms, monocular depth estimation methods, and binocular depth estimation methods. This method has a relatively low degree of dependence on hardware, and can be used to blur the background for various scenes, not just faces, and is widely used. The above background blur algorithms have certain limitations, among which the first type is limited to the face environment. The second type has better applicability, but there is a premise assumption, that is, a clear image is required as input, and the background blur of defocused images (blurred images) is not supported.

[0004] There is an example where, when the foreground is focused, the RGB single-frame image has a certain background blur effect, but the effect is not good. The foreground ROI (region of interest) is, for example, a face, and the face and the background are not well distinguished. When the foreground is focused, the QPD single-frame image has a good background blur effect, but there is a certain blur at the foreground face boundary. When the foreground is defocused, the background blur effect of both the RGB single-frame image and the QPD single-frame image is not good, because the ROI area is defocused, and conventional background blur algorithms cannot handle such situations. Therefore, how to achieve a background blur effect in a defocused situation has become an urgent problem to be solved. Summary of the invention

[0005] The purpose of the present invention is to provide an image processing method, which can achieve the background blur effect by using QPD image (single-frame image), and the background blur effect is better than that of traditional single-frame RGB image; it does not depend on the clarity of the image, and both defocused images and focused images can achieve the background blur effect; post-processing is based on machine learning methods and morphological transformation to improve the foreground edge recognition.

[0006] The present invention provides an image processing method, comprising:

[0007] Step S1, obtaining a QPD image, wherein the QPD image is a defocused image or a focused image;

[0008] Step S2, using a pre-trained disparity estimation model to predict disparity information of the QPD image, and outputting a disparity image;

[0009] Step S3, performing adaptive multi-parallax layering and morphological transformation based on machine learning on the disparity image to obtain a foreground object mask;

[0010] Step S4, training the QPD image using a pre-trained deblurring model to obtain a deblurred image;

[0011] Step S5: weightedly fuse the foreground object mask with the deblurred image to output a background blurred image.

[0012] Furthermore, four adjacent pixels of the same color in the QPD image form a group, and there is parallax between any two of the four pixels in the same group; based on the QPD image, an upper image, a lower image, a left image and a right image are obtained by calculation.

[0013] Furthermore, the upper image is to take the average value of the upper left and upper right pixels in each color group as the pixel value of the group after four-in-one; the lower image is to take the average value of the lower left and lower right pixels in each color group as the pixel value of the group after four-in-one; the left image is to take the average value of the upper left and lower left pixels in each color group as the pixel value of the group after four-in-one; the right image is to take the average value of the upper right and lower right pixels in each color group as the pixel value of the group after four-in-one.

[0014] Furthermore, step S2 specifically includes:

[0015] S21, establishing a QPD disparity data set, wherein the QPD disparity data set includes: the upper image, the lower image, the left image, and the right image;

[0016] S22, training a QPD disparity estimation neural network model;

[0017] S23, inputting QPD data, performing disparity estimation using a pre-trained neural network model, and outputting the disparity image.

[0018] Furthermore, the QPD disparity estimation neural network model includes: a feature encoder; the feature encoder is applied to the upper image and the lower image, and each of the images is mapped to a dense feature map; a recursive full field transform algorithm is used to calculate the visual similarity between all pixel pairs in the upper image and the lower image to construct a related volume and generate related features; the related features are passed through several convolutional layers and predict disparity updates, and then upsampled to obtain upper and lower phase disparity maps.

[0019] Furthermore, the feature encoder is applied to the left image and the right image, and a recursive full field transform algorithm is used to calculate the visual similarity between all pixel pairs in the left image and the right image to construct a related volume, thereby obtaining a left-right phase disparity map; the upper and lower phase disparity maps are fused with the left-right phase disparity maps, and the final disparity image is obtained after upsampling and further repair.

[0020] Furthermore, the recursive full field transform algorithm operates on feature maps of 1 / 4, 1 / 8 and 1 / 16 resolutions simultaneously through a multi-resolution update operator.

[0021] Further, step S3 includes step S31, K-Means stratification; step S31 specifically includes:

[0022] S311, converting the disparity image into one-dimensional data as input of the K-means algorithm;

[0023] S312, clustering the one-dimensional data using a K-means algorithm;

[0024] S313 , re-adjusting the category corresponding to the clustered one-dimensional data to the image size corresponding to the disparity image.

[0025] Furthermore, step S3 also includes step S32, morphological transformation; step S32 specifically includes:

[0026] S321, using a morphological opening operation with a preset kernel size to eliminate noise in the vicinity of the region of interest;

[0027] S322, using a continuous region search function to perform connected region analysis on the region of interest;

[0028] S323: Use the morphological closing operation with the preset kernel size to remove the noise inside the region of interest.

[0029] Furthermore, step S4 specifically includes:

[0030] S41, establish QPD defuzzification data set;

[0031] S42, training a neural network model for deblurring;

[0032] S43, reasoning stage: input QPD data and use the pre-trained deblurring neural network model to perform deblurring.

[0033] Furthermore, in step S42, the raw domain blur image of QPD is input into the deblurred neural network model to output the deblurred Raw image, and the pixel-by-pixel bi-norm loss function of the output image and the label image is calculated, and the model is iteratively trained until it is optimal, so that the trained deblurred image is as close to the label image as possible.

[0034] Further, step S42 specifically includes:

[0035] The left image and the right image are respectively input into the first weight sharing module of the twin, and the feature weights of the left image and the right image are shared through the first weight sharing module to extract the first coarse-grained feature; then the fine-grained feature extraction and fusion are performed in turn through the first SKFF module and the first feature transformation module to obtain the left and right fused images;

[0036] The upper image and the lower image are respectively input into the second weight sharing module of the twin, and the feature weights of the upper image and the lower image are shared by the second weight sharing module to extract the second coarse-grained features; and then the fine-grained features are extracted and fused by the second SKFF module and the second feature transformation module in turn to obtain the upper and lower fused images;

[0037] The left-right fused image and the top-bottom fused image are further fused through the third SKFF module and the third feature transformation module to obtain the top-bottom, left-right fused image.

[0038] Furthermore, step S42 specifically includes:

[0039] The image after fusion of up, down, left and right is subjected to feature fine-tuning and detail retention by a reconstruction module, and then the feature is subjected to difference operation by an upsampling module to restore the feature size to the size of the input image, and finally the result of averaging the left image and the right image is superimposed by a residual block to finally output the deblurred image.

[0040] Furthermore, in step S43, the inference stage inputs the raw domain blur image of the QPD into the trained deblurring neural network model, and outputs the deblurred Raw image, which is processed by an image signal processor to obtain a corresponding RGB image.

[0041] Furthermore, step S5 adopts the following formula:

[0042] I bokeh =Deblur(I QPD )*Mroi +Blur(I QPD ) * (1-M roi )

[0043] Among them, I QPD For the QPD image, Deblur(I QPD ) is the deblurred image output by the deblurring network; M roi Beblur(I QPD ) is the image after Gaussian blur operation.

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

[0045] The present invention provides an image processing method, comprising: obtaining a QPD image, wherein the QPD image is a defocused image or a focused image; using a pre-trained disparity estimation model to predict the disparity information of the QPD image, and outputting a disparity image; performing adaptive multi-disparity layering and morphological transformation based on machine learning on the disparity image to obtain a foreground target mask; training the QPD image using a pre-trained deblurring model to obtain a deblurred image; weightedly fusing the foreground target mask with the deblurred image, and outputting a background blur image. The present invention can achieve a background blur effect using a QPD image (single-frame image), and the background blur effect is better than that of a traditional single-frame RGB image; it is independent of the clarity of the image, and both defocused images and focused images can achieve a background blur effect; post-processing is performed based on a machine learning method and morphological transformation to improve the foreground edge recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 The figure is a flowchart of an image processing method according to an embodiment of the present invention.

[0047] Figure 2 It is a schematic diagram of obtaining a sub-image by calculating a QPD image in the image processing method of the present invention.

[0048] Figure 3 It is a schematic diagram of forming a parallax image when the foreground is defocused in the image processing method of the present invention.

[0049] Figure 4 The figure is a schematic diagram of forming a parallax image under foreground focusing in the image processing method of the present invention.

[0050] Figure 5 This is a schematic diagram of a target mask obtained after the disparity image with foreground defocus is processed by layering and morphological transformation in the image processing method of an embodiment of the present invention.

[0051] Figure 6This is a schematic diagram of a target mask obtained after the disparity image under foreground focus is processed by layering and morphological transformation in the image processing method of an embodiment of the present invention.

[0052] Figure 7 A schematic diagram of obtaining a deblurred image when the foreground is defocused in the image processing method of the present invention.

[0053] Figure 8 A schematic diagram of obtaining a deblurred image under foreground focus in the image processing method of the present invention.

[0054] Fig. 9 The image processing method of the present invention outputs a background blurred image after fusion under foreground defocus.

[0055] Fig.10 The image processing method of the present invention outputs a background blurred image after fusion under foreground focus.

[0056] The reference numerals are as follows:

[0057] 01-parallax image with foreground defocus; 02-foreground target mask with foreground defocus; 03-parallax image with foreground focus; 04-foreground target mask with foreground focus. DETAILED DESCRIPTION

[0058] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. The advantages and features of the present invention will become more apparent from the following description. It should be noted that the accompanying drawings are in a very simplified form and use an inaccurate scale, which is only used to conveniently and clearly assist in explaining the purpose of the embodiments of the present invention.

[0059] For ease of description, some embodiments of the present application may use spatially relative terms such as "above", "below", "top", "below", etc. to describe the relationship between one element or component and another (or other) elements or components as shown in the various figures of the embodiments. It should be understood that in addition to the orientations described in the drawings, the spatially relative terms are also intended to include different orientations of the device in use or operation. For example, if the device in the drawings is turned over, the elements or components described as being "below" or "below" other elements or components will subsequently be positioned as being "above" or "above" other elements or components. The terms "first", "second", etc. below are used to distinguish between similar elements and are not necessarily used to describe a specific order or time sequence. It is to be understood that these terms used in this way are interchangeable where appropriate.

[0060] The embodiment of the present invention provides an image processing method, such as Figure 1 As shown, including:

[0061] Step S1, obtaining a QPD image, where the QPD image is a defocused image or a focused image;

[0062] Step S2, using a pre-trained disparity estimation model to predict the disparity information of the QPD image and output a disparity image;

[0063] Step S3, performing adaptive multi-parallax layering and morphological transformation based on machine learning on the disparity image to obtain a foreground target mask;

[0064] Step S4, training the QPD image using a pre-trained deblurring model to obtain a deblurred image;

[0065] Step S5: weightedly fuse the foreground target mask and the deblurred image to output a background blurred image.

[0066] Combine the following Figures 1 to 10 Each step of the image processing method of this embodiment is described in detail.

[0067] Step S1, obtaining a QPD (quadruple-phase pixel) image; the QPD image is a defocused image (blurred image) or a focused image (clear image). Figure 2 As shown in FIG. 1 , in a QPD image obtained by taking a QPD camera, four adjacent pixels (each small square represents one pixel) share a micro lens, and four adjacent pixels can use the same color filter (e.g., red R, green G, blue B filter). In the QPD image, four adjacent pixels of the same color are grouped together, and there is parallax between two of the four pixels in the same group. The QPD image can be a color image or a grayscale image. In the QPD original image, when the four adjacent pixels use the same color filter, the QPD original image can be a color image; when the four adjacent pixels in the QPD original image do not use a color filter, the QPD original image can be a grayscale image.

[0068] According to the QPD image, the upper image, lower image, left image and right image are calculated. The upper image is to take the average value of the upper left and upper right pixels in each color group as the pixel value of the group after four-in-one. The lower image is to take the average value of the lower left and lower right pixels in each color group as the pixel value of the group after four-in-one. The left image is to take the average value of the upper left and lower left pixels in each color group as the pixel value of the group after four-in-one. The right image is to take the average value of the upper right and lower right pixels in each color group as the pixel value of the group after four-in-one.

[0069] Step S2: Use the pre-trained disparity estimation model to predict the disparity information of the QPD image and output the disparity image. Step S2 specifically includes:

[0070] S21, establishing a QPD disparity dataset, where the QPD disparity dataset includes: an upper image, a lower image, a left image, and a right image;

[0071] S22, training a QPD disparity estimation neural network model;

[0072] S23, input QPD data, use the pre-trained neural network model to perform disparity estimation, and output a disparity map.

[0073] like Figure 3 As shown in FIG. 1 , the QPD image is a foreground defocused image (blurred image), and a parallax image under foreground defocus is obtained through step S2. Figure 4 As shown, the QPD image is a foreground focused image (clear image), and a parallax image under foreground focus is obtained through step S2.

[0074] Specifically, the QPD disparity estimation neural network model includes: a feature encoder. The feature encoder is applied to the upper and lower images and maps each image to a dense feature map, which is then used to construct the correlation volume; instance normalization is used in the feature encoder. The correlation volume uses the dot product between feature vectors as a measure of visual similarity. The RAFT (Recurrent All-Pairs Field Transforms) algorithm is used to calculate the visual similarity between all pixel pairs in the upper and lower images to construct the 4D correlation volume. A multi-level update operator predicts a series of disparity fields from the initial starting point; in each iteration, the current estimate of the disparity is used to index the correlation volume and generate a set of relevant features; these features are passed through several convolutional layers; the current disparity estimate also passes through several convolutional layers; the features extracted by association, difference, and RINDNet are then connected and injected into the GRU; the GRU updates the hidden state; the new hidden state is then used to predict the disparity update. Multiple hidden states: The original RAFT performs updates entirely at a fixed high resolution; the multi-resolution update operator operates on feature maps with 1 / 4, 1 / 8, and 1 / 16 resolutions at the same time. GRUs are cross-connected by using each other's hidden states as inputs. Experiments are conducted using higher resolution models, where GRUs are updated to 1 / 4, 1 / 8, and 1 / 16 of the input image resolution. After upsampling, the predicted disparity field is 1 / 4 or 1 / 8 of the input image resolution; the upper and lower phase disparity maps are obtained using the same convex upsampling method as RAFT.

[0075] Next, the feature encoder is applied to the left and right images and each image is mapped to a dense feature map. The recursive full field transform algorithm is used to calculate the visual similarity between all pixel pairs in the left and right images to construct the correlation volume; instance normalization is used in the feature encoder. The original RAFT performs updates entirely at a fixed high resolution; the left and right phase disparity maps are calculated by RAFT through the multi-resolution update operator running on the feature maps of 1 / 4, 1 / 8 and 1 / 16 resolutions simultaneously. The upper and lower phase disparity maps are fused with the left and right phase disparity maps, upsampled and further inpainted to obtain the final disparity image; inpainting can be done using a small convolutional neural network.

[0076] Step S3: performing adaptive multi-disparity layering and morphological transformation based on machine learning on the disparity image to obtain a foreground object mask.

[0077] Step S3 includes step S31 and K-Means stratification; step S31 specifically includes:

[0078] S311, converting the disparity image into one-dimensional data as input of the K-means algorithm;

[0079] S312, clustering one-dimensional data using K-means algorithm;

[0080] S313 , re-adjusting the category corresponding to the clustered one-dimensional data to the image size corresponding to the disparity image.

[0081] Step S3 also includes step S32, morphological transformation; morphological transformation is some simple operations based on the shape of the image, usually performed on a binary image, requiring two inputs, the first is the original image, and the second is called a structural element or kernel, which determines the nature of the operation. The two basic morphological operators are erosion and dilation, and its variant forms are opening and closing operations.

[0082] Step S32 specifically includes:

[0083] S321. Use a morphological opening operation with a preset kernel size to eliminate noise in the neighboring area of ​​the region of interest. The kernel size is not limited and can be configured according to actual needs. The kernel size can be any one of 3x3, 5x5, 7x7 or 9x9, as well as other suitable sizes.

[0084] S322, using a function to find continuous regions (such as findContours function) to perform connected region analysis of the region of interest; the connected region refers to the entire foreground region.

[0085] S323, using a morphological closing operation with a preset kernel size to remove noise inside the region of interest.

[0086] like Figure 5 As shown, the QPD image is a foreground defocused image. After step S2, a disparity image 01 under foreground defocus is obtained. After K-Means layering and morphological transformation processing in step S3, a foreground target mask 02 under foreground defocus is obtained. Figure 6 As shown, the QPD image is a foreground focused image (clear image), and the disparity image 03 under foreground focus is obtained through step S2, and the foreground target mask 04 under foreground focus is obtained after K-Means layering and morphological transformation processing in step S3.

[0087] Compared with the watershed algorithm and the graph cut algorithm, the adaptive K-means algorithm adopted in the present invention is more robust and efficient. It does not require manual setting of thresholds or multiple selection of foregrounds. Combined with morphological transformation processing, it can obtain more accurate foreground target mask information.

[0088] Step S4, the QPD image is trained with a pre-trained deblurring model to obtain a deblurred image. Deblurring is to deblur the entire image area including the foreground and the background. In step S4, if the QPD image is a defocused image, then after the entire image area is deblurred, the entire image area changes from a defocused blurred image to a clear image; if the QPD image itself is a focused image, then after the entire image area is deblurred, the entire image area changes from a focused image (clear image) to a clearer image or maintains the original high-definition level. Step S4 is generalizable and is applicable to blurred images and clear images.

[0089] like Figure 7 As shown in FIG. 1 , the QPD image is a foreground defocused image (blurred image), and a deblurred image under foreground defocus is obtained through step S4. Figure 8 As shown, the QPD image is a foreground focused image (clear image), and a deblurred image under foreground focus is obtained through step S4.

[0090] Step S4 specifically includes:

[0091] S41, establish QPD defuzzification data set;

[0092] S42, training a neural network model for deblurring;

[0093] S43, reasoning stage: input QPD data and use the pre-trained model for deblurring.

[0094] Specifically, in step S41, the QPD deblurring data set includes an upper image, a lower image, a left image, and a right image.

[0095] Step S42, training a neural network model for deblurring; in this training phase, the raw domain blur image of the QPD is input into the deblurring neural network to output the deblurred Raw image, the pixel-by-pixel two-norm loss function of the output image and the label image is calculated, and the training is iteratively performed until the model is optimal (the loss function is low), so that the deblurred image trained by the model is as close to the label image as possible.

[0096] The deblurring neural network model may include: a weight sharing module, an SKFF module, a feature transformation module, a reconstruction module, and an upsampling module. Among them, the SKFF (Selective kernel feature fusion) module is used to dynamically adjust the feature receptive field. It first generates a global feature description by combining information from multiple resolution scales, then uses these descriptions to recalibrate the feature map, and finally performs an aggregate update. Based on the attention mechanism, the feature transformation module performs pixel-by-pixel multiplication on the feature channel dimension, counts the strength of the cross-correlation between features, and then enhances or suppresses the feature channel dimension information to achieve feature fusion.

[0097] Step S42 specifically includes:

[0098] The left image and the right image are respectively input into the first weight sharing module of the twin, and the feature weights of the left image and the right image are shared through the first weight sharing module to extract the first coarse-grained feature; then the fine-grained feature extraction and fusion are performed in turn through the first SKFF module and the first feature transformation module to obtain the left and right fused images;

[0099] The upper image and the lower image are respectively input into the second weight sharing module of the twin, and the feature weights of the upper image and the lower image are shared by the second weight sharing module to extract the second coarse-grained features; and then the fine-grained features are extracted and fused by the second SKFF module and the second feature transformation module in turn to obtain the upper and lower fused images;

[0100] The left-right fused image and the top-bottom fused image are further fused through the third SKFF module and the third feature transformation module to obtain the top-bottom, left-right fused image;

[0101] The image after fusion of top, bottom, left and right is subjected to feature fine-tuning and detail retention by a reconstruction module, and then subjected to difference operation by an upsampling module to restore the feature size to the size of the input image, and finally subjected to a residual block to superimpose the average result of the left image and the right image, and finally output the deblurred image. The reconstruction module can adopt a multi-layer cascaded residual operation unit.

[0102] Step S43, inference stage: input QPD data and use the pre-trained model for deblurring; in the inference stage, input the raw domain blur image of QPD into the trained deblurring neural network, output the deblurred Raw image and process it with ISP (image signal processor) to obtain the corresponding RGB image.

[0103] The present invention uses a deep learning model based on the phase characteristics of QPD image data to obtain more accurate disparity information and deblurring effects.

[0104] Step S5: weighted fusion of the foreground target mask and the deblurred image, and outputting a fused background blur image. Step S5 uses the following formula:

[0105] I bokeh =Deblur(I QPD ) * M roi +Blur(I QPD ) * (1-M roi )

[0106] Among them, I QPD For QPD images, Deblur(I QPD ) is the deblurred image output by the deblurring network; M roi Beblur is the foreground target mask output after the disparity image morphological transformation; QPD ) is the image after Gaussian blur operation. Deblur(I QPD ) * M roi Foreground area processing, the foreground defocused image is deblurred to become a clear image; Blur (I QPD ) * (1-M roi ) For the background area, the background area is blurred and defocused; finally, an image with a clear foreground and a blurred background is obtained. The background blur algorithm of the present invention can achieve a background blur effect in a foreground defocused scene. The background blur algorithm of the present invention can also achieve a background blur effect in a foreground focused scene.

[0107] like Fig. 9 As shown in FIG. 1 , the QPD image is a foreground defocused image (blurred image), and a fused background blurred image under foreground defocus is obtained through step S5. Fig.10 As shown, the QPD image is a foreground focused image (clear image), and a fused background blurred image under foreground focus is obtained through step S5.

[0108] It has been verified that the comparison of the background blur effect of close-range defocusing shows that the method of the present invention has a very good background blur visual effect; while the foreground of the second method in the background technology failed to achieve the focusing effect, but the background that is desired to be blurred is focused. The comparison of the background blur effect of medium-range defocusing shows that the method of the present invention has a very good background blur visual effect, while the second method in the background technology has a certain background blur effect, but the overall foreground and background contrast is not significant. The comparison of the background blur effect of long-range focusing shows that the method of the present invention can still achieve the background blur effect, while the second method in the background technology is basically ineffective. The comparison of the background blur effect of long-range defocusing shows that the method of the present invention can still achieve the background blur effect, while the second method in the background technology is basically ineffective.

[0109] In summary, the present invention provides an image processing method, including: obtaining a QPD image, wherein the QPD image is a defocused image or a focused image; using a pre-trained disparity estimation model to predict the disparity information of the QPD image, and outputting a disparity image; performing adaptive multi-disparity layering and morphological transformation based on machine learning on the disparity image to obtain a foreground target mask; training the QPD image using a pre-trained deblurring model to obtain a deblurred image; weightedly fusing the foreground target mask with the deblurred image to output a background blur image. The present invention can achieve the background blur effect using a QPD image (single-frame image), and the background blur effect is better than that of a traditional single-frame RGB image; it does not depend on the clarity of the image, and both defocused images and focused images can achieve the background blur effect; post-processing based on machine learning methods and morphological transformation can improve the foreground edge recognition.

[0110] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the method disclosed in the embodiment, since it corresponds to the device disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.

[0111] The above description is only a description of the preferred embodiment of the present invention, and is not any limitation on the scope of rights of the present invention. Any technical personnel in this field can make possible changes and modifications to the technical solution of the present invention by using the methods and technical contents disclosed above without departing from the spirit and scope of the present invention. Therefore, any simple modifications, equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention shall fall within the protection scope of the technical solution of the present invention.

Claims

1. An image processing method, characterized in that: include: Step S1, obtaining a QPD image, wherein the QPD image is a defocused image or a focused image; Step S2, using a pre-trained disparity estimation model to predict disparity information of the QPD image, and outputting a disparity image; Step S3, performing adaptive multi-parallax layering and morphological transformation based on machine learning on the disparity image to obtain a foreground object mask; Step S4, training the QPD image using a pre-trained deblurring model to obtain a deblurred image; Step S5: weightedly fuse the foreground object mask with the deblurred image to output a background blurred image.

2. The image processing method according to claim 1, characterized in that: Four adjacent pixels of the same color in the QPD image form a group, and there is parallax between any two of the four pixels in the same group; an upper image, a lower image, a left image and a right image are obtained by calculation based on the QPD image.

3. The image processing method according to claim 2, characterized in that: The upper image is obtained by taking the average value of the upper left and upper right pixels in each color group as the pixel value of the group after four-in-one combination; the lower image is obtained by taking the average value of the lower left and lower right pixels in each color group as the pixel value of the group after four-in-one combination; the left image is obtained by taking the average value of the upper left and lower left pixels in each color group as the pixel value of the group after four-in-one combination; the right image is obtained by taking the average value of the upper right and lower right pixels in each color group as the pixel value of the group after four-in-one combination.

4. The image processing method according to claim 2, wherein: Step S2 specifically includes: S21, establishing a QPD disparity data set, wherein the QPD disparity data set includes: the upper image, the lower image, the left image, and the right image; S22, training a QPD disparity estimation neural network model; S23, inputting QPD data, performing disparity estimation using the pre-trained neural network model, and outputting the disparity image.

5. The image processing method according to claim 4, characterized in that: The QPD disparity estimation neural network model includes: a feature encoder; the feature encoder is applied to the upper image and the lower image, and each of the images is mapped to a dense feature map; a recursive full field transform algorithm is used to calculate the visual similarity between all pixel pairs in the upper image and the lower image to construct a correlation volume and generate relevant features; the relevant features are passed through several convolutional layers and predict disparity updates, and then upsampled to obtain upper and lower phase disparity maps.

6. The image processing method according to claim 5, characterized in that: The feature encoder is applied to the left image and the right image, and a recursive full field transform algorithm is used to calculate the visual similarity between all pixel pairs in the left image and the right image to construct a correlation volume to obtain a left-right phase disparity map; the upper and lower phase disparity maps are fused with the left and right phase disparity maps, and the final disparity image is obtained after upsampling and further repair.

7. The image processing method according to claim 5, characterized in that: The recursive full field transform algorithm operates on feature maps with 1 / 4, 1 / 8 and 1 / 16 resolutions simultaneously through a multi-resolution update operator.

8. The image processing method according to claim 1, characterized in that: Step S3 includes step S31 and K-Means stratification; step S31 specifically includes: S311, converting the disparity image into one-dimensional data as input of the K-means algorithm; S312, clustering the one-dimensional data using the K-means algorithm; S313 , re-adjusting the category corresponding to the clustered one-dimensional data to the image size corresponding to the disparity image.

9. The image processing method according to claim 8, characterized in that: Step S3 also includes step S32, morphological transformation; step S32 specifically includes: S321, using a morphological opening operation with a preset kernel size to eliminate noise in the vicinity of the region of interest; S322, using a continuous region search function to perform connected region analysis on the region of interest; S323: Use the morphological closing operation with the preset kernel size to remove the noise inside the region of interest.

10. The image processing method according to claim 1, wherein: Step S4 specifically includes: S41, establish QPD defuzzification data set; S42, training a neural network model for deblurring; S43, reasoning stage: input QPD data and use the pre-trained deblurring neural network model to perform deblurring.

11. The image processing method according to claim 10, characterized in that: In step S42, the raw domain blur image of QPD is input into the deblurred neural network model to output the deblurred Raw image, and the pixel-by-pixel bi-norm loss function of the output image and the label image is calculated. The model is iteratively trained until it is optimal, so that the trained deblurred image is as close to the label image as possible.

12. The image processing method according to claim 10, characterized in that: Step S42 specifically includes: The left image and the right image are respectively input into the first weight sharing module of the twin, and the feature weights of the left image and the right image are shared by the first weight sharing module to extract the first coarse-grained feature; and then the fine-grained feature extraction and fusion are performed in turn by the first SKFF module and the first feature transformation module to obtain the left and right fused images; The upper image and the lower image are respectively input into the second weight sharing module of the twin, and the feature weights of the upper image and the lower image are shared by the second weight sharing module to extract the second coarse-grained features; and then the fine-grained features are extracted and fused by the second SKFF module and the second feature transformation module in turn to obtain the upper and lower fused images; The left-right fused image and the top-bottom fused image are further fused through a third SKFF module and a third feature transformation module to obtain a top-bottom, left-right fused image.

13. The image processing method according to claim 12, characterized in that: Step S42 specifically also includes: The image after fusion of up, down, left and right is subjected to feature fine-tuning and detail retention by a reconstruction module, and then the feature is subjected to difference operation by an upsampling module to restore the feature size to the size of the input image, and finally the result of averaging the left image and the right image is superimposed by a residual block to finally output the deblurred image.

14. The image processing method according to claim 10, characterized in that: Step S43: In the inference stage, the raw domain blur image of the QPD is input into the trained deblurring neural network model, and the deblurred Raw image is output and processed by an image signal processor to obtain a corresponding RGB image.

15. The image processing method according to claim 1, characterized in that: Step S5 uses the following formula: I bokeh =Deblur(I QPD )*M roi +Blur(I QPD ) * (1-M roi ) Among them, I QPD For the QPD image, Deblur(I QPD ) is the deblurred image output by the deblurring network; M roi Beblur(I QPD ) is the image after Gaussian blur operation.