An image fusion method, device, equipment and storage medium
Patent Information
- Application Number
- CN202410299900.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-15
- Publication Date
- 2026-09-29
- Estimated Expiration
- 2044-03-15
AI Technical Summary
然而,在利用相机拍摄图像时,由于相机镜头受景深限制,很难拍摄到场景都聚焦良好的图像,而在某些工业和医疗领域,对图像精度要求都比较高,现有相机拍摄出来的图像一般都不能直接使用,需要经过特定的图像处理才能使用
[0043]本发明提供的图像融合方法,利用灰度方差计算序列图像每个像素点的聚焦度获取聚焦度序列分数,在其基础上对灰度方差方法进行改进,提高了运行速度同时保证融合效果,从而将多种聚焦图像合成为一张全聚焦图像,融合效果更好。
Smart Images

Figure CN118071622B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to an image fusion method, apparatus, device, and storage medium. Background Technology
[0002] Image acquisition and processing are widely used technologies in daily life, industrial production, and medical fields. Currently, various types of cameras are typically used to acquire images. However, when shooting images with a camera, the depth of field limitation of the camera lens makes it difficult to capture images where the entire scene is in focus. In certain industrial and medical fields, high image accuracy is required, and images captured by existing cameras are generally not usable directly and require specific image processing. However, most existing image processing technologies can only achieve high-precision results for images with a single fixed focal length and cannot be used to process multiple images with different focal lengths simultaneously. Summary of the Invention
[0003] In view of this, the purpose of the present invention is to overcome the shortcomings of the prior art and provide an image fusion method, apparatus, device and storage medium.
[0004] This invention provides the following technical solution:
[0005] Firstly, this application provides an image fusion method, including:
[0006] Acquire an image sequence, the image sequence comprising multiple initial images with different focal lengths;
[0007] Each of the initial images in the image sequence is converted to grayscale to obtain a grayscale image sequence;
[0008] By improving the grayscale variance, the focus degree of each pixel in each grayscale image in the grayscale image sequence is calculated to obtain a focus score sequence containing the focus degree of each pixel; the focus score sequence includes the pixel coordinates of each pixel focus degree.
[0009] From the focus score sequence, obtain the target pixel focus set contained in each target pixel coordinate, take the index corresponding to the maximum value in each target pixel focus set as the target index of the target pixel coordinate, and construct a target matrix based on the target index;
[0010] A blank image is constructed based on the size of the initial image, and a corresponding target image is selected from the image sequence according to the target index of each target pixel coordinate and the target matrix;
[0011] The target pixel corresponding to the target pixel coordinates is obtained from the target image, and the target pixel is filled into the target pixel coordinates of the blank image to obtain the fused image.
[0012] In one embodiment, acquiring the image sequence, the image sequence including multiple images with different focal lengths, includes:
[0013] Obtain the image sequence z(I1,I2,I3,...,I...) k );
[0014] Where k = 1, 2, 3, ..., m; I k Each image is a single image of the same size, and m represents the number of images with different focal lengths.
[0015] In one embodiment, the step of converting each image in the image sequence to grayscale to obtain a grayscale image sequence includes:
[0016] The weighted average method is used to convert each image in the image sequence to grayscale to obtain a grayscale image. The formula for the weighted average method is:
[0017] Grayscale value = 0.299 × R + 0.587 × G + 0.114 × B
[0018] RGB represents the colors of the red, green, and blue channels, respectively.
[0019] The grayscale image is stored in the image sequence g(Ig1,Ig2,Ig3,...,Ig...). k In the process, the grayscale image sequence is obtained, wherein Ig n For grayscale images, n = 1, 2, k.
[0020] In one embodiment, calculating the focus of each pixel in each grayscale image of the grayscale image sequence by improving the grayscale variance includes:
[0021] The improved grayscale variance is:
[0022]
[0023] Where pixelz(i,j) is the focus of the pixel at position (i,j) of the k-th image, the sliding window size is 2n, f(i,j) represents the pixel of the grayscale image at (i,j), and x and y are variables with values ranging from (-n / 3 to n / 3).
[0024] In one embodiment, obtaining a focus score sequence comprising the focus degree of each pixel includes:
[0025] Based on the calculated focus of a single pixel, store it in p(i,j) according to its corresponding position;
[0026] The focus score of each pixel in the grayscale image is stored in the focus score sequence s(p1, p2, p3, ..., p...). k )middle.
[0027] In one embodiment, obtaining the target pixel focus set contained in each target pixel coordinate from the focus score sequence, and using the index corresponding to the maximum value of each target pixel focus set as the target index of the pixel coordinate, includes:
[0028] Based on the target pixel coordinates, obtain the maximum value in the target pixel focus set within the focus score sequence;
[0029] The index of the maximum value of the pixel focus set is saved according to the target pixel coordinates, and the index is saved in the target coordinates of the matrix to obtain the target matrix, wherein the target coordinates are the same as the target pixel coordinates.
[0030] In one embodiment, the step of constructing a blank image based on the size of the initial image and selecting a corresponding target image from the image sequence according to the target index of each target pixel coordinate includes:
[0031] Construct a blank image of the same size as the initial image, and obtain the target index from the (i,j) position of the target matrix;
[0032] Select the target image corresponding to the target number from the image sequence.
[0033] Secondly, this application provides an image fusion apparatus, comprising:
[0034] An acquisition module is used to acquire an image sequence, the image sequence including multiple initial images with different focal lengths;
[0035] The processing module is used to perform grayscale processing on each of the initial images in the image sequence to obtain a grayscale image sequence;
[0036] The calculation module is used to calculate the focus degree of each pixel of each grayscale image in the grayscale image sequence by improving the grayscale variance, and obtain a focus score sequence containing the focus degree of each pixel; the focus score sequence includes the pixel coordinates of the focus degree of each pixel.
[0037] The focusing module is used to obtain the set of target pixel focus degrees contained in each target pixel coordinate from the focusing score sequence, take the index corresponding to the maximum value in each target pixel focus degree set as the target index of the target pixel coordinate, and construct a target matrix based on the target index;
[0038] The construction module is used to construct a blank image based on the size of the initial image, and select the corresponding target image from the image sequence according to the target index of each target pixel coordinate and the target matrix;
[0039] The fusion module is used to obtain the target pixel corresponding to the target pixel coordinate from the target image, fill the target pixel into the target pixel coordinate of the blank image, and obtain the fused image.
[0040] Thirdly, this application provides an electronic device including a memory and at least one processor, the memory storing a computer program, and the processor executing the computer program to implement the image fusion method as described in the first aspect.
[0041] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when executed, implements the image fusion method as described in the first aspect.
[0042] The embodiments of the present invention have the following beneficial effects:
[0043] The image fusion method provided by this invention uses grayscale variance to calculate the focus of each pixel in a sequence of images to obtain a focus sequence score. Based on this, the grayscale variance method is improved, which increases the running speed while ensuring the fusion effect, thereby combining multiple focused images into a single fully focused image with better fusion results.
[0044] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0045] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0046] Figure 1 A schematic diagram of an image fusion method is shown;
[0047] Figure 2A schematic diagram of a method for acquiring grayscale image sequences is shown.
[0048] Figure 3 A schematic diagram of a target matrix construction method is shown;
[0049] Figure 4 A schematic diagram of an initial image for image fusion is shown;
[0050] Figure 5 This illustrates another example of an initial image for image fusion.
[0051] Figure 6 This illustrates another example of an initial image for image fusion.
[0052] Figure 7 A schematic diagram of an image fusion result is shown;
[0053] Figure 8 A schematic diagram of the frame structure of an image fusion device is shown.
[0054] Explanation of key component symbols:
[0055] 800. Image fusion device; 801. Acquisition module; 802. Processing module; 803. Calculation module; 804. Focusing module; 805. Construction module; 806. Fusion module. Detailed Implementation
[0056] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0057] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0058] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein in the template description is for the purpose of describing particular embodiments only and is not intended to limit the invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0059] Example 1
[0060] See Figure 1 , Figure 1 This is a schematic diagram of an image fusion method provided in this embodiment. This method can be used to fuse images of the same scene or target at different focal lengths. The method includes:
[0061] S101. Obtain an image sequence, the image sequence including multiple initial images with different focal lengths.
[0062] Specifically, if a clear image of a scene or target is required, capturing images with only one device or a fixed focal length may not yield sufficient accuracy. Therefore, different devices, or different focal lengths of the same device, can be used to capture multiple images, resulting in an image sequence z(I1,I2,I3,...,I...). k );
[0063] Where k = 1, 2, 3, ..., m; I k Each image is a single image of the same size, and m represents the number of images with different focal lengths.
[0064] This embodiment provides an image foundation for subsequent image fusion by capturing images of the same target at different focal lengths, thereby ensuring that the fused image meets the requirements.
[0065] S102. Perform grayscale processing on each of the initial images in the image sequence to obtain a grayscale image sequence.
[0066] See Figure 2 Step S102 includes:
[0067] S1021. Using the weighted average method, each image in the image sequence is converted to grayscale to obtain a grayscale image.
[0068] The formula for the weighted average method is as follows:
[0069] Grayscale value = 0.299 × R + 0.587 × G + 0.114 × B
[0070] RGB represents the colors of the red, green, and blue channels, respectively.
[0071] S1022. Save the grayscale image in the image sequence g(Ig1,Ig2,Ig3,...,Ig...). k The grayscale image sequence is obtained in the process.
[0072] Among them Ig n For grayscale images, n = 1, 2, k.
[0073] The weighted average method is used to convert the captured color image into a grayscale image. Since the weighted average method emphasizes the contribution of each component in the color image and provides richer difference results, more details can be preserved.
[0074] S103. Calculate the focus degree of each pixel in the grayscale image sequence by improving the grayscale variance, and obtain a focus score sequence containing the focus degree of each pixel; the focus score sequence includes the pixel coordinates of the focus degree of each pixel.
[0075] Specifically, the improved grayscale variance is:
[0076]
[0077] Where pixelz(i,j) is the focus of the pixel at position (i,j) of the k-th image, the sliding window size is 2n, f(i,j) represents the pixel of the grayscale image at (i,j), and x and y are variables with values ranging from (-n / 3 to n / 3).
[0078] The improved formula reduces the number of summations, optimizing the algorithm's running speed. Furthermore, the addition of f(3x+i,3y+j)-f(3x+i+3,3y+j+3) to the formula allows it to obtain more grayscale difference information from the surrounding area, ensuring the multi-focus image fusion effect while improving the algorithm's processing speed.
[0079] Then, the focus of a single pixel calculated according to the above formula is stored in p(i,j) according to the corresponding position.
[0080] For example, if the focus of the first coordinate (1,1) of the first grayscale image is L, then the calculated L is stored in p(1,1), and so on, to obtain the focus of all pixels of the first grayscale image.
[0081] Then, the focus level of each pixel in the grayscale image is stored in the focus score sequence s(p1, p2, p3, ..., p...). k )middle.
[0082] Specifically, the target pixel coordinates of an image correspond to a focus score. Since there are multiple captured images, each with its own target pixel coordinates, a score sequence can be obtained.
[0083] For example, for coordinate (1,1) in an image, since there are multiple images, each containing coordinate (1,1), the pixel focus of all images corresponding to coordinate (1,1) can be taken as a sequence, namely the focus score sequence.
[0084] S104. Obtain the target pixel focus set contained in each target pixel coordinate from the focus score sequence, take the index corresponding to the maximum value in each target pixel focus set as the target index of the target pixel coordinate, and construct a target matrix based on the target index.
[0085] See Figure 3 Step S104 includes:
[0086] S1041. Based on the target pixel coordinates, obtain the maximum value in the target pixel focus set in the focus score sequence.
[0087] Specifically, a target pixel coordinate (i,j) corresponds to a focus score sequence s(p1,p2,p3,...,p k Since the focus scores in each focus score sequence may be different, we can select the largest one from each focus score sequence, which is the maximum value in the target pixel focus set s(k)(i,j).
[0088] S1042. Save the index of the maximum value of the pixel focus set according to the target pixel coordinates, and save the index in the target coordinates of the matrix to obtain the target matrix, wherein the target coordinates are the same as the target pixel coordinates.
[0089] After obtaining the maximum value from the focused score sequence, the index k of the maximum value in the focused score sequence is determined.
[0090] For example, if the maximum value of the target pixel coordinate (1,1) in the focus score sequence is A, and A is the fifth position in the focus score sequence, then the fifth position is retained in the (1,1) position of the matrix, and so on, to obtain the target matrix.
[0091] S105. Construct a blank image based on the size of the initial image, and select the corresponding target image from the image sequence according to the target index of each target pixel coordinate and the target matrix.
[0092] Construct a blank image of the same size as the initial image, and obtain the target index from the (i,j) position of the target matrix; select the target image corresponding to the target index from the image sequence.
[0093] Specifically, after constructing a blank image, the corresponding pixels need to be filled in each coordinate of the blank image, and the pixels corresponding to different coordinates are different.
[0094] First, the coordinates of the blank image need to be determined. For example, if the coordinates of the blank image are (1,1), and if pixels need to be filled, the target number needs to be obtained from the (1,1) position of the target matrix based on the coordinates (1,1), which is the number five in step S104. Then, the target image is selected from the image sequence based on the number five, which is the fifth image in the image sequence.
[0095] S106. Obtain the target pixel corresponding to the target pixel coordinate from the target image, and fill the target pixel into the target pixel coordinate of the blank image to obtain the fused image.
[0096] From the fifth image, select the pixel at coordinate (1,1) and fill it into the blank image at position (1,1) until all pixels of the blank image are filled, thus obtaining the fused image.
[0097] See Figures 4-6 , Figures 4-6 This is a schematic diagram of the initial image for image fusion provided in this embodiment.
[0098] in, Figure 4 , 5 Images 6 and 7 are initial images with different focal lengths. Figure 7 According to Figure 4 , 5 Image of the fused result after fusion of 6.
[0099] As can be seen, the image fusion method of this application can synthesize multiple focused images into a single all-focused image, resulting in a better fusion effect.
[0100] Example 2
[0101] See Figure 8 This application also provides a schematic diagram of the frame structure of an image fusion device 800, including:
[0102] The acquisition module 801 is used to acquire an image sequence, the image sequence including multiple initial images with different focal lengths;
[0103] Processing module 802 is used to perform grayscale processing on each of the initial images in the image sequence to obtain a grayscale image sequence;
[0104] The calculation module 803 is used to calculate the focus degree of each pixel of each grayscale image in the grayscale image sequence by improving the grayscale variance, and to obtain a focus score sequence containing the focus degree of each pixel; the focus score sequence includes the pixel coordinates of the focus degree of each pixel.
[0105] The focusing module 804 is used to obtain the target pixel focus set contained in each target pixel coordinate from the focusing score sequence, take the index corresponding to the maximum value in each target pixel focus set as the target index of the target pixel coordinate, and construct a target matrix based on the target index;
[0106] Construction module 805 is used to construct a blank image according to the size of the initial image, and select the corresponding target image from the image sequence according to the target index of each target pixel coordinate and the target matrix;
[0107] The fusion module 806 is used to obtain the target pixel corresponding to the target pixel coordinate from the target image, fill the target pixel into the target pixel coordinate of the blank image, and obtain the fused image.
[0108] It is understood that the implementation method of the image fusion method described in Embodiment 1 above is also applicable to this embodiment, so it will not be described again here.
[0109] Example 3
[0110] This application also provides a computer device, which may be, but is not limited to, a desktop computer, a laptop, etc. Its form is not limited, mainly depending on whether it needs to support the interface display function of a web browser. Exemplarily, the computer device includes a memory and at least one processor. The memory stores a computer program, and the processor executes the computer program to implement the image fusion method described in Embodiment 1 above.
[0111] The processor can be an integrated circuit chip with signal processing capabilities. The processor can be a general-purpose processor, including at least one of a Central Processing Unit (CPU), Graphics Processing Unit (GPU), Network Processor (NP), Digital Signal Processor (DSP), Application-Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The general-purpose processor can be a microprocessor or any conventional processor, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application.
[0112] The memory can be, but is not limited to, Random Access Memory (RAM), Read Only Memory (ROM), Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), and Electrically Erasable Programmable Read-Only Memory (EEPROM). The memory stores computer programs, and the processor, upon receiving execution instructions, can execute the computer programs accordingly.
[0113] Furthermore, the memory may include a stored program area and a stored data area, wherein the stored program area may store the operating system and application programs required for at least one function; the stored data area may store data created based on the use of the computer device (such as iterative data, version data, etc.). In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0114] Example 4
[0115] This application also provides a computer-readable storage medium storing computer-executable instructions. When the computer-executable instructions are invoked and executed by a processor, the computer-executable instructions cause the processor to execute the image fusion method described in Embodiment 1 above.
[0116] It is understood that the implementation method of the image fusion method described in Embodiment 1 above is also applicable to this embodiment, so it will not be described again here.
[0117] The computer-readable storage medium can be either a non-volatile storage medium or a volatile storage medium. For example, the computer-readable storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0118] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that, in alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0119] In addition, the functional modules or units in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0120] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a smartphone, personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0121] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
[0122] In all examples shown and described herein, any specific values should be interpreted as merely exemplary and not as limitations; therefore, other examples of exemplary embodiments may have different values.
[0123] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0124] The above-described embodiments are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention.
Claims
1. An image fusion method, characterized in that, include: Acquire an image sequence, the image sequence comprising multiple initial images with different focal lengths; Each of the initial images in the image sequence is converted to grayscale to obtain a grayscale image sequence; By improving the grayscale variance, the focus degree of each pixel in each grayscale image in the grayscale image sequence is calculated to obtain a focus score sequence containing the focus degree of each pixel; the focus score sequence includes the pixel coordinates of each pixel focus degree. From the focus score sequence, obtain the target pixel focus set contained in each target pixel coordinate, take the index corresponding to the maximum value in each target pixel focus set as the target index of the target pixel coordinate, and construct a target matrix based on the target index; A blank image is constructed based on the size of the initial image, and a corresponding target image is selected from the image sequence according to the target index of each target pixel coordinate and the target matrix; Obtain the target pixel corresponding to the target pixel coordinates from the target image, and fill the target pixel coordinates of the blank image with the target pixel to obtain the fused image; The acquisition of the image sequence, which includes multiple images with different focal lengths, includes: Acquire image sequences ; in, ; Each image is a single image, and all images are the same size. Number of images at different focal lengths; The step of converting each image in the image sequence to grayscale to obtain a grayscale image sequence includes: The weighted average method is used to convert each image in the image sequence to grayscale to obtain a grayscale image. The formula for the weighted average method is: Grayscale value = 0.299 × R + 0.587 × G + 0.114 × B RGB represents the colors of the red, green, and blue channels, respectively. The grayscale image is saved in the image sequence. In the process, the grayscale image sequence is obtained, wherein To convert the image to grayscale, n =1,2, k ; The step of calculating the focus of each pixel in each grayscale image of the grayscale image sequence by improving the grayscale variance includes: The improved grayscale variance is: in, For the first The image is in The focus of the position pixel, the sliding window size is , Indicates grayscale image in pixels, and The variable has a range of values. .
2. The image fusion method according to claim 1, characterized in that, Obtaining the focus score sequence containing the focus of each pixel includes: Based on the calculated focus of each individual pixel, it is stored at its corresponding position. middle; The focus score of each pixel in the grayscale image is stored in a focus score sequence. middle.
3. The image fusion method according to claim 1, characterized in that, The step of obtaining the target pixel focus set contained in each target pixel coordinate from the focus score sequence, taking the index corresponding to the maximum value in each target pixel focus set as the target index of the target pixel coordinate, and constructing a target matrix based on the target index includes: Based on the target pixel coordinates, obtain the maximum value in the target pixel focus set within the focus score sequence; The index of the maximum value of the pixel focus set is saved according to the target pixel coordinates, and the index is saved in the target coordinates of the matrix to obtain the target matrix, wherein the target coordinates are the same as the target pixel coordinates.
4. The image fusion method according to claim 3, characterized in that, The step of constructing a blank image based on the size of the initial image, and selecting the corresponding target image from the image sequence according to the target index of each target pixel coordinate and the target matrix, includes: Construct a blank image of the same size as the initial image, from the target matrix. The target sequence number is obtained from the location; Select the target image corresponding to the target number from the image sequence.
5. An image fusion apparatus, characterized in that, For implementing the image fusion method as described in claim 1, the image fusion apparatus includes: An acquisition module is used to acquire an image sequence, the image sequence including multiple initial images with different focal lengths; The processing module is used to perform grayscale processing on each of the initial images in the image sequence to obtain a grayscale image sequence; The calculation module is used to calculate the focus degree of each pixel of each grayscale image in the grayscale image sequence by improving the grayscale variance, and obtain a focus score sequence containing the focus degree of each pixel; the focus score sequence includes the pixel coordinates of the focus degree of each pixel. The focusing module is used to obtain the set of target pixel focus degrees contained in each target pixel coordinate from the focusing score sequence, take the index corresponding to the maximum value in each target pixel focus degree set as the target index of the target pixel coordinate, and construct a target matrix based on the target index; The construction module is used to construct a blank image based on the size of the initial image, and select the corresponding target image from the image sequence according to the target index of each target pixel coordinate and the target matrix; The fusion module is used to obtain the target pixel corresponding to the target pixel coordinate from the target image, fill the target pixel into the target pixel coordinate of the blank image, and obtain the fused image.
6. An electronic device, characterized in that, It includes a memory and at least one processor, the memory storing a computer program, and the processor executing the computer program to implement the image fusion method as described in any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed, implements the image fusion method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Adaptive focus detection multi-focus image fusion method based on WIML comparison graph
CN110738628A
Relief image generation method, system and device and storage medium
CN117557723A