Multi-focus image fusion method for eliminating defocusing diffusion effect
By generating real data sets based on optical imaging principles and using a two-stage fusion strategy of diffusion models and image fidelity networks, the problem of defocus diffusion effects in multi-focus image fusion is solved and high-quality image fusion effects are achieved.
Patent Information
- Application Number
- CN202410686666.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-30
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-05-30
AI Technical Summary
Existing multi-focus image fusion technology is difficult to effectively eliminate the defocus diffusion effect, mainly due to the unrealistic data set, insufficient backbone network structure and defects in the fusion strategy, resulting in color distortion and artifacts in the generated images.
A multi-focus image fusion data set is generated based on the principle of optical imaging, using a combination of diffusion model and image fidelity network, using a two-stage fusion strategy of 'generation and correction', and simulating real defocus by masking isometric lines and disc Gaussian blur to reduce Color distortion and artifact issues for generative models.
The performance of multi-focus image fusion is significantly improved, the defocus diffusion effect is effectively eliminated, the quality of the generated images is optimal, and the performance of various generation models is enhanced.
Smart Images

Figure CN118657668A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of multi-focus image fusion, and in particular relates to a multi-focus image fusion method for eliminating defocus diffusion effect. Background Art
[0002] Defocus blur (also called out-of-focus blur) is a distortion that occurs when the light source is off-focus in the image plane, i.e. objects that are out of focus appear as blurry spots instead of dots. Due to the depth of field (DoF) limitation of the camera lens, it is difficult to focus on all objects in complex scenes, resulting in some objects appearing out-of-focus blur. MFIF is designed to address the defocus blur problem caused by the depth of field of the camera lens. MFIF combines information from multiple source images with the same scene but different focused objects and generates a "fully focused" image.
[0003] The primary challenge facing current multi-focus image fusion is the defocus diffusion effect, which refers to the boundary area around the foreground object that is blurred in both source images due to the defocus of the background. Existing fusion methods are not very effective in solving DSE, which can be attributed to three aspects: dataset, architecture, and fusion strategy. First, there is a significant difference between the synthetic training set and the real multi-focus images. Due to the lack of training sets containing real multi-focus images and true values, the current mainstream practice is to synthesize training data from clear images using Gaussian filters or mean filters. However, the real defocus blur is more complex than the blur generated by these filters because it is affected by factors such as equipment, lighting, and object distance. Therefore, the two types of blur are not completely consistent, especially these filters cannot simulate the real DSE, which seriously limits the network performance, and this problem has long been ignored in the field of MFIF. Second, the current mainstream MFIF algorithms often use convolutional neural networks (CNN) or Transformer as the backbone network and use generative adversarial networks (GAN) as the generation strategy. However, the shortcomings of these mainstream architectures are that they increase the complexity of eliminating DSE. The local receptive field of CNN limits the model's ability to perceive the global focus of the object, and DSE usually occurs near the contours and edges of the focused object, which makes it difficult for CNN to accurately identify and solve DSE. Problems such as gradient vanishing, mode collapse, and convergence failure in GAN make it difficult to train the model to achieve the expected results. Transformer cannot solve the DSE problem at the pixel level based on global interactions and long-distance dependencies at the patch level. Finally, the existing state-of-the-art algorithms mainly adopt two fusion strategies: cascade and generation. The cascade strategy usually merges the focus area from the source image based on the binary decision map. However, since DSE exists in multiple source images at the same time, cascading cannot eliminate DSE anyway. The generation strategy involves using the network to extract and fuse effective features from multiple source images and reconstruct the fused image. Obviously, generation strategies have the potential to solve DSE, but they inevitably lead to severe color distortion and artifacts. Summary of the invention
[0004] The purpose of the present invention is to propose a multi-focus image fusion method for eliminating the defocus diffusion effect, which can effectively solve the defocus diffusion effect.
[0005] To achieve the above object, the present invention provides a multi-focus image fusion method for eliminating defocus diffusion effect, comprising:
[0006] Generate a multi-focus image fusion dataset based on the defocus blur prior of optical imaging principles;
[0007] Using the multi-focus image fusion data set to train a diffusion model, inputting the source image into the trained diffusion model, and obtaining an output fused image;
[0008] The source image and the fused image output by the diffusion model are input into the image fidelity network to obtain the fused multi-focus image.
[0009] Optionally, based on the defocus blur prior of the optical imaging principle, generating a multi-focus image fusion dataset includes:
[0010] Using randomly generated masks to guide the synthesis of multi-focus images to obtain mask images;
[0011] For the region of interest in the mask image, dense equidistant lines are set to obtain a mask Md image having a plurality of equidistant lines;
[0012] The mask Md image is used to guide the generation of a multi-focus source image to simulate a far-focus source image and a near-focus source image;
[0013] Based on an image degradation simulation method, the far-focus source image and the near-focus source image are processed to obtain the multi-focus image fusion data set.
[0014] Optionally, the mask image is
[0015]
[0016] Among them, M represents the generated binary mask, represents the mask generation function, I0 is an all-zero matrix of the same size as I, I represents the input source image, ρ1, ρ2 and ρ3 represent the area, shape and position of the region of interest respectively.
[0017] Optionally, for the region of interest in the mask image, setting dense equidistant lines includes:
[0018] Calculate the Euclidean distance between the non-boundary pixels of the region of interest and each boundary pixel of the region of interest in the mask, and select the shortest distance as D(x, y); where D(x, y) refers to the shortest distance from the non-boundary pixel M(x, y) in the mask image to the boundary pixel;
[0019] Based on the shortest distance D(x,y) from each pixel to the region of interest, a distance map of the same size as the mask image is formed; in the distance map, all pixels with values equal to D form an equidistant line;
[0020] Based on the equidistant lines, a distance set including several distance thresholds is established, and the dense equidistant lines are set based on the distance set; wherein each distance threshold in the distance set is generated by a random function, and each distance threshold satisfies a preset condition.
[0021] Optionally, the method for calculating the Euclidean distance is:
[0022]
[0023] Among them, (x si ,y si ) represents the coordinates of each boundary pixel Si, ||·|| represents the Euclidean distance in spatial coordinates, (x, y) represents the two-dimensional coordinates of the image pixel, which is used to locate the pixel position, P(x, y) represents the value of the pixel point with coordinates (x, y) in the distance map P, and n represents the total number of boundary pixels in the mask image;
[0024] The preset conditions that each distance threshold satisfies are:
[0025] D=R2(Max(P),Min(P),k),
[0026] Among them, D is the distance set, R2 is a random function, Max(P) and Min(P) represent the maximum and minimum values in the distance graph respectively, and k is a number.
[0027] Optionally, the method of simulating the far-focus source image is:
[0028]
[0029] Among them, I ω Indicates disk blur, I ω (x, y) represents the pixels covered by the window ω centered at (x, y) in image I, η represents the brightness parameter, r represents the window radius, I A (x, y) represents the source image I A The value of the pixel with spatial coordinates (x, y) in the mask image M, γ1 represents the disk filter, and M(x, y) represents the value of the pixel with spatial coordinates (x, y) in the mask image M;
[0030] The method to simulate a near-focus source image is:
[0031]
[0032] Among them, γ2 represents the Gaussian filter, σ represents the standard deviation of the Gaussian filter, and I B (x, y) represents the value of the pixel with spatial coordinates (x, y) in the synthesized source image B.
[0033] Optionally, based on an image degradation simulation method, the far-focus source image and the near-focus source image are processed, including:
[0034] Use a mean filter to define the boundaries within the mask;
[0035] Based on the boundaries within the defined mask, the center pixels are classified into non-boundary pixels and boundary pixels;
[0036] Performing a degradation operation on the far-focus source image and the near-focus source image;
[0037] According to the classified non-boundary pixels and boundary pixels, and the far-focus source image and the near-focus source image after the degradation operation, a multi-focus source image is synthesized, that is, the multi-focus image fusion data set is generated.
[0038] Optionally, the method for classifying the center pixel into a non-boundary pixel and a boundary pixel is:
[0039]
[0040] Where B represents the boundary map, Q(x, y) represents the boundary within the defined mask;
[0041] The method of performing degradation operation on the far-focus source image and the near-focus source image is:
[0042] H t =[(H*k h1 *k h2 )↓ s ]↑ u +n,
[0043] Among them, k h1 represents Gaussian blur, k h2 Indicates disk-like blur, ↓ s and ↑ u represents downsampling and upsampling operations, n represents randomly selected salt and pepper noise and Gaussian white noise, H t represents the result image processed by the image degradation operation, and H represents the source image I A or I B They are uniformly denoted as H;
[0044] The multi-focus source image is:
[0045]
[0046] Among them, H f (x, y) represents the final synthesized initial multi-focus source image.
[0047] Optionally, the image fidelity network adopts a lightweight convolutional network; the lightweight convolutional network is a CNN including several convolutional layers; except for the first layer and the last layer, each layer includes several filters of preset sizes for inputting images; the first layer and the last layer are composed of a single filter of preset size for image reconstruction, and the loss function is a mean square error;
[0048] The fused multi-focus image is:
[0049]
[0050] Among them, I final represents the fused multi-focus image, I initial represents the initial fused image output by the diffusion model, represents the image fidelity network, I A Represents the source image A, I B Represents the source image B.
[0051] The present invention has the following beneficial effects:
[0052] We focus on solving a long-neglected problem in multi-focus image fusion (MFIF), namely the unreality of the dataset, and propose a new method to generate a multi-focus image dataset. This method not only introduces the concept of equidistant lines in the mask to guide the filter blur, but also combines the advantages of disk blur and Gaussian blur. This method significantly narrows the gap between the synthetic training dataset and the real multi-focus images.
[0053] For the first time, a two-stage fusion strategy of "generation and correction" is introduced. In the generation stage, a diffusion model is used as the network architecture to effectively eliminate the defocus diffusion effect. In the correction stage, a lightweight network is proposed to alleviate the color distortion and artifact problems inherent in the generation model. Experiments have shown that this strategy can improve the performance of various generation models.
[0054] The present invention conducts extensive comparison and ablation experiments to prove the performance of the proposed model. Experimental results on seven test sets show that the model of the present invention can effectively solve the defocus diffusion effect and achieve the best performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0056] Figure 1 A schematic flow chart of a multi-focus image fusion method for eliminating defocus diffusion effect according to an embodiment of the present invention;
[0057] Figure 2 Schematic diagram of defocusing and defocusing imaging principle according to an embodiment of the present invention;
[0058] Figure 3 A schematic diagram of visual comparison of different blurring methods according to an embodiment of the present invention;
[0059] Figure 4 This is a schematic diagram of the model principle of an embodiment of the present invention;
[0060] Figure 5 Schematic diagram of the data set synthesis method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0061] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0062] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0063] Defocus blur prior:
[0064] From an optical point of view, camera imaging is the process of light passing through the lens and then being captured by the sensor. At the moment the shutter is pressed, the focal length of the lens is fixed, and the distance between the lens and the imaging plane of the sensor is also fixed. Therefore, there is a focal plane in the camera, and objects on the focal plane can be focused on the imaging plane and obtain a clear image. However, in the process of photography, there are often objects in the scene that are far away from the defocused plane. According to geometric optics, the light emitted or reflected by these objects forms a disk on the imaging plane after passing through the lens, which is called the blur circle (CoC) outside the focal plane.
[0065] From a mathematical point of view, defocus blur degenerates into:
[0066] d(x,y)=K(x,y)*h(x,y)+n(x,y),
[0067] Where (x, y) represents the spatial coordinates of the light on the lens, d(x, y) is the defocused blurred image, K(x, y) is the PSF, h(x, y) is the clear image, and n(x, y) is the noise. Ideally, the PSF can be described as:
[0068]
[0069] Where (c, d) represents the center of the lens and r is the radius of the defocus blur.
[0070] According to geometric optics, the farther the object is from the focal plane, the larger the CoC is, and the closer the object is to the focal plane, the smaller the CoC is. However, when the object is very close to the focal plane, factors such as diffraction and interference of light, front-end noise, and sensor sampling make the final image of light not present in the form of CoC.
[0071] In addition, in the real world, this embodiment found that bright spots are more obvious after defocusing. This is because the light emitted or reflected by the bright spots passes through the convex lens of the lens to form an image, while the dark spots do not emit or reflect less light and do not participate in the imaging process. The defocus blur characteristics at different distances are as follows Figure 2 shown.
[0072] Based on the foregoing, this embodiment summarizes the following priors:
[0073] Priori 1. When an object is outside the focal plane and is not particularly close to the focal plane, the light emitted or reflected by it forms a disk on the image plane after passing through the lens.
[0074] Priori 2. The farther the object is from the focal plane, the larger the CoC is, and the closer the object is to the focal plane, the smaller the CoC is.
[0075] Priori 3. When the object is outside the focal plane and is particularly close to the focal plane, factors such as diffraction and interference of light, front-end noise, and sensor sampling make the final image of the light not appear in the form of CoC, but more like Gaussian blur.
[0076] Prior 4. Since bright spots are greatly affected during defocused imaging, the bright areas are more obvious after defocusing.
[0077] Based on prior 1, this embodiment applies a disk blur method to pixels to simulate the diffusion of blur circles. This embodiment applies Gaussian blur and disk blur to obtain two corresponding images of a high-definition city night scene, such as Figure 3 As shown. Obviously, the image obtained by disk blur is closer to the visual perception of defocus blur in the real world. Especially in the luminous area, Gaussian blur cannot simulate the blur circle, while disk blur can.
[0078] Based on priori 2, when simulating defocus blur, this embodiment needs to design the distance relationship between far and near, and adjust the degree of pixel diffusion.
[0079] Based on priori 3, when the object is very close to the focal plane, this embodiment uses Gaussian blur to simulate the interference of various factors.
[0080] Based on prior 4, this embodiment should make the diffusion of the bright area of the image more obvious to make it more consistent with the real scene, rather than treating all pixels equally.
[0081] Multi-focus image fusion effectively improves the visual quality of images with partial focus defects. Defocus diffusion effect (DSE) is one of the most challenging problems in the field of multi-focus image fusion. To solve this problem, this embodiment proposes a comprehensive solution, which includes three key aspects: dataset generation, backbone network selection, and fusion strategy. In terms of dataset generation, this embodiment solves the significant gap between synthetic datasets and real multi-focus images by summarizing the defocus blur prior (DBP) based on the principle of optical imaging. With the support of DBP, this embodiment designs an innovative dataset generation technology. This technology defines the concept of mask equidistant lines and effectively combines Gaussian blur and disk blur to simulate distance-sensitive near-focus and far-focus blur. In terms of backbone network selection, this embodiment finds that the diffusion model is more suitable for MFIF than CNN and Transformer. By using synthetic multi-source images as additional conditions for DDPM training, DSE in the fusion process is effectively eliminated. In terms of fusion strategy, this embodiment proposes a two-stage "generate and correct" strategy, introducing a lightweight image fidelity network that can alleviate the image distortion problem inherent in the generative model. The benchmark experimental results show that: (i) the generative model of this embodiment has the best performance and produces fully focused images without DSE; (ii) the dataset generation method and image fidelity network proposed in this embodiment are model-independent and effectively enhance various MFIF algorithms.
[0082] This embodiment adopts a comprehensive approach consisting of three parts: dataset generation strategy, diffusion model and image fidelity network, such as Figure 4 As shown. During the training process, this embodiment proposes a new data generation method to obtain a more realistic multi-focus image fusion (MFIF) dataset, and uses this dataset to train the diffusion model in the first stage. In the second stage, the source image and its corresponding image generated by the diffusion model are input into the image fidelity network to obtain the corrected image. During the fusion (testing) process, the model receives the real multi-focus source image as input and outputs a fully focused fused image.
[0083] A multi-focus image fusion method for eliminating defocus diffusion effect proposed in this embodiment includes:
[0084] Generate a multi-focus image fusion dataset based on the defocus blur prior of optical imaging principles;
[0085] The diffusion model is trained using the multi-focus image fusion dataset, and the source image is input into the diffusion model to obtain the corresponding image;
[0086] The source image and the corresponding image are input into the image fidelity network to obtain the fused multi-focus image.
[0087] Furthermore, the defocus blur prior based on the optical imaging principle is used to generate a multi-focus image fusion dataset including:
[0088] Using randomly generated masks to guide the synthesis of multi-focus images to obtain mask images;
[0089] For the region of interest in the mask image, dense equidistant lines are set to obtain a mask Md image having a plurality of equidistant lines;
[0090] The mask Md image is used to guide the generation of a multi-focus source image to simulate a far-focus source image and a near-focus source image;
[0091] Based on an image degradation simulation method, the far-focus source image and the near-focus source image are processed to obtain the multi-focus image fusion data set.
[0092] Furthermore, for the region of interest in the mask image, setting dense equidistant lines includes:
[0093] Calculate the Euclidean distance between the non-boundary pixels of the region of interest and each boundary pixel of the region of interest in the mask, and select the shortest distance as D(x,y);
[0094] Based on the shortest distance D(x, y) from each pixel to the region of interest, a distance map of the same size as the mask image is formed;
[0095] For each determined distance d, all pixels in the distance map having a value equal to d form an equidistant line;
[0096] Based on the equidistant lines, a distance set including several distance thresholds is established, and the dense equidistant lines are set based on the distance set; wherein each distance threshold in the distance set is generated by a random function, and each distance threshold satisfies a preset condition.
[0097] Furthermore, based on the image degradation simulation method, the far-focus source image and the near-focus source image are processed, including:
[0098] Use a mean filter to define the boundaries within the mask;
[0099] Based on the boundaries within the defined mask, the center pixels are classified into non-boundary pixels and boundary pixels;
[0100] Performing a degradation operation on the far-focus source image and the near-focus source image;
[0101] According to the classified non-boundary pixels and boundary pixels, and the far-focus source image and the near-focus source image after the degradation operation, a multi-focus source image is synthesized, that is, the multi-focus image fusion data set is generated.
[0102] Specifically, the data set generation method in this embodiment is:
[0103] Due to the lack of real multi-focus datasets, this embodiment introduces a new dataset generation method, which is a core contribution of the model of this embodiment. Experimental observations show that even with the use of a diffusion model, other data generation methods still cannot eliminate the defocus spread effect (DSE). The data generation method of this embodiment includes four steps: random mask generation, dense equidistant line setting, multi-focus map fusion, and simulated DSE image degradation. These steps are discussed in detail below. For clarity, a high-definition natural image is defined as I∈R H*W*3 , where H and W represent the size of I. The process flow is as follows Figure 5 shown.
[0104] 1) Random mask generation: Consistent with existing methods in the field, this embodiment uses randomly generated masks to guide the synthesis of multi-focus images. These masks contain random positions, areas, and shapes of regions of interest (ROIs), as described in formula (3).
[0105]
[0106] Where M represents the generated binary mask (black pixels represent the background and white pixels represent the region of interest); φ represents the mask generation function; I0 is an all-zero matrix of the same size as I; ρ1, ρ2 and ρ3 are random parameters generated according to formula (4), representing the area, shape and position of the region of interest, respectively.
[0107] ρ1,ρ2,ρ3=R1(H,W), (4)
[0108] Wherein, R1 represents a function used to generate random parameters.
[0109] The advantage of randomly generated masks is that they can generate a large number of multi-focus source images on a limited dataset, circumventing the limitations of hand-made masks. Although these random masks lack consideration of image content and semantic information, they do not prevent the network from generating high-quality fused images, because image clarity is the key feature of the task.
[0110] 2) Setting of dense equidistant lines: According to priors 1 to 3, it can be clearly seen that in actual imaging scenes, defocus blur is very sensitive to distance. Therefore, this embodiment proposes the concept of equidistant lines of the mask. That is, the boundary of the region of interest is regarded as the depth of field boundary of the lens, and the pixels equidistant from the boundary form equidistant lines, and different equidistant lines are set at different distances.
[0111] Specifically, assume that the boundary pixel set of the region of interest is represented by S = {S1, S2, ..., S n}; In this embodiment, the Euclidean distance between the non-boundary pixel (x, y) and each boundary pixel Si in the mask is calculated, and the shortest distance is selected as D(x, y), as shown in formula (5).
[0112]
[0113] Where (xsi, ysi) represents the coordinates of pixel Si, and ||·|| represents the Euclidean distance in the spatial coordinates. Therefore, each pixel has its shortest distance to the ROI, forming a distance map P of the same size as M. For each determined distance D, all pixels in P with a value equal to D form an isoline. To set dense isolines, this embodiment establishes a distance set D = {D1, D2,..., D k}, where each threshold in D is generated by a random function R2, satisfying D1 < D2 <... < Dk, as shown in formula (6):
[0114] D = R2(Mar(P), Min(P), k), (6)
[0115] Where Max(P) and Min(P) represent the maximum and minimum values in P, respectively.
[0116] Through these steps, this embodiment obtains a mask Md with k isolines. As Figure 5 shown, each isoline perfectly reflects the shape of the ROI region, similar to the inward or outward diffusion of the ROI shape. In an actual shooting scenario, the boundary of the DoF is often determined by the shape of the focused object. Obviously, this phenomenon of the diffusion of the ROI shape is consistent with the actual situation.
[0117] 3) Multi-focus image generation: Use Md with isolines to guide the generation of multi-focus source images. Priors 2 - 3 clearly point out the differences between near focus and far focus: near focus is more in line with disc blur, while far focus is similar to Gaussian blur. Therefore, this embodiment adopts the following steps to simulate the far-focus source image IA and the near-focus source image IB.
[0118] For IA, this embodiment uses disc blur to simulate far defocus, as shown in formula (7).
[0119]
[0120] Where, Iω represents disc blur; Iω(x, y) represents the pixels covered by the window ω centered at (x, y) in the image I; η represents the brightness parameter; r represents the window radius, which is calculated by formula (8).
[0121]
[0122] Among them, r1, r2, ..., rk are integers randomly selected from the interval (0, 50], satisfying r1 < r2 < ... < rk. The random generation from r1 to rk effectively simulates defocus blur at different distances. It is obvious from formula (8) that the farther away from the DoF boundary, the larger r is, the greater the blur, and the more obvious the diffusion effect.
[0123] For IB, in this embodiment, Gaussian blur is used to simulate near defocus, and at the same time, lens and front-end noise are introduced, as shown in formula (9).
[0124]
[0125] Among them, γ2 represents the Gaussian filter; r is the window radius, which is also calculated by formula (8); σ represents the standard deviation of the Gaussian filter, which is determined by formula (10).
[0126]
[0127] Among them, σ1, ..., σk are numbers randomly selected from the interval (0, 100], satisfying σ1 < σ2 < ... < σk. In the case of near-focus blur, the target farther away from the DoF boundary is closer to the lens, resulting in increased blur.
[0128] Simulating DSE image degradation: Considering that DSE is composed of various noises and blurs mixed together, this embodiment designs the following image degradation process for simulation. First, a mean filter is used to define the boundaries within the mask, as shown in formula (11)
[0129]
[0130] Among them, 2r + 1 represents the window size. If the mean of the window is equal to 0 or 1, the central pixel is classified as a non-boundary pixel; otherwise, it is regarded as a boundary pixel, as shown in formula (12)
[0131]
[0132] Among them, B represents the boundary mapping. Inspired by the blind image super-resolution model, this embodiment performs a degradation operation on the synthesized multi-focus source image IA or IB (collectively referred to as H), as shown in formula (13)
[0133] H t =[(H*k h1 *k h2 )↓ s ↑ u +n, (13)
[0134] Among them, kh1 represents Gaussian blur, kh2 represents disk blur; ↓s and ↑u represent downsampling and upsampling operations to increase the additional loss of clarity; n represents randomly selected salt and pepper noise and Gaussian white noise. Finally, the final multi-focus source image is synthesized according to the boundary map B:
[0135]
[0136] Wherein, Hf represents the final synthesized source image.
[0137] Specifically, in this embodiment, the method for training the diffusion model is:
[0138] Since the performance of the generated model is poor in the MFIF field, the diffusion model is introduced. The dataset was obtained during the dataset generation process. xi and yi represent partially defocused synthetic source images. zi represents a “fully focused” image with high definition. In addition, D represents samples drawn from the unknown conditional distribution p(z|(x,y)).
[0139] A pure noise image can be viewed as the result of gradually adding Gaussian noise to the signal through a fixed Markov chain. Assuming that the algorithm generates the noisy image through T steps, starting from the normal image z0, the algorithm continuously iteratively optimizes the image (z0,...,zT-1,zT) according to the transition distribution q(zt|zt-1) so that zT~N(0,I), where t∈{0,1,...,T}, N represents the Gaussian noise distribution, and I is the same identity matrix as the initial state z0. The task of MFIF is to learn an inverse Markov chain conditioned on (x,y) that can restore the noisy image to z0. Specifically, the model needs to iteratively converge from zT~N(0,I) to z0~p(z|(x,y)) according to its learned pθ(zt-1|zt,(x,y)).
[0140] The method to obtain pθ(zt-1|zt,(x,y)) is to train a noise estimation network, as shown in Algorithm 1. The noise estimation network uses U-net, which has the same number of layers as DDPM. The process of recovering from the noisy image is shown in Algorithm 2. The derivation process of the specific formula is similar to that of DDPM.
[0141] Specifically, the image fidelity network proposed in this implementation is:
[0142] The goal of the image fidelity network is to reduce color distortion and artifacts caused by the inherent defects of the generative model. This embodiment is inspired by Jiwon Kim and uses a lightweight convolutional network. The convolutional network is a CNN containing 20 convolutional layers. Except for the first and last layers, each layer has 64 filters of size 3×3×64 for input images. The first and last layers are composed of a single filter of size 3×3×64 for image reconstruction, and the loss function is the mean square error. This embodiment uses a set of data as an example to illustrate its working principle. G represents the trained diffusion generation model. F, IA and IB represent the image fidelity network and two images to be fused, respectively.
[0143] The input of F is three images, including a pair of source images and an output image generated by the trained diffusion model. Therefore, this embodiment uses G, IA and IB to obtain the initial fused image Iinitial, that is,
[0144]
[0145] When training F, this embodiment first generates a data set for this stage, and then inputs the source image into the diffusion model to obtain a final data set for training.
[0146] According to the superiority of residual learning proved by Jiwon Kim, F does not directly output the final fused image Ifinal, but outputs the residual between Ifinal and Iinitial. The final fused image is shown in formula (16):
[0147]
[0148] The following is an example of the improvement effect of the method of this embodiment:
[0149] 1. Multi-focus image fusion based on deep learning;
[0150] Mainstream deep learning-based multi-focus image fusion (MFIF) algorithms usually use cascade and generation strategies to generate fused images. The main goal of cascade-based fusion algorithms is to create high-quality binary decision graphs, which play a key role in reflecting the detection of focus areas and directly determine the quality of the fused image. Liu et al. proposed the first CNN-based decision graph algorithm, which uses CNN to learn the mapping from the original image to the decision graph to obtain high-quality decision graphs, providing a prototype for many subsequent algorithms. Tang et al. proposed pixel-level convolutional neural network (p-CNN), a method for learning focus measurement that can identify focus and non-focus pixels in the source image. Li et al. proposed DRPL, which directly converts the entire image into a binary mask so that there is no need for patch operation. This method effectively solves the problem of estimating blur levels between focus and non-focus areas. In order to alleviate the negative impact of dataset scarcity on model performance, this embodiment proposes a self-supervised model based on a new residual gradient prior in previous work. This model achieves good results without MFIF training data. In addition, this embodiment proposes VSPFuse based on visual saliency prior, which uses salient object detection as a pre-training task. Recently, this embodiment proposes an edge perception layer based on image manifold theory and domain transformation, which can improve the performance of the CNN architecture. However, since the decision graph cannot restore the details of the common defocused area, all of the above methods cannot effectively solve DSE. Since the method of this embodiment is essentially an end-to-end generation method, this disadvantage can be avoided to a limited extent.
[0151] For models that adopt a generative strategy, their goal is to generate fused images end-to-end based on the source input. These models can bypass the need for decision graphs, which is consistent with other image fusion tasks. Zhang et al. introduced a general image fusion framework IFCNN based on CNN for multi-image fusion tasks. Zhao et al. proposed a multi-level fusion architecture based on CNN and used image super-resolution to improve image details. Xu et al. proposed U2Fusion, which adopted an unsupervised learning strategy, designed a good loss function and an efficient backbone network, and achieved significant performance improvements in unified image fusion, laying the foundation for this field. Huang et al. proposed an end-to-end fusion method based on GAN to restore image details through generative adversarial learning. Ma et al. proposed Swin-Fusion using Swin-Transformer as the backbone network. Using the powerful feature representation ability of Transformer, Swin-Fusion achieved the best performance in multiple image fusion tasks. These models can only slightly alleviate DSE, but inevitably lead to color distortion and obvious artifacts. In contrast, this embodiment adopts a two-stage training strategy, in which the diffusion model effectively suppresses DSE and the lightweight image fidelity network alleviates the color distortion problem.
[0152] 2. Diffusion Model
[0153] Recent studies have shown that diffusion models have the ability to generate high-quality images, videos, molecules, and other types of data. The basic idea of diffusion models is to systematically perturb the distribution of data in the forward diffusion process, and then restore the distribution of data by learning the inverse diffusion process.
[0154] Diffusion models have significant advantages over CNNs, Transformer models, and GANs. First, the diffusion model adopts a unique generation strategy that refines the probability distribution of data through iterations instead of directly generating samples, which makes it more flexible in dealing with different data types. Second, the diffusion model performs well in the field of image generation, especially in tasks involving high-quality, high-resolution images. In contrast, CNNs and Transformer models usually require larger model sizes to achieve similar results, which increases computational costs. Finally, the diffusion model performs well in handling sparse data during training because its generation process does not rely on dense point-to-point information propagation, while CNNs and Transformers usually have higher requirements for data.
[0155] In the context of image fusion, diffusion models have particularly valuable applications. Diffusion models provide a refreshing alternative to image fusion via a probabilistic framework. By iteratively diffusing information over the input image, it is able to effectively integrate content from multiple sources. In addition, the ability of diffusion models to handle complex multimodal data distributions makes them particularly suitable for fusing images with different properties or features. For example, Zhao et al. considered the fusion task as a conditional generation problem and proposed a multimodal image fusion method (DDFM) based on a denoising diffusion model. This method exploits robust generative priors and effectively alleviates the problems of training instability and lack of interpretability common to GAN-based generation techniques. Li et al. proposed DDPM-based FusionDiff for MFIF tasks, which is noise-resistant and can produce excellent fusion results from source images with noise interference. However, this method is still powerless in eliminating DSE and solving the problem of dataset scarcity.
[0156] The model of this embodiment is similar to FusionDiff, and also uses the classic DDPM to generate a fused image. However, it is worth noting that the method of this embodiment effectively alleviates DSE and can generate a more realistic multi-focus image dataset.
[0157] 3. MFIF dataset generation
[0158] Due to the lack of real MFIF training sets and benchmark data, several methods have been proposed to generate training data sets. Guo et al. synthesized a large-scale multi-focus image dataset and used a normalized point spread function to simulate defocus for the first time. However, it ignored the problem of different diffusion levels of different pixels in the same image due to brightness differences. Li et al. used 12 hand-drawn masks combined with Gaussian blur to generate synthetic data for training, but this made the network prone to overfitting on these masks. Ma et al. first used the α mask boundary defocus model and Gaussian blur to generate training data with DSE effect, but Gaussian blur made the generated data lack of realism. Nian et al. generated training data based on light field data and refocused using the characteristics of light field cameras that can record the cumulative intensity and depth information of light. However, due to the limitations of the light field camera itself, the actual generated effect has a single and slight blur.
[0159] Different from the above methods, the dataset generation method proposed in this embodiment fully considers the imaging prior. This method introduces the concept of equidistant lines for the first time to guide mask-based image filtering. In addition, it combines the advantages of Gaussian blur and disk blur to realistically simulate real defocus blur and DSE.
[0160] In order to effectively solve the defocus diffusion effect, this embodiment proposes solutions for the above three aspects. In terms of data sets, in order to simulate more realistic defocus blur, this embodiment summarizes prior knowledge based on imaging principles, including concepts such as point spread function (PSF), defocus circle, focal plane, far-field defocus, and near-field defocus. Supported by these defocus blur priors, this embodiment introduces a new method to generate a data set of multi-focus images. In this method, this embodiment introduces the concept of equidistant lines in the mask, which consists of pixels with equal shortest distances to the region of interest (ROI). This embodiment densely arranges equidistant lines in the mask to ensure that each pixel in the mask is assigned a corresponding distance range. For pixels closer to the ROI, this embodiment assumes that the objects they are associated with in the imaging scene are closer to the depth of focus, so Gaussian blur is used to simulate the noise introduced by factors such as lenses and circuits. For pixels farther from the ROI, this embodiment uses a disk blur that is more similar to real defocus blur, which effectively simulates the DSE caused by light spots. This method significantly narrows the gap between synthetic training data sets and real multi-focus images.
[0161] In terms of architecture, this embodiment adopts a diffusion model that has recently performed well in the field of image generation. There are two main reasons for using a diffusion model for MFIF tasks: strong adaptability to synthesizing information in zoomed areas and tolerance to noise. On the one hand, diffusion models are good at adaptively synthesizing information from different image regions. Therefore, they can also merge regions with different focus levels, ensuring that details acquired from different focal planes can be accurately integrated. On the other hand, diffusion models inherently contain denoising capabilities, which improve the quality of the fused image by reducing noise artifacts, and this noise reduction greatly benefits the elimination of DSE. In order to adapt to the MFIF task, this embodiment uses two synthetic source images and one noisy image as the conditions of the model, and the corresponding high-resolution natural image as GT. Experiments have shown that even the original diffusion model DDPM can achieve optimal performance when combined with synthetic datasets.
[0162] In terms of fusion strategy, this embodiment introduces a two-stage strategy of "generation and correction" for the first time, which includes a diffusion model and a lightweight image fidelity network. For images generated by the diffusion model, the image fidelity network effectively eliminates color distortion and artifacts, ensuring high fidelity between the fused image and the source image. Experiments have shown that the image fidelity network is not only effective for images generated by the diffusion model, but also improves the quality of fused images generated by other models such as Transformer and CNN.
[0163] The contributions of the present invention are summarized as follows:
[0164] We focus on solving a long-neglected problem in multi-focus image fusion (MFIF), namely the unreality of the dataset, and propose a new method to generate a multi-focus image dataset. This method not only introduces the concept of equidistant lines in the mask to guide the filter blur, but also combines the advantages of disk blur and Gaussian blur. This method significantly narrows the gap between the synthetic training dataset and the real multi-focus images.
[0165] Based on the imaging principle, the defocus blur priors of MFIF are summarized. These priors include the concepts of defocus circle, point spread function (PSF), object distance, near-field defocus, and far-field defocus, which strongly support the rationality of the proposed dataset generation method.
[0166] For the first time, a two-stage fusion strategy of "generation and correction" is introduced. In the generation stage, a diffusion model is used as the network architecture to effectively eliminate the defocus diffusion effect. In the correction stage, a lightweight network is proposed to alleviate the color distortion and artifact problems inherent in the generation model. Experiments have shown that this strategy can improve the performance of various generation models.
[0167] Extensive comparisons and ablation experiments were conducted to demonstrate the performance of the proposed model. Experimental results on seven test sets show that the model of this embodiment can effectively solve the defocus diffusion effect and achieve the best performance.
[0168] The above are only preferred specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A multi-focus image fusion method to eliminate the defocus diffusion effect, It is characterized in that include: Generate a multi-focus image fusion dataset based on the defocus blur prior of optical imaging principles; Using the multi-focus image fusion data set to train a diffusion model, inputting the source image into the trained diffusion model, and obtaining an output fused image; The source image and the fused image output by the diffusion model are input into the image fidelity network to obtain the fused multi-focus image.
2. The multi-focus image fusion method for eliminating defocus diffusion effect according to claim 1, It is characterized in that Based on the defocus blur prior of optical imaging principles, the multi-focus image fusion dataset is generated, including: Using randomly generated masks to guide the synthesis of multi-focus images to obtain mask images; For the region of interest in the mask image, dense equidistant lines are set to obtain a mask Md image having a plurality of equidistant lines; The mask Md image is used to guide the generation of a multi-focus source image to simulate a far-focus source image and a near-focus source image; Based on an image degradation simulation method, the far-focus source image and the near-focus source image are processed to obtain the multi-focus image fusion data set.
3. The multi-focus image fusion method for eliminating defocus diffusion effect according to claim 2, It is characterized in that The mask image is Among them, M represents the generated binary mask, represents the mask generation function, I 0 is a zero matrix of the same size as I, where I represents the input source image, and ρ 1 , 2 and ρ 3 Respectively represent the area, shape and location of the region of interest.
4. The multi-focus image fusion method for eliminating defocus diffusion effect according to claim 2, It is characterized in that For the region of interest in the mask image, setting dense equidistant lines includes: Calculate the Euclidean distance between the non-boundary pixels of the region of interest and each boundary pixel of the region of interest in the mask, and select the shortest distance as D(x, y); where D(x, y) refers to the shortest distance from the non-boundary pixel M(x, y) in the mask image to the boundary pixel; Based on the shortest distance D(x, y) from each pixel to the region of interest, a distance map of the same size as the mask image is formed; in the distance map, all pixels with values equal to D form an equidistant line; Based on the equidistant lines, a distance set including several distance thresholds is established, and the dense equidistant lines are set based on the distance set; wherein each distance threshold in the distance set is generated by a random function, and each distance threshold satisfies a preset condition.
5. The multi-focus image fusion method for eliminating defocus diffusion effect according to claim 4, It is characterized in that The method for calculating the Euclidean distance is: Among them, (x si ,y si ) represents the coordinates of each boundary pixel Si, ||·|| represents the Euclidean distance in spatial coordinates, (x, y) represents the two-dimensional coordinates of the image pixel, P(x, y) represents the value of the pixel with coordinates (x, y) in the distance map P, and n represents the total number of boundary pixels in the mask image; The preset conditions that each distance threshold satisfies are: D=R 2 (Max(P),Min(P),k), Where D is the distance set, R 2 is a random function, Max(P) and Min(P) represent the maximum and minimum values in the distance graph respectively, and k is a number.
6. The multi-focus image fusion method for eliminating defocus diffusion effect according to claim 2, It is characterized in that The method for simulating the far-focus source image is: Among them, I ω Indicates disk blur, I ω (x, y) represents the pixels covered by the window ω centered at (x, y) in image I, η represents the brightness parameter, r represents the window radius, and IA(x, y) represents the source image I A The value of the pixel with coordinates (x, y) in the hollow domain, γ 1 represents a disk filter, M(x, y) represents the value of the pixel with spatial coordinates (x, y) in the mask image M; The method to simulate a near-focus source image is: Among them, γ 2 represents the Gaussian filter, σ represents the standard deviation of the Gaussian filter, I B (x, y) represents the value of the pixel with spatial coordinates (x, y) in the synthesized source image B.
7. The multi-focus image fusion method for eliminating defocus diffusion effect according to claim 2, It is characterized in that Based on the image degradation simulation method, the far-focus source image and the near-focus source image are processed, including: Use a mean filter to define the boundaries within the mask; Based on the boundaries within the defined mask, the center pixels are classified into non-boundary pixels and boundary pixels; Performing a degradation operation on the far-focus source image and the near-focus source image; According to the classified non-boundary pixels and boundary pixels, and the far-focus source image and the near-focus source image after the degradation operation, a multi-focus source image is synthesized, that is, the multi-focus image fusion data set is generated.
8. The multi-focus image fusion method for eliminating defocus diffusion effect according to claim 7, It is characterized in that The method for classifying center pixels into non-boundary pixels and boundary pixels is: Where B represents the boundary map, Q(x, y) represents the boundary within the defined mask; The method of performing degradation operation on the far-focus source image and the near-focus source image is: H t =[(H*k h1 *k h2 )↓ s ]↑ u +n, Among them, k h1 represents Gaussian blur, k h2 Indicates disk-like blur, ↓ s and ↑ u represents downsampling and upsampling operations, n represents randomly selected salt and pepper noise and Gaussian white noise, H t represents the result image processed by the image degradation operation, and H represents the source image I A or I B They are uniformly denoted as H; The multi-focus source image is: Among them, H f (x, y) represents the final synthesized initial multi-focus source image.
9. The multi-focus image fusion method for eliminating defocus diffusion effect according to claim 1, It is characterized in that The image fidelity network adopts a lightweight convolutional network; the lightweight convolutional network is a CNN including several convolutional layers; except for the first layer and the last layer, each layer includes several filters of preset sizes for inputting images; the first layer and the last layer are composed of a single filter of preset size for image reconstruction, and the loss function is a mean square error; The fused multi-focus image is: Among them, I final represents the fused multi-focus image, I initial represents the initial fused image output by the diffusion model, represents the image fidelity network, I A Represents the source image A, I B Represents the source image B.
Citation Information
Patent Citations
Image fusion processing system and method of display
CN115690149A
Multi-focus image fusion method based on attention mechanism
CN117475283A
Cited By
Full-focusing super-resolution imaging method based on deconvolution
CN120355809A
A super-resolution imaging method based on deconvolution and full focusing
CN120355809B
