Image fusion processing method and device, equipment, storage medium and chip
Determining the fusion mask image through the optical flow image solves the alignment problem caused by large differences when collecting images from multiple cameras, and improves the quality of image fusion.
Patent Information
- Application Number
- CN202310182239.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-23
- Publication Date
- 2024-08-27
AI Technical Summary
In the existing technology, multi-frame images collected by multiple cameras have large differences in pixels, brightness and resolution, making it impossible to achieve accurate alignment, resulting in a large number of unaligned areas being eliminated, which affects the image fusion effect.
By acquiring the first image and the second image, the fusion mask image is determined based on the optical flow image, indicating the fusion area and the non-fusion area, and the image is fused based on this to avoid relying on image alignment.
It improves the quality of image fusion, avoids the problem of removing misaligned areas due to differences between images, and achieves more reasonable fusion area decisions.
Smart Images

Figure CN118552415A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technology, and in particular to an image fusion processing method, device, equipment, storage medium and chip. Background Art
[0002] With the development of terminal technology, the functions of terminal devices such as smart phones are becoming more and more abundant, and image processing is one of the important functions of terminal devices. Limited by the spatial structure of terminal devices, the camera module of terminal devices cannot achieve the shooting level of professional cameras. Therefore, in related technologies, the fused image is usually obtained by fusing multiple frames of images collected by multiple cameras in the camera module to improve the quality of the output image.
[0003] Image fusion methods in related technologies usually rely on the alignment of multiple frames. However, if there are large differences between multiple frames captured by multiple cameras (such as pixel differences, large brightness differences, or image resolution differences), it is impossible to accurately align multiple frames, resulting in a large number of unaligned areas being eliminated, which in turn leads to a discrete and messy distribution of the fusion area, which seriously affects the image fusion effect. Summary of the invention
[0004] In order to overcome the problems existing in the related art, the embodiments of the present disclosure provide an image fusion processing method, device, equipment, storage medium and chip to solve the defects in the related art.
[0005] According to a first aspect of an embodiment of the present disclosure, there is provided an image fusion processing method, the method comprising:
[0006] Acquire a first image and a second image, wherein the first image is acquired by a first camera of the electronic device, and the second image is acquired by a second camera of the electronic device, and a field of view angle of the first camera is greater than a field of view angle of the second camera;
[0007] determining a corresponding optical flow image based on the first image and the second image;
[0008] Determine a fusion mask image based on the optical flow image, where the fusion mask image is used to indicate a fusion area and a non-fusion area in the fusion image;
[0009] The first image and the second image are fused based on the fused area, the non-fused area and the optical flow image to obtain the fused image.
[0010] In some embodiments, determining a fused mask image based on the optical flow image comprises:
[0011] Determining optical flow change information of the optical flow image;
[0012] A fused mask image is determined based on the optical flow image and the optical flow change information.
[0013] In some embodiments, determining the optical flow change information of the optical flow image includes:
[0014] For each point in the optical flow image, determining a first optical flow value difference between two points at a set distance from each point in a first set direction of each point, and a second optical flow value difference between two points at a set distance from each point in a second set direction of each point, wherein the first set direction is a direction parallel to a target optical flow direction, and the second set direction is a direction perpendicular to the target optical flow direction, and the target optical flow direction is determined based on a central direction corresponding to a pre-divided direction interval to which an actual optical flow direction of each point belongs;
[0015] The optical flow change information of each point is determined based on the first optical flow value difference and the second optical flow value difference.
[0016] In some embodiments, the fused mask image includes a first indication area and a second indication area, the first indication area is used to indicate a fused area of the fused image, and the second indication area is used to indicate a non-fused area of the fused image;
[0017] The determining of the fused mask image based on the optical flow image and the optical flow change information includes:
[0018] An objective function is constructed based on the optical flow image and the optical flow change information, wherein the objective function includes a first residual term, a second residual term and a third residual term, wherein the first residual term is used to generate a first penalty value based on a Gaussian function of the optical flow change information corresponding to each point in the fused mask image, so as to limit the first indication area to a position where the optical flow change information is smaller, and limit the second indication area to a position where the optical flow change information is larger; the second residual term is used to generate a second penalty value based on a preset constant or variable, so as to limit the first indication area to a position where the optical flow value is smaller, and the optical flow value is determined based on the optical flow vector in the optical flow image; the third residual term is used to generate a third penalty value based on the optical flow change information corresponding to each point in the fused mask image and the optical flow change information of the adjacent points of each point, so as to improve the smoothness and / or continuity of the first indication area and the second indication area;
[0019] The objective function is solved based on a preset function solving algorithm to obtain the fused mask image.
[0020] In some embodiments, the method further comprises:
[0021] Correcting the optical flow image to obtain a corrected optical flow image;
[0022] The fusing the first image and the second image based on the fused area, the non-fused area and the optical flow image includes:
[0023] The first image and the second image are fused based on the fused area, the non-fused area and the corrected optical flow image.
[0024] In some embodiments, the correcting the optical flow image includes:
[0025] Determine a gradient value corresponding to each pixel position in the first image;
[0026] The optical flow value corresponding to the first pixel position whose gradient information is greater than the set gradient threshold is corrected.
[0027] In some embodiments, the correcting the optical flow value corresponding to the first pixel position whose gradient information is greater than a set gradient threshold comprises:
[0028] Calculating an angle between a gradient vector of at least one target pixel in a target window and a gradient vector of the first pixel, wherein the target window is a window of a preset size centered at the first pixel position in the first image, and the at least one target pixel includes a pixel in the target window whose gradient value is greater than the set gradient threshold;
[0029] A Gaussian weighted average of the optical flow values corresponding to the at least one target pixel is determined based on the angle and used as the corrected optical flow value corresponding to the first pixel position.
[0030] In some embodiments, the fusing the first image and the second image based on the fused area, the non-fused area and the optical flow image to obtain the fused image includes:
[0031] Affine transforming the second image into a coordinate system of the first image based on the optical flow image to obtain a third image;
[0032] The first image and the third image are fused based on the fused area and the non-fused area to obtain the fused image.
[0033] In some embodiments, the fused mask image includes a first indication area and a second indication area, the first indication area is used to indicate a fused area of the fused image, and the second indication area is used to indicate a non-fused area of the fused image;
[0034] The fusing the first image and the third image based on the fused area and the non-fused area to obtain the fused image includes:
[0035] In the fusion area of the fusion image, retain the pixel value of the third image;
[0036] In the non-fused area of the fused image, the pixel values of the first image are retained.
[0037] In some embodiments, the first indication area further includes a preset fusion transition area, and the preset fusion transition area is used to indicate the fusion transition area in the fusion area;
[0038] The retaining the pixel value of the third image in the fusion area of the fusion image comprises:
[0039] In a fusion transition region in the fusion region, a fusion pixel value is retained, and the fusion pixel value is obtained by fusing the pixel value of the first image and the pixel value of the third image using a predetermined fusion transition weight.
[0040] In some embodiments, the method further comprises determining the fusion transition weight in advance based on:
[0041] performing distance transformation on the second indication area in the fused mask image to obtain a distance transformation image;
[0042] The blending transition weight is determined based on the distance transform image.
[0043] According to a second aspect of an embodiment of the present disclosure, there is provided an image fusion processing device, the device comprising:
[0044] An image acquisition module, used to acquire a first image and a second image, wherein the first image is acquired by a first camera of the electronic device, and the second image is acquired by a second camera of the electronic device, and the field of view of the first camera is greater than the field of view of the second camera;
[0045] an optical flow determination module, configured to determine a corresponding optical flow image based on the first image and the second image;
[0046] A mask determination module, used to determine a fused mask image based on the optical flow image, wherein the fused mask image is used to indicate a fused area and a non-fused area in the fused image;
[0047] An image fusion module is used to fuse the first image and the second image based on the fusion area, the non-fusion area and the optical flow image to obtain the fusion image.
[0048] In some embodiments, the mask determination module includes:
[0049] an information determining unit, configured to determine optical flow change information of the optical flow image;
[0050] A mask determining unit is used to determine a fused mask image based on the optical flow image and the optical flow change information.
[0051] In some embodiments, the information determination unit is further configured to:
[0052] For each point in the optical flow image, determining a first optical flow value difference between two points at a set distance from each point in a first set direction of each point, and a second optical flow value difference between two points at a set distance from each point in a second set direction of each point, wherein the first set direction is a direction parallel to a target optical flow direction, and the second set direction is a direction perpendicular to the target optical flow direction, and the target optical flow direction is determined based on a central direction corresponding to a pre-divided direction interval to which an actual optical flow direction of each point belongs;
[0053] The optical flow change information of each point is determined based on the first optical flow value difference and the second optical flow value difference.
[0054] In some embodiments, the fused mask image includes a first indication area and a second indication area, the first indication area is used to indicate a fused area of the fused image, and the second indication area is used to indicate a non-fused area of the fused image;
[0055] The mask determination unit is further configured to:
[0056] An objective function is constructed based on the optical flow image and the optical flow change information, wherein the objective function includes a first residual term, a second residual term and a third residual term, wherein the first residual term is used to generate a first penalty value based on a Gaussian function of the optical flow change information corresponding to each point in the fused mask image, so as to limit the first indication area to a position where the optical flow change information is smaller, and limit the second indication area to a position where the optical flow change information is larger; the second residual term is used to generate a second penalty value based on a preset constant or variable, so as to limit the first indication area to a position where the optical flow value is smaller, and the optical flow value is determined based on the optical flow vector in the optical flow image; the third residual term is used to generate a third penalty value based on the optical flow change information corresponding to each point in the fused mask image and the optical flow change information of the adjacent points of each point, so as to improve the smoothness and / or continuity of the first indication area and the second indication area;
[0057] The objective function is solved based on a preset function solving algorithm to obtain the fused mask image.
[0058] In some embodiments, the apparatus further comprises:
[0059] An optical flow correction module, used to correct the optical flow image to obtain a corrected optical flow image;
[0060] The image fusion module is further used to perform fusion processing on the first image and the second image based on the fusion area, the non-fusion area and the corrected optical flow image.
[0061] In some embodiments, the optical flow correction module includes:
[0062] a gradient determination unit, configured to determine a gradient value corresponding to each pixel position in the first image;
[0063] The optical flow correction unit is used to correct the optical flow value corresponding to the first pixel position whose gradient information is greater than a set gradient threshold.
[0064] In some embodiments, the optical flow correction unit is further configured to:
[0065] Calculating an angle between a gradient vector of at least one target pixel in a target window and a gradient vector of the first pixel, wherein the target window is a window of a preset size centered at the first pixel position in the first image, and the at least one target pixel includes a pixel in the target window whose gradient value is greater than the set gradient threshold;
[0066] A Gaussian weighted average of the optical flow values corresponding to the at least one target pixel is determined based on the angle and used as the corrected optical flow value corresponding to the first pixel position.
[0067] In some embodiments, the image fusion module includes:
[0068] An image transformation unit, configured to affine transform the second image into a coordinate system of the first image based on the optical flow image to obtain a third image;
[0069] An image fusion unit is used to fuse the first image and the third image based on the fusion area and the non-fusion area to obtain the fused image.
[0070] In some embodiments, the fused mask image includes a first indication area and a second indication area, the first indication area is used to indicate a fused area of the fused image, and the second indication area is used to indicate a non-fused area of the fused image;
[0071] The image fusion unit is also used for:
[0072] In the fusion area of the fusion image, retain the pixel value of the third image;
[0073] In the non-fused area of the fused image, the pixel values of the first image are retained.
[0074] In some embodiments, the first indication area further includes a preset fusion transition area, and the preset fusion transition area is used to indicate the fusion transition area in the fusion area;
[0075] The image fusion unit is further used to retain a fusion pixel value in a fusion transition area in the fusion area, where the fusion pixel value is obtained by fusing the pixel value of the first image with the pixel value of the third image using a predetermined fusion transition weight.
[0076] In some embodiments, the image fusion module further includes a transition weight determination unit;
[0077] The transition weight determination unit is used to:
[0078] performing distance transformation on the second indication area in the fused mask image to obtain a distance transformation image;
[0079] The blending transition weight is determined based on the distance transform image.
[0080] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, the device comprising:
[0081] A first camera, a second camera, a processor, and a memory for storing a computer program, wherein a field of view of the first camera is greater than a field of view of the second camera;
[0082] Wherein, the processor is configured to implement, when executing the computer program:
[0083] Acquire a first image and a second image, where the first image is acquired by the first camera and the second image is acquired by the second camera;
[0084] determining a corresponding optical flow image based on the first image and the second image;
[0085] Determine a fusion mask image based on the optical flow image, where the fusion mask image is used to indicate a fusion area and a non-fusion area in the fusion image;
[0086] The first image and the second image are fused based on the fused area, the non-fused area and the optical flow image to obtain the fused image.
[0087] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the following is implemented:
[0088] Acquire a first image and a second image, wherein the first image is acquired by a first camera of the electronic device, and the second image is acquired by a second camera of the electronic device, and a field of view angle of the first camera is greater than a field of view angle of the second camera;
[0089] determining a corresponding optical flow image based on the first image and the second image;
[0090] Determine a fusion mask image based on the optical flow image, where the fusion mask image is used to indicate a fusion area and a non-fusion area in the fusion image;
[0091] The first image and the second image are fused based on the fused area, the non-fused area and the optical flow image to obtain the fused image.
[0092] According to a fifth aspect of an embodiment of the present disclosure, a chip is provided, including:
[0093] Processors and interfaces;
[0094] The processor is used to read instructions through the interface to execute any one of the above-mentioned image fusion processing methods.
[0095] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:
[0096] The present invention obtains a first image and a second image, determines a corresponding optical flow image based on the first image and the second image, and then determines a fusion mask image based on the optical flow image, wherein the fusion mask image is used to indicate a fusion area and a non-fusion area in the fusion image, and then fuses the first image and the second image based on the fusion area, the non-fusion area and the optical flow image to obtain the fusion image. Since the fusion mask image is determined based on the optical flow image, and the first image and the second image are fused based on the fusion mask image and the optical flow image, there is no need to rely on image alignment for image fusion. Compared with the fusion method that relies on image alignment in the related art, the problem of a large number of non-aligned areas being eliminated due to large differences between images, thereby affecting the image fusion effect, can be avoided, and reasonable fusion area decisions can be made based on the optical flow image, thereby improving the quality of image fusion.
[0097] 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 disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0098] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0099] Figure 1A is a flowchart of an image fusion processing method according to an exemplary embodiment of the present disclosure;
[0100] Figure 1B is a schematic diagram of a first image according to an exemplary embodiment of the present disclosure;
[0101] Figure 1C is a schematic diagram of a second image according to an exemplary embodiment of the present disclosure;
[0102] Figure 1D is a schematic diagram showing an optical flow image corresponding to a first image and a second image according to an exemplary embodiment of the present disclosure;
[0103] Figure 2 is a flowchart showing how to determine a fused mask image based on the optical flow image according to an exemplary embodiment of the present disclosure;
[0104] Figure 3A is a flowchart showing how to determine the optical flow change information of the optical flow image according to an exemplary embodiment of the present disclosure;
[0105] Figure 3B is a schematic diagram of calculating the difference in optical flow values according to an exemplary embodiment of the present disclosure;
[0106] Figure 4A is a flowchart showing how to determine a fused mask image based on the optical flow image and the optical flow change information according to an exemplary embodiment of the present disclosure;
[0107] Figure 4B is a schematic diagram of a fast-moving object in two images according to an exemplary embodiment of the present disclosure;
[0108] Figure 5A is a flowchart showing how to correct the optical flow image according to an exemplary embodiment of the present disclosure;
[0109] Figure 5B is a schematic diagram showing that a slight optical flow error causes a straight line texture to be distorted according to an exemplary embodiment of the present disclosure;
[0110] Fig. 6A is a flowchart showing how to correct the optical flow value corresponding to the first pixel position whose gradient information is greater than a set gradient threshold according to an exemplary embodiment of the present disclosure;
[0111] Figure 6Bis a schematic diagram showing an acute angle between two gradient vectors according to an exemplary embodiment of the present disclosure;
[0112] Fig. 7A is a flowchart showing how to perform fusion processing on the first image and the second image based on the fusion area, the non-fusion area and the optical flow image according to an exemplary embodiment of the present disclosure;
[0113] Figure 7B is a schematic diagram of a third image according to an exemplary embodiment of the present disclosure;
[0114] Figure 7C is a schematic diagram of a fused mask image according to an exemplary embodiment of the present disclosure;
[0115] Fig.7D is a schematic diagram of a fused image according to an exemplary embodiment of the present disclosure;
[0116] Figure 8 is a flow chart showing how to determine the fusion transition weight according to an exemplary embodiment of the present disclosure;
[0117] Fig. 9 is a block diagram of an image fusion processing device according to an exemplary embodiment of the present disclosure;
[0118] Fig.10 is a block diagram of another image fusion processing device according to an exemplary embodiment of the present disclosure;
[0119] Fig.11 It is a block diagram of an electronic device according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0120] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0121] Figure 1A is a flow chart of an image fusion processing method according to an exemplary embodiment; Figure 1B is a schematic diagram of a first image according to an exemplary embodiment of the present disclosure; Figure 1C is a schematic diagram of a second image according to an exemplary embodiment of the present disclosure; Figure 1D The figure is a schematic diagram showing an optical flow image corresponding to a first image and a second image according to an exemplary embodiment of the present disclosure.
[0122] The method of this embodiment can be applied to an electronic device having a first camera (eg, a wide-angle camera, etc.) and a second camera (eg, a telephoto camera, etc.).
[0123] like Figure 1A As shown, the method includes the following steps S101-S104:
[0124] In step S101 , a first image and a second image are acquired.
[0125] In this embodiment, the first image may be captured by a first camera of the electronic device, and the second image may be captured by a second camera of the electronic device.
[0126] For example, the first image may be an image taken by a wide-angle lens with lower resolution but wider field of view (eg Figure 1B ), and the second image may be an image with a high resolution but a small field of view taken by a telephoto lens (such as Figure 1C shown).
[0127] In step S102, a corresponding optical flow image is determined based on the first image and the second image.
[0128] In this embodiment, after the first image and the second image are acquired, a corresponding optical flow image (such as Figure 1D shown).
[0129] It is worth noting that the above-mentioned preset optical flow algorithm can be selected from relevant technologies based on actual application requirements, such as DisFlow algorithm, PWCNet algorithm, etc., which is not limited in this embodiment.
[0130] In step S103, a fused mask image is determined based on the optical flow image.
[0131] In this embodiment, after the corresponding optical flow image is determined based on the first image and the second image, a fusion mask image may be determined based on the optical flow image, and the fusion mask image is used to indicate a fusion area and a non-fusion area in the fusion image.
[0132] The fused mask image may include a first indication area and a second indication area, wherein the first indication area is used to indicate a fused area in the fused image, and the second indication area is used to indicate a non-fused area in the fused image.
[0133] In some embodiments, after obtaining the optical flow image corresponding to the first image and the second image, the optical flow image can be used and combined with the mask image algorithm in the related technology to generate a fused mask image, wherein the mask image algorithm can be set based on actual application requirements, such as setting it to a binary classification algorithm constrained by Markov random field (MRF), etc. This embodiment does not limit this mask image algorithm.
[0134] In some other embodiments, the above method of determining the fused mask image based on the optical flow image can also refer to the following Figure 2 The illustrated embodiment will not be described in detail here.
[0135] In step S104, the first image and the second image are fused based on the fused area, the non-fused area and the optical flow image to obtain the fused image.
[0136] In this embodiment, after the fused mask image is determined based on the optical flow image, the first image and the second image may be fused based on the fused mask image and the optical flow image obtained in step S102 to obtain the fused image.
[0137] In some embodiments, considering that a small optical flow error in an optical flow image may cause a straight line texture distortion during subsequent image fusion, in order to improve the image fusion effect, this embodiment may correct the optical flow image before image fusion to obtain a corrected optical flow image, and then perform fusion processing on the first image and the second image based on the fusion area, the non-fusion area and the corrected optical flow image. The above-mentioned method of correcting the optical flow image can refer to the following Figure 5A The illustrated embodiment will not be described in detail here.
[0138] In some other embodiments, the above-mentioned method of fusing the first image and the second image based on the fusion area, the non-fusion area and the optical flow image can also refer to the following Fig. 7A The illustrated embodiment will not be described in detail here.
[0139] From the above description, it can be seen that the method of this embodiment obtains a first image and a second image, and determines a corresponding optical flow image based on the first image and the second image, and then determines a fusion mask image based on the optical flow image, and then fuses the first image and the second image based on the fusion area, the non-fusion area and the optical flow image to obtain the fusion image. Since the fusion mask image is determined based on the optical flow image, and the first image and the second image are fused based on the fusion mask image and the optical flow image, there is no need to rely on image alignment for image fusion. Compared with the fusion method that relies on image alignment in the related art, it can avoid the problem that a large number of non-aligned areas are eliminated due to large differences between images, thereby affecting the image fusion effect. Reasonable fusion area decisions can be made based on the optical flow image, thereby improving the quality of image fusion.
[0140] Figure 2 It is a flowchart showing how to determine a fused mask image based on the optical flow image according to an exemplary embodiment of the present disclosure; based on the above embodiment, this embodiment uses how to determine a fused mask image based on the optical flow image as an example to exemplify.
[0141] like Figure 2 As shown, the determination of the fused mask image based on the optical flow image in the above step S103 may include the following steps S201-S202:
[0142] In step S201, optical flow change information of the optical flow image is determined.
[0143] In this embodiment, after the optical flow images corresponding to the first image and the second image are obtained, the optical flow change information of the optical flow images may be determined in a preset optical flow change detection manner.
[0144] It is worth noting that the above-mentioned preset optical flow change detection method can be selected from relevant technologies based on actual application requirements, such as selecting a method in the relevant technology for counting the difference between the maximum optical flow value and the minimum optical flow value in a preset window in the optical flow image, or selecting a method in the relevant technology for counting the gradient size of each point in the optical flow image, etc. This embodiment does not limit this.
[0145] In some embodiments, the above method for determining the optical flow change information of the optical flow image can also refer to the following Figure 3A The illustrated embodiment will not be described in detail here.
[0146] In step S202, a fused mask image is determined based on the optical flow image and the optical flow change information.
[0147] In this embodiment, after determining the optical flow change information of the optical flow image, the fused mask image can be determined using the optical flow change information and the optical flow image obtained in the above step S102. For example, by analyzing the optical flow change information, the first indication area in the fused mask image can be set at a position where the optical flow change information is small, and the second indication area in the fused mask image can be set at a position where the optical flow change information is large. The reason for this setting is that the position where the optical flow change information is large (that is, the optical flow suddenly changes) is generally an area where the first image and the second image are misaligned, or an area where there is occlusion in the first image and the second image. If such an area is set as a fusion area, problems such as graphic distortion and duplication will occur when the subsequent image is affinely transformed (warped), which will affect the quality of image fusion.
[0148] On the other hand, the first indication area in the fusion mask image can also be set at a position with a smaller optical flow value by analyzing the optical flow image. The reason for this setting is that the position with a larger optical flow value is generally due to the difference in shooting time (such as shutter time) and exposure time between the first camera and the second camera, resulting in a large deviation in the position of the fast-moving object on the first image and the second image, which in turn leads to the existence of an occluded area or a motion blurred area in the first image and the second image. If such an area is set as a fusion area, problems such as graphic distortion and repetition will occur when the subsequent image is affinely transformed (warped), which will affect the quality of image fusion.
[0149] In some embodiments, the above method of determining the fused mask image based on the optical flow image and the optical flow change information can also refer to the following Figure 4A The illustrated embodiment will not be described in detail here.
[0150] From the above description, it can be seen that this embodiment determines the optical flow change information of the optical flow image, and determines the fused mask image based on the optical flow image and the optical flow change information. This can achieve accurate determination of the fused mask image based on the optical flow image and the optical flow change information, thereby improving the accuracy of subsequent fusion processing of the first image and the second image based on the fused mask image and the optical flow image, thereby improving the quality of image fusion.
[0151] Figure 3A It is a flowchart showing how to determine the optical flow change information of the optical flow image according to an exemplary embodiment of the present disclosure; based on the above embodiment, this embodiment takes how to determine the optical flow change information of the optical flow image as an example for exemplary description.
[0152] like Figure 3AAs shown, the determination of the optical flow change information of the optical flow image in the above step S201 may include the following steps S301-S302:
[0153] In step S301, for each point in the optical flow image, determine the difference in first optical flow values between two points at a set distance from each point in a first set direction of each point, and the difference in second optical flow values between two points at a set distance from each point in a second set direction of each point.
[0154] In this embodiment, when determining the optical flow change information of the optical flow image, the difference in first optical flow values between two points at a set distance from each point in a first set direction of each point in the optical flow image can be determined, as well as the difference in second optical flow values between two points at a set distance from each point in a second set direction of each point.
[0155] Among them, the first set direction is a direction parallel to the target optical flow direction, the second set direction is a direction perpendicular to the target optical flow direction, and the target optical flow direction is determined based on the central direction corresponding to the pre-divided direction interval to which the actual optical flow direction of each point belongs.
[0156] For example, Figure 3B : is a schematic diagram of calculating the difference in optical flow values according to an exemplary embodiment of the present disclosure. In this embodiment, eight central directions can be pre-set, such as 0°, 45°, 90°, ..., 270°, and 315°, and then based on these central directions, eight corresponding direction intervals are divided, namely (-22.5°, 22.5°], (22.5°, 67.5°], (67.5°, 112.5°], ..., (250.5, 292.5], and (292.5, 337.5].
[0157] On this basis, if Figure 3B As shown, for point P in the optical flow image (i.e., Figure 3B The square at the center of the image is used to determine the direction interval to which its optical flow direction belongs, and then the target optical flow direction of point P can be determined based on the center direction corresponding to the direction interval to which it belongs. Exemplarily, if the optical flow direction of point P is 47°, then the direction interval to which it belongs is (22.5°, 67.5°], and thus the center direction 45° of the direction interval can be determined as the target optical flow direction of point P. Further, it is possible to determine the first set direction of point P (i.e., the direction parallel to the target optical flow direction) and the set distance from point P (exemplarily, the set distance is 2, i.e. Figure 3B The distance between the two squares in the first set direction) is the point P1 which is the "positive" set distance from the point P in the first set direction (e.g., Figure 3B), and point P2 which is a "negative" set distance from point P in the first set direction (e.g., Figure 3B The square at the lower left corner in the figure), and then the difference between the optical flow value at point P1 and the optical flow value at point P2 can be calculated to obtain the first optical flow value difference mentioned above.
[0158] Similarly, two points (i.e., Figure 3B Specifically, the first optical flow value difference d can be calculated based on the following formulas (3-1) and (3-2) respectively: T and the second optical flow value difference d V :
[0159] d T =||F(p t+ )-F(p t- )||; (3-1)
[0160] d V =||F(p v+ )-F(p v -)||; (3-2)
[0161] In the above formula, F(p t+ ) is the optical flow value of point P1 which is a positive set distance t from point P in the first set direction; F(p t- ) is the optical flow value of point P2 which is a “negative” set distance t from point P in the first set direction; F(p v+ ) is the optical flow value of point P3 which is at a positive set distance v from point P in the second set direction; F(p v- ) is the optical flow value of point P4 at a "negative" set distance v from point P in the second set direction. That is to say, t and v are the interval distances between points in the first set direction and the second set direction, respectively, and can take the same value in the specific implementation process, such as both taking 2.
[0162] In step S302, the optical flow change information of each point is determined based on the first optical flow value difference and the second optical flow value difference.
[0163] In this embodiment, after the first optical flow value difference and the second optical flow value difference are determined, the optical flow change information of each point may be determined based on the first optical flow value difference and the second optical flow value difference.
[0164] Exemplarily, the larger one of the first optical flow value difference and the second optical flow value difference may be determined as the optical flow change information of each point.
[0165] Still with the first optical flow value difference d T and the second optical flow value difference d V For example, the optical flow change information D(p) of point P can be determined based on the following formula (3-3):
[0166] D(p)=max(d T ,d V ); (3-3)
[0167] It can be seen from the above description that this embodiment determines, for each point in the optical flow image, a first optical flow value difference between two points at a set distance from each point in a first set direction of each point, and a second optical flow value difference between two points at a set distance from each point in a second set direction of each point, and determines the optical flow change information of each point based on the first optical flow value difference and the second optical flow value difference. This can achieve accurate acquisition of the optical flow change information of the optical flow image, and further can achieve subsequent accurate determination of the fusion mask image based on the optical flow image and the optical flow change information, which can improve the accuracy of the fusion processing of the first image and the second image, and further improve the quality of image fusion.
[0168] Figure 4A It is a flowchart showing how to determine a fused mask image based on the optical flow image and the optical flow change information according to an exemplary embodiment of the present disclosure; based on the above-mentioned embodiment, this embodiment uses an example of how to determine a fused mask image based on the optical flow image and the optical flow change information.
[0169] In this embodiment, the fused mask image may include a first indication area and a second indication area, wherein the first indication area is used to indicate a fused area of the fused image, and the second indication area is used to indicate a non-fused area of the fused image.
[0170] On this basis, the determination of the fused mask image based on the optical flow image and the optical flow change information in the above step S202 may include the following steps S401-S402:
[0171] In step S401, an objective function is constructed based on the optical flow image and the optical flow change information.
[0172] In this embodiment, when the fused mask image is determined based on the optical flow image and the optical flow change information, an objective function may be first constructed based on the optical flow image and the optical flow change information.
[0173] In some embodiments, a binary classification method based on Markov random field (MRF) constraints may be used to construct the above objective function.
[0174] The above objective function may include a first residual term, a second residual term and a third residual term.
[0175] The first residual term may be used to generate a first penalty value based on a Gaussian function of the optical flow change information corresponding to each point in the fused mask image, so as to limit the first indication area to a position where the optical flow change information is smaller, and limit the second indication area to a position where the optical flow change information is larger;
[0176] The second residual term may be used to generate a second penalty value based on a preset constant or variable, so as to limit the first indication area to a position with a smaller optical flow value, where the optical flow value is determined based on an optical flow vector in the optical flow image.
[0177] The third residual term is used to generate a third penalty value based on the optical flow change information corresponding to each point in the fused mask image and the optical flow change information of the adjacent points of each point, so as to improve the smoothness and / or continuity of the first indication area and the second indication area.
[0178] For example, the objective function E can be constructed based on the following formula (4-1):
[0179] E=∑ P E O (D(p), B(p))+∑ p E b (F(p), B(p))+∑ p,q∈N E s (D(p), D(q), B(p), B(q)); (4-1)
[0180] In the above formula, p is a point in the fused mask image; N is the set of all neighboring points around point p; D(p) is the optical flow change information corresponding to point p; F(p) is the optical flow information corresponding to point p (i.e., the optical flow value corresponding to point p in the optical flow image); B(p) is the value corresponding to point p in the fused mask image to be solved, B(p)∈{0,1}; when B(p)=1, it means that point p is determined to be the first indication area; when B(p)=0, it means that point p is determined to be the second indication area; E o (D(p), B(p)) is the first residual term (or called “abnormal term”); E b (F(p), B(p)) is the second residual term (or called "motion blur term"); E_s(D(p), D(p), B(p), B(q)) is the third residual term (or called "smoothness term").
[0181] Regarding the above abnormal item E o(D(p), B(p)), which can be used to distinguish the "abnormal" areas caused by parallax occlusion or object motion in the first image and the second image according to the optical flow change information, because such "abnormal" areas are prone to produce obvious distortion and repeated traces during the subsequent image affine transformation, which will affect the quality of image fusion. For example, the specific form of the abnormal term can be shown in the following formula (4-2):
[0182]
[0183] As shown in the above formula (4-2), the abnormal term E o (D(p), B(p)) is the logarithm of the probability density function of the two Gaussian types as the penalty value, that is, it represents the penalty value of the point p being determined as the first indication area and the second indication area respectively; μ0 and μ1 are the means of the two Gaussian functions, and σ0 and σ1 are the variances of the two Gaussian functions. In this embodiment, μ0=0, and μ1 can be set in advance through experimental analysis, for example, set to 18; α is a weight factor, which can be set to 1 in the specific implementation process.
[0184] That is to say, when When , the penalty value of point p as the first indication area is less than the penalty value of point p as the second indication area; and when When , the penalty value of point p being determined as the first indication area is greater than the penalty value of point p being determined as the second indication area.
[0185] Regarding the above motion blur term E b (F(p), B(p)), which can be used to distinguish the areas where fast-moving objects are located in the first image and the second image. For example, Figure 4B is a schematic diagram showing a fast-moving object in two images according to an exemplary embodiment of the present disclosure; Figure 4B As shown, due to the difference in shutter time and exposure time between the first camera and the second camera, there will be a large deviation in the position of the fast-moving object in the two images, which will cause serious motion blur. Therefore, in this embodiment, fusion processing is avoided as much as possible in the area with very large optical flow values (that is, avoid setting B(p)=1 when the optical flow value is very large). For example, the specific form of the motion blur term can be shown in the following formula (4-3):
[0186]
[0187] As shown in the above formula (4-3), when the optical flow F(p) is greater than the preset threshold δ F , and the penalty value of point p being determined as the first indication area is infinite; when the optical flow F(p) is greater than the preset threshold δ F, and the penalty value of point p being determined as the second indication area is 0; when the optical flow amplitude is less than or equal to the preset threshold δ F When , the penalty value is 0 regardless of whether the point p is determined to be the first indication area or the second indication area. F The value is 150.
[0188] Regarding the above smoothing term E s (D(p), D(q), B(p), B(q)), which can be used to improve the continuity of the first indication area and the second indication area (that is, to improve the continuity of the fused area and the non-fused area). In this embodiment, it is considered that the occlusion and non-occlusion, high-speed motion of objects and other problems in actual application scenarios often exist in patches, that is, each pixel is not independent, so a regular constraint is provided by the above-mentioned smoothing term to make the first indication area and the second indication area smooth and continuous. Exemplarily, the specific form of the smoothing term can be shown as follows (4-4):
[0189]
[0190] As shown in the above formula (4-4), when point p and point q are judged as different categories (i.e., one is judged as the first indication area and the other is judged as the second indication area), a penalty value will be generated, and the greater the optical flow change value of point p and point q, the greater the penalty value. Among them, β is a weight factor, and the greater the β, the greater the impact of the smoothing term, so that the continuity of the fused area and the non-fused area can be improved.
[0191] In step S402, the objective function is solved based on a preset function solving algorithm to obtain the fused mask image.
[0192] In this embodiment, after constructing the objective function based on the optical flow image and the optical flow change information, the objective function may be solved based on a preset function solving algorithm to obtain the fused mask image.
[0193] It is worth noting that the above-mentioned preset function solving algorithm can be set based on actual business needs, such as being set to the Boykov–Kolmogorov algorithm, etc., and this embodiment does not limit this.
[0194] As can be seen from the above description, this embodiment constructs an objective function based on the optical flow image and the optical flow change information, and solves the objective function based on a preset function solving algorithm to obtain the fused mask image, so as to accurately determine the fused mask image, and lay a foundation for the subsequent fusion processing of the first image and the second image based on the fused mask image and the optical flow image. Since the fused mask image is determined based on the optical flow image without relying on image alignment to determine the fused mask image, it can avoid the problem that a large number of unaligned areas are eliminated due to large differences between images, thereby affecting the image fusion effect. A reasonable fusion area decision can be made based on the optical flow image, thereby improving the quality of subsequent image fusion. Furthermore, this embodiment adopts a binary classification method based on MRF constraints to construct and solve the objective function, which can ensure that the obtained first indication area is more continuous and smooth, and thus the fusion area in the fused image can be made more continuous and smooth. At the same time, the binary classification method based on MRF constraints to construct and solve the objective function can also make the boundary between the fused area and the non-fused area at the smooth part of the optical flow, thereby reducing the probability of artifacts.
[0195] Figure 5A is a flowchart showing how to correct the optical flow image according to an exemplary embodiment of the present disclosure; Figure 5B 1 is a schematic diagram showing that a slight optical flow error causes a straight line texture to be distorted according to an exemplary embodiment of the present disclosure. Based on the above embodiment, this embodiment uses how to correct the optical flow image as an example to exemplify the above embodiment.
[0196] like Figure 5B As shown, considering that a small optical flow error in the optical flow image will cause linear texture distortion when the second image is subsequently affine transformed to the first image coordinate system (i.e., Figure 5B In order to solve the problem that the straight line texture in the image is distorted from top to bottom, which may affect the effect of subsequent image fusion, the present embodiment can correct the optical flow image before image fusion to obtain a corrected optical flow image, and then the first image and the second image can be fused based on the fused area, the non-fused area and the corrected optical flow image.
[0197] like Figure 5A As shown, the image fusion processing method of this embodiment may further include correcting the optical flow image based on the following steps S501-S502:
[0198] In step S501, the gradient value corresponding to each pixel position in the first image is determined.
[0199] In this embodiment, when the optical flow image needs to be corrected, the gradient value corresponding to each pixel position in the first image may be determined based on a preset gradient algorithm.
[0200] It is worth noting that the above-mentioned preset gradient algorithm can be set based on actual application requirements, such as being set to a gradient detection algorithm based on a Sobel operator, etc., and this embodiment does not limit this.
[0201] In step S502, the optical flow value corresponding to the first pixel position whose gradient information is greater than a set gradient threshold is corrected.
[0202] In this embodiment, after the gradient value corresponding to each pixel position in the first image is determined, the optical flow value corresponding to the pixel position (ie, the first pixel position) whose gradient information is greater than a set gradient threshold may be corrected.
[0203] It can be understood that the optical flow value corresponding to the pixel position where the gradient information is greater than the set gradient threshold, that is, the optical flow value at the strong texture, can be corrected to effectively reduce the distortion traces in the fused image and improve the quality of the fused image.
[0204] In some embodiments, the above-mentioned method of correcting the optical flow value corresponding to the first pixel position may adopt the optical flow value correction method in the related art, which is not limited in this embodiment.
[0205] In some other embodiments, the above-mentioned method of correcting the optical flow value corresponding to the first pixel position whose gradient information is greater than the set gradient threshold value can also refer to the following Fig. 6A The illustrated embodiment will not be described in detail here.
[0206] From the above description, it can be seen that this embodiment can correct the optical flow image by determining the gradient value corresponding to each pixel position in the first image, and correcting the optical flow value corresponding to the first pixel position whose gradient information is greater than the set gradient threshold, thereby improving the quality of subsequent fusion processing of the first image and the second image based on the optical flow image.
[0207] Fig. 6A This is a flowchart showing how to correct the optical flow value corresponding to the first pixel position whose gradient information is greater than the set gradient threshold according to an exemplary embodiment of the present disclosure; based on the above embodiment, this embodiment uses an example of how to correct the optical flow value corresponding to the first pixel position whose gradient information is greater than the set gradient threshold as an example.
[0208] like Fig. 6AAs shown, the correction of the optical flow value corresponding to the first pixel position whose gradient information is greater than the set gradient threshold in the above step S502 may include the following steps S601-S602:
[0209] In step S601, the angle between the gradient vector of at least one target pixel in the target window and the gradient vector of the first pixel is calculated.
[0210] In this embodiment, when the optical flow value corresponding to the first pixel position whose gradient information is greater than the set gradient threshold is corrected, the angle between the gradient vector of at least one target pixel in the target window and the gradient vector of the first pixel can be calculated first, that is, the angle between the gradient vector of each target pixel in the at least one target pixel and the gradient vector of the first pixel.
[0211] The target window is a window of a preset size centered at the first pixel position in the first image. Exemplarily, the window of the preset size may be a 7*7 window.
[0212] The at least one target pixel includes a pixel in the target window whose gradient value is greater than the set gradient threshold.
[0213] In some embodiments, the angle between the gradient vector of each target pixel and the gradient vector of the first pixel may be an acute angle. Figure 6B is a schematic diagram showing an acute angle between two gradient vectors according to an exemplary embodiment of the present disclosure; Figure 6B As shown, when the angle between the two gradient vectors is an acute angle, the "angle" concerned in this embodiment can be directly taken as the angle between the two gradient vectors; and when the angle between the two gradient vectors is an obtuse angle, the "angle" concerned in this embodiment can be taken as the complementary angle of the angle.
[0214] In step S602, a Gaussian weighted average of the optical flow values corresponding to the at least one target pixel is determined based on the angle, and used as the corrected optical flow value corresponding to the first pixel position.
[0215] In this embodiment, after calculating the angle between the gradient vector of at least one target pixel in the target window and the gradient vector of the first pixel, the Gaussian weighted average of the optical flow value corresponding to the at least one target pixel can be calculated based on the angle, and the Gaussian weighted average can be determined as the corrected optical flow value corresponding to the first pixel position.
[0216] For example, the corrected optical flow value corresponding to the first pixel position may be determined based on the following formula (6-1):
[0217]
[0218] In the above formula, f x and f y are respectively the corrected optical flow values in the x direction and the y direction corresponding to the first pixel position; N is the set of pixels in the target window whose gradient values are greater than the set gradient threshold (i.e., the set of at least one target pixel); θ i is the angle between the gradient vector of the i-th pixel in the set and the gradient vector of the first pixel; σ is the standard deviation of the Gaussian function, and exemplarily, σ=1.
[0219] From the above description, it can be seen that this embodiment calculates the angle between the gradient vector of at least one target pixel in the target window and the gradient vector of the first pixel, and determines the Gaussian weighted average of the optical flow values corresponding to the at least one target pixel based on the angle, and uses it as the corrected optical flow value corresponding to the first pixel position. This can achieve a reasonable correction of the optical flow value corresponding to the first pixel position, thereby achieving correction of the optical flow image, and improving the quality of subsequent fusion processing of the first image and the second image based on the optical flow image.
[0220] Fig. 7A is a flowchart showing how to perform fusion processing on the first image and the second image based on the fusion area, the non-fusion area and the optical flow image according to an exemplary embodiment of the present disclosure; Figure 7B is a schematic diagram of a third image according to an exemplary embodiment of the present disclosure; Figure 7C is a schematic diagram of a fused mask image according to an exemplary embodiment of the present disclosure; Fig.7D is a schematic diagram of a fused image according to an exemplary embodiment of the present disclosure.
[0221] Based on the above embodiment, this embodiment uses an example of how to fuse the first image and the second image based on the fusion area, the non-fusion area and the optical flow image to exemplify the process.
[0222] like Fig. 7A As shown, the above-mentioned step S104 of fusing the first image and the second image based on the fused area, the non-fused area and the optical flow image to obtain the fused image may include the following steps S701-S702:
[0223] In step S701, the second image is affine transformed into the coordinate system of the first image based on the optical flow image to obtain a third image.
[0224] In this embodiment, after obtaining the first image and the second image, and the optical flow image corresponding to the first image and the second image, the second image can be affine transformed (warped) to the coordinate system of the first image based on the optical flow image to obtain a third image. It is worth noting that the above-mentioned method of performing affine transformation on the second image can refer to the explanation and description in the relevant technology, and this embodiment does not limit this.
[0225] For example, the first image and the second image can be registered by optical flow image to obtain the image affine transformation relationship, and then based on the image affine transformation relationship, the second image is affine transformed into the coordinate system of the first image to obtain the third image (such as Figure 7B shown).
[0226] In some embodiments, for example, in order to ensure that the color and / or brightness of the fused image obtained by subsequent image fusion presents overall consistency, before performing image registration based on the first image and the second image, the first image and the second image can be preprocessed based on a preset processing method to obtain the preprocessed first image and the preprocessed second image, and then image registration is performed based on the preprocessed first image and the preprocessed second image to obtain the image affine transformation relationship.
[0227] Exemplarily, the above-mentioned preset processing method may include at least one of brightness correction and color correction.
[0228] It is worth noting that the optical flow image of this embodiment may be an optical flow image corresponding to the first image and the second image determined in step S102, or may be an optical flow image based on Figure 5A or Fig. 6A The optical flow image after correction in the embodiment shown.
[0229] In step S702, the first image and the third image are fused based on the fused area and the non-fused area to obtain the fused image.
[0230] Figure 7C FIG. 1 is a schematic diagram of a fused mask image according to an exemplary embodiment of the present disclosure. Figure 7C As shown, the fused mask image includes a first indication area (ie, Figure 7C The white area in the figure) and the second indicator area (i.e., Figure 7C The first indicating area is used to indicate the fused area in the fused image, and the second indicating area is used to indicate the non-fused area in the fused image.
[0231] On this basis, when the first image and the third image are fused based on the fused area and the non-fused area, pixel values in different images can be retained for the fused area and the non-fused area of the fused image, specifically including the following two cases (1) and (2):
[0232] (1) retaining pixel values of the third image within a fusion region of the fusion image;
[0233] (2) In the non-fused area of the fused image, the pixel values of the first image are retained.
[0234] In other embodiments, in order to make the transition between the fused area and the non-fused area in the fused image more natural, a fused transition area (hereinafter referred to as a preset fused transition area) may be set in the first indication area of the fused mask image. The preset fused transition area is used to indicate the fused transition area in the fused area of the fused image (i.e., Fig.7D fusion transition area in the
[0235] On this basis, when the first image and the third image are fused based on the fused area and the non-fused area, the following situation (3) may also be possible:
[0236] (3) In the fusion transition area of the fusion area, the fusion pixel value is retained.
[0237] The fused pixel value may be obtained by fusing the pixel value of the first image and the pixel value of the third image using a predetermined fusion transition weight.
[0238] That is to say, in this embodiment, the pixel values of the third image are completely retained in the fusion area (i.e., the fusion area excluding the fusion transition area), the pixel values of the first image are completely retained in the non-fusion area, and the fusion pixel values of the first image and the second image are retained in the fusion transition area.
[0239] In other embodiments, the above-mentioned determination method of the fusion transition weight can also refer to the following Figure 8 The illustrated embodiment will not be described in detail here.
[0240] It can be seen from the above description that this embodiment can achieve the effect of fusion transition, avoid the problem of ghosting at the boundary between the fusion area and the non-fusion area, and ensure the quality of the fusion image.
[0241] Figure 8 It is a flowchart showing how to determine the fusion transition weight according to an exemplary embodiment of the present disclosure; based on the above embodiment, this embodiment uses how to determine the fusion transition weight as an example to exemplify.
[0242] like Figure 8 As shown, the image fusion processing method of this embodiment may also include the following steps S801-S802:
[0243] In step S801, distance transformation is performed on the second indication area in the fused mask image to obtain a distance transformed image.
[0244] In this embodiment, after the fused mask image is obtained, distance transformation may be performed on the second indication area in the fused mask image to obtain a distance transformation image.
[0245] The distance transformation image can be used to represent the distance between each pixel in the fusion mask image and the target fusion boundary.
[0246] It is worth noting that the above-mentioned distance transformation method can refer to the explanation and description in the relevant technology, and this embodiment does not limit this.
[0247] In step S802, the fusion transition weight is determined based on the distance transformation image.
[0248] In this embodiment, after distance transformation is performed on the second indication area in the fused mask image to obtain a distance transformation image, the fusion transition weight corresponding to the preset fusion transition area may be determined based on the distance transformation image.
[0249] In some embodiments, after obtaining the above-mentioned distance transformation image, based on the distance transformation image, the fusion transition weight corresponding to the point closer to the boundary of the preset fusion transition area can be set to be larger, and the fusion transition weight corresponding to the point farther from the boundary of the preset fusion transition area can be set to be smaller, wherein the above-mentioned points are points in the preset fusion transition area.
[0250] For example, the fusion transition weight W can be determined based on the following formula (8-1): b :
[0251]
[0252] Among them, s b is the boundary distance of the preset fusion transition area, that is, the range of the preset fusion transition area is [0,s b ], so d<s b The above points may be indicated as points in a preset fusion transition area.
[0253] It can be seen from the above description that this embodiment obtains a distance transformation image by performing a distance transformation on the second indication area in the fusion mask image, and determines the fusion transition weight corresponding to the preset fusion transition area based on the distance transformation image, so as to accurately determine the fusion transition weight, and then subsequently perform fusion processing on the third image and the first image based on the fusion transition weight in the fusion transition area of the fusion image, so as to better avoid the problem of ghosting at the fusion boundary, thereby improving the quality of the image output by the electronic device.
[0254] Fig. 9 It is a block diagram of an image fusion processing device according to an exemplary embodiment of the present disclosure; the device of this embodiment can be applied to an electronic device having a first camera (such as a wide-angle camera, etc.) and a second camera (such as a telephoto camera, etc.).
[0255] like Fig. 9 As shown, the device includes: an image acquisition module 110, an optical flow determination module 120, a mask determination module 130 and an image fusion module 140, wherein:
[0256] An image acquisition module 110 is used to acquire a first image and a second image, wherein the first image is acquired by a first camera of the electronic device, and the second image is acquired by a second camera of the electronic device, and the field of view of the first camera is greater than the field of view of the second camera;
[0257] An optical flow determination module 120, configured to determine a corresponding optical flow image based on the first image and the second image;
[0258] A mask determination module 130, configured to determine a fused mask image based on the optical flow image, wherein the fused mask image is used to indicate a fused area and a non-fused area in the fused image;
[0259] The image fusion module 140 is used to fuse the first image and the second image based on the fused area, the non-fused area and the optical flow image to obtain the fused image.
[0260] It can be seen from the above description that the device of this embodiment obtains a first image and a second image, and determines a corresponding optical flow image based on the first image and the second image, and then determines a fusion mask image based on the optical flow image, and then fuses the first image and the second image based on the fusion area, the non-fusion area and the optical flow image to obtain the fusion image. Since the fusion mask image is determined based on the optical flow image, and the first image and the second image are fused based on the fusion mask image and the optical flow image, there is no need to rely on image alignment for image fusion. Compared with the fusion method that relies on image alignment in the related art, it can avoid the problem that a large number of non-aligned areas are eliminated due to large differences between images, thereby affecting the image fusion effect. Reasonable fusion area decisions can be made based on the optical flow image, thereby improving the quality of image fusion.
[0261] Fig.10 It is a block diagram of another image fusion processing device according to an exemplary embodiment of the present disclosure; the device of this embodiment can be applied to an electronic device having a first camera (such as a wide-angle camera, etc.) and a second camera (such as a telephoto camera, etc.).
[0262] The image acquisition module 210, the optical flow determination module 220, the mask determination module 230 and the image fusion module 240 are the same as those described above. Fig. 9 The functions of the image acquisition module 110 , the optical flow determination module 120 , the mask determination module 130 and the image fusion module 140 in the illustrated embodiment are the same and will not be described in detail herein.
[0263] like Fig.10 As shown, the mask determination module 230 may include:
[0264] An information determining unit 231 is used to determine optical flow change information of the optical flow image;
[0265] The mask determining unit 232 is configured to determine a fused mask image based on the optical flow image and the optical flow change information.
[0266] In some embodiments, the information determination unit 231 may also be used to:
[0267] For each point in the optical flow image, determining a first optical flow value difference between two points at a set distance from each point in a first set direction of each point, and a second optical flow value difference between two points at a set distance from each point in a second set direction of each point, wherein the first set direction is a direction parallel to a target optical flow direction, and the second set direction is a direction perpendicular to the target optical flow direction, and the target optical flow direction is determined based on a central direction corresponding to a pre-divided direction interval to which an actual optical flow direction of each point belongs;
[0268] The optical flow change information of each point is determined based on the first optical flow value difference and the second optical flow value difference.
[0269] In some embodiments, the fused mask image may include a first indication area and a second indication area, wherein the first indication area is used to indicate a fused area of the fused image, and the second indication area is used to indicate a non-fused area of the fused image;
[0270] Furthermore, the mask determination unit 232 may also be used to:
[0271] An objective function is constructed based on the optical flow image and the optical flow change information, wherein the objective function includes a first residual term, a second residual term and a third residual term, wherein the first residual term is used to generate a first penalty value based on a Gaussian function of the optical flow change information corresponding to each point in the fused mask image, so as to limit the first indication area to a position where the optical flow change information is smaller, and limit the second indication area to a position where the optical flow change information is larger; the second residual term is used to generate a second penalty value based on a preset constant or variable, so as to limit the first indication area to a position where the optical flow value is smaller, and the optical flow value is determined based on the optical flow vector in the optical flow image; the third residual term is used to generate a third penalty value based on the optical flow change information corresponding to each point in the fused mask image and the optical flow change information of the adjacent points of each point, so as to improve the smoothness and / or continuity of the first indication area and the second indication area;
[0272] The objective function is solved based on a preset function solving algorithm to obtain the fused mask image.
[0273] In some embodiments, the above apparatus may further include:
[0274] An optical flow correction module 250 is used to correct the optical flow image to obtain a corrected optical flow image;
[0275] Furthermore, the image fusion module 240 may also be configured to perform fusion processing on the first image and the second image based on the fusion area, the non-fusion area and the corrected optical flow image.
[0276] In some embodiments, the optical flow correction module 250 may include:
[0277] A gradient determination unit 251, configured to determine a gradient value corresponding to each pixel position in the first image;
[0278] The optical flow correction unit 252 is used to correct the optical flow value corresponding to the first pixel position whose gradient information is greater than a set gradient threshold.
[0279] In some embodiments, the optical flow correction unit 252 may also be used to:
[0280] Calculating an angle between a gradient vector of at least one target pixel in a target window and a gradient vector of the first pixel, wherein the target window is a window of a preset size centered at the first pixel position in the first image, and the at least one target pixel includes a pixel in the target window whose gradient value is greater than the set gradient threshold;
[0281] A Gaussian weighted average of the optical flow values corresponding to the at least one target pixel is determined based on the angle and used as the corrected optical flow value corresponding to the first pixel position.
[0282] In some embodiments, the image fusion module 240 may include:
[0283] An image transformation unit 241, configured to affine transform the second image into a coordinate system of the first image based on the optical flow image to obtain a third image;
[0284] The image fusion unit 242 is configured to perform fusion processing on the first image and the third image based on the fusion area and the non-fusion area to obtain the fused image.
[0285] In some embodiments, the fused mask image may include a first indication area and a second indication area, wherein the first indication area is used to indicate a fused area of the fused image, and the second indication area is used to indicate a non-fused area of the fused image;
[0286] Furthermore, the image fusion unit 242 may also be used for:
[0287] In a fusion region of the fusion image, retaining pixel values of the third image;
[0288] In the non-fused area of the fused image, the pixel values of the first image are retained.
[0289] In some embodiments, the first indication area may further include a preset fusion transition area, and the preset fusion transition area is used to indicate the fusion transition area in the fusion area;
[0290] Furthermore, the image fusion unit 242 can also be used to retain the fusion pixel value in the fusion transition area in the fusion area, and the fusion pixel value is obtained by fusing the pixel value of the first image and the pixel value of the third image using a predetermined fusion transition weight.
[0291] In some embodiments, the image fusion module 240 may further include a transition weight determination unit 243;
[0292] The transition weight determination unit 243 is used to:
[0293] performing distance transformation on the second indication area in the fused mask image to obtain a distance transformation image;
[0294] The blending transition weight is determined based on the distance transform image.
[0295] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0296] Fig.11 900 is a block diagram of an electronic device according to an exemplary embodiment. For example, the device 900 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0297] Reference Fig.11 , device 900 may include one or more of the following components: a processing component 902 , a memory 904 , a power component 906 , a multimedia component 908 , an audio component 910 , an input / output (I / O) interface 912 , a sensor component 914 , and a communication component 916 .
[0298] The processing component 902 generally controls the overall operation of the device 900, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 902 may include one or more processors 920 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 902 may include one or more modules to facilitate the interaction between the processing component 902 and other components. For example, the processing component 902 may include a multimedia module to facilitate the interaction between the multimedia component 908 and the processing component 902.
[0299] The memory 904 is configured to store various types of data to support operations on the device 900. Examples of such data include instructions for any application or method operating on the device 900, contact data, phone book data, messages, pictures, videos, etc. The memory 904 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0300] The power supply component 906 provides power to the various components of the device 900. The power supply component 906 can include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 900.
[0301] The multimedia component 908 includes a screen that provides an output interface between the device 900 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 908 includes a front camera and / or a rear camera. When the device 900 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0302] The audio component 910 is configured to output and / or input audio signals. For example, the audio component 910 includes a microphone (MIC), and when the device 900 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 904 or sent via the communication component 916. In some embodiments, the audio component 910 also includes a speaker for outputting audio signals.
[0303] I / O interface 912 provides an interface between processing component 902 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0304] The sensor assembly 914 includes one or more sensors for providing various aspects of status assessment for the device 900. For example, the sensor assembly 914 can detect the open / closed state of the device 900, the relative positioning of components, such as the display and keypad of the device 900, and the sensor assembly 914 can also detect the position change of the device 900 or a component of the device 900, the presence or absence of user contact with the device 900, the orientation or acceleration / deceleration of the device 900, and the temperature change of the device 900. The sensor assembly 914 can also include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 914 can also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 914 can also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0305] The communication component 916 is configured to facilitate wired or wireless communication between the device 900 and other devices. The device 900 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, 4G or 5G or a combination thereof. In an exemplary embodiment, the communication component 916 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 916 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0306] In an exemplary embodiment, the device 900 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0307] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 904 including instructions, and the instructions can be executed by the processor 920 of the device 900 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0308] In an exemplary embodiment, a chip is also provided, including a processor and an interface;
[0309] The processor is used to read instructions through the interface to execute the above method.
[0310] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the disclosure disclosed herein. The present disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0311] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. An image fusion processing method, characterized in that: The method comprises: Acquire a first image and a second image, wherein the first image is acquired by a first camera of the electronic device, and the second image is acquired by a second camera of the electronic device, and a field of view angle of the first camera is greater than a field of view angle of the second camera; determining a corresponding optical flow image based on the first image and the second image; Determine a fusion mask image based on the optical flow image, where the fusion mask image is used to indicate a fusion area and a non-fusion area in the fusion image; The first image and the second image are fused based on the fused area, the non-fused area and the optical flow image to obtain the fused image.
2. The method according to claim 1, characterized in that The step of determining a fused mask image based on the optical flow image comprises: Determining optical flow change information of the optical flow image; A fused mask image is determined based on the optical flow image and the optical flow change information.
3. The method according to claim 2, characterized in that The determining of the optical flow change information of the optical flow image includes: For each point in the optical flow image, determining a first optical flow value difference between two points at a set distance from each point in a first set direction of each point, and a second optical flow value difference between two points at a set distance from each point in a second set direction of each point, wherein the first set direction is a direction parallel to a target optical flow direction, and the second set direction is a direction perpendicular to the target optical flow direction, and the target optical flow direction is determined based on a central direction corresponding to a pre-divided direction interval to which an actual optical flow direction of each point belongs; The optical flow change information of each point is determined based on the first optical flow value difference and the second optical flow value difference.
4. The method according to claim 2, characterized in that: The fused mask image includes a first indication area and a second indication area, the first indication area is used to indicate a fused area of the fused image, and the second indication area is used to indicate a non-fused area of the fused image; The determining of the fused mask image based on the optical flow image and the optical flow change information includes: An objective function is constructed based on the optical flow image and the optical flow change information, wherein the objective function includes a first residual term, a second residual term and a third residual term, wherein the first residual term is used to generate a first penalty value based on a Gaussian function of the optical flow change information corresponding to each point in the fused mask image, so as to limit the first indication area to a position where the optical flow change information is smaller, and limit the second indication area to a position where the optical flow change information is larger; the second residual term is used to generate a second penalty value based on a preset constant or variable, so as to limit the first indication area to a position where the optical flow value is smaller, and the optical flow value is determined based on the optical flow vector in the optical flow image; the third residual term is used to generate a third penalty value based on the optical flow change information corresponding to each point in the fused mask image and the optical flow change information of the adjacent points of each point, so as to improve the smoothness and / or continuity of the first indication area and the second indication area; The objective function is solved based on a preset function solving algorithm to obtain the fused mask image.
5. The method according to claim 1, characterized in that The method further comprises: Correcting the optical flow image to obtain a corrected optical flow image; The fusing the first image and the second image based on the fused area, the non-fused area and the optical flow image includes: The first image and the second image are fused based on the fused area, the non-fused area and the corrected optical flow image.
6. The method according to claim 5, characterized in that The correcting the optical flow image comprises: Determine a gradient value corresponding to each pixel position in the first image; The optical flow value corresponding to the first pixel position whose gradient information is greater than the set gradient threshold is corrected.
7. The method according to claim 6, characterized in that The correcting of the optical flow value corresponding to the first pixel position whose gradient information is greater than the set gradient threshold comprises: Calculating an angle between a gradient vector of at least one target pixel in a target window and a gradient vector of the first pixel, wherein the target window is a window of a preset size centered at the first pixel position in the first image, and the at least one target pixel includes a pixel in the target window whose gradient value is greater than the set gradient threshold; A Gaussian weighted average of the optical flow values corresponding to the at least one target pixel is determined based on the angle and used as the corrected optical flow value corresponding to the first pixel position.
8. The method according to claim 1 or 5, characterized in that: The fusing the first image and the second image based on the fused area, the non-fused area and the optical flow image to obtain the fused image includes: Affine transforming the second image into a coordinate system of the first image based on the optical flow image to obtain a third image; The first image and the third image are fused based on the fused area and the non-fused area to obtain the fused image.
9. The method according to claim 8, characterized in that The fused mask image includes a first indication area and a second indication area, the first indication area is used to indicate a fused area of the fused image, and the second indication area is used to indicate a non-fused area of the fused image; The fusing the first image and the third image based on the fused area and the non-fused area to obtain the fused image includes: In a fusion region of the fusion image, retaining pixel values of the third image; In the non-fused area of the fused image, the pixel values of the first image are retained.
10. The method according to claim 9, characterized in that The first indication area also includes a preset fusion transition area, and the preset fusion transition area is used to indicate the fusion transition area in the fusion area; The retaining the pixel value of the third image in the fusion area of the fusion image comprises: In a fusion transition region in the fusion region, a fusion pixel value is retained, and the fusion pixel value is obtained by fusing the pixel value of the first image and the pixel value of the third image using a predetermined fusion transition weight.
11. The method according to claim 10, characterized in that The method further includes determining the fusion transition weight in advance based on the following manner: performing distance transformation on the second indication area in the fused mask image to obtain a distance transformation image; The blending transition weight is determined based on the distance transform image.
12. An image fusion processing device, characterized in that: The device comprises: An image acquisition module, used to acquire a first image and a second image, wherein the first image is acquired by a first camera of the electronic device, and the second image is acquired by a second camera of the electronic device, and the field of view of the first camera is greater than the field of view of the second camera; an optical flow determination module, configured to determine a corresponding optical flow image based on the first image and the second image; A mask determination module, used to determine a fused mask image based on the optical flow image, wherein the fused mask image is used to indicate a fused area and a non-fused area in the fused image; An image fusion module is used to fuse the first image and the second image based on the fusion area, the non-fusion area and the optical flow image to obtain the fusion image.
13. The device according to claim 12, characterized in that The mask determination module comprises: an information determining unit, configured to determine optical flow change information of the optical flow image; A mask determining unit is used to determine a fused mask image based on the optical flow image and the optical flow change information.
14. The device according to claim 13, characterized in that The information determination unit is also used for: For each point in the optical flow image, determining a first optical flow value difference between two points at a set distance from each point in a first set direction of each point, and a second optical flow value difference between two points at a set distance from each point in a second set direction of each point, wherein the first set direction is a direction parallel to a target optical flow direction, and the second set direction is a direction perpendicular to the target optical flow direction, and the target optical flow direction is determined based on a central direction corresponding to a pre-divided direction interval to which an actual optical flow direction of each point belongs; The optical flow change information of each point is determined based on the first optical flow value difference and the second optical flow value difference.
15. The device according to claim 13, characterized in that The fused mask image includes a first indication area and a second indication area, the first indication area is used to indicate a fused area of the fused image, and the second indication area is used to indicate a non-fused area of the fused image; The mask determination unit is further configured to: An objective function is constructed based on the optical flow image and the optical flow change information, wherein the objective function includes a first residual term, a second residual term and a third residual term, wherein the first residual term is used to generate a first penalty value based on a Gaussian function of the optical flow change information corresponding to each point in the fused mask image, so as to limit the first indication area to a position where the optical flow change information is smaller, and limit the second indication area to a position where the optical flow change information is larger; the second residual term is used to generate a second penalty value based on a preset constant or variable, so as to limit the first indication area to a position where the optical flow value is smaller, and the optical flow value is determined based on the optical flow vector in the optical flow image; the third residual term is used to generate a third penalty value based on the optical flow change information corresponding to each point in the fused mask image and the optical flow change information of the adjacent points of each point, so as to improve the smoothness and / or continuity of the first indication area and the second indication area; The objective function is solved based on a preset function solving algorithm to obtain the fused mask image.
16. The device according to claim 12, characterized in that The device also includes: An optical flow correction module, used to correct the optical flow image to obtain a corrected optical flow image; The image fusion module is further used to perform fusion processing on the first image and the second image based on the fusion area, the non-fusion area and the corrected optical flow image.
17. The device according to claim 16, characterized in that The optical flow correction module comprises: a gradient determination unit, configured to determine a gradient value corresponding to each pixel position in the first image; The optical flow correction unit is used to correct the optical flow value corresponding to the first pixel position whose gradient information is greater than a set gradient threshold.
18. The device according to claim 17, characterized in that The optical flow correction unit is also used for: Calculating an angle between a gradient vector of at least one target pixel in a target window and a gradient vector of the first pixel, wherein the target window is a window of a preset size centered at the first pixel position in the first image, and the at least one target pixel includes a pixel in the target window whose gradient value is greater than the set gradient threshold; A Gaussian weighted average of the optical flow values corresponding to the at least one target pixel is determined based on the angle and used as the corrected optical flow value corresponding to the first pixel position.
19. The device according to claim 12 or 16, characterized in that The image fusion module comprises: An image transformation unit, configured to affine transform the second image into a coordinate system of the first image based on the optical flow image to obtain a third image; An image fusion unit is used to fuse the first image and the third image based on the fusion area and the non-fusion area to obtain the fused image.
20. The device according to claim 19, characterized in that The fused mask image includes a first indication area and a second indication area, the first indication area is used to indicate a fused area of the fused image, and the second indication area is used to indicate a non-fused area of the fused image; The image fusion unit is also used for: In a fusion region of the fusion image, retaining pixel values of the third image; In the non-fused area of the fused image, the pixel values of the first image are retained.
21. The device according to claim 20, characterized in that The first indication area also includes a preset fusion transition area, and the preset fusion transition area is used to indicate the fusion transition area in the fusion area; The image fusion unit is further used to retain a fusion pixel value in a fusion transition area in the fusion area, where the fusion pixel value is obtained by fusing the pixel value of the first image with the pixel value of the third image using a predetermined fusion transition weight.
22. The device according to claim 21, characterized in that The image fusion module also includes a transition weight determination unit; The transition weight determination unit is used to: performing distance transformation on the second indication area in the fused mask image to obtain a distance transformation image; The blending transition weight is determined based on the distance transform image.
23. An electronic device, characterized in that: The device comprises: A first camera, a second camera, a processor, and a memory for storing a computer program, wherein a field of view of the first camera is greater than a field of view of the second camera; Wherein, the processor is configured to implement, when executing the computer program: Acquire a first image and a second image, where the first image is acquired by the first camera and the second image is acquired by the second camera; determining a corresponding optical flow image based on the first image and the second image; Determine a fusion mask image based on the optical flow image, where the fusion mask image is used to indicate a fusion area and a non-fusion area in the fusion image; The first image and the second image are fused based on the fused area, the non-fused area and the optical flow image to obtain the fused image.
24. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by the processor, it realizes: Acquire a first image and a second image, wherein the first image is acquired by a first camera of the electronic device, and the second image is acquired by a second camera of the electronic device, and a field of view angle of the first camera is greater than a field of view angle of the second camera; determining a corresponding optical flow image based on the first image and the second image; Determine a fusion mask image based on the optical flow image, where the fusion mask image is used to indicate a fusion area and a non-fusion area in the fusion image; The first image and the second image are fused based on the fused area, the non-fused area and the optical flow image to obtain the fused image.
25. A chip, characterized in that: include: Processors and interfaces; The processor is used to read instructions through the interface to execute the image fusion processing method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Image merging method and apparatus
CN106803899A
Image processing method and device, electronic equipment and storage medium
CN109615593A
Image processing method and device, electronic equipment and storage medium
CN112581415A
Image fusion method and device for double-camera shooting, and electronic system
CN113592777A
Image fusion processing method and device and electronic system
CN115115568A
Cited By
Image processing method and device, equipment and storage medium
CN122089789A
