Image fusion method, device and storage medium
By calculating auxiliary images and guiding image fusion, the problem of over-smoothing of images and unnatural visual effects in multi-image fusion is solved, the image quality is improved, and a more natural visual effect is achieved.
Patent Information
- Application Number
- CN202410799369.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-06-20
AI Technical Summary
Existing multi-image fusion technology has problems such as over-smoothing of images, unnatural visual effects, and color casts, resulting in low quality of fused images.
By obtaining different types of image gradients, calculating auxiliary maps, and using the auxiliary maps to guide image fusion, establish image gradient relationships, suppress gradient differences, and then achieve image fusion.
Improves the visual effect of the fused image, making it more natural, enhancing image quality, and avoiding over-smoothing of gradients and color cast problems.
Smart Images

Figure CN118365541B
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image fusion method, device and storage medium. Background Art
[0002] Multi-sensor data fusion refers to the multi-level, multi-faceted and multi-layered processing and integration of information from multiple sensors to obtain richer, more accurate and more reliable useful information. Among them, image fusion technology has a wide range of applications. It refers to a new technology for comprehensive processing of images from different sources. Its purpose is to extract information from multiple source images and integrate the information of two or more source images to obtain a more accurate, comprehensive and reliable image description of the same scene or target.
[0003] At present, there are still defects in multi-image fusion, such as excessive smoothing of the fused image, unnatural visual effects, color cast and other problems, which make the fused image quality low. Summary of the invention
[0004] In order to solve the above problems, the present application at least provides an image fusion method, device and storage medium.
[0005] In a first aspect, the present application provides an image fusion method, comprising: respectively acquiring a gradient of a first image and a gradient of a second image to obtain a first gradient and a second gradient; wherein the first image and the second image are obtained by performing image acquisition on the same scene, the first image and the second image belong to different image types, and the image quality of the second image is better than that of the first image; based on the first gradient and the second gradient, calculating an auxiliary image; wherein the similarity between the product of the auxiliary image and the second gradient and the first gradient is greater than a preset similarity; and using the auxiliary image to guide the fusion of the first image and the second image to obtain a target fused image.
[0006] In one embodiment, the similarity between the gradient direction of the auxiliary image and the gradient direction of the second gradient is greater than a preset similarity; based on the first gradient and the second gradient, the auxiliary image is calculated, including: an energy function is constructed with the goal of minimizing the difference between the product of the auxiliary image and the second gradient and the first gradient, and minimizing the projection value of the gradient of the auxiliary image in the direction perpendicular to the second gradient; based on the energy function, the auxiliary image corresponding to the first image and the second image is solved.
[0007] In one embodiment, based on the energy function, the auxiliary image corresponding to the first image and the second image is solved, including: obtaining the horizontal gradient and the vertical gradient corresponding to the current iteration period to obtain the current horizontal gradient and the current vertical gradient; substituting the current horizontal gradient and the current vertical gradient into the energy function to solve the intermediate fusion image corresponding to the current iteration period; detecting whether the intermediate fusion image corresponding to the current iteration period converges; if the intermediate fusion image corresponding to the current iteration period converges, substituting the intermediate fusion image, the current horizontal gradient and the current vertical gradient corresponding to the current iteration period into the energy function to solve the intermediate auxiliary image corresponding to the current iteration period, and using the intermediate auxiliary image corresponding to the current iteration period as the auxiliary image corresponding to the first image and the second image.
[0008] In one embodiment, the horizontal gradient and the vertical gradient corresponding to the current iteration cycle are obtained to obtain the current horizontal gradient and the current vertical gradient, including: obtaining the initial horizontal gradient and the initial vertical gradient, and taking the initial horizontal gradient as the current horizontal gradient and the initial vertical gradient as the current vertical gradient; or, obtaining the horizontal gradient and the vertical gradient corresponding to the previous iteration cycle to obtain the previous horizontal gradient and the previous vertical gradient; and obtaining the intermediate fusion image and the intermediate auxiliary image solved in the previous iteration cycle; substituting the previous horizontal gradient, the intermediate fusion image and the intermediate auxiliary image solved in the previous iteration cycle into the energy function to solve and obtain the current horizontal gradient; substituting the previous vertical gradient, the intermediate fusion image and the intermediate auxiliary image solved in the previous iteration cycle into the energy function to solve and obtain the current vertical gradient.
[0009] In one embodiment, detecting whether the intermediate fusion image corresponding to the current iteration cycle converges includes: obtaining the intermediate fusion image solved in the next iteration cycle; comparing the image difference between the intermediate fusion image corresponding to the current iteration cycle and the intermediate fusion image solved in the next iteration cycle; if the image difference is greater than a preset difference threshold, the intermediate fusion image corresponding to the current iteration cycle has not converged; if the image difference is not greater than the preset difference threshold, the intermediate fusion image corresponding to the current iteration cycle has converged.
[0010] In one embodiment, the first image is a visible light image, and the second image is an infrared image; an auxiliary image is used to guide the fusion of the first image and the second image to obtain a target fused image, including: converting the visible light image to a brightness-separated color space domain to obtain a brightness domain image and a color domain image corresponding to the visible light image; using the auxiliary image, fusing the brightness domain image of the visible light image and the infrared image to obtain a visible light brightness fusion image; combining the color domain image of the visible light image and the visible light brightness fusion image to obtain a target fused image.
[0011] In one embodiment, the first gradient is the gradient of the brightness domain of the visible light image, and the second gradient is the gradient of the infrared image; using the auxiliary image, the brightness domain image of the visible light image and the infrared image are fused to obtain a visible light brightness fusion image; the auxiliary image, the brightness domain of the visible light image and the gradient of the infrared image are substituted into the energy function to solve the visible light brightness fusion image.
[0012] In one embodiment, the auxiliary image, the brightness domain of the visible light image, and the gradient of the infrared image are substituted into an energy function to solve a visible light brightness fusion map, including: substituting the auxiliary image, the gradient of the brightness domain of the visible light image, and the gradient of the infrared image into an energy function to solve an initial fusion map; and extracting texture information of the infrared image; superimposing the texture information of the infrared image and the initial fusion map to obtain a visible light brightness fusion map.
[0013] According to a second aspect of the present application, there is provided an image fusion device, comprising: a gradient acquisition module, used to respectively acquire the gradient of a first image and the gradient of a second image to obtain a first gradient and a second gradient; wherein the first image and the second image are obtained by performing image acquisition on the same scene, the first image and the second image belong to different image types, and the image quality of the second image is better than that of the first image; an auxiliary graph calculation module, used to calculate an auxiliary graph based on the first gradient and the second gradient; wherein the similarity between the product of the auxiliary graph and the second gradient and the first gradient is greater than a preset similarity; and an image fusion module, used to use the auxiliary graph to guide the fusion of the first image and the second image to obtain a target fused image.
[0014] A third aspect of the present application provides an electronic device, including a memory and a processor, wherein the processor is used to execute program instructions stored in the memory to implement the above-mentioned image fusion method.
[0015] A fourth aspect of the present application provides a computer-readable storage medium on which program instructions are stored, and when the program instructions are executed by a processor, the above-mentioned image fusion method is implemented.
[0016] The above scheme obtains the first gradient and the second gradient by respectively acquiring the gradient of the first image and the gradient of the second image; wherein the first image and the second image are obtained by performing image acquisition on the same scene, the first image and the second image belong to different image types, and the image quality of the second image is better than that of the first image; based on the first gradient and the second gradient, an auxiliary map is calculated; wherein the similarity between the product of the auxiliary map and the second gradient and the first gradient is greater than a preset similarity; the auxiliary map is used to guide the fusion of the first image and the second image to obtain a target fused image, and the gradient relationship between the first image and the second image can be established through the auxiliary map to suppress the gradient difference between the first image and the second image, which helps to prevent problems such as excessive gradient smoothing and color cast on the target fused image, making the visual effect of the target fused image more natural and improving the image quality of the target fused image.
[0017] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.
[0019] Figure 1 It is a schematic diagram of an implementation environment of a solution provided by an embodiment of the present application;
[0020] Figure 2 is a flow chart of an image fusion method shown in an exemplary embodiment of the present application;
[0021] Figure 3 is a flow chart of a calculation auxiliary graph shown in an exemplary embodiment of the present application;
[0022] Figure 4 is a block diagram of an image fusion device shown in an exemplary embodiment of the present application;
[0023] Figure 5 is a schematic structural diagram of an electronic device shown in an exemplary embodiment of the present application;
[0024] Figure 6 It is a schematic diagram of the structure of a computer-readable storage medium shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0025] The scheme of the embodiment of the present application is described in detail below in conjunction with the drawings of the specification.
[0026] In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures, interfaces, and technologies are provided to facilitate a thorough understanding of the present application.
[0027] The term "and / or" in this article is only an association information describing the associated objects, indicating that there may be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the previous and next associated objects are in an "or" relationship. In addition, "many" in this article means two or more than two. In addition, the term "at least one" in this article means any combination of at least two of any one or more of a plurality of, for example, including at least one of A, B, and C, can mean including any one or more elements selected from the set consisting of A, B, and C.
[0028] The image fusion method provided in the embodiment of the present application is described below.
[0029] Please refer to Figure 1 , which shows a schematic diagram of a solution implementation environment provided by an embodiment of the present application. The solution implementation environment may include a terminal 110 and a server 120, and the terminal 110 and the server 120 are connected to each other in communication.
[0030] The number of the terminal 110 may be one or more. The terminal 110 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto.
[0031] Server 120 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.
[0032] In one example, the server 120 may perform image fusion processing on the first image and the second image acquired from the terminal 110 to obtain a target fused image. Of course, the server 120 may store the target fused image locally, transmit it back to the terminal 110, or transmit it to another terminal 110. The first image and the second image may be acquired from the same terminal or different terminals.
[0033] In one example, a client running a target application is installed in the terminal 110, for example, the target application may be an application providing an image fusion function. The server 120 may be a background server of the target application, configured to provide background services for the client of the target application, so that the terminal 110 performs image fusion processing on the first image and the second image to obtain a target fused image.
[0034] In the image fusion method provided in the embodiment of the present application, the execution subject of each step can be the terminal 110, such as the client of the target application installed and running in the terminal 110, or the server 120, or the terminal 110 and the server 120 can interact and cooperate to execute, that is, part of the steps of the method are executed by the terminal 110 and the other steps are executed by the server 120.
[0035] See also Figure 2 , Figure 2 is a flowchart of an image fusion method shown in an exemplary embodiment of the present application. The image fusion method can be applied to Figure 1 It should be understood that the method can also be applied to other exemplary implementation environments and be specifically executed by devices in other implementation environments, and this embodiment does not limit the implementation environment to which the method is applicable.
[0036] like Figure 2 As shown, the image fusion method at least includes steps S210 to S230, which are described in detail as follows:
[0037] Step S210: respectively obtain the gradient of the first image and the gradient of the second image to obtain the first gradient and the second gradient; wherein the first image and the second image are obtained by capturing images of the same scene, the first image and the second image belong to different image types, and the image quality of the second image is better than that of the first image.
[0038] Images are captured for the same scene to obtain a first image and a second image, and the number of the first image and the second image may be one or more.
[0039] The image types to which the first image and the second image belong may include at least two of visible light images, grayscale images, depth images, infrared images, radar images, and the like.
[0040] The image quality of the second image is better than that of the first image. For example, the second image is an infrared image captured when the ambient light is lower than a preset ambient light threshold, and the first image is a visible light image captured at the same time. At this time, the image quality of the infrared image is better than that of the visible light image.
[0041] Exemplarily, taking the case where the first image is a visible light image and the second image is an infrared image, an image acquisition device is deployed for the target scene. The image acquisition device contains a visible light image acquisition sensor and an infrared image acquisition sensor. The visible light image acquisition sensor and the infrared image acquisition sensor are respectively started to acquire images of the target scene, and a visible light image of the target scene is obtained as the first image, and an infrared image of the target scene is obtained as the second image.
[0042] After obtaining the first image and the second image, gradient extraction is performed on the first image and the second image respectively to obtain a first gradient and a second gradient.
[0043] Image gradient calculation is the magnitude of image change. For the edge of the image, the gray value changes greatly, and the gradient value changes greatly; on the contrary, for the smoother part of the image, the gray value changes less, and the corresponding gradient value changes less.
[0044] Specifically, the image gradient refers to the rate of change of a certain pixel in the image in the x and y directions (compared with adjacent pixels). It is a two-dimensional vector consisting of two components, namely the change in the x-axis and the change in the y-axis. The change in the x-axis refers to the pixel value on the right side of the current pixel minus the pixel value on the left side of the current pixel, thereby obtaining the x-axis component, and the change in the y-axis refers to the pixel value on the bottom side of the current pixel minus the pixel value on the top side of the current pixel, thereby obtaining the y-axis component. A two-dimensional vector is formed based on the above two components to obtain the gradient of the pixel.
[0045] Step S220: calculating an auxiliary map based on the first gradient and the second gradient; wherein the similarity between the product of the auxiliary map and the second gradient and the first gradient is greater than a preset similarity.
[0046] Assume that there is an auxiliary graph, the product of the auxiliary graph and the second gradient is approximately equal to the first gradient, and the relevant formula can be expressed as the following formula 1:
[0047]
[0048] Among them, I refers to the first image, G refers to the second image, and s refers to the auxiliary image. refers to the first gradient corresponding to the first image, It refers to the second gradient corresponding to the second image.
[0049] The similarity between the product of the auxiliary image and the second gradient and the first gradient is calculated, and if the similarity is greater than a preset similarity, it is determined that the product of the auxiliary image and the second gradient is similar to the first gradient.
[0050] Based on Formula 1, and given the first gradient and the second gradient, the auxiliary map can be calculated. The greater the similarity between the product of the calculated auxiliary map and the second gradient and the first gradient, the more accurate the auxiliary map is.
[0051] Exemplarily, the auxiliary graph can be solved by mathematical methods. For example, an energy function can be constructed based on the first gradient, the second gradient, and the auxiliary graph to be solved. In the energy function, the closer the value of the data item is to the ideal state, the lower its energy value is. In the present application, the closer the value of the data item is to the ideal state, the greater the similarity between the product of the corresponding auxiliary graph and the second gradient and the first gradient, and the more accurate the auxiliary graph is. Therefore, by optimizing the energy function, the best auxiliary graph can be solved.
[0052] Exemplarily, the auxiliary graph can also be solved by a neural network model. For example, the neural network model is trained using training samples, the training samples include a plurality of first sample gradients corresponding to first sample images and a second sample gradient corresponding to a second sample image, the first sample gradient and the second sample gradient are input into a pre-trained neural network model, and the pre-trained neural network model outputs an auxiliary graph. The model training loss can be: using the output auxiliary graph to guide the first sample image and the second sample image to fuse to obtain a sample fusion image, and performing a quality assessment on the sample fusion image. The higher the quality of the sample fusion image, the smaller the model training loss, and the lower the quality of the sample fusion image, the greater the model training loss. Of course, other methods can also be used to calculate the model training loss. The model training loss is used to perform model parameter adjustment to obtain a trained neural network model, and the neural network model is used to predict the auxiliary graph corresponding to the first gradient and the second gradient.
[0053] It should be noted that the above examples are merely illustrative, and other methods may be used to calculate the auxiliary graph, which is not limited in this application.
[0054] Since the image quality of the second image is better than that of the first image, it is hoped that more image information of the second image can be introduced into the first image during the fusion process of the first image and the second image. In order to accurately introduce the image information of the second image, it is hoped that the gradient of the first image is close to the gradient of the second image. However, in actual scenes, since the first image and the second image belong to different image types, the gradients of the first image and the second image are different. Therefore, the present application uses the auxiliary image obtained by solution to make up for the gradient difference between the first image and the second image.
[0055] Step S230: using the auxiliary image to guide the fusion of the first image and the second image to obtain a target fused image.
[0056] The auxiliary image is used to establish a relationship between the gradient of the first image and the gradient of the second image. Therefore, the auxiliary image is used as a bridge to guide the fusion of the first image and the second image to obtain a target fused image.
[0057] Exemplarily, the first image and the second image can be fused by mathematical methods. For example, an energy function can be constructed based on the first gradient, the second gradient, the auxiliary image and the target fused image to be solved, and the final target fused image can be obtained by iteratively optimizing the energy function.
[0058] Exemplarily, the first image and the second image may also be fused through a neural network model, and the trained neural network model contains an image fusion network, the input of which includes the auxiliary image, the first image, and the second image, and the output is a target fused image. The training method of the image fusion network may refer to the model training method in step S220, and may also be trained in other ways, which is not limited in this application.
[0059] It should be noted that the above examples are only exemplary descriptions, and other methods can also be used to use auxiliary images to guide the fusion of the first image and the second image, and this application does not limit this.
[0060] Since the first image and the second image are of different image types, there is a large difference between the first image and the second image. Direct fusion may reduce the image quality, such as excessive smoothing, unnatural visual effects, color cast, etc. of the fused image.
[0061] Therefore, the present application takes into account the inconsistency between the gradient of the first image and the gradient of the second image, establishes a gradient relationship between the first image and the second image through an auxiliary image, suppresses the gradient difference between the first image and the second image, and helps prevent problems such as excessive gradient smoothing and color cast on the target fused image, making the visual effect of the target fused image more natural and improving the image quality of the target fused image.
[0062] Next, some embodiments of the present application are described in detail.
[0063] In some embodiments, the similarity between the gradient direction of the auxiliary image and the gradient direction of the second gradient is greater than a preset similarity; in step S220, the auxiliary image is calculated based on the first gradient and the second gradient, including: constructing an energy function with the goal of minimizing the difference between the product of the auxiliary image and the second gradient and the first gradient, and minimizing the projection value of the gradient of the auxiliary image in the direction vertical to the second gradient; based on the energy function, solving the auxiliary image corresponding to the first image and the second image.
[0064] Since there is a lot of noise in the first image, there is also a lot of noise in the auxiliary image. Therefore, it is necessary to perform noise reduction on the auxiliary image by making the gradient direction of the auxiliary image close to the gradient direction of the second image to suppress the noise in the auxiliary image.
[0065] The smaller the difference between the product of the auxiliary image and the second gradient and the first gradient, the higher the similarity between the product of the auxiliary image and the second gradient and the first gradient; the smaller the projection value of the gradient of the auxiliary image in the vertical direction of the second gradient, the higher the similarity between the gradient direction of the auxiliary image and the gradient direction of the second gradient.
[0066] The formula for expressing the difference between the product of the auxiliary image and the second gradient and the first gradient is given as an example:
[0067] For example, the difference a between the product of the auxiliary map and the second gradient and the first gradient can be expressed as the following formula 2:
[0068]
[0069] in, represents the gradient in the x direction at the pixel coordinate i in the first image I; represents the gradient in the x direction at the pixel coordinate i in the second image G; represents the gradient at pixel coordinate i in the auxiliary image s in the x direction; represents the gradient at pixel coordinate i in the auxiliary image s in the y direction; represents the pixel value at pixel coordinate i in the auxiliary image s; , are the preset intensity factors respectively.
[0070] In addition, the data items It is used to fuse the auxiliary graph in the x direction and the auxiliary graph in the y direction to obtain the total auxiliary graph s. The representation of the auxiliary graph s is obtained in advance through this data item to facilitate subsequent calculations.
[0071] For another example, the difference a between the product of the auxiliary map and the second gradient and the first gradient can also be expressed as the following formula 3:
[0072]
[0073] Formula 3 can avoid the situation where the difference a is also enlarged or reduced due to the first image I and the second image G being enlarged or reduced, thereby improving the calculation accuracy.
[0074] The following example illustrates the formula for expressing the projection value of the gradient of the auxiliary image in the direction perpendicular to the second gradient:
[0075] For example, the projection value b of the gradient of the auxiliary image in the direction perpendicular to the second gradient can be expressed as the following formula 4:
[0076]
[0077] Where i represents the pixel coordinate; represents the gradient of the second image G, that is, the second gradient; Perpendicular to ; ; T represents transpose operation; Represents the gradient of the auxiliary graph s at point i; is the preset intensity factor.
[0078] For another example, the projection value b of the gradient of the auxiliary image in the direction perpendicular to the second gradient can also be expressed as the following formula 5:
[0079]
[0080] Among them, GauFilter represents mean filtering.
[0081] Compared with Formula 4, Formula 5 adds a mean filter for I. The mean filter retains the large gradient in the first image I and helps to protect the edge information in the second image G.
[0082] The energy function is constructed based on the above formula.
[0083] For example, based on the above formula 3 and formula 5, the energy function J can be constructed by referring to the following formula 6:
[0084]
[0085] The original first image is represented as I0, and the intermediate image corresponding to the first image in the iterative optimization process of the energy function is represented as I, wherein the energy function is optimized for the first time, I0=I; represents the pixel value at pixel coordinate i in the intermediate image; represents the pixel value at the pixel coordinate i in the original first image; the subsequent data items correspond to the above formula 3 and formula 5 respectively.
[0086] Furthermore, Formula 6 can be vectorized to obtain Formula 7:
[0087]
[0088] Among them, I is vectorized as ; I0 is vectorized as ; s vectorized representation ; n is the number of pixels; T represents the transpose operation;
[0089] is the diagonal matrix in the x direction corresponding to G, and the calculation method can be referred to the following formula 8:
[0090]
[0091] is the diagonal matrix in the y direction corresponding to G, and the calculation method can be referred to the following formula 9:
[0092]
[0093] In Formula 8 and Formula 9, G is a vectorized representation of the second image; diag is used to construct a diagonal matrix; and sign is a sign function, which is used to output 1 when the input is greater than or equal to 0, and output -1 when the input is less than 0.
[0094] Further, , They represent the gradient matrices in the x-direction and y-direction corresponding to I respectively; and the calculation method of M can refer to the following formula 10:
[0095]
[0096] Of course, in addition to the energy functions exemplified above, the energy function may also be constructed in other ways, which is not limited in this application.
[0097] According to the energy function, the auxiliary images corresponding to the first image and the second image are solved.
[0098] Specifically, the energy function is iteratively optimized, and in each iteration the value of the data item is updated according to the current energy function and the optimization algorithm, and a new energy function value is calculated until a stopping condition is met.
[0099] Among them, commonly used optimization algorithms include gradient descent method, genetic algorithm and simulated annealing algorithm.
[0100] Next, we will give an example to illustrate the optimization process of the energy function:
[0101] In some embodiments, based on the energy function, the auxiliary image corresponding to the first image and the second image is solved, including: obtaining the horizontal gradient and the vertical gradient corresponding to the current iteration period to obtain the current horizontal gradient and the current vertical gradient; substituting the current horizontal gradient and the current vertical gradient into the energy function to solve the intermediate fusion image corresponding to the current iteration period; detecting whether the intermediate fusion image corresponding to the current iteration period converges; if the intermediate fusion image corresponding to the current iteration period converges, substituting the intermediate fusion image, the current horizontal gradient, and the current vertical gradient corresponding to the current iteration period into the energy function to solve the intermediate auxiliary image corresponding to the current iteration period, and using the intermediate auxiliary image corresponding to the current iteration period as the auxiliary image corresponding to the first image and the second image.
[0102] Specifically, the current horizontal gradient and the current vertical gradient corresponding to the current iteration cycle are obtained, including: obtaining the initial horizontal gradient and the initial vertical gradient, taking the initial horizontal gradient as the current horizontal gradient, and taking the initial vertical gradient as the current vertical gradient; or, obtaining the horizontal gradient and the vertical gradient corresponding to the previous iteration cycle, and obtaining the previous horizontal gradient and the previous vertical gradient; and obtaining the intermediate fusion image and the intermediate auxiliary image solved in the previous iteration cycle; substituting the previous horizontal gradient, the intermediate fusion image and the intermediate auxiliary image solved in the previous iteration cycle into the energy function, and solving to obtain the current horizontal gradient; substituting the previous vertical gradient, the intermediate fusion image and the intermediate auxiliary image solved in the previous iteration cycle into the energy function, and solving to obtain the current vertical gradient.
[0103] For example, the initial horizontal gradient and the initial vertical gradient are vectors of all 1s.
[0104] If it is the first iteration, the initial horizontal gradient is used as the current horizontal gradient, and the initial vertical gradient is used as the current vertical gradient.
[0105] If it is not the first iteration, the horizontal gradient and vertical gradient corresponding to the previous iteration cycle, the intermediate fusion image and the intermediate auxiliary image calculated in the previous iteration cycle are substituted into the energy function to calculate the current vertical gradient and the current horizontal gradient respectively.
[0106] The current horizontal gradient and the current vertical gradient are substituted into the energy function constructed in the above embodiment to obtain the intermediate fused image corresponding to the current iteration period.
[0107] Then, it is detected whether the intermediate fusion image corresponding to the current iteration cycle meets the preset conditions.
[0108] Specifically, an intermediate fusion image obtained by solving the next iteration cycle is obtained; the image difference between the intermediate fusion image corresponding to the current iteration cycle and the intermediate fusion image obtained by solving the next iteration cycle is compared; if the image difference is greater than a preset difference threshold, the intermediate fusion image corresponding to the current iteration cycle has not converged; if the image difference is not greater than the preset difference threshold, the intermediate fusion image corresponding to the current iteration cycle has converged.
[0109] For example, see Figure 3 , Figure 3 A flowchart of a calculation auxiliary diagram is shown for an exemplary embodiment of the present application, as shown in FIG. Figure 3 As shown, including:
[0110] Step S310: Obtain the horizontal gradient and the vertical gradient corresponding to the current iteration cycle to obtain the current horizontal gradient and the current vertical gradient.
[0111] For example, the current iteration cycle is the tth iteration, and the current horizontal gradient is recorded as , and record the current vertical gradient as .
[0112] Step S320: Substitute the current horizontal gradient and the current vertical gradient into the energy function, and solve to obtain the intermediate fused image corresponding to the current iteration cycle.
[0113] That is, according to the current horizontal gradient and the current vertical gradient Calculate the intermediate fusion image .
[0114] Specifically, taking Formula 7 as an example, delete the energy function J with The irrelevant terms are obtained as formula 11:
[0115]
[0116] right Taking the derivative, we get formula 12:
[0117]
[0118] Solved :
[0119]
[0120] Where E is the identity matrix, whose diagonal elements from the upper left corner to the lower right corner are all 1, and the rest of the elements are all 0.
[0121] Step S330: Substitute the intermediate fusion image corresponding to the current iteration cycle, the current horizontal gradient, and the current vertical gradient into the energy function, and solve to obtain the intermediate auxiliary image corresponding to the current iteration cycle.
[0122] That is, according to the intermediate fusion image corresponding to the current iteration cycle , current horizontal gradient and the current vertical gradient , solve and obtain the intermediate auxiliary graph corresponding to the current iteration cycle .
[0123] Specifically, still taking Formula 7 as an example, delete the energy function J with The irrelevant terms give Formula 13:
[0124]
[0125] By taking the derivative, we get :
[0126]
[0127] Among them, the one calculated in the previous step ,renew .
[0128] Step S340: Substitute the intermediate auxiliary image, the intermediate fusion image, the current horizontal gradient, and the current vertical gradient corresponding to the current iteration cycle into the energy function, and solve to obtain the intermediate fusion image corresponding to the next iteration cycle;
[0129] Specifically, according to the intermediate auxiliary graph corresponding to the current iteration cycle , the intermediate fusion image corresponding to the current iteration cycle , current horizontal gradient , solve and get the horizontal gradient corresponding to the next iteration cycle Taking Formula 7 as an example, delete the energy function J and The irrelevant terms are obtained as formula 14:
[0130]
[0131] The horizontal gradient corresponding to the next iteration cycle is obtained by derivation. :
[0132]
[0133] Similarly, using the same method, the vertical gradient corresponding to the next iteration cycle can be solved :
[0134]
[0135] Then, according to step S320, the intermediate fusion image corresponding to the next iteration cycle is calculated .
[0136] Step S350: comparing the image difference between the intermediate fusion image of the current iteration cycle and the intermediate fusion image of the next iteration cycle.
[0137] Step S360: Determine whether the image difference is greater than a preset difference threshold, if so, execute step S310; if not, execute step S370.
[0138] For example, in judging and Is it satisfied? ,in, is the preset difference threshold.
[0139] Step S370: Use the intermediate auxiliary image corresponding to the current iteration cycle as the auxiliary image corresponding to the first image and the second image.
[0140] If the image difference is not greater than the preset difference threshold, it is considered that I converges, and the intermediate auxiliary image corresponding to the current iteration cycle is used as the auxiliary image corresponding to the first image and the second image, and the iterative optimization process ends.
[0141] It should be noted that the intermediate auxiliary image corresponding to the next iteration cycle may also be used as the auxiliary image corresponding to the first image and the second image, and this application does not limit this.
[0142] After the auxiliary image is obtained, the auxiliary image is used to guide the fusion of the first image and the second image to obtain a target fused image.
[0143] Exemplarily, the target fused image is iteratively solved using an energy function.
[0144] Specifically, assume that the energy function is expressed as formula 15:
[0145]
[0146] Vectorizing formula 15 yields formula 16:
[0147]
[0148] Where F is a diagonal matrix:
[0149]
[0150] H represents a diagonal matrix:
[0151] .
[0152] By deriving formula 16, the target fusion image I to be solved is obtained as follows:
[0153]
[0154] In some implementations, the result obtained by deriving Formula 16 may be used as an initial fusion image, texture information in the second image may be extracted, and the texture information may be superimposed on the initial fusion image to obtain a final target fusion image.
[0155] Exemplarily, the image fusion process is explained by taking the first image as a visible light image and the second image as an infrared image as an example: the visible light image is converted to a brightness-separated color space domain to obtain a brightness domain image and a color domain image corresponding to the visible light image; the brightness domain image of the visible light image and the infrared image are fused using an auxiliary image to obtain a visible light brightness fusion image; the color domain image of the visible light image and the visible light brightness fusion image are combined to obtain a target fused image.
[0156] Specifically, the right RGB domain of the visible light image is converted into the YUV domain, where Y is the brightness domain image and UV is the color domain image.
[0157] The auxiliary image is used to fuse the brightness domain image of the visible light image and the infrared image. At this time, the first gradient is the gradient of the brightness domain of the visible light image, and the second gradient is the gradient of the infrared image. The auxiliary image, the brightness domain of the visible light image, and the gradient of the infrared image are substituted into the energy function to solve the visible light brightness fusion image.
[0158] Specifically, the auxiliary image, the gradient of the brightness domain of the visible light image and the gradient of the infrared image are substituted into the energy function to solve the initial fusion image; and the texture information of the infrared image is extracted; the texture information of the infrared image and the initial fusion image are superimposed to obtain a visible light brightness fusion image.
[0159] The specific implementation method of using the energy function to solve the initial fusion graph can be found in the above embodiment, and this application will not go into details here.
[0160] Furthermore, the texture information of the infrared image is extracted.
[0161] For example, bilateral filtering is used to extract low-frequency information of the infrared image, and then the infrared image and the low-frequency information are subtracted to obtain the texture information of the infrared image. The formula for extracting the low-frequency information of the infrared image can be the following formula 17:
[0162]
[0163] in, is the low-frequency information at pixel coordinate i of the infrared image; , g is a Gaussian function, which can be specifically expressed as ; is the Gaussian weight, The larger it is, the stronger the bilateral filtering is. represents the filtering range (such as 15*15, 25*25 pixel range), i and j represent the image pixel coordinates, and the above formula 17 represents the bilateral filtering of a pixel point i, so It represents a range centered on i.
[0164] Then, the texture information of the infrared image is obtained by subtracting the infrared image from the low-frequency information. For details, see the following formula 18:
[0165]
[0166] Among them, TexG is the texture information of the infrared image.
[0167] It should be noted that TexG often contains edge information. In order to minimize the edge information in the high-frequency information of the infrared image and keep most of the edge information in LowG, a smaller value needs to be set when using bilateral filtering to extract low-frequency information. The filter coefficient ensures that most of the edge information can be retained in LowG, while most of the texture information is removed from LowG.
[0168] Then, let the initial fusion image obtained by the solution be I, and the texture information of the infrared image and the initial fusion image are superimposed to obtain the visible light brightness fusion image , see the following formula 19 for details:
[0169]
[0170] Finally, the above visible light brightness fusion map is used to replace the brightness domain image Y of the original visible light image, combined with the color domain image UV of the original visible light image, and the new YUV is converted to the RGB domain to obtain the final target fusion image.
[0171] The image fusion method provided by the present application obtains the first gradient and the second gradient by respectively acquiring the gradient of the first image and the gradient of the second image; wherein the first image and the second image are obtained by image acquisition of the same scene, the first image and the second image belong to different image types, and the image quality of the second image is better than that of the first image; based on the first gradient and the second gradient, an auxiliary map is calculated; wherein the similarity between the product of the auxiliary map and the second gradient and the first gradient is greater than a preset similarity; the auxiliary map is used to guide the fusion of the first image and the second image to obtain a target fused image, and the gradient relationship between the first image and the second image can be established through the auxiliary map to suppress the gradient difference between the first image and the second image, which helps to prevent problems such as excessive gradient smoothing and color cast on the target fused image, so that the visual effect of the target fused image is more natural and the image quality of the target fused image is improved.
[0172] Figure 4 FIG. 1 is a block diagram of an image fusion device shown in an exemplary embodiment of the present application. Figure 4 As shown, the exemplary image fusion device 400 includes: a gradient acquisition module 410, an auxiliary image calculation module 420 and an image fusion module 430. Specifically:
[0173] A gradient acquisition module 410 is used to acquire the gradient of the first image and the gradient of the second image respectively, to obtain the first gradient and the second gradient; wherein the first image and the second image are obtained by collecting images of the same scene, the first image and the second image belong to different image types, and the image quality of the second image is better than that of the first image;
[0174] An auxiliary graph calculation module 420 is used to calculate an auxiliary graph based on the first gradient and the second gradient; wherein the similarity between the product of the auxiliary graph and the second gradient and the first gradient is greater than a preset similarity;
[0175] The image fusion module 430 is used to use the auxiliary image to guide the fusion of the first image and the second image to obtain a target fused image.
[0176] It should be noted that the image fusion device provided in the above embodiment and the image fusion method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment, and will not be repeated here. In practical applications, the image fusion device provided in the above embodiment can distribute the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.
[0177] See also Figure 5 , Figure 5 1 is a schematic diagram of the structure of an embodiment of an electronic device of the present application. The electronic device 500 includes a memory 501 and a processor 502, and the processor 502 is used to execute program instructions stored in the memory 501 to implement the steps in any of the above-mentioned image fusion method embodiments. In a specific implementation scenario, the electronic device 500 may include but is not limited to: a microcomputer, a server, and in addition, the electronic device 500 may also include a mobile device such as a laptop computer and a tablet computer, which is not limited here.
[0178] Specifically, the processor 502 is used to control itself and the memory 501 to implement the steps in any of the above-mentioned image fusion method embodiments. The processor 502 can also be called a central processing unit (CPU). The processor 502 may be an integrated circuit chip with signal processing capabilities. The processor 502 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 502 can be implemented by an integrated circuit chip.
[0179] See also Figure 6 , Figure 6The computer-readable storage medium 600 stores program instructions 610 that can be executed by a processor, and the program instructions 610 are used to implement the steps in any of the above-mentioned image fusion method embodiments.
[0180] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0181] The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.
[0182] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0183] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or part of the contribution to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform all or part of the steps of each implementation method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program code.
Claims
1. An image fusion method, It is characterized in that include: Acquire the gradient of the first image and the gradient of the second image respectively to obtain the first gradient and the second gradient; wherein the first image and the second image are obtained by performing image acquisition on the same scene, the first image and the second image belong to different image types, and the image quality of the second image is better than that of the first image; Based on the first gradient and the second gradient, an auxiliary map is calculated; wherein the similarity between the product of the auxiliary map and the second gradient and the first gradient is greater than a preset similarity, and the similarity between the gradient direction of the auxiliary map and the gradient direction of the second gradient is greater than a preset similarity; The step of calculating an auxiliary graph based on the first gradient and the second gradient includes: constructing an energy function with the goal of minimizing the difference between the product of the auxiliary image and the second gradient and the first gradient, and minimizing the projection value of the gradient of the auxiliary image in the direction vertical to the second gradient; Based on the energy function, solving the auxiliary images corresponding to the first image and the second image; An energy function is constructed based on the first gradient, the second gradient, the auxiliary image and the target fused image to be solved, and the energy function is iteratively optimized to solve and obtain the target fused image.
2. The method according to claim 1, It is characterized in that The step of calculating the auxiliary graphs corresponding to the first image and the second image based on the energy function includes: Get the horizontal gradient and vertical gradient corresponding to the current iteration cycle to obtain the current horizontal gradient and the current vertical gradient; Substituting the current horizontal gradient and the current vertical gradient into the energy function, and solving to obtain an intermediate fused image corresponding to the current iteration cycle; Detecting whether the intermediate fusion image corresponding to the current iteration cycle converges; If the intermediate fusion image corresponding to the current iteration cycle converges, the intermediate fusion image corresponding to the current iteration cycle, the current horizontal gradient and the current vertical gradient are substituted into the energy function to obtain the intermediate auxiliary image corresponding to the current iteration cycle by solution, and the intermediate auxiliary image corresponding to the current iteration cycle is used as the auxiliary image corresponding to the first image and the second image.
3. The method according to claim 2, It is characterized in that The step of obtaining the horizontal gradient and the vertical gradient corresponding to the current iteration cycle to obtain the current horizontal gradient and the current vertical gradient includes: Obtaining an initial horizontal gradient and an initial vertical gradient, taking the initial horizontal gradient as the current horizontal gradient, and taking the initial vertical gradient as the current vertical gradient; or, Obtain the horizontal gradient and vertical gradient corresponding to the previous iteration cycle, and obtain the previous horizontal gradient and the previous vertical gradient; and obtain the intermediate fusion image and the intermediate auxiliary image obtained by solving the previous iteration cycle; Substituting the previous horizontal gradient, the intermediate fusion image obtained by solving the previous iteration cycle, and the intermediate auxiliary image into the energy function to solve and obtain the current horizontal gradient; The previous vertical gradient, the intermediate fusion image obtained by solving the previous iteration cycle, and the intermediate auxiliary image are substituted into the energy function to solve and obtain the current vertical gradient.
4. The method according to claim 2, It is characterized in that The detecting whether the intermediate fusion image corresponding to the current iteration cycle converges includes: Obtaining the intermediate fused image solved in the next iteration cycle; Comparing the image difference between the intermediate fusion image corresponding to the current iteration period and the intermediate fusion image obtained by solving the next iteration period; If the image difference is greater than a preset difference threshold, the intermediate fusion image corresponding to the current iteration cycle has not converged; If the image difference is not greater than the preset difference threshold, the intermediate fused image corresponding to the current iteration period converges.
5. The method according to claim 1, It is characterized in that The first image is a visible light image, the second image is an infrared image, the first gradient is a gradient in a brightness domain of the visible light image, and the second gradient is a gradient of the infrared image; constructing an energy function based on the first gradient, the second gradient, the auxiliary image, and a target fused image to be solved, iteratively optimizing the energy function, and solving to obtain a target fused image, includes: Converting the visible light image to a brightness-separated color space domain to obtain a brightness domain image and a color domain image corresponding to the visible light image; An energy function is constructed based on the gradient of the brightness domain of the visible light image, the gradient of the infrared image, the auxiliary image, and the visible light brightness fusion image to be solved, and the energy function is iteratively optimized to solve the visible light brightness fusion image; The color domain image of the visible light image and the visible light brightness fusion image are combined to obtain a target fused image.
6. The method according to claim 5, It is characterized in that The step of constructing an energy function based on the gradient of the brightness domain of the visible light image, the gradient of the infrared image, and the auxiliary image, iteratively optimizing the energy function, and solving to obtain a visible light brightness fusion image includes: Substituting the auxiliary image, the gradient of the brightness domain of the visible light image and the gradient of the infrared image into an energy function to obtain an initial fusion image; and extracting texture information of the infrared image; The texture information of the infrared image and the initial fusion map are superimposed to obtain a visible light brightness fusion map.
7. An electronic device, It is characterized in that The electronic device comprises a memory and a processor, and the processor is used to execute program instructions stored in the memory to implement the steps in the method according to any one of claims 1 to 6.
8. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores program instructions, and the program instructions can be executed by a processor to implement the steps in the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
A method, apparatus and electric device for image fusion
US20200342580A1
Bi-level optimization-based infrared and visible light fusion method
US20220044442A1
