All-focus image diffusion generation method based on light field data
By generating fully focused images using light field data and diffusion models, the problems of defocusing and blurring caused by limited depth of field and insufficient datasets are solved, thus achieving efficient generation of high-quality fully focused images.
Patent Information
- Application Number
- CN202410428150.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-10
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2044-04-10
AI Technical Summary
Existing technologies struggle to capture all clear, full-focus images in the same scene, and the lack of large-scale, scene-rich datasets during multi-focus image fusion results in poor learning efficiency for network models.
A full-focus image diffusion generation method based on light field data is adopted. Light field focused stacked images are generated by virtual scene rendering or light field camera shooting. A supervised training dataset is constructed, and wavelet transform is used to convert image information to the frequency domain. Combined with diffusion model and image detail restoration module, full-focus images are generated.
It enables the generation of high-quality full-focus images from a single or a small number of defocused images, improving the model's generalization and robustness, reducing computational resource consumption, and enhancing the quality of full-focus image synthesis.
Smart Images

Figure CN118212136B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing and imaging technology, specifically relating to a method for generating fully focused images based on light field data. Background Technology
[0002] As we know from the principles of imaging, optical lenses have a limited depth of field. In actual shooting, areas outside the depth of field will appear out of focus and blurry. Therefore, in most cases, existing imaging devices struggle to obtain images where all objects or areas in a scene are sharp. In some emerging fields, a shallow depth of field can be used to highlight the subject and blur the background, but most photographers desire a completely sharp image, i.e., a fully focused image.
[0003] Multi-focus image fusion (MFIF) technology combines the focus stacks of multiple partially focused images of the same scene to form a single fully focused fused image. MFIF imaging technology aligns well with human observation habits, and has therefore seen rapid development in fields such as computer vision, image processing, and imaging technology.
[0004] Traditional multi-focus image fusion methods can be divided into two main categories: transform domain-based and spatial domain-based methods. In 2020, Liu et al. […].<Multi-focus image fusion:a survey of the state of the art> This section provides a detailed overview. Transform domain-based methods are implemented through three steps: image decomposition (transformation), coefficient fusion, and image reconstruction (inverse transform). Simply put, it transforms the image to another domain and then performs various fusion operations through inverse transform. Depending on the image representation model, it can be further subdivided into methods based on multi-scale transform, sparse representation, gradient domain, and hybrid transform. Spatial domain-based methods are obtained by processing and fusing the original image in its spatial domain. These methods typically fuse the source images based on the image's spatial activity and a certain fusion rule.
[0005] Deep learning-based multi-focus image fusion technology was first proposed by Liu et al. in 2017.<Multi-focus imagefusion with a deep convolutional neural network> First proposed in China, and after years of rapid development, there are now nearly a hundred deep learning-based methods for Multifocal Image Fusion (MFIF). Convolutional Neural Networks (CNNs) and Generative Adversarial Networks (GANs) have been successfully applied to MFIF research. Classification-based MFIF methods use classification convolutional networks to model multifocal image fusion as a pixel focus attribute discrimination problem, and can be further subdivided into image block-based methods and image segmentation-based methods. Regression-based methods use network models to predict the fused image, learning the end-to-end mapping between the source image and the fused image. Depending on the network model training method, these can be divided into supervised learning and unsupervised learning.
[0006] Thanks to continuous research in image processing in recent years, traditional and deep learning-based MFIF research has made great progress. However, with the increasing diversity of image data and higher evaluation standards, many challenges still need to be addressed in the MFIF field. These include the need for the entire focusing stack as input for image fusion, the lack of large-scale datasets with real labels, and the fact that network models and learning efficiency cannot yet achieve the expected results. Summary of the Invention
[0007] The purpose of this invention is to provide a method for generating fully focused images based on light field data, which can solve the problem of local defocusing and blurring in images captured in the same scene due to the limited depth of field of the camera; and overcome the problem of lacking large-scale, scene-rich datasets in the process of multi-focus image fusion.
[0008] The technical solution adopted in this invention is a method for generating fully focused image diffusion based on light field data, which specifically includes the following steps:
[0009] Step 1: Use virtual scene rendering software to synthesize or use a light field camera to capture and process light field data of different scenes, use the light field refocusing algorithm to generate light field focused stacked images, and build a supervised training dataset; use wavelet transform to transform the image information in the supervised training dataset from the spatial domain to the frequency domain; Step 2: Use the diffusion model as the basic network structure to build a generative neural network model for fully focused images;
[0010] Step 3: Input the supervised training dataset obtained from the wavelet transform in Step 1 into the generative neural network model built in Step 2 for training, and perform diffusion processing on the low-frequency information of the image.
[0011] Step 4: Construct an image detail information recovery module using the high-frequency information of the image to reconstruct the high-frequency detail information of the image converted to the wavelet domain;
[0012] Step 5: Use a regular camera to capture non-light field focused stacked images, process them, and combine them with the supervised training dataset described in Step 1 to form a hybrid dataset; then use wavelet transform again to transform the image information in the hybrid dataset from the spatial domain to the frequency domain.
[0013] Step 6: Use the hybrid dataset processed by wavelet transform in Step 5 to pre-train and fine-tune the generative neural network model, thereby enhancing the generalization and robustness of the generative neural network model to different datasets and scenarios.
[0014] The invention is further characterized by:
[0015] Step 1 is as follows:
[0016] Construct a virtual 3D scene in Blender, add light sources and set the lighting intensity and distribution of the virtual scene, or directly download and use a pre-built scene from another user; install a virtual light field camera plugin in Blender, adjust the camera's orientation and size to align it with the target scene, set parameters such as image resolution, image output format, number of output sub-aperture images, and focal length, and then render and synthesize multiple sets of images from different perspectives within the same scene, i.e., sub-aperture image set A;
[0017] Alternatively, use Lytro or other light field cameras, set the relevant imaging parameters of the camera and take pictures of the object to obtain the original light field image data, read the original light field image data and convert it into a data format that can be processed by MATLAB, and then extract parameters such as image size, lens array size, and distance between lenses from it. After denoising and back projection, the light field image data is converted into image plane data, and finally the sub-aperture image set B is obtained.
[0018] Choose a spatial or frequency domain light field image refocusing algorithm, set the refocusing range and number of steps, and refocus the sub-aperture image set A and / or sub-aperture image set B to obtain a light field focused stacked image. Select the central sub-aperture image as the ground truth of the fully focused image, and together with the corresponding N defocused images in different focal planes, form a 1:N supervised training dataset, where N≥1.
[0019] Wavelet transform decomposes the input image information into low-frequency and high-frequency components without loss of image information. The low-frequency component contains global information of the image, representing the average value of the image information; the high-frequency component contains detailed information of the image, representing the average value of the image information in the vertical, horizontal, and diagonal directions. Let I be the defocused images of the input image located in different focal planes, where I∈R. H×W×CWhere H, W, and C are the image length, width, and channels, respectively, they can be obtained through a single discrete wavelet transform:
[0020] {A 1 V 1 H 1 D 1}=DWT(I)
[0021] Therefore, after k wavelet transforms, we have:
[0022] {A k V k H k D k}=DWT(A k-1 )
[0023] Where A represents the average value of the input image, containing global information of the image, which is low-frequency information; V, H, and D represent the average values of the image in the vertical, horizontal, and diagonal directions, respectively, which are high-frequency information, k∈[1,K], and the original input image I is denoted as A. 0 K is the wavelet transform order.
[0024] Step 2 is as follows:
[0025] During the model training phase, forward diffusion noise addition and backward denoising are performed simultaneously.
[0026] The forward diffusion process generates a noisy image x0 from a noise-free image x0 through T steps of noise addition. T The next moment x t All are caused by x from the previous moment t-1 The formula for adding noise to the forward diffusion is as follows:
[0027]
[0028] Among them, z t For noise that follows a Gaussian distribution, α t It is an empirical value, and satisfies α. t =1-β t , β t For a predefined variance, β increases as t increases. t It gets larger and larger, that is, β1 < β2 < β3 ... < β T α t Gradually decrease;
[0029] The original image x0 and the image x after T-step noise addition can be obtained using the noise addition formula. T The relationship between them; the inverse denoising process from x TReaching x0 involves continuously restoring the noisy image to the original input image, i.e., using a network to estimate the noise. And gradually remove until the original image is restored;
[0030] The noise z added in step t of the forward process t Noise predicted at step t of the reverse process The mean squared error is used as the optimization function of the deep learning network, and the parameters in the deep learning model are updated using the stochastic gradient descent algorithm according to the optimization function. The optimization function of the network is:
[0031]
[0032] Where z t This refers to the noise added during the forward noise generation process. The noise predicted by the deep learning network during the reverse denoising process is t∈[1,T].
[0033] The method for diffusion processing of low-frequency information in the image in step 3 is as follows:
[0034] Since the low-frequency information A of the image after wavelet transform represents the average value of the input image information and contains global information of the image, it is crucial for image restoration.
[0035] In the diffusion model, wavelet transform is used to convert image domain information into wavelet domain information, and diffusion processing is performed only on low-frequency information A of the image. This reduces the image dimension and thus the computational cost of the model.
[0036] After one wavelet transform, the spatial dimension of the diffusion model processing wavelet components is four times smaller than that of the original image. Therefore, after k wavelet transforms, the spatial dimension of the original image is reduced by 4. k By using wavelet transform, the inference time and computational resource consumption of the model can be greatly reduced, thus drastically improving the training efficiency of the model.
[0037] {A k V k H k D k}=DWT(A k-1 )
[0038] Where k∈[1,K], and the original input image I is denoted as A. 0 K is the wavelet transform order.
[0039] Wavelet transform processing can significantly reduce the inference time and computational resource consumption of the model, thereby dramatically improving the training efficiency of the model.
[0040] Step 4 involves constructing an image detail information recovery module to reconstruct high-frequency detail information in the image. The specific method is as follows:
[0041] To recover as much information as a fully focused image from a defocused image, this method proposes an image detail information recovery module. The vertical component V and horizontal component H from the high-frequency information obtained by wavelet transform are used to supplement the diagonal component D. During the reconstruction of the V, H, and D coefficients, the image detail information recovery module selectively processes image detail information through a frequency domain channel attention mechanism, enhancing the extraction and utilization of image detail information and improving the efficiency of image processing and recovery. Then, three depthwise separable convolutions are used to extract features from the input coefficients, a cross-attention layer is used to recover details in the diagonal direction, and dilated convolutions are used to extract local information and improve the receptive field, ultimately obtaining the reconstructed image detail information.
[0042] Step 5 specifically involves:
[0043] Light field images captured by light field cameras contain rich information such as light intensity and direction, and can be refocused to obtain a light field focus stack; while images captured by ordinary cameras contain less information and cannot be obtained by a single shot and processing to obtain a focus stack image. Therefore, ordinary cameras require special equipment to obtain non-light field focus stacks.
[0044] According to the Gaussian imaging formula Where u, v, and f represent the object distance, phase distance, and focal length in the imaging system, respectively. Ordinary cameras can achieve focusing on different focal planes of the same scene by either manually adjusting the focal length while maintaining a fixed camera position or by moving the camera while keeping the focal length constant. The intermediate image is selected as the ground truth image from the obtained non-light field focusing stack and matched with other defocused images to obtain the supervised training dataset.
[0045] Non-light field focused stacked images are obtained by taking pictures with a regular camera. After processing, they are combined with the supervised training dataset described in step 1 to form a hybrid dataset.
[0046] Perform k wavelet transforms on the defocused image and its corresponding ground truth image in the mixed dataset to obtain low-frequency information A. k and image high-frequency detail information V k H k D k ;
[0047] Step 6 specifically involves:
[0048] The hybrid dataset processed by wavelet transform in step 5 is used for model pre-training and fine-tuning, so that the model can show good performance under different input conditions.
[0049] First, the low-frequency information A of the image after k wavelet transforms is... k Input diffusion model processing yields V high-frequency detail information of the image k H k D k Image detail restoration is obtained Then the high-frequency detail information of the reconstructed image Low-frequency information of the image obtained after diffusion The fully focused image is obtained by combining and performing k inverse wavelet transforms.
[0050]
[0051] The final reconstructed image, i.e., the fully focused image, is k∈[1,K];
[0052] If the input consists of multiple out-of-focus images at different focal planes, the preprocessing module first extracts the feature information of each image to obtain a new image, which is then input into the trained neural network to obtain a fully focused image. If the input consists of a single out-of-focus image at different focal planes, the neural network can directly generate its corresponding fully focused image.
[0053] Existing multi-focus image fusion techniques require a complete focus stack to obtain a fully focused image where all parts are sharp. This method, however, can obtain a fully focused image from a single or a small number of defocused images at different focal planes.
[0054] The beneficial effects of this invention are:
[0055] This invention proposes a novel method to synthesize a large-scale hybrid dataset of all-focus images by combining light field refocusing data with classic camera multi-focal plane data. This dataset uses a diffusion model as input to defocused images located on different focal planes to generate their corresponding all-focus images. First, the light field synthesis and real-world shooting datasets used in this invention are characterized by simple and low-cost multi-focus image acquisition and can calculate and generate any number of sets of images of the same scene on different focal planes. Furthermore, compared to traditional multi-focus image fusion methods and existing deep learning methods, the diffusion model-based all-focus image generation method used in this invention has a significant advantage in the quality of all-focus image synthesis. More importantly, the all-focus image diffusion generation method based on light field data proposed in this invention requires only a single focal slice as input to obtain a high-quality all-focus image. Compared to other all-focus image synthesis methods, this invention offers greater flexibility in terms of the number of input images. Attached Figure Description
[0056] Figure 1This is a flowchart of the full-focus image diffusion generation method based on light field data according to the present invention;
[0057] Figure 2 This is a schematic diagram illustrating the construction of the hybrid dataset in this invention;
[0058] Figure 3 This is a schematic diagram of the neural network model structure generated by the present invention;
[0059] Figure 4(a) is a schematic diagram of the defocused image input to the model of the present invention.
[0060] Figure 4(b) is a schematic diagram of the truth image of the model input of the present invention.
[0061] Figure 4(c) is a schematic diagram of the fully focused image output by the model of the present invention. Detailed Implementation
[0062] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments.
[0063] Example 1
[0064] The present invention provides a method for generating fully focused images based on light field data, which is implemented according to the following steps:
[0065] Step 1: Use virtual scene rendering software to synthesize or use a light field camera to capture and process light field data of different scenes, use the light field refocusing algorithm to generate light field focused stacked images, and build a supervised training dataset; use wavelet transform to transform the image information in the supervised training dataset from the spatial domain to the frequency domain; Step 2: Use the diffusion model as the basic network structure to build a generative neural network model for fully focused images;
[0066] Step 3: Input the supervised training dataset obtained from the wavelet transform in Step 1 into the generative neural network model built in Step 2 for training, and perform diffusion processing on the low-frequency information of the image.
[0067] Step 4: Construct an image detail information recovery module using the high-frequency information of the image to reconstruct the high-frequency detail information of the image converted to the wavelet domain;
[0068] Step 5: Use a regular camera to capture non-light field focused stacked images, process them, and combine them with the supervised training dataset described in Step 1 to form a hybrid dataset; then use wavelet transform again to transform the image information in the hybrid dataset from the spatial domain to the frequency domain.
[0069] Step 6: Use the hybrid dataset after wavelet transform in Step 5 to pre-train and fine-tune the generative neural network model to enhance its generalization and robustness to different datasets and scenarios.
[0070] Example 2
[0071] Based on Example 1, the virtual scene rendering software adjusts the orientation of the virtual camera to synthesize multiple sets of images from different perspectives within the same scene, thus obtaining a sub-aperture image set A;
[0072] Raw light field image data is obtained by photographing objects using a light field camera. The light field data is then preprocessed and decoded using the MATLAB light field toolbox to obtain the sub-aperture image set B.
[0073] Select an image refocusing algorithm in the spatial or frequency domain of the light field, set the refocusing range and number of steps, and refocus sub-aperture image set A and / or sub-aperture image set B to obtain light field focus stack images. Each light field focus stack includes at least one defocused image in a different focus plane.
[0074] The central sub-aperture image is selected as the ground truth of the fully focused image, and together with the corresponding N defocused images located in different focal planes, they form a 1:N supervised training dataset, where N≥1.
[0075] Step 1 uses wavelet transform to transform the input image information from the spatial domain to the frequency domain. The specific method is as follows:
[0076] Before inputting defocused images at different focal planes into the model, the input image information is first processed by wavelet transform. The wavelet transform decomposes the input image information into low-frequency and high-frequency information without losing image information, which can be represented by four coefficients A, V, H, and D. Among them, coefficient A represents the average value of the input image, which contains the global information of the image and is low-frequency information; coefficient V represents the average value of the vertical information of the image; coefficient H represents the average value of the horizontal information of the image; and coefficient D represents the average value of the diagonal information of the image. Coefficients V, H, and D are high-frequency information.
[0077] Let I be the input defocused images located in different focal planes, where I ∈ R. H×W×C Where H, W, and C are the image length, width, and channels, respectively, they can be obtained through a single discrete wavelet transform:
[0078] {A 1 V 1 H 1 D 1}=DWT(I)
[0079] After k wavelet transforms, we have:
[0080] {A k V k H k D k}=DWT(A k-1 )
[0081] Where k∈[1,K], and the original input image I is denoted as A. 0 K is the wavelet transform order.
[0082] Example 3
[0083] This invention provides a method for generating fully focused image diffusion based on light field data, such as... Figure 1 As shown, specifically:
[0084] Step 1: Obtain light field focused stacked images using Blender software and the light field refocusing algorithm, and construct a model training dataset. The dataset construction process is as follows: Figure 2 As shown.
[0085] Step 1.1: Build a virtual 3D scene in Blender and set the lighting intensity and distribution of the scene by adding light sources such as point lights, area lights, sunlight or spotlights, or download a pre-built scene that has been publicly available from others.
[0086] Step 1.2: Install the virtual light field camera plugin, adjust the camera size and orientation to capture the desired scene, set the image resolution to 512*512, output the image in OpenEXR format, use RGB color, output 3*3 sub-aperture images, and set the focal length to 50mm, etc., and obtain the light field sub-aperture image of the virtual scene through rendering.
[0087] Step 1.3: Convert the exported light field data in EXR format to RGB format, and then write the corresponding MATLAB program according to the spatial domain digital refocusing algorithm to complete the refocusing of the original light field image;
[0088] Step 1.3.1: Load the light field image data and convert it into a linear array, ensuring that the resolution and number of sub-apertures are correct;
[0089] Step 1.3.2: Translate each sub-aperture image according to the spatial refocusing formula and sum them to calculate the average;
[0090] Step 1.3.3: Set different depth of focus ranges according to different scenes, and set the step size to 10 to obtain 10 light field refocusing images, that is, each focus stack contains 10 focus slices;
[0091] Step 1.4: Select the central sub-aperture image of the light field as the ground truth image, and match it with the focusing stack to obtain a supervised training dataset in the form of 1:10;
[0092] Step 2, as follows Figure 2As shown, images are captured using a light field camera to obtain raw light field image data. After extracting and preprocessing the raw light field image data, a light field focusing stack is obtained through a light field image refocusing algorithm, and a supervised training dataset is constructed.
[0093] Step 2.1: Use Lytro's Illum light field camera to capture raw light field image data in various indoor and outdoor scenes. When shooting, pay attention to the impact of camera parameters, light intensity, etc. on image quality.
[0094] Step 2.2: Export the LFP format light field image file from the Illum light field camera. This file contains light field image data, light field image size, and camera serial number. To extract the light field image, the LFP file can be processed using the MATLAB light field toolbox 0.4.
[0095] Step 2.2.1: Export the white image to the local device and process it using the camera's "Export Pairing Data" function; the white image can be used to correct the dark corners of the image caused by lens shading and to help locate the coordinates of the microlens center;
[0096] Step 2.2.2: Decode the light field file using the white image obtained in step 2.2.1. Perform a demosaic operation on the decoded light field image according to the Bayer format in the light field camera to obtain an RGB color image. Then, perform color correction and cropping on the RGB image to obtain a sub-aperture image with a size of 1080*1080 and ending with jpg.
[0097] Step 2.3: Process the sub-aperture image according to the light field spatial domain refocusing algorithm described in Step 1.3 to obtain the light field focusing stack, and match it with the ground truth to construct a supervised training dataset.
[0098] Step 3, as follows Figure 3 As shown, the supervised training dataset obtained in steps 1.4 and 2.3 is subjected to wavelet transform to convert the image information from the spatial domain to the frequency domain, separating the high-frequency and low-frequency information of the image for subsequent processing by various modules.
[0099] Wavelet transform can be understood as consisting of low-pass and high-pass filters. The original signal can be decomposed into a new representation by passing through these complementary filters in multiple stages.
[0100] Step 3.1: After a two-dimensional discrete wavelet transform, the image information can be represented by A. 1 V 1 H 1 D 1 The four coefficients represent:
[0101] {A 1 V1 H 1 D 1} = 2D - DWT(I)
[0102] Step 3.2: After performing k two-dimensional discrete wavelet transforms on the input image, A can be used. k V k H k D k To represent information in an image:
[0103] {A k V k H k D k}=2D-DWT(A k-1 )
[0104] A, V, H, and D represent the average value (low-frequency information) and the average value of high-frequency information in the input image along the vertical, horizontal, and diagonal lines, respectively. k∈[1,K], the original input image I can be denoted as A 0 K is the wavelet transform scale.
[0105] Step 4: Build a U-Net-like neural network based on a diffusion model for generating fully focused images.
[0106] The diffusion model possesses the characteristics of adding noise via forward diffusion and removing noise via reverse diffusion, making it highly effective for image restoration tasks. The forward diffusion process continuously adds Gaussian noise to the clear image from x0 until a purely noisy image x is finally obtained. T .
[0107] The forward process contains no learnable parameters; as t increases, the image x... t Only with the previous moment x t-1 This process can be viewed as a Markov process, satisfying the following formula:
[0108]
[0109]
[0110] Through derivation, we can obtain x t Relationship with x0:
[0111]
[0112] Among them, β for different t t The variance is a predefined variance, and satisfies β1 < β2 < ... < β T And it has α t =1-β t , t∈[1,T],β t ∈[0.0001,0.002].
[0113] Reverse denoising is the process of removing pure noise from an image x. T The process of denoising step by step to reconstruct the original clear image x0. If we obtain the inverse process q(x)... t-1 |x t ), then random noise x can be used to... T An image is gradually reconstructed, therefore a neural network p is used. θ (x t-1 |x t Fitting the inverse process q(x) t-1 |x t )have:
[0114]
[0115]
[0116]
[0117] Because t and x t Since this is known, we only need to use a neural network to fit the noise. μ can then be obtained θ (x t ,t).
[0118] The noise added during the forward diffusion process ∈ t Noise predicted during the reverse denoising process The mean squared error is used as the optimization function of the deep learning network, and the parameters in the deep learning model are updated using the stochastic gradient descent algorithm according to the optimization function. The optimization function of the network is:
[0119]
[0120] Where, ∈ t This refers to the noise added in step t during the forward noise addition process. This represents the noise predicted by the deep learning network at step t during the reverse denoising process.
[0121] Step 4.2: During model training, perform forward diffusion noise addition and backward denoising simultaneously to enable the model to learn fully during inference and achieve better results.
[0122] This method uses a U-Net-like architecture as the noise estimation network. The information recovered by the diffusion model is the average information (low-frequency information) A of the image obtained by wavelet transform. To achieve effective recovery, the time step T of the training phase is set to 200, and the implicit sampling step is set to 10.
[0123] Step 5: Input the data processed by wavelet transform in Step 3 into the diffusion model network built in Step 4 for training.
[0124] Step 5.1: Use K-order two-dimensional discrete wavelet transform to convert the image domain information into the frequency domain. This allows for diffusion processing of only the low-frequency information of the image after each wavelet transform without sacrificing image information, thereby improving diffusion efficiency and reducing model training time and inference process.
[0125] Step 5.2: After one wavelet transform, the spatial dimension of the diffusion model processing wavelet components is four times smaller than that of the original image. Therefore, after K wavelet transforms, the spatial dimension of the original image is reduced by 4. K In this paper, the wavelet scale K is set to 2, which is a reduction of 16 times. Wavelet transform significantly reduces the model's inference time and computational resource consumption, dramatically improving training efficiency and representing a substantial improvement over the inefficiency of traditional diffusion models.
[0126] Step 6: Construct an image detail information restoration module to obtain a higher quality full-focus image by reconstructing the image detail information.
[0127] Step 6.1: To achieve better image restoration and detail reconstruction, we designed an image detail information restoration module, which restores the high-frequency image information V obtained by wavelet transform. k H k D k Reconstruction
[0128] Step 6.2, the image detail information restoration module also uses information from the vertical V and horizontal H directions of the image to supplement the diagonal D details, thereby better realizing the reconstruction of local details of the image;
[0129] Step 6.2.1: Set up a channel attention mechanism based on frequency domain information to selectively extract important details of the image and improve the performance of the model;
[0130] Step 6.2.2: Set up three depthwise separable convolutions to improve the efficiency of feature extraction from input coefficients;
[0131] Step 6.2.3: Set up two cross-attention mechanisms to supplement the diagonal detail information with detailed information in the vertical and horizontal directions;
[0132] Step 6.2.4: Based on the property that dilated convolution can increase the receptive field while maintaining the original input feature map size, we use dilated convolution to restore local image information. Specifically, the first and last convolutional layers are used to extract local information, while the intermediate dilated convolutions are used to expand the receptive field.
[0133] Step 6.2.5 uses three depthwise separable convolutions to reduce the number of channels, thereby obtaining the average coefficients of the reconstruction. Step 7: Use a regular camera to capture non-light field focused stacks, process them, and merge them with the supervised training datasets obtained in Steps 1 and 2 to form a hybrid dataset; then use wavelet transform to convert the image information of the hybrid dataset to the frequency domain.
[0134] Step 7.1, due to the inherent limitations of ordinary cameras, according to the Gaussian imaging formula... Where u, v, and f represent the object distance, phase distance, and focal length in the imaging system, respectively. Using a regular camera to obtain a non-light field focusing stack mainly involves keeping the positions u of the camera and the scene being photographed constant and continuously adjusting the camera focal length f to obtain a set of defocused images containing multiple images at different focal planes; or keeping the camera focal length f and the scene being photographed constant and changing the object distance u by adjusting the camera position vertically to obtain a set of defocused images at different focal planes.
[0135] Step 7.2, for the first method mentioned in step 7.1, the camera needs to be fixed at the expected shooting position, and then starting with a certain focal length, the object is shot separately with the same focal length step size to obtain a set of non-light field focusing stacks;
[0136] Step 7.3, for the second method mentioned in step 7.1, usually requires setting a vertical slider facing the shooting scene, then fixing the camera's focal length, and then moving the camera position to obtain a set of non-light field focusing stacks in different focusing planes;
[0137] Step 7.4: Select a specific image from the focus stack as the ground truth image and match it with other images to form a supervised training dataset; this dataset, together with the supervised training datasets obtained in Step 1 and Step 2, forms a mixed dataset.
[0138] Step 7.5: Perform k two-dimensional discrete wavelet transforms on the defocused image (Figure 4(a)) and the ground truth image (Figure 4(b)) in the mixed dataset to obtain the average coefficients A. k and image high-frequency detail information V k H k D k This is for subsequent model processing:
[0139] {A k V k H k Dk}=2D-DWT(A k-1 )
[0140] Step 8: Use the mixed dataset processed in Step 7 to pre-train and fine-tune the model to achieve robustness and generalization of the network to different inputs.
[0141] First, the average coefficients A of the image obtained after k wavelet transforms are calculated. k Input diffusion model processing yields Then, the high-frequency detail information V k H k D k Image detail restoration is obtained Then the reconstructed image detail information Average information of the image obtained after diffusion The fully focused image obtained by combining and performing k-fold two-dimensional discrete inverse wavelet transform is shown in Figure 4(c):
[0142]
[0143] In this paper, the wavelet scale K is set to 3. The final reconstructed image, i.e., the full-focus image;
[0144] If the input consists of multiple out-of-focus images at different focal planes, the preprocessing module can extract the feature information of each image to obtain a new image, which can then be input into the trained network to obtain a fully focused image. If the input consists of a single out-of-focus image at a certain focal plane, the neural network can directly generate its corresponding fully focused image.
Claims
1. A method for generating fully focused image diffusion based on light field data, characterized in that, The specific steps are as follows: Step 1: Use virtual scene rendering software to synthesize or use a light field camera to capture and process light field data of different scenes, use the light field refocusing algorithm to generate light field focused stack images, and construct a supervised training dataset; use wavelet transform to transform the image information in the supervised training dataset from the spatial domain to the frequency domain. Step 2: Based on the diffusion model with a U-Net structure as the main network, construct a generative neural network model for full-focus images; Step 3: Input the supervised training dataset obtained from Step 1 after wavelet transform into the generative neural network model built in Step 2 for training, and perform diffusion processing on the low-frequency information of the image. Step 4: Construct an image detail information recovery module using the high-frequency information of the image to reconstruct the high-frequency detail information of the image converted to the wavelet domain; Step 5: Obtain non-light field focused stacked images using a regular camera. After processing, these images, along with the supervised training dataset described in Step 1, form a hybrid dataset. Wavelet transform is then used again to convert the image information in the hybrid dataset from the spatial domain to the frequency domain. Step 5 is detailed below: Unlike the focusing stacking method obtained by light field synthesis, ordinary cameras use a fixed camera position to adjust the focal length or keep the focal length unchanged while moving the camera to change the object distance to achieve focusing on different focal planes of the same scene. The light field focused stacked image obtained in step 1 and the non-light field focused stacked image obtained by ordinary camera are matched with their ground truth to construct a hybrid dataset. The center sub-aperture image of the light field focused stacked image is selected as the ground truth image, and the middle image of the non-light field focused stacked image is selected as the ground truth image. Together with the corresponding N defocused images in different focal planes, they form a 1:N form of supervised training dataset. Perform k wavelet transforms on both the defocused image and its corresponding ground truth image in the mixed dataset to obtain the low-frequency information of the image. and image high-frequency detail information ; Among them, coefficient The average value of the input image represents the global information of the image and is low-frequency information; coefficients The average value and coefficients representing the vertical information of an image The average value and coefficients representing horizontal information of an image The coefficient represents the average value of the diagonal information of the image. High-frequency information; Step 6: Pre-train and fine-tune the generative neural network model using the hybrid dataset obtained from the wavelet transform in Step 5 to enhance the generalization ability and robustness of the generative neural network model to different datasets and scenarios; Step 6 is detailed below: Low-frequency information of the image Input diffusion model processing yields High-frequency detail information of the image Image detail restoration is obtained ; the high-frequency detail information of the reconstructed image Low-frequency average information of the image obtained after diffusion The fully focused image is obtained by combining and performing k inverse wavelet transforms. The final reconstructed image, i.e., the full-focus image; K is the wavelet transform order; If the input consists of multiple out-of-focus images on different focal planes, a new image is obtained by extracting the feature information of each image, and then input into the trained model to obtain a fully focused image. If the input consists of a single out-of-focus image on a certain focal plane, the model can directly generate its corresponding fully focused image.
2. The method for generating a fully focused image diffusion based on light field data according to claim 1, characterized in that, The method for generating the light field focusing stacked image described in step 1 is as follows: The virtual scene rendering software adjusts the orientation of the virtual camera to synthesize multiple sets of images from different perspectives within the same scene, thus obtaining a sub-aperture image set A. Alternatively, a light field camera can be used to photograph objects to obtain raw light field image data. The light field data can then be preprocessed and decoded using the MATLAB light field toolbox to obtain the sub-aperture image set B. Select an image refocusing algorithm in the spatial or frequency domain of the light field, set the refocusing range and number of steps, and refocus sub-aperture image set A and / or sub-aperture image set B to obtain light field focus stack images. Each light field focus stack includes at least one defocused image in a different focus plane. The central sub-aperture image is selected as the ground truth of the fully focused image, and together with the corresponding N defocused images located in different focal planes, they form a 1:N supervised training dataset. .
3. The method for generating a fully focused image diffusion based on light field data according to claim 2, characterized in that, Step 1 uses wavelet transform to transform the input image information from the spatial domain to the frequency domain. The specific method is as follows: Before inputting defocused images at different focal planes into the model, the input image information is first processed by wavelet transform. Wavelet transform decomposes the input image information into low-frequency and high-frequency information without loss of image information. The four coefficients represent; Let the input defocused images located on different focal planes be denoted as . , ∈R × ×C Where H, W, and C are the image length, width, and channel dimensions, respectively, they can be obtained through a single discrete wavelet transform: After k wavelet transforms, we have: in The original input image is denoted as K is the wavelet transform order.
4. The method for generating a fully focused image diffusion based on light field data according to claim 1, characterized in that, The main network of the diffusion model described in step 2 is a U-Net structure network, which has the characteristics of adding noise through forward diffusion and removing noise through reverse diffusion; The main network of the diffusion model is a U-Net structure network, which aims to learn Markov chains and gradually convert Gaussian noise into training data, and has a good effect on image restoration tasks. The forward diffusion process uses fixed variance scheduling }, input noise-free image The data is transformed into corrupted noise data through a T-step noise-adding process. That is, a picture with pure noise; an image. Only with the previous moment related, This refers to the noise added in step t during the forward noise addition process. ; The reverse denoising process from arrive It is the process of continuously restoring a noisy image to the original input image, that is, using a deep learning network to predict noise. And gradually remove until the original image is restored; Noise added during the forward diffusion process Noise predicted during the reverse denoising process The mean squared error is used as the optimization function of the deep learning network, and the parameters in the deep learning model are updated using the stochastic gradient descent algorithm based on the optimization function.
5. The method for generating a fully focused image diffusion based on light field data according to claim 3, characterized in that, The method for diffusion processing of low-frequency information in the image in step 3 is as follows: Because the low-frequency information in the image after wavelet transform It represents the average value of the input image information, which contains global information about the image, and is therefore crucial for image restoration; In the diffusion model, wavelet transform is used to convert image domain information into the wavelet domain, focusing only on low-frequency image information. Diffusion processing is performed to reduce the spatial dimension of the image, thereby reducing the computational cost of the model. After one wavelet transform, the spatial dimension of the diffusion model processing wavelet components is four times smaller than that of the original image. Therefore, after K wavelet transforms, the spatial dimension of the original image is reduced. times.
6. The method for generating a fully focused image diffusion based on light field data according to claim 3, characterized in that, Step 4 involves constructing an image detail information recovery module to reconstruct high-frequency detail information in the image. The specific method is as follows: The vertical component of the high-frequency information in the image obtained by wavelet transform. and horizontal components diagonal components Supplementing; Image detail information recovery module During coefficient reconstruction, a frequency domain channel attention mechanism is first used to enhance the extraction and utilization of image detail information. Then, three depthwise separable convolutions are used to extract features from the input coefficients. A cross-attention layer is used to recover detail information in the diagonal direction, and dilated convolutions are used to extract local information and improve the receptive field, ultimately obtaining the reconstructed image detail information. .
Citation Information
Patent Citations
Rapid imaging method and device based on neural network positioning algorithm
CN112258597A
Image processing method, equipment and device for medical image
CN115546136A
