Image processing method and device
By obtaining one-to-one correspondence between the pixels of the two frames of the image to be fused in the electronic device, and using the weight mapping matrix of the preset dimension and the guided filtering operation, the problem of large calculation and long time consumption of the HDR fusion algorithm is solved, and a faster response is achieved. speed and higher image quality.
Patent Information
- Application Number
- CN202011225826.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-05
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2040-11-05
AI Technical Summary
Existing HDR fusion algorithms are computationally intensive and time-consuming in electronic devices, affecting user experience.
By obtaining one-to-one correspondence between the pixels of two frames of images to be fused, the fusion weight value is obtained based on the weight mapping matrix of preset dimensions, a fusion mask matrix is established, and a guided filtering operation is performed to achieve image fusion and reduce the amount of calculation and time-consuming.
It improves the response speed of the HDR fusion process, reduces the dependence on hardware, is suitable for low-performance platforms, and improves the dynamic range and layering of images.
Smart Images

Figure CN112634183B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image processing, and in particular relates to an image processing method and device. Background Art
[0002] As the functions of electronic devices continue to improve, users have an increasing demand for the shooting functions of electronic devices. High-Dynamic Range (HDR), as a function of the camera of an electronic device, shoots multiple images with different exposures in the same scene and finally synthesizes the multiple images, thereby enhancing the dynamic range of the final photo and increasing the layering of the photo.
[0003] At present, the HDR fusion algorithm commonly used in electronic devices mainly obtains multiple images with different exposures, and fuses them through Poisson fusion, exposure fusion and other methods to obtain a high dynamic range image. The obtained high dynamic range image has better details in overexposure and dark areas than a single image taken.
[0004] However, the current HDR fusion algorithm will generate large amount of calculation and consume a lot of time during application. Summary of the invention
[0005] The present invention provides an image processing method and device to solve the problem that the HDR fusion algorithm in the prior art generates a large amount of calculation and consumes a lot of time during application.
[0006] In order to solve the above-mentioned technical problems, the present invention is achieved as follows:
[0007] In a first aspect, an embodiment of the present invention provides an image processing method, the image processing method comprising:
[0008] Acquire two frames of images to be fused, where the pixels in the two frames of images to be fused correspond to each other one by one;
[0009] Based on a weight mapping matrix of a preset dimension, obtaining fusion weight values of two pixel points in one-to-one correspondence in the two frames of the to-be-fused images, and establishing a fusion mask matrix according to the fusion weight values;
[0010] Performing a guided filtering operation on the fusion mask matrix to obtain a target fusion mask matrix;
[0011] According to the target fusion mask matrix, image fusion is performed on the two frames of the images to be fused to obtain a target image.
[0012] In a second aspect, an embodiment of the present invention provides an image processing device, the device comprising:
[0013] An acquisition module is used to acquire two frames of images to be fused, where the pixels in the two frames of images to be fused correspond to each other one by one;
[0014] An establishment module is used to obtain fusion weight values of two pixel points corresponding to each other in two frames of the to-be-fused images based on a weight mapping matrix of a preset dimension, and to establish a fusion mask matrix according to the fusion weight values;
[0015] A filtering module, used for performing a guided filtering operation on the fusion mask matrix to obtain a target fusion mask matrix;
[0016] The fusion module is used to perform image fusion on the two frames of the to-be-fused images according to the target fusion mask matrix to obtain a target image.
[0017] According to a third aspect of an embodiment of the present invention, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned image processing method are implemented.
[0018] According to a fourth aspect of an embodiment of the present invention, a device is provided, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the above-mentioned image processing method when executed by the processor.
[0019] In an embodiment of the present invention, the present invention includes: obtaining two frames of images to be fused, the pixels in the two frames of images to be fused correspond one to one; based on a weight mapping matrix of a preset dimension, obtaining the fusion weight values of two pixels in the two frames of images to be fused that correspond one to one, and establishing a fusion mask matrix according to the fusion weight values; performing a guided filtering operation on the fusion mask matrix to obtain a target fusion mask matrix; according to the target fusion mask matrix, performing image fusion on the two frames of images to be fused to obtain a target image. In the present invention, since the fusion weight value of the pixel point only needs to be queried according to the index in the weight mapping matrix, the amount of calculation is extremely small and the response speed is extremely fast. Compared with the methods such as Poisson fusion and exposure fusion in the prior art, it has a faster response speed, improves the fusion speed of the HDR fusion process, and reduces the dependence on hardware, and can be better adapted to low-performance platforms. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 is a schematic diagram of steps of an image processing method provided by an embodiment of the present invention;
[0021] Figure 2 is a schematic diagram of specific steps of an image processing method provided by an embodiment of the present invention;
[0022] Figure 3It is a schematic diagram showing a weight mapping matrix provided by an embodiment of the present invention;
[0023] Figure 4 is a structural block diagram of an image processing device provided by an embodiment of the present invention;
[0024] Figure 5 It is a block diagram of a device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0025] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0026] Figure 1 is a flowchart of the steps of an image processing method provided by an embodiment of the present invention, such as Figure 1 As shown, the method may include:
[0027] Step 101: obtain two frames of images to be fused, where the pixels in the two frames of images to be fused correspond to each other one by one.
[0028] Optionally, the two frames of images to be fused are: at least two original images of the same size generated by one shooting operation at different exposure times.
[0029] In an embodiment of the present invention, the HDR function of the camera includes the camera generating two original images of the same size at different exposure times through a single shooting operation in the same shooting scene, and using the best details in the original image corresponding to each exposure time to fuse the two original images, so that the dynamic range and layering of the final image after fusion are higher, and the details of the bright and dark areas are highly expressed, so that the shooting effect is higher. Therefore, in one implementation, the two frames of images to be fused obtained by the embodiment of the present invention can be: at least two original images of the same size generated by a single shooting operation at different exposure times, wherein the two original images have the same size and the pixels of the two original images correspond one to one.
[0030] The image to be fused can be an image in the YUV (brightness channel, chroma channel, saturation channel) domain. Images in the YUV domain often run on devices with relatively general hardware performance. If HDR fusion algorithms with higher hardware resources are applied on these devices, such as Poisson fusion, exposure fusion, etc., it will take a long time and affect the user experience. The image fusion method of the embodiment of the present invention requires fewer hardware resources, takes less time, and improves the fusion performance.
[0031] It should be noted that, in other implementations, the two frames of images to be fused obtained by the embodiments of the present invention may also be two fused images, and the fused image may be an image obtained by fusing two original images of the same size. In addition, the two frames of images to be fused may also be two new fused images, and the new fused image may be an image obtained by fusing two fused images of the same size.
[0032] Step 102: based on a weight mapping matrix of a preset dimension, obtain fusion weight values of two pixel points in one-to-one correspondence in the two frames of the to-be-fused images, and establish a fusion mask matrix according to the fusion weight values.
[0033] In the embodiment of the present invention, since the two images to be fused have the same size and the pixels correspond one to one, in the fusion process of the two images to be fused, the pixels corresponding one to one in the two images to be fused need to be fused according to the fusion weight value to obtain the target image, that is, for the first pixel in one image to be fused, there is a second pixel corresponding to the first pixel in the other image to be fused, and the first pixel and the second pixel are fused according to the fusion weight value to obtain the pixel corresponding to the first pixel and the second pixel in the target image. Among them, the pixel values of the pixels corresponding one to one in the two frames of images to be fused can construct a pixel value group, and a fusion weight value is determined for the pixel value group, so that the fusion between the pixels corresponding one to one can be achieved.
[0034] For example, one of the two images to be fused is a bright frame image and the other is a dark frame image. The average pixel value of the bright frame image is greater than the average pixel value of the dark frame image. The pixel value of a pixel in the bright frame image is 100, and the pixel value of the pixel corresponding to the pixel in the dark frame image is 50, then the pixel value group is (100, 50).
[0035] Obtaining the fusion weight value of each pixel of the image to be fused may refer to obtaining the fusion weight value of each pixel of one of the two images to be fused. In this case, the fusion weight value of all pixels refers to the fusion weight value of all pixels in one image to be fused.
[0036] Since the sum of the fusion weights of two corresponding pixels in the two images to be fused is 1, the fusion weight value of the pixel of one of the two images to be fused is obtained, and the fusion weight value of the corresponding pixel of the other image to be fused is also obtained.
[0037] Specifically, when fusing two images to be fused, the pixel value of a pixel in the bright frame image is 100, and the pixel value of the pixel corresponding to the pixel in the dark frame image is 50, then the pixel value group is (100, 50), and the corresponding fusion weight value needs to be set for the pixel value group (100, 50), and the sum of the weight corresponding to the pixel with a pixel value of 100 and the weight corresponding to the pixel with a pixel value of 50 is 1. The logic of the HDR algorithm is to ensure that there will be no overly bright or overly dark areas in the final fused image. Therefore, when the pixel value of the pixel with a pixel value of 100 is too large, the weight of the pixel with a pixel value of 100 is reduced when it is fused, and when the pixel value of the pixel with a pixel value of 50 is too small, the weight of the pixel with a pixel value of 50 is reduced when it is fused (it can also be understood as increasing the weight corresponding to the pixel with a pixel value of 100).
[0038] Based on the above ideas, the embodiment of the present invention can establish a weight mapping matrix of preset dimensions in advance, and the weight mapping matrix can realize the allocation of weights for two one-to-one corresponding pixel points corresponding to the pixel value group according to the size difference of the pixel values in the pixel value group. Specifically, the embodiment of the present invention can assign a fusion weight value to the pixel value group, and the fusion weight value can be the weight value corresponding to the pixel points from the bright frame in the pixel value group, and the weight value corresponding to the pixel points from the dark frame in the pixel value group is 1-fusion weight value. Of course, the fusion weight value can also be the weight value corresponding to the pixel points from the dark frame in the pixel value group, and the embodiment of the present invention is not limited to this.
[0039] Each element in the weight mapping matrix is a fusion weight value, and the index of each element can be composed of two pixel values, that is, the weight mapping matrix reflects the mapping relationship between each pixel value group and its corresponding fusion weight value.
[0040] For example, for a pixel value group of a bright frame image to be fused and a dark frame image to be fused (the pixel value of the pixel from the dark frame is 50, and the pixel value of the pixel from the bright frame is 100), the fusion weight value represented by the element at the index (50,100) of the weight mapping matrix is 0.6 (assuming that the fusion weight value is the weight value corresponding to the pixel from the bright frame in the pixel value group). When the bright and dark frame images are fused, the weight value corresponding to the pixel from the bright frame in the pixel value group is 0.6, and the weight value corresponding to the pixel from the dark frame in the pixel value group is 0.4.
[0041] Since the pixel value range is 0-255, the dimension of the weight mapping matrix can be 256×256, so the weight mapping matrix covers 256×256 pixel value groups, covering all pixel value groups that can be generated by the pixel point. After each element of the weight mapping matrix is assigned a value, all pixel value groups can be mapped to the corresponding fusion weight value in the weight mapping matrix. It should be noted that the dimension of the weight mapping matrix can also be set according to actual needs, but it cannot be greater than 256×256.
[0042] After obtaining the fusion weight value of each pixel of the image to be fused, a fusion mask matrix can be established based on the fusion weight values of all pixels. The dimension of the fusion mask matrix is the same as the dimension of the image to be fused, that is, assuming that the image to be fused is 100×100 in dimension, the fusion mask matrix is also 100×100 in dimension.
[0043] The fusion mask matrix covers all the fusion weight values required for the fusion of two frames of images to be fused. The fusion mask matrix can be regarded as a fusion weight map. When the two frames of images to be fused are subsequently fused, the fusion mask matrix can be called to determine the fusion weight values of the pixels and complete the image fusion.
[0044] Optionally, step 102 may also be implemented by establishing the weight mapping matrix of a preset dimension according to a preset mapping rule.
[0045] In an embodiment of the present invention, since the fusion weight value of each pixel point only needs to be queried according to the index in the weight mapping matrix of 256×256 dimension, the preset dimension is preferably 256×256, which makes the calculation amount extremely small and the response speed extremely fast. Compared with the Poisson fusion and exposure fusion methods in the prior art, it has a faster response speed and improves the fusion speed of the HDR fusion process.
[0046] Step 103: Perform a guided filtering operation on the fusion mask matrix to obtain a target fusion mask matrix.
[0047] In an embodiment of the present invention, the directly generated fusion mask matrix can be regarded as a fusion weight map. When it is first generated, there are many mid-high frequency changes inside it. Directly using the fusion mask matrix for image fusion will result in poor image details of the final fused image due to the large number of mid-high frequency changes. In an embodiment of the present invention, a guided filtering operation is performed on the fusion mask matrix. The purpose is to remove the high-mid frequency information in the fusion mask matrix so that the fused image is smoother and the image quality is improved. However, the guided filtering operation will also retain the edge information of the fusion mask matrix. This is to avoid defects such as the Buddha light effect caused by the object feature edges in the fused image being too smooth (the object feature edges are too smooth to produce an effect similar to the Buddha light).
[0048] Step 104: perform image fusion on the two frames of the images to be fused according to the target fusion mask matrix to obtain a target image.
[0049] In an embodiment of the present invention, the target fusion mask matrix includes the fusion weight values of all two pixel points that correspond one to one in the two frames of images to be fused. The target fusion mask matrix can be used to perform image fusion on the two frames of images to be fused according to the fusion weight value of each pixel point to obtain a target image. The target image has a smoother display effect and retains the clear feature edges of object features. In addition, after HDR fusion, the target image has a higher dynamic range and layering, and the details of bright and dark areas are highly expressed.
[0050] For example, one of the two images to be fused is a bright frame image and the other is a dark frame image. The pixel value of a pixel in the bright frame image is 100, and the pixel value of the corresponding pixel in the dark frame image is 50. Then the pixel value group is (100, 50). The corresponding element of the pixel from the bright and dark frames in the target fusion mask matrix is 0.6, that is, the fusion weight value corresponding to the pixel value group is 0.6.
[0051] When image fusion is performed, the pixel value of the corresponding pixel point in the target image = 100 × 0.6 + 50 × (1-0.6) = 80. The same operation is performed on all pixel points of the target image to obtain the pixel values of all pixel points in the target image.
[0052] In summary, an image processing method provided by an embodiment of the present invention includes: obtaining two frames of images to be fused, the pixels in the two frames of images to be fused correspond one to one; based on a weight mapping matrix of a preset dimension, obtaining the fusion weight values of two pixels in the two frames of images to be fused that correspond one to one, and establishing a fusion mask matrix according to the fusion weight values; performing a guided filtering operation on the fusion mask matrix to obtain a target fusion mask matrix; according to the target fusion mask matrix, performing image fusion on the two frames of images to be fused to obtain a target image. In the present invention, since the fusion weight value of the pixel point only needs to be queried according to the index in the weight mapping matrix, the amount of calculation is extremely small and the response speed is extremely fast. Compared with the methods such as Poisson fusion and exposure fusion in the prior art, it has a faster response speed, improves the fusion speed of the HDR fusion process, and reduces the dependence on hardware, and can be better adapted to low-performance platforms.
[0053] Figure 2 is a flowchart of specific steps of an image processing method provided by an embodiment of the present invention, such as Figure 2 As shown, the method may include:
[0054] Step 201: obtain two frames of images to be fused, where the pixels in the two frames of images to be fused correspond to each other one by one.
[0055] This step may specifically refer to the above step 101, which will not be described in detail here.
[0056] Optionally, the two frames of images to be fused are: any two fused images among all fused images obtained by fusion of any two original images among n original images of the same size generated by one shooting operation with different exposure times;
[0057] Alternatively, the two frames of images to be fused are any two new fused images among all new fused images obtained by fusion of any two of the fused images.
[0058] In other implementations, the two frames of images to be fused obtained by the embodiment of the present invention may also be two fused images, and the fused image may be an image obtained by fusing two original images of the same size. In addition, the two frames of images to be fused may also be two new fused images, and the new fused image may be an image obtained by fusing two fused images of the same size.
[0059] Step 202: According to the pixel values of the pixels in the to-be-fused images, a pixel value group including the pixel values of the two pixel points in one-to-one correspondence is established.
[0060] In the embodiment of the present invention, since the two images to be fused have the same size and the pixels correspond one to one, the two corresponding pixels can have corresponding pixel values in the two images to be fused respectively. Therefore, a pixel value group containing two pixel values can be established based on the two corresponding pixels.
[0061] For example, one of the two images to be fused is a bright frame image and the other is a dark frame image. The pixel value of a pixel in the bright frame image is 100, and the pixel value of the pixel corresponding to the pixel in the dark frame image is 50, then the pixel value group is (100, 50).
[0062] Step 203, using the pixel value group as a query index, using the value of the element queried in the weight mapping matrix of a preset dimension as the fusion weight value of the pixel point corresponding to the pixel value group, and establishing the fusion mask matrix according to the fusion weight value.
[0063] Each element in the weight mapping matrix is a fusion weight value, and the index of each element can be composed of two pixel values, that is, the weight mapping matrix reflects the mapping relationship between each pixel value group and the corresponding fusion weight value.
[0064] Therefore, by using the pixel values included in the pixel value group as the query index, the value of the element queried from the remapping matrix can be used as the fusion weight value of the pixel point corresponding to the pixel value group.
[0065] Optionally, step 203 may be implemented by establishing the weight mapping matrix of a preset dimension according to a preset mapping rule.
[0066] Optionally, step 203 may include:
[0067] Sub-step 2031: establishing the weight mapping matrix of a preset dimension based on the following formula 1;
[0068] Formula 1:
[0069] Where, aij=Max(0,255-(255-i)×decay); b0,Min(255,(im)×n))
[0070] W is the value of each element in the weight mapping matrix, i is the number of rows of the element, j is the number of columns of the element, the dimension of the weight mapping matrix is h×w=256×256, Max is the maximum value operation, Min is the minimum value operation, the weight decay factor decay is a positive real number, m and n are constants, preferably, m=40, n=3.
[0071] In the embodiment of the present invention, i is the number of rows of the element, and its value range is 0-255, j is the number of columns of the element, and its value range is 0-255. When the weight value of the pixel point from the bright frame is used as the fusion weight value, a ij and b ij The physical meaning of the formula idea is linear. When the average pixel value of the pixel point is in the bright frame pixel value range representing the bright frame, a smaller fusion weight value is set for the pixel point, and when the average pixel value of the pixel point is in the dark frame pixel value range representing the dark frame, a larger fusion weight value is set for the pixel point. In this way, a weight mapping matrix with a slow transition from light to dark can be obtained.
[0072] It should be noted that the value of the weight decay factor decay is a positive real number. Preferably, the value of the weight decay factor decay is 2.
[0073] The weight mapping matrix is converted into a weight graph for display, and the following can be obtained: Figure 3 The schematic diagram shown, Figure 3A weight mapping matrix display schematic diagram provided by an embodiment of the present invention is shown, wherein the upper left corner of the weight map 10 after the weight mapping matrix conversion is the coordinate origin (0,0), the horizontal axis is used to represent the bright frame pixel value, and the vertical axis is used to represent the dark frame pixel value, which reflects the idea that the brighter the bright frame, the less likely it is to take a too large fusion weight value. In practical applications, the pixel value of the bright frame that is smaller than the pixel value of the dark frame will not be used, so only the upper right triangle area 11 is specifically used.
[0074] Optionally, the two frames of images to be fused include a first image to be fused and a second image to be fused, and an average pixel value of the first image to be fused is greater than an average pixel value of the second image to be fused; step 203 may further include:
[0075] Sub-step 2032: In the pixel value group, the pixel value of the second pixel point in the second image to be fused is determined as the query row of the query index, and the pixel value of the first pixel point corresponding to the second pixel point in the first image to be fused is determined as the query column of the query index.
[0076] Sub-step 2033: According to the query index, query the value of the corresponding element in the weight mapping matrix, and use the value of the queried element as the fusion weight value of the pixel point corresponding to the pixel value group.
[0077] In the embodiment of the present invention, since the average pixel value of the first image to be fused is greater than the average pixel value of the second image to be fused, the first image to be fused may be used as a bright frame image, and the second image to be fused may be used as a dark frame image.
[0078] Furthermore, based on the weight mapping matrix established in the above sub-step 2031, the row of the index of each element in the weight mapping matrix corresponds to the pixel value of the pixel point from the dark frame in the pixel value group, and the column corresponds to the pixel value of the pixel point from the bright frame in the pixel value group. Therefore, the embodiment of the present invention can determine the pixel value of the second pixel point in the second image to be fused as the query row of the query index, and determine the pixel value of the first pixel point corresponding to the second pixel point in the first image to be fused as the query column of the query index, and based on the query index, query the value of the corresponding element in the weight mapping matrix, and use the value of the queried element as the fusion weight value of the pixel point corresponding to the pixel value group.
[0079] For example, for the bright frame image to be fused and the dark frame image to be fused, the pixel value group composed of the pixel values of two corresponding pixels (the pixel value of the pixel from the dark frame is 50, and the pixel value of the pixel from the bright frame is 100). Under the idea of the HDR fusion algorithm, in order to achieve higher image quality, so that there will be no overly bright or overly dark areas in the final fused image, the fusion weight value represented by the element of the weight mapping matrix at the index (50, 100) position can be 0.6. In one implementation method, when the bright and dark frames are fused, the weight value of the pixel from the bright frame in the pixel value group is 0.6, and the weight value of the pixel from the dark frame in the pixel value group is 0.4.
[0080] Step 204: Perform a guided filtering operation on the fused mask matrix using a guided matrix having preset texture features to obtain the target fused mask matrix.
[0081] The detail of the edge feature of the target fusion mask matrix is greater than or equal to a preset detail threshold, and the similarity between the texture feature of the target fusion mask matrix and the preset texture feature is greater than a preset similarity threshold.
[0082] In an embodiment of the present invention, one implementation of the guided filtering operation may be to perform a guided filtering operation on the fused mask matrix by setting a guided matrix having a preset texture feature, wherein the preset texture feature may be a texture feature that exhibits a smoother effect.
[0083] The guide matrix allows the filter used to perform the guided filtering operation to know the degree of change in the texture features of the fused mask matrix, and at the same time calculate what position in the fused mask matrix is the edge, and retain the details of the edge position, so that the final output target fused mask matrix is similar to the fused mask matrix in terms of overall and edge position, but the texture part is similar to the guide matrix. This can remove the high-mid frequency information in the fused mask matrix, making the fused image smoother and improving the image quality, but the guided filtering operation will also retain the edge information of the fused mask matrix, in order to avoid defects such as the Buddha light effect caused by the edges of the object features in the fused image being too smooth.
[0084] Step 205: perform image fusion on the two frames of the to-be-fused images according to the target fusion mask matrix to obtain a target image.
[0085] This step may specifically refer to the above step 104, which will not be described in detail here.
[0086] Optionally, the value of each element of the fusion mask matrix is a fusion weight value of a pixel point corresponding to the element; step 205 may specifically include:
[0087] Sub-step 2051: performing image fusion on the first image to be fused and the second image to be fused according to the target fusion mask matrix and formula 2 to obtain the target image.
[0088] Formula 2: B = ev0 × M + evl × (1-M).
[0089] Among them, B is the value of the pixel point of the target image, ev0 is the pixel value of the first pixel point of the first image to be fused, ev1 is the pixel value of the second pixel point corresponding to the first pixel point in the second image to be fused, and M is the element value of the element corresponding to the pixel point in the target fusion mask matrix; the target fusion mask matrix corresponds one to one to the elements in the fusion mask matrix; the two frames of images to be fused include the first image to be fused and the second image to be fused, and the average pixel value of the first image to be fused is greater than the average pixel value of the second image to be fused.
[0090] For example, the first image to be fused is a bright frame image, the second image to be fused is a dark frame image, the pixel value of a pixel in the bright frame image is 100, and the pixel value of the pixel corresponding to the pixel in the dark frame image is 50, then the pixel value group is (100, 50). The corresponding element of the pixel value group in the target fusion mask matrix is 0.6, that is, when fused, the weight of the pixel with a pixel value of 100 is 0.6, and the weight of the pixel with a pixel value of 50 is 0.4.
[0091] When image fusion is performed, based on the above formula 2, the pixel value of the corresponding pixel point in the target image is B=100×0.6+50×(1-0.6)=80. The same operation is performed on all the pixels of the target image to obtain the pixel values of all the pixels in the target image.
[0092] In summary, an image processing method provided by an embodiment of the present invention includes: obtaining two frames of images to be fused, the pixels in the two frames of images to be fused correspond to each other; based on a weight mapping matrix of a preset dimension, obtaining the fusion weight values of two pixels in the two frames of images to be fused that correspond to each other, and establishing a fusion mask matrix according to the fusion weight values; according to the target fusion mask matrix, performing image fusion on the two frames of images to be fused to obtain a target image. In the present invention, since the fusion weight values of the pixels only need to be queried according to the index in the weight mapping matrix, the amount of calculation is extremely small and the response speed is extremely fast. Compared with the Poisson fusion and exposure fusion methods in the prior art, it has a faster response speed, improves the fusion speed of the HDR fusion process, and reduces the dependence on hardware, and can be better adapted to low-performance platforms.
[0093] Figure 4 is a structural block diagram of an image processing device provided by an embodiment of the present invention, such as Figure 4 As shown, the device may include:
[0094] An acquisition module 301 is used to acquire two frames of images to be fused, where the pixels in the two frames of images to be fused correspond to each other one by one;
[0095] Establishing module 302, for obtaining fusion weight values of two pixel points corresponding to each other in two frames of the to-be-fused images based on a weight mapping matrix of a preset dimension, and establishing a fusion mask matrix according to the fusion weight values;
[0096] Optionally, establishing module 302 includes:
[0097] An acquisition submodule, used for establishing a pixel value group including the pixel values of the two pixel points in one-to-one correspondence according to the pixel values of the pixel points in the image to be fused;
[0098] The query submodule is used to use the pixel value group as a query index and the value of the element queried in the weight mapping matrix of a preset dimension as the fusion weight value of the pixel point corresponding to the pixel value group.
[0099] Optionally, the two frames of images to be fused include a first image to be fused and a second image to be fused, and an average pixel value of the first image to be fused is greater than an average pixel value of the second image to be fused; the query submodule includes:
[0100] an index establishing unit, configured to determine, in the pixel value group, a pixel value of a second pixel point in the second image to be fused as a query row of the query index, and determine a pixel value of a first pixel point in the first image to be fused corresponding to the second pixel point as a query column of the query index;
[0101] A mapping unit is used to query the value of the corresponding element in the weight mapping matrix according to the query index, and use the value of the queried element as the fusion weight value of the pixel point corresponding to the pixel value group.
[0102] A filtering module 303 is used to perform a guided filtering operation on the fusion mask matrix to obtain a target fusion mask matrix;
[0103] Optionally, the filtering module 303 includes:
[0104] A filtering submodule, configured to perform a guided filtering operation on the fusion mask matrix through a guided matrix having preset texture features to obtain the target fusion mask matrix;
[0105] The detail of the edge feature of the target fusion mask matrix is greater than or equal to a preset detail threshold, and the similarity between the texture feature of the target fusion mask matrix and the preset texture feature is greater than a preset similarity threshold.
[0106] The fusion module 304 is used to perform image fusion on the two frames of the to-be-fused images according to the target fusion mask matrix to obtain a target image.
[0107] Optionally, the value of each element of the fusion mask matrix is a fusion weight value of a pixel point corresponding to the element; the fusion module 304 includes:
[0108] According to the target fusion mask matrix and Formula 2, the first image to be fused and the second image to be fused are fused to obtain the target image;
[0109] Formula 2: B = ev0 × M + evl × (1-M).
[0110] Wherein, B is the value of the pixel of the target image, ev0 is the pixel value of the first pixel of the first image to be fused, ev1 is the pixel value of the second pixel corresponding to the first pixel in the second image to be fused, and M is the element value of the element corresponding to the pixel in the target fusion mask matrix; the target fusion mask matrix corresponds to the elements in the fusion mask matrix one by one;
[0111] The two frames of images to be fused include a first image to be fused and a second image to be fused, and an average pixel value of the first image to be fused is greater than an average pixel value of the second image to be fused.
[0112] Optionally, the device further comprises:
[0113] The mapping matrix establishing module is used to establish the weight mapping matrix of a preset dimension according to a preset mapping rule.
[0114] Optionally, the mapping matrix establishing module includes:
[0115] A first establishing submodule is used to establish the weight mapping matrix of a preset dimension based on the following formula 1;
[0116] Formula 1:
[0117] Where aj = Max(0,255-(255-i)×decay); b,V0,Min(255,(im)×n))
[0118] W is the value of each element in the weight mapping matrix, i is the number of rows of the element, j is the number of columns of the element, the dimension of the weight mapping matrix is h×w=256×256, Max is the maximum value operation, Min is the minimum value operation, the value of the weight decay factor decay is a positive real number, and the values of m and n are preset constants.
[0119] Optionally, the two frames of images to be fused are: two original images of the same size generated by one shooting operation at different exposure times.
[0120] Optionally, the two frames of images to be fused are: any two fused images among all fused images obtained by fusion of any two original images among n original images of the same size generated by one shooting operation with different exposure times;
[0121] Alternatively, the two frames of images to be fused are any two new fused images among all new fused images obtained by fusion of any two of the fused images.
[0122] In summary, an image processing device provided by an embodiment of the present invention includes: obtaining two frames of images to be fused, where the pixels in the two frames of images to be fused correspond to each other; based on a weight mapping matrix of a preset dimension, obtaining the fusion weight values of two pixels in the two frames of images to be fused that correspond to each other, and establishing a fusion mask matrix according to the fusion weight values; performing a guided filtering operation on the fusion mask matrix to obtain a target fusion mask matrix; and performing image fusion on the two frames of images to be fused according to the target fusion mask matrix to obtain a target image. In the present invention, since the fusion weight value of the pixel point only needs to be queried according to the index in the weight mapping matrix, the amount of calculation is extremely small and the response speed is extremely fast. Compared with the methods such as Poisson fusion and exposure fusion in the prior art, it has a faster response speed, improves the fusion speed of the HDR fusion process, and reduces the dependence on hardware, and can be better adapted to low-performance platforms.
[0123] In addition, the embodiment of the present invention also provides a device, which can be specifically referred to Figure 5 The device 600 includes a processor 610, a memory 620, and a computer program stored in the memory 620 and executable on the processor 610. When the computer program is executed by the processor 610, each process of the image processing method of the above-mentioned embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0124] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, each process of the above-mentioned image processing method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0125] The embodiment of the present invention further provides a computer program, which can be stored in a cloud or local storage medium. When the computer program is run by a computer or a processor, it is used to perform the corresponding steps of the image processing method of the embodiment of the present invention, and is used to implement the corresponding modules in the image processing device according to the embodiment of the present invention.
[0126] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0127] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. An image processing method, characterized in that: The image processing method comprises: Acquire two frames of images to be fused, wherein the pixels in the two frames of images to be fused correspond to each other one by one; Based on a weight mapping matrix of a preset dimension, obtaining fusion weight values of two pixel points in one-to-one correspondence in the two frames of the to-be-fused images, and establishing a fusion mask matrix according to the fusion weight values; Performing a guided filtering operation on the fusion mask matrix to obtain a target fusion mask matrix; According to the target fusion mask matrix, performing image fusion on the two frames of the images to be fused to obtain a target image; Wherein, the weight mapping matrix of a preset dimension is established based on the following formula 1; Formula 1: Among them, a ij =Max(0,255-(255-i)×decay); b ij =Max(0,Min(255,(im)×n)); W is the value of each element in the weight mapping matrix, i is the number of rows of the element, j is the number of columns of the element, the dimension of the weight mapping matrix is h×w=256×256, Max is the maximum value operation, Min is the minimum value operation, the value of the weight decay factor decay is a positive real number, and the values of m and n are preset constants.
2. The method according to claim 1, characterized in that The weight mapping matrix based on the preset dimension is used to obtain the fusion weight values of two pixel points in one-to-one correspondence in the two frames of the to-be-fused images, including: According to the pixel values of the pixel points in the to-be-fused image, a pixel value group including the pixel values of the two pixel points in one-to-one correspondence is established; The pixel value group is used as a query index, and the value of the element queried in the weight mapping matrix of a preset dimension is used as the fusion weight value of the pixel point corresponding to the pixel value group.
3. The method according to claim 2, characterized in that The two frames of images to be fused include a first image to be fused and a second image to be fused, and an average pixel value of the first image to be fused is greater than an average pixel value of the second image to be fused; The method of using the pixel value group as a query index and using the value of an element queried in a weight mapping matrix of a preset dimension as a fusion weight value of a pixel point corresponding to the pixel value group includes: In the pixel value group, a pixel value of a second pixel point in the second image to be fused is determined as a query row of the query index, and a pixel value of a first pixel point corresponding to the second pixel point in the first image to be fused is determined as a query column of the query index; According to the query index, the value of the corresponding element is queried in the weight mapping matrix, and the value of the queried element is used as the fusion weight value of the pixel point corresponding to the pixel value group.
4. The method according to claim 3, characterized in that The step of establishing a fusion mask matrix according to the fusion weight value comprises: The value of each element of the fusion mask matrix is the fusion weight value of the pixel point corresponding to the element; The step of fusing the two frames of the to-be-fused images according to the target fusion mask matrix to obtain a target image includes: According to the target fusion mask matrix and Formula 2, the first image to be fused and the second image to be fused are fused to obtain the target image; Formula 2: B = ev0 × M + ev1 × (1-M); Wherein, B is the value of the pixel of the target image, ev0 is the pixel value of the first pixel of the first image to be fused, ev1 is the pixel value of the second pixel corresponding to the first pixel in the second image to be fused, and M is the element value of the element corresponding to the pixel in the target fusion mask matrix; the target fusion mask matrix corresponds to the elements in the fusion mask matrix one by one; The two frames of images to be fused include a first image to be fused and a second image to be fused, and an average pixel value of the first image to be fused is greater than an average pixel value of the second image to be fused.
5. The method according to any one of claims 1 to 4, characterized in that: The two frames of images to be fused are: two original images of the same size generated by one shooting operation at different exposure times.
6. The method according to any one of claims 1 to 4, characterized in that: The two frames of images to be fused are: any two fused images among all fused images obtained by fusion of any two original images among n original images of the same size generated by one shooting operation with different exposure times; Alternatively, the two frames of images to be fused are any two new fused images among all new fused images obtained by fusion of any two of the fused images.
7. The method according to claim 6, characterized in that The step of performing a guided filtering operation on the fusion mask matrix to obtain a target fusion mask matrix includes: Performing a guided filtering operation on the fusion mask matrix through a guided matrix having preset texture features to obtain the target fusion mask matrix; The detail of the edge feature of the target fusion mask matrix is greater than or equal to a preset detail threshold, and the similarity between the texture feature of the target fusion mask matrix and the preset texture feature is greater than a preset similarity threshold.
8. An image processing device, characterized in that: The image processing device comprises: An acquisition module is used to acquire two frames of images to be fused, where the pixels in the two frames of images to be fused correspond to each other one by one; An establishment module is used to obtain fusion weight values of two pixel points corresponding to each other in two frames of the to-be-fused images based on a weight mapping matrix of a preset dimension, and to establish a fusion mask matrix according to the fusion weight values; A filtering module, used for performing a guided filtering operation on the fusion mask matrix to obtain a target fusion mask matrix; A fusion module, used for performing image fusion on the two frames of the to-be-fused images according to the target fusion mask matrix to obtain a target image; Wherein, the weight mapping matrix of a preset dimension is established based on the following formula 1; Formula 1: Among them, a ij =Max(0.255-(255-i)×decav); b ij =Max(0,Min(255,(1-m)×n)); W is the value of each element in the weight mapping matrix, i is the number of rows of the element, j is the number of columns of the element, the dimension of the weight mapping matrix is h×w=256×256, Max is the maximum value operation, Min is the minimum value operation, the value of the weight decay factor decay is a positive real number, and the values of m and n are preset constants.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the image processing method according to any one of claims 1 to 7 are implemented.
10. A device, characterized in that: The method comprises a processor, a memory and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the image processing method according to any one of claims 1 to 7 when executed by the processor.
Citation Information
Patent Citations
Image synthesis method and system using alpha channels
CN102332158A
Guided filter parameter automatic adjustment-based remote sensing image fusion method
CN108648165A
Medium and long wave infrared image fusion method and device applied to ship detection field under sea-sky background
CN108717689A
Image processing method and device
CN109194873A
Hyperspectral image classification method based on semi-supervised WGAN-GP
CN109389080A
