A multi-focus image fusion method, device, equipment and medium
By enhancing and filtering multi-focus images using a mask model and a guided filter, and combining this with a fusion model for pixel-wise weighted feature fusion, the failure problem in boundary regions during multi-focus image fusion is solved, thus improving image quality.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TERMINUSBEIJING TECH CO LTD
- Filing Date
- 2023-03-13
- Publication Date
- 2026-06-05
AI Technical Summary
Existing technologies often fail in the boundary region when performing multi-focus image fusion, affecting the quality of the fused image.
Multi-focus images are enhanced using a masking model, filtered using a guided filter, and fused pixel-wise weighted features are fused using a fusion model. This includes self-supervised training of the mask generator and the guided filter, reducing reliance on large-scale labeled data.
It improves the accuracy of multi-focus image fusion, solves the failure problem in the boundary region, and improves the quality of the fused image.
Smart Images

Figure CN116452476B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and more specifically, to a method, apparatus, device, and medium for fusing multi-focus images. Background Technology
[0002] Image fusion aims to generate a unified image containing important and meaningful information from multiple source images, improving the completeness and accuracy of scene description. It fuses information from numerous images of the same scene, which can be taken from various sensors, different locations, or different times. Compared to any single source image, a fused image can provide more comprehensive information for the human visual system or other applications.
[0003] Existing technologies typically involve fusing multi-focus images. Multi-focus images refer to images with varying degrees of sharpness formed when different targets are at different distances from the lens during the capture of a 3D scene using an optical imaging system. However, fusing different multi-focus images often results in failures at boundary regions, thus affecting the quality of the fused image. Summary of the Invention
[0004] Based on the above-mentioned technical problems, the present invention aims to enhance the image to be fused by using a mask model and a guided filter, especially the image boundary region, and then fuse the enhanced image based on pixel-by-pixel weighted features and methods to obtain the fused image.
[0005] The first aspect of this invention provides a method for fusing multi-focus images, the method comprising:
[0006] Acquire the multi-focus images to be fused in the target scene;
[0007] The focused and defocused regions in the multi-focus image are enhanced using a trained mask model to obtain a first enhanced image;
[0008] The first enhanced image is filtered by a guided filter to obtain the second enhanced image;
[0009] The second enhanced images corresponding to the multi-focus image to be fused are fused to obtain the fused image.
[0010] In some embodiments of the present invention, the mask model includes a mask generator, and the training steps of the mask model include:
[0011] Acquire a multi-focus sample image, perform a blur transformation on the multi-focus sample image to obtain a blurred image corresponding to the multi-focus sample image, and use the multi-focus sample image and the blurred image corresponding to the multi-focus sample image as a training image pair;
[0012] Obtain the binary mask label through the bootstrap block;
[0013] The training image pairs and the binary mask labels are input into the mask generator for self-supervised training until the loss function converges, at which point the training ends.
[0014] In some embodiments of the present invention, obtaining the binary mask label through the bootstrap block includes:
[0015] A sharpness image is obtained based on the multi-focus sample image and the blurred image corresponding to the multi-focus sample image;
[0016] The binary mask label is obtained based on the sharpness image.
[0017] In some embodiments of the present invention, the mask model further includes an encoder, which employs a dense convolutional neural network architecture.
[0018] In some embodiments of the present invention, the step of filtering the first enhanced image using a guided filter to obtain a second enhanced image includes:
[0019] Determine the guide image for the first enhanced image;
[0020] The high-frequency information in the guiding image is transferred to the first enhanced image by a guiding filter to obtain the second enhanced image.
[0021] In some embodiments of the present invention, fusing all the second enhanced images corresponding to the multi-focus image to be fused to obtain the fused image includes:
[0022] The trained fusion model fuses all the second enhanced images corresponding to the multi-focus image to be fused to obtain the fused image. The fusion model includes a backbone network and a feature fusion module. The backbone network is composed of N convolutional layers of different scales, and the feature fusion module is composed of N multi-scale feature fusion sub-modules.
[0023] In some embodiments of the present invention, the fusion formula is as follows:
[0024] y=Conv2D(x, inchannel, outchannel, ksize)
[0025] Where x is the input image of each layer, y is the weighted feature map of the output, inchannel represents the number of input channels, outchannel represents the number of output channels, ksize is the convolution size, and Conv2D represents two-dimensional convolution.
[0026] A second aspect of the present invention provides a multi-focus image fusion apparatus, the apparatus comprising:
[0027] The acquisition module is configured to acquire multi-focus images to be fused in the target scene;
[0028] The first enhancement module is configured to enhance the focused and defocused regions in the multi-focus image using a trained mask model to obtain a first enhanced image;
[0029] The second enhancement module is configured to filter the first enhancement image using a guided filter to obtain the second enhancement image;
[0030] The fusion module is configured to fuse all the second enhanced images corresponding to the multi-focus image to be fused, so as to obtain the fused image.
[0031] A third aspect of the present invention provides a computer device including a memory and a processor, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the processor performs the multi-focus image fusion method described in various embodiments of the present invention.
[0032] A fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the multi-focus image fusion method described in various embodiments of the present invention.
[0033] The technical solutions provided in this application embodiment have at least the following technical effects or advantages:
[0034] This application employs a masking model and a guided filter to perform dual enhancement on multi-focus images. Then, a fusion model performs pixel-by-pixel weighted summation to obtain the fused image. This addresses the failure issue that often occurs in boundary regions when fusing different multi-focus images, thereby improving the quality of the fused image. The masking model uses guided blocks for self-supervised training, eliminating the need for large-scale labeled datasets and saving training time. It achieves the classification and pixel-by-pixel weighted summation of pixels near the boundary regions of focused and defocused areas using an initial binary mask, thus improving the accuracy of fused multi-focus images.
[0035] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit the invention. Attached Figure Description
[0036] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:
[0037] Figure 1 A schematic diagram illustrating the steps of a multi-focus image fusion method in an exemplary embodiment of this application is shown;
[0038] Figure 2 A schematic diagram of an exemplary embodiment of this application is shown;
[0039] Figure 3 A schematic diagram of the structure of a multi-focus image fusion apparatus in an exemplary embodiment of this application is shown;
[0040] Figure 4 This illustration shows a schematic diagram of the structure of a computer device provided in an exemplary embodiment of this application. Detailed Implementation
[0041] The embodiments of this application will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of this application. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concepts of this application. It will be apparent to those skilled in the art that this application can be implemented without one or more of these details. In other instances, to avoid confusion with this application, some technical features well-known in the art have not been described.
[0042] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments according to this application. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms “comprising” and / or “including” are used in this specification, they indicate the presence of the stated features, integrals, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or combinations thereof.
[0043] Exemplary embodiments according to this application will now be described in more detail with reference to the accompanying drawings. However, these exemplary embodiments may be implemented in many different forms and should not be construed as being limited to the embodiments set forth herein. The drawings are not drawn to scale, and some details may be enlarged and omitted for clarity. The shapes of the various regions and layers shown in the figures, as well as their relative sizes and positional relationships, are merely exemplary and may deviate from reality due to manufacturing tolerances or technical limitations. Furthermore, those skilled in the art can design regions / layers with different shapes, sizes, and relative positions as needed.
[0044] The following is in conjunction with the instruction manual appendix. Figure 1 -Appendix Figure 4 Several embodiments are given to describe exemplary implementations according to this application. It should be noted that the following application scenarios are shown only to facilitate understanding of the spirit and principles of this application, and the implementations of this application are not limited in any way. Rather, the implementations of this application can be applied to any applicable scenario.
[0045] In some exemplary embodiments of this application, a method for fusing multi-focus images is provided, such as... Figure 1 As shown, the method includes:
[0046] S1. Obtain the multi-focus images to be fused in the target scene;
[0047] S2. Enhance the focused and defocused regions in the multi-focus image using the trained mask model to obtain the first enhanced image;
[0048] S3. Filter the first enhanced image using a guided filter to obtain the second enhanced image;
[0049] S4. Fuse all the second enhanced images corresponding to the multi-focus image to be fused to obtain the fused image.
[0050] Image fusion is a method of combining information from many images of the same scene, taken from various sensors, different locations, or at different times. The fused image retains all the supplementary and redundant information from the input image, which is highly useful for human visual perception and image processing tasks. For example, in medical imaging applications, computed tomography (CT), magnetic resonance (MR), and positron emission tomography (PET) images are fused together for better analysis and diagnosis of diseases. Similarly, in remote sensing applications, multispectral (MS) images with low resolution and high spectral density are fused with panchromatic (PAN) images with high resolution and low spectral density to obtain the spectral content resolution of the MS image with high spatial resolution. In surveillance applications, different images (infrared, visible, and near-infrared) are acquired from different sensors and fused for detection or night vision. In photography applications, multifocal images, multiple exposure images, etc., are fused together to obtain images that are better perceived by human vision and computer processing. Therefore, image fusion has a wide range of applications. The purpose of image fusion is to fuse details of important information extracted from two or more images. Therefore, the multi-focus images to be fused in S1 must have at least two images, or N multi-focus images to be fused, where N is greater than or equal to 2.
[0051] In a preferred implementation, the masking model includes a mask generator, and the training steps of the masking model include: acquiring multi-focus sample images; performing a blur transformation on the multi-focus sample images to obtain blurred images corresponding to the multi-focus sample images; using the multi-focus sample images and the blurred images corresponding to the multi-focus sample images as training image pairs; obtaining binary mask labels through a guide block; and inputting the training image pairs and the binary mask labels into the mask generator for self-supervised training until the loss function converges, at which point the training ends. Specifically, when obtaining binary mask labels through the guide block, a sharpness image is first obtained based on the multi-focus sample images and the blurred images corresponding to the multi-focus sample images; then, the binary mask labels are obtained based on the sharpness image. Specifically, relevant multi-focus image fusion datasets are collected and organized, including the Lytro dataset and the processed COCO dataset. The multi-focus source images in the Lytro dataset are captured directly from the real world by a camera. The COCO dataset uses Gaussian blur and hand-crafted decision maps to generate multi-focus image pairs.
[0052] The guiding block can reduce the solution domain and accelerate the convergence speed of binary mask generation without using manually labeled data, and can achieve or even surpass the accuracy achieved by supervised learning methods. The steps of generating binary mask labels using the guiding block include: based on the principle of repeated blurring, where the difference between focused pixels before and after blurring is greater than that between defocused pixels, thus allowing the detection of the sharpness of each pixel. The blurring formula is:
[0053] B1 = Blur(I1)
[0054] B2 = Blur(I2)
[0055] Where I1 and I2 represent the multi-focus sample images, and B1 and B2 represent the blurred images corresponding to the multi-focus sample images. The sharpness image formula is as follows:
[0056] S1 = I1 - B1
[0057] S2=I2-B2
[0058] Finally, the maximum value of the sharpness images S1 and S2 is used to obtain the binary mask label. Furthermore, this can be used for enhancing individual images, as well as for enhancing multiple fused images. The binary mask label formula is:
[0059] M I =S1+S2
[0060] Among them, M I This represents the binary mask label of the initially fused image. The initial binary mask generated through self-supervised training provides a rough classification of pixels near the boundary between the focused and defocused regions. Here, the source focused image can be directly enhanced using the mask model, or the source focused image can be initially fused first, and then the initially fused image can be enhanced using the mask model.
[0061] The masking model includes an encoder and a decoder. The encoder employs a dense convolutional neural network architecture, while the decoder is designed to be adapted to the encoder. In some embodiments of this application, filtering the first enhanced image using a guided filter to obtain a second enhanced image includes: determining a guided image of the first enhanced image; and transferring high-frequency information from the guided image to the first enhanced image using the guided filter to obtain the second enhanced image.
[0062] It's important to note that guided filtering computes its output by considering the content of a guide image, which can be the input image itself or another different image. Besides being used as an edge-preserving smoothing operator like the popular bilateral filter, it performs better in edge preservation, requires no gradient inversion, and is considered one of the fastest edge-preserving filters. Its basic idea is that there is a linear relationship between a point on a function and its neighboring points; therefore, a complex function can be represented by many locally linear functions. When the value of a point on this function is needed, simply compute the values of all linear functions containing that point and then take the average. To date, guided filters have been successfully applied in computer vision and computer graphics, including edge-aware smoothing, image matting / feathering, noise reduction, and image inpainting. Specifically, for a guide image G, the guided filter filters the input image I, resulting in an output image O. Finally, the output image O can retain the main information of I while obtaining the changing trend of the guide image G. The guided filter (GF) is defined as follows:
[0063] O=GF γε (I, G)
[0064] Where γ represents the window radius that determines the filter size, and ε represents the regularization parameter. The overall implementation steps of guided filtering (GF) are as follows: First, obtain the correlation coefficient parameters between I and G using boxFilter. Second, calculate the correlation coefficient parameters based on the mean, including the autocorrelation variance var and the correlation covariance cov. Third, calculate the window linear transformation parameters. Then, calculate the average value of the window linear transformation parameters according to the formula. Finally, use these parameters to obtain the output image of the guided filter. The guiding image of the first enhanced image can be determined; it can be identified as the guiding image itself. The high-frequency information in the guiding image is transferred to the first enhanced image through the guided filter to obtain the second enhanced image. The basic formula can be expressed as:
[0065] F1 = GF(M1, I1)
[0066] F2 = GF(M2, I2)
[0067] Where F1 and F2 represent the filtered results. The above formula applies filtering to the multi-focus sample image, and M1 and M2 are the labels corresponding to the multi-focus sample image. In this embodiment, the filtering operation is placed after the first enhancement operation; both methods are acceptable. Because many corresponding pixel values are the same in the source image, especially in smooth areas, the network cannot detect them, resulting in blurred initial binary masks in some pixels, leading to inaccurate fusion results. Using a guided filter can precisely solve this problem.
[0068] In a preferred implementation, fusing all second-enhanced images corresponding to the multi-focus image to be fused to obtain a fused image includes: fusing all second-enhanced images corresponding to the multi-focus image to be fused using a trained fusion model to obtain a fused image. The fusion model includes a backbone network and a feature fusion module. The backbone network consists of cascaded convolutional layers of N scales, and the feature fusion module consists of N multi-scale feature fusion sub-modules. The fusion formula is:
[0069] y=Conv2D(x, inchannel, outchannel, ksize)
[0070] Where x is the input image for each layer, y is the weighted feature map of the output, inchannel represents the number of input channels, outchannel represents the number of output channels, ksize is the convolution size, and Conv2D represents two-dimensional convolution. Figure 2 As shown, x represents the input image, f1(x) represents the first convolutional processing function, and f4(x) represents the fourth convolutional processing function. Each layer has a short direct connection to other layers via a feedforward method. Each branch uses different parameters to process source images with significant differences. Each branch has four convolutional blocks, and each convolutional block contains five convolutional layers. Figure 2 (Not shown). The training method is the same as that in the prior art, but in this application, decision maps in a small number of images are manually annotated. Finally, we generated a multi-focus image fusion dataset containing 20,000 unlabeled images and 1,000 labeled images for training until the training reached a preset number of times.
[0071] The fusion model primarily employs a pixel-wise weighted feature sum method to obtain the fused image. Specifically, the feature map fused by the feature fusion module in the fusion model is binarized to obtain an initial decision map. Then, a fully connected method is used to refine the initial decision map to obtain the final decision map. A weight mask is obtained from the final decision map based on the spatial domain or transform domain. This weight mask can be obtained through a mask module. The pixel-weighted summation of the unfused image is then performed using the weight mask to obtain the final fused image.
[0072] F fise =F1×A + F2×B
[0073] Where A and B are weight values, F1 and F2 represent the two images to be fused after filtering, and F fise This represents the final fused image. It can be seen that the two models proposed in this application can be used collaboratively in different orders, describing the fusion process as a pixel-level classification problem, thus addressing the issues of excessively long model inference time and excessively large training resources typically found in current self-supervised learning algorithms.
[0074] This application employs a masking model and a guided filter to perform dual enhancement on multi-focus images. Then, a fusion model performs pixel-by-pixel weighted summation to obtain the fused image. This addresses the failure issue that often occurs in boundary regions when fusing different multi-focus images, thereby improving the quality of the fused image. The masking model uses guided blocks for self-supervised training, eliminating the need for large-scale labeled datasets and saving training time. It achieves the classification and pixel-by-pixel weighted summation of pixels near the boundary regions of focused and defocused areas using an initial binary mask, thus improving the accuracy of fused multi-focus images.
[0075] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit the invention.
[0076] In some exemplary embodiments of this application, a multi-focus image fusion apparatus is also provided to execute the multi-focus image fusion method described in various embodiments of this application, such as... Figure 3 As shown, the device includes:
[0077] The acquisition module 301 is configured to acquire the multi-focus images to be fused in the target scene;
[0078] The first enhancement module 302 is configured to enhance the focused and defocused regions in the multi-focus image using a trained mask model to obtain a first enhanced image;
[0079] The second enhancement module 303 is configured to filter the first enhancement image through a guided filter to obtain the second enhancement image;
[0080] The fusion module 304 is configured to fuse all the second enhanced images corresponding to the multi-focus image to be fused to obtain the fused image.
[0081] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application.
[0082] It should also be emphasized that the system provided in this application embodiment can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results. Basic AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operating / interactive systems, and mechatronics. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0083] Please refer to the following. Figure 4 This illustrates a schematic diagram of a computer device provided by some embodiments of this application. For example... Figure 4 As shown, the computer device 2 includes: a processor 200, a memory 201, a bus 202, and a communication interface 203. The processor 200, the communication interface 203, and the memory 201 are connected via the bus 202. The memory 201 stores a computer program that can run on the processor 200. When the processor 200 runs the computer program, it executes the multi-focus image fusion method provided in any of the foregoing embodiments of this application.
[0084] The memory 201 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 203 (which can be wired or wireless), such as the Internet, wide area network, local area network, or metropolitan area network.
[0085] Bus 202 can be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. Memory 201 is used to store programs. After receiving an execution instruction, the processor 200 executes the program. The multi-focus image fusion method disclosed in any of the foregoing embodiments of this application can be applied to the processor 200, or implemented by the processor 200.
[0086] The processor 200 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 200 or by instructions in software form. The processor 200 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules may reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 201. The processor 200 reads the information in memory 201 and, in conjunction with its hardware, completes the steps of the above method.
[0087] This application also provides a computer-readable storage medium corresponding to the multi-focus image fusion method provided in the foregoing embodiments, wherein a computer program is stored thereon, and the computer program, when run by a processor, executes the multi-focus image fusion method provided in any of the foregoing embodiments.
[0088] In addition, examples of the computer-readable storage medium may include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other optical and magnetic storage media, which will not be described in detail here.
[0089] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the multi-focus image fusion method provided in any of the foregoing embodiments. The method includes: acquiring multi-focus images to be fused in a target scene; enhancing the focused and defocused regions in the multi-focus images using a trained mask model to obtain a first enhanced image; filtering the first enhanced image using a guided filter to obtain a second enhanced image; and fusing all the second enhanced images corresponding to the multi-focus images to be fused to obtain a fused image.
[0090] It should be noted that the algorithms and displays provided herein are not inherently related to any particular computer, virtual device, or other equipment. Various general-purpose devices can also be used in conjunction with the teachings herein. The required structure for constructing such devices is obvious from the above description. Furthermore, this application is not directed to any particular programming language. It should be understood that the content of this application described herein can be implemented using various programming languages, and the above description of specific languages is for the purpose of disclosing the best mode of implementation of this application. Numerous specific details are set forth in the specification provided herein. However, it is to be understood that embodiments of this application can be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0091] Those skilled in the art will understand that the various component embodiments of this application can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art should understand that microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some or all of the components in the virtual machine creation apparatus according to embodiments of this application.
[0092] The above description is merely a preferred embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for fusing multi-focus images, characterized in that, The method includes: Acquire the multi-focus images to be fused in the target scene; The focused and defocused regions in the multi-focus image are enhanced using a trained mask model to obtain a first enhanced image; The first enhanced image is filtered by a guided filter to obtain the second enhanced image; The second enhanced images corresponding to the multi-focus image to be fused are fused to obtain the fused image; The mask model includes a mask generator, and the training steps of the mask model include: Acquire a multi-focus sample image, perform a blur transformation on the multi-focus sample image to obtain a blurred image corresponding to the multi-focus sample image, and use the multi-focus sample image and the blurred image corresponding to the multi-focus sample image as a training image pair; Obtain the binary mask label through the bootstrap block; The training image pairs and the binary mask labels are input into the mask generator for self-supervised training until the loss function converges, at which point the training ends.
2. The multi-focus image fusion method according to claim 1, characterized in that, The process of obtaining the binary mask label through the bootstrap block includes: A sharpness image is obtained based on the multi-focus sample image and the blurred image corresponding to the multi-focus sample image; The binary mask label is obtained based on the sharpness image.
3. The multi-focus image fusion method according to claim 1, characterized in that, The mask model also includes an encoder, which employs a dense convolutional neural network architecture.
4. The multi-focus image fusion method according to claim 1, characterized in that, The step of filtering the first enhanced image using a guided filter to obtain the second enhanced image includes: Determine the guide image for the first enhanced image; The high-frequency information in the guiding image is transferred to the first enhanced image by a guiding filter to obtain the second enhanced image.
5. The multi-focus image fusion method according to claim 1, characterized in that, The step of fusing all the second enhanced images corresponding to the multi-focus image to be fused to obtain the fused image includes: The trained fusion model fuses all the second enhanced images corresponding to the multi-focus image to be fused to obtain the fused image. The fusion model includes a backbone network and a feature fusion module. The backbone network is composed of N convolutional layers of different scales, and the feature fusion module is composed of N multi-scale feature fusion sub-modules.
6. The multi-focus image fusion method according to claim 5, characterized in that, The fusion formula used in the fusion model is: Where x is the input image of each layer, y is the weighted feature map of the output, inchannel represents the number of input channels, outchannel represents the number of output channels, ksize is the convolution size, and Conv2D represents two-dimensional convolution.
7. A multi-focus image fusion device, characterized in that, The device includes: The acquisition module is configured to acquire multi-focus images to be fused in the target scene; The first enhancement module is configured to enhance the focused and defocused regions in the multi-focus image using a trained mask model to obtain a first enhanced image; The second enhancement module is configured to filter the first enhancement image using a guided filter to obtain the second enhancement image; The fusion module is configured to fuse all the second enhanced images corresponding to the multi-focus image to be fused, to obtain a fused image; The mask model includes a mask generator, and the training steps of the mask model include: Acquire a multi-focus sample image, perform a blur transformation on the multi-focus sample image to obtain a blurred image corresponding to the multi-focus sample image, and use the multi-focus sample image and the blurred image corresponding to the multi-focus sample image as a training image pair; Obtain the binary mask label through the bootstrap block; The training image pairs and the binary mask labels are input into the mask generator for self-supervised training until the loss function converges, at which point the training ends.
8. A computer device, comprising a memory and a processor, characterized in that, The memory stores computer-readable instructions that, when executed by a processor, cause the processor to perform the method as described in any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-6.