Image fusion method and device, electronic equipment and storage medium
By performing pixel sampling and parameter analysis on the image, dynamically identifying and processing different pixel points in the image, the problem of poor image fusion effect in the prior art is solved, and a more natural and efficient image fusion effect is achieved.
Patent Information
- Application Number
- CN202411656914.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2044-11-19
AI Technical Summary
In the prior art, image fusion requires the user to manually set the fusion parameters, which makes the final effect difficult to meet the needs of use and is prone to stiff splicing traces.
By sampling the initial insertion image pixels to obtain primary color channel values, determine color parameters and spatial dispersion, dynamically identify reference pixel points, background pixel points and foreground pixel points, and correct the transparency of background pixel points to generate target insertion images to achieve natural image fusion.
It improves the quality and visual effect of image fusion, avoids stiff splicing traces, realizes instant fusion of images and expands application scenarios, and improves the applicability and immediacy of image fusion.
Smart Images

Figure CN119671874A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer graphics, and in particular to an image fusion method, device, electronic device and storage medium. Background Art
[0002] With the continuous development of computer image processing technology, image fusion has been widely used in many industries as a solution that can fuse different media videos. In related technologies, in order to achieve the fusion of different media videos, users are often required to manually set the fusion parameters, resulting in the final image fusion effect failing to meet usage requirements. Summary of the invention
[0003] This application provides an image fusion method, device, electronic device and storage medium, which aims to perform real-time dynamic control of electronic devices, thereby improving driving safety. The technical solution is as follows:
[0004] In a first aspect, the present application provides an image fusion method, comprising: acquiring an initial insertion image and a target image, performing pixel sampling on the initial insertion image to obtain primary color channel values of each pixel in the initial insertion image; determining the color parameters of each pixel based on the primary color channel values of each pixel; determining the spatial dispersion of each pixel based on the primary color channel values of each pixel and the position information of each pixel in the initial insertion image; determining a reference pixel among each pixel based on the color parameter and the spatial dispersion; determining background pixels and foreground pixels among each pixel based on the chromaticity difference between each pixel and the reference pixel; correcting the transparency of the background pixels to the target transparency, and generating a target insertion image based on the background pixels and foreground pixels of the target transparency; and inserting the target insertion image into a preset insertion position of the target image.
[0005] In the above technical solution, by sampling the pixels of the initial inserted image to obtain the primary color channel values and determine the color parameters and spatial dispersion, it is possible to comprehensively analyze the image features from the two key dimensions of color and spatial distribution. Based on this, the reference pixels are determined and the background pixels and foreground pixels are distinguished, so that the key elements and background parts in the image can be accurately identified, providing data support for subsequent image processing. The correction of the transparency of the background pixels and the process of generating the target inserted image can make the inserted image and the target image more natural and harmonious when fused, avoiding the appearance of abrupt splicing marks, thereby effectively improving the quality and visual effect of image synthesis. Finally, the target inserted image is inserted into the preset position of the target image, realizing the instant fusion of the image and expanding the application scenarios, thereby improving the applicability and immediacy of image fusion.
[0006] In combination with the first aspect, in some possible implementations, pixel sampling is performed on the initial inserted image to obtain the primary color channel value of each pixel in the initial inserted image, including: dividing the inserted image into multiple sub-images of preset sizes, each sub-image containing at least one pixel; selecting a preset number of pixels from each sub-image; and performing color quantization on each pixel based on a preset color quantization algorithm to determine the primary color channel value of each pixel.
[0007] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, color quantization is performed on each pixel based on a preset color quantization algorithm to determine the primary color channel value corresponding to each pixel, including: obtaining an initial primary color channel value of a first pixel among each pixel, where the first pixel is any pixel among each pixel; converting the initial primary color channel value into binary data, and saving the binary data in layers to obtain a color quantization parameter of the first pixel; obtaining a quantization parameter set corresponding to the color quantization parameter, and determining the primary color channel value corresponding to the quantization parameter set as the primary color channel value of the first pixel.
[0008] In the above technical solution, by dividing the initial inserted image into multiple sub-images, the image can be processed in blocks, which greatly reduces the amount of data processed at one time and reduces the calculation burden and memory usage of the system. At the same time, only a preset number of pixels are selected from each sub-image for processing, which further reduces the amount of calculation, so that the entire color quantization process can be completed in a shorter time, especially when facing high-resolution images or scenes that require real-time image processing, the processing speed can be significantly improved to meet the needs of immediacy. By converting the initial primary color channel values into binary data and saving them in layers, the color information distortion caused by the accumulation of errors in the data format conversion or calculation process can be avoided. Furthermore, the color information can be hierarchically managed and called according to different needs and accuracy requirements through the layered storage method, so as to reduce the storage space occupied and improve the efficiency of the image during storage and transmission.
[0009] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, the color parameters of each pixel are determined based on the primary color channel values of each pixel, including: determining the maximum primary color value and the minimum primary color value of the first pixel in the primary color channel values of the first pixel; determining the color saturation of the first pixel based on the maximum primary color value and the minimum primary color value; determining the color brightness value of the first pixel based on the primary color channel values of the first pixel and the weight values of each primary color channel.
[0010] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, the spatial dispersion of each pixel point is determined based on the primary color channel value and the position information of each pixel point in the initial insertion image, including: obtaining the average position information of the primary color channel value of the first pixel point in the initial insertion image; based on the average position information and the first position information of the first pixel point in the initial insertion image, determining the spatial dispersion of the first pixel point.
[0011] In the above technical solution, by analyzing the primary color channel value of the first pixel, its maximum primary color value and minimum primary color value are determined, and then the color saturation of the first pixel is calculated based on these two values. At the same time, by combining the primary color channel value of the first pixel and the weight value of each primary color channel, the color brightness value of the pixel can be determined, thereby providing an important basis for subsequent color parameter analysis. The spatial dispersion of the pixel is determined by obtaining the average position information of the primary color channel value of the first pixel in the initial insertion image and comparing it with the actual position information of the first pixel in the initial insertion image. This process helps to evaluate the distribution of pixels in the entire image and provides key information for subsequent pixel classification and image processing. The accuracy of image fusion is improved by accurately calculating the color saturation, color brightness value and spatial dispersion of the first pixel.
[0012] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, before determining the spatial dispersion of each pixel point based on the primary color channel value and the position information of each pixel point in the initial insertion image, it also includes: classifying the primary color channel value of each pixel point to obtain a primary color channel value set; in each pixel point, obtaining a pixel point set corresponding to a target primary color channel value in the primary color channel value set, the target primary color channel value being any primary color channel value in the primary color channel value set; and determining the average position information of the target primary color channel value based on the second position information of each second pixel point in the pixel point set in the initial insertion image.
[0013] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, a reference pixel is determined among each pixel based on color parameters and spatial dispersion, including: inputting the color saturation, color brightness value and spatial dispersion of the first pixel into a pre-trained weight analysis model to obtain a saturation weight, a brightness value weight and a dispersion weight; determining the pixel score of the first pixel based on the color saturation, color brightness value, spatial dispersion and the saturation weight, brightness value weight and dispersion weight of the first pixel; and determining the third pixel with the largest pixel score among each pixel as the reference pixel.
[0014] In the above technical solution, by carefully classifying the primary color channel values of each pixel, this method can accurately identify and organize the color information in the image, thereby ensuring the accuracy of color classification. Furthermore, the average position of the target primary color channel value is calculated using the position information of the pixel, thereby enhancing the accuracy of color distribution analysis. In addition, by applying a pre-trained weight analysis model, this method dynamically evaluates the importance of the color saturation, brightness value and spatial dispersion of each pixel, thereby assigning a reasonable weight to each pixel. This weight-based pixel score calculation method not only improves the accuracy of pixel selection, but also makes the entire image processing process more efficient and intelligent. Finally, by selecting the pixel with the highest pixel score as the reference point, this method can optimize the calculation process while ensuring the accuracy of the processing result, thereby improving the immediacy of image fusion.
[0015] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, it also includes: obtaining the number of occurrences of the primary color channel value of the first pixel point during the pixel traversal process; obtaining the number of occurrences corresponding to the number of occurrences based on the weight analysis model; determining the pixel score of the first pixel point based on the color saturation, color brightness value, spatial dispersion, saturation weight, brightness value weight, and dispersion weight of the first pixel point, including: determining the pixel score of the first pixel point based on the color saturation, color brightness value, spatial dispersion, number of occurrences, saturation weight, brightness value weight, dispersion weight, and number of weights of the first pixel point.
[0016] In the above technical solution, by counting the number of times the primary color channel value of the first pixel appears in the entire pixel traversal process, and using the weight analysis model to obtain the number of times weight corresponding to the number of times, the solution not only considers the color attributes of the pixel (such as saturation, brightness value and spatial dispersion), but also introduces the information of the frequency of occurrence of the pixel, thereby providing a more comprehensive evaluation for each pixel. When determining the pixel score of the first pixel, the color saturation, brightness value, spatial dispersion and their weights are combined, and the number of times the pixel appears and its corresponding weight are also considered, thereby improving the accuracy and efficiency of image processing.
[0017] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, background pixels and foreground pixels are determined in each pixel based on the chromaticity difference between each pixel and the reference pixel, including: determining the color similarity between each pixel in the initial inserted image and the reference pixel; if the color similarity is less than a preset similarity threshold, determining the pixel as a foreground pixel; if the color similarity is greater than or equal to the preset similarity threshold, determining the pixel as a background pixel.
[0018] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, the transparency of the background pixel is corrected to the target transparency, including: determining the saturation overflow value and the grayscale overflow value of the background pixel based on the color similarity between the background pixel and the reference pixel; based on the saturation overflow value and the grayscale overflow value, generating a saturation smoothing mask of the background pixel, and correcting the transparency of the background pixel to the target transparency based on the saturation smoothing mask.
[0019] In the above technical scheme, by calculating the color similarity between each pixel in the inserted image and the reference pixel and comparing the color similarity with the preset similarity threshold, the pixels can be effectively distinguished as foreground pixels and background pixels, so as to accurately identify the foreground object and background in the initial image. For the pixels identified as the background, the method further determines the saturation overflow value and the grayscale overflow value based on the color similarity between the pixels and the reference pixel. These overflow values reflect the degree of difference between the background pixels and the reference pixels in color, and can accurately adjust the color attributes of the background pixels. The saturation smoothing mask is generated by the calculated saturation overflow value and grayscale overflow value to correct the transparency of the background pixels to the target transparency, thereby improving the accuracy of image fusion.
[0020] In a second aspect, the present application provides an image fusion device, comprising:
[0021] An image acquisition unit is used to acquire an initial insertion image and a target image, perform pixel sampling on the initial insertion image, and obtain a primary color channel value of each pixel point in the initial insertion image;
[0022] A color acquisition unit, used to determine the color parameter of each pixel based on the primary color channel value of each pixel;
[0023] A dispersion acquisition unit, used to determine the spatial dispersion of each pixel based on the original color channel value of each pixel and the position information of each pixel in the initial insertion image;
[0024] A pixel point determination unit, used for determining a reference pixel point among the pixels based on a color parameter and a spatial dispersion;
[0025] A chromaticity comparison unit, used to determine background pixels and foreground pixels in each pixel based on the chromaticity difference between each pixel and the reference pixel;
[0026] A correction unit, used for correcting the transparency of the background pixel points to a target transparency, and generating a target insertion image based on the background pixel points and foreground pixel points of the target transparency;
[0027] The inserting unit is used to insert the target insertion image into a preset insertion position of the target image.
[0028] In a third aspect, the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, any of the above image fusion methods is implemented.
[0029] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed, any of the above image fusion methods is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0031] Figure 1 is a system architecture diagram of an image fusion method provided in an embodiment of the present application;
[0032] Figure 2 It is a flowchart of an image fusion method provided in an embodiment of the present application;
[0033] Figure 3 It is a flowchart of an image fusion method provided in an embodiment of the present application;
[0034] Figure 4 is a scene schematic diagram of an image fusion method provided in an embodiment of the present application;
[0035] Figure 5 It is a flowchart of an image fusion method provided in an embodiment of the present application;
[0036] Figure 6 It is a flowchart of an image fusion method provided in an embodiment of the present application;
[0037] Figure 7 It is a flowchart of an image fusion method provided in an embodiment of the present application;
[0038] Figure 8 It is a flowchart of an image fusion method provided in an embodiment of the present application;
[0039] Fig. 9 It is a flowchart of an image fusion method provided in an embodiment of the present application;
[0040] Fig.10 is a scene schematic diagram of an image fusion method provided in an embodiment of the present application;
[0041] Fig.11 is a scene schematic diagram of an image fusion method provided in an embodiment of the present application;
[0042] Fig.12 is a structural schematic diagram of an image fusion device provided in an embodiment of the present application;
[0043] Fig.13 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0044] In order to make the features and advantages of the present application more obvious and easy to understand, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0045] The technical solution in the present application will be described clearly and in detail below in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B: "and / or" in the text is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0046] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features.
[0047] In the related art, when performing image fusion, the user needs to manually select the background color. Then, the process of manually selecting the background color is not only time-consuming but also requires certain professional skills of the user. If the background color is not selected properly, it will lead to poor fusion effect, such as blurred edges, background residue and other problems, thus affecting the quality of the final image or video.
[0048] In order to improve the applicability and immediacy of image fusion, the present application embodiment provides an image fusion method, and the execution subject of the image fusion method is a terminal device or a server. The following are detailed descriptions respectively. It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments. Figure 1 , Figure 1 This is a system architecture diagram of an image fusion method provided in an embodiment of the present application. The specific process of the image fusion method can be as follows:
[0049] Figure 1 It is a system architecture diagram of an image fusion method provided in an embodiment of the present application, wherein the system architecture includes a terminal device 140, the Internet 130, a gateway 120, a server 110, and the like.
[0050] The terminal device 140 includes but is not limited to mobile phones, computers, intelligent voice interaction devices, etc. The embodiments of the present application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, etc. In addition, it can be a single device or a combination of multiple devices. For example, multiple desktop computers are interconnected through a local area network, share a display, etc. to work together, and together constitute a terminal device 140. The terminal device 140 can communicate with the Internet 130 in a wired or wireless manner to exchange data.
[0051] The server 110 refers to a computer system that can provide certain services to the terminal device 140. Compared with the ordinary terminal device 140, the server 110 has higher requirements in terms of stability, security, performance, etc. The server 110 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
[0052] The gateway 120 is also called an internetwork connector or a protocol converter. The gateway realizes network interconnection at the transport layer and is a computer system or device that acts as a converter. The gateway is a translator between two systems that use different communication protocols, data formats or languages, or even completely different architectures. At the same time, the gateway can also provide filtering and security functions. The message sent by the terminal device 140 to the server 110 must be sent to the corresponding server 110 through the gateway 120. The message sent by the server 110 to the terminal device 140 must also be sent to the corresponding terminal device 140 through the gateway 120.
[0053] In the embodiment of the present application, both the terminal device and the server run a preset image fusion application, which is used to fuse two or more images. When the server is the execution subject of this solution, the server will receive a video data fusion request sent from the terminal device, and based on the preset image fusion application, fuse the video data uploaded by the terminal device and return the video stream data to the terminal device in real time. After receiving the video stream data returned by the server, the terminal device performs a video broadcast display. When the terminal device is the execution subject of this solution, the image fusion task is performed by the preset image fusion application running in the terminal device. Specifically, the terminal device receives the images to be fused input by the user, or obtains these images from local storage or network resources. Then, the image fusion application on the terminal device will fuse these images according to the preset algorithm and parameters to generate a new fused image. After the processing is completed, the terminal device can directly display the fused image, or send the fused image data to other devices or platforms for further processing or sharing.
[0054] In addition, whether the image fusion task is performed on the server or the terminal device, the preset image fusion application should be highly flexible and scalable to support image inputs of different formats, resolutions and quantities, and be able to adjust the fusion algorithm and parameters of the image fusion application according to actual needs to obtain the best fusion effect.
[0055] Specifically, the processing objects of the image fusion application include the initial insertion image and the target image. The initial insertion image is a frame of the video selected by the user to be inserted, and the target image can be a frame of the real-time video. The initial insertion image is sampled by a preset pixel sampling algorithm. After the sampling is detected, the preset pixel color quantization algorithm is called to quantize the color of each pixel. After the quantization is completed, each pixel is traversed to determine the number of occurrences, color saturation, color brightness and spatial dispersion of the color corresponding to the primary color channel value of each pixel.
[0056] The pre-trained weight analysis model is used to calculate the weight analysis of the number of occurrences, color saturation, color brightness and spatial dispersion of the color corresponding to the primary color channel value of each pixel point, and the number of occurrences weight, saturation weight, brightness value weight and dispersion weight are obtained. The number of occurrences, color saturation, color brightness and spatial dispersion and the number of occurrences weight, saturation weight, brightness value weight and dispersion weight are substituted into the pixel score calculation formula to obtain the pixel score of each pixel point. The pixel point with the largest pixel score is determined and determined as the reference pixel point, that is, the color key of the initial inserted image is obtained.
[0057] After obtaining the reference pixel points, the pixel points of the entire initial insertion image are traversed to determine the color similarity between each pixel point and the reference pixel point, and the pixel points whose color similarity is greater than or equal to the preset similarity threshold are determined as background pixel points, and the pixel points whose color similarity is less than the preset similarity threshold are determined as foreground pixel points. At the same time, the saturation overflow value and grayscale overflow value of the background pixel points are determined by the color similarity, and the transparency of the background pixel points is adjusted to the target transparency by the saturation overflow value and the grayscale overflow value and combined with the foreground pixel points to generate a target insertion image, and the target insertion image is inserted into the preset insertion position of the target image.
[0058] based on Figure 1 The system architecture diagram shown below will be combined with Figure 2-Figure 10 , an image fusion method provided in an embodiment of the present application is introduced in detail.
[0059] Based on the above situation, the present application embodiment proposes an image fusion method. Figure 2 , Figure 2 FIG. 1 is a flow chart of an image fusion method provided in an embodiment of the present application. Figure 2 As shown, the method of the embodiment of the present application may include the following steps S101-step S101.
[0060] S101, obtaining an initial insertion image and a target image, performing pixel sampling on the initial insertion image, and obtaining a primary color channel value of each pixel point in the initial insertion image.
[0061] In the embodiment of the present application, the initial insertion image is a frame of the video to be inserted that is pre-selected by the user, and the target image is a frame of the real-time video of the real scene. Each pixel in the initial insertion image contains the values of the three primary color channels of red, green, and blue. According to a predetermined sampling algorithm, the initial image is divided into sub-images of a preset number of sizes, and a preset number of pixels are selected from each sub-image, and the primary color channel value of each pixel is recorded at the same time. The primary color channel value is usually expressed in the form of an integer, ranging from 0 to 255, corresponding to the depth of the color.
[0062] Specifically, a preset pixel sampling algorithm including but not limited to a Poisson-Disk random sampling algorithm is used to divide the initial insertion image according to a preset grid size to obtain multiple sub-images of the same size. In each sub-image, a pixel is randomly selected as the target pixel of the sub-image. After random sampling, the number of pixels collected is only about N / 16, thereby reducing data redundancy and reducing the amount of data to be processed subsequently.
[0063] It should be noted that each pixel is usually composed of three color channels: red (R), green (G), and blue (B), and each channel can have 256 different brightness levels (from 0 to 255). Therefore, each pixel can be represented as (R, G, B), where R, G, and B are all integers between 0 and 255.
[0064] Since each channel has 256 possible values, the total number of combinations of the three channels is 1677721. In order to reduce the number of colors and the amount of data, in this embodiment, the original color value of each pixel in the initial insertion image is traversed through the octree color quantization algorithm, and each original color value is converted into binary data and assigned to the leaf node in the octree, so as to reduce the number of colors of each pixel from 16,777,216 to 262144, thereby significantly reducing memory usage and computational complexity while still maintaining the basic visual quality of the image.
[0065] The primary color channel value of each pixel is obtained and color quantization processing is performed to obtain the color quantization parameter corresponding to each pixel, and the quantization parameter set corresponding to the color quantization parameter is further determined. There are multiple range intervals of color quantization parameters in the quantization parameter set, which are used to determine the parameter range interval corresponding to the color quantization parameter, so as to determine the primary color channel value corresponding to the color interval as the primary color channel value of each pixel.
[0066] S102, determining a color parameter of each pixel based on the primary color channel value of each pixel.
[0067] In the embodiment of the present application, the color parameters include color saturation and color brightness value, wherein saturation refers to the vividness of the color, that is, the purity or intensity of the color. It indicates the distance of the color position on the color wheel from the center point. The higher the saturation, the brighter the color; the lower the saturation, the closer the color is to gray. The color brightness value refers to the lightness and darkness of the color, describing the brightness or dullness of the color. In the RGB color model, brightness can be obtained by calculating the weighted average of the three RGB channels, where the weight of each channel reflects the sensitivity of the human eye to different colors.
[0068] Specifically, the red, green, and blue channel values of each pixel are extracted from the primary color channel values of each pixel, and the maximum brightness and minimum brightness corresponding to the red, green, and blue channel values are found respectively. The brightness difference between the maximum brightness and the minimum brightness is calculated, and the brightness difference is further divided by the maximum brightness to obtain the color saturation of each pixel.
[0069] The maximum brightness value corresponding to the red, green and blue channels of each pixel is extracted from the primary color channel value of each pixel, and the color brightness value of each pixel is obtained by adding the maximum brightness values.
[0070] S103, determining the spatial dispersion of each pixel based on the primary color channel value of each pixel and the position information of each pixel in the initial insertion image.
[0071] Specifically, the coordinate values of the original color channel values of all pixels in the preset area of each pixel are traversed, and the coordinate values are accumulated and divided by the total number of pixels in the neighborhood to obtain the average position information, and the actual coordinate position and the average position information of the currently traversed pixel are further substituted into the Euclidean distance formula to obtain the Euclidean distance of the current pixel, and the Euclidean distance is used as the spatial dispersion of the current pixel.
[0072] S104: Determine a reference pixel point among the pixels based on the color parameter and the spatial dispersion.
[0073] Specifically, after obtaining the color saturation, color brightness value and spatial dispersion corresponding to each pixel point in S102-S103, the color saturation, color brightness value and spatial dispersion are output to a pre-trained weight analysis model to obtain the saturation weight corresponding to the color saturation, the brightness value weight corresponding to the color brightness value and the dispersion weight corresponding to the spatial dispersion. At the same time, the number of occurrences of the primary color channel value corresponding to the currently traversed pixel point in the entire traversal process is determined, and the number of occurrences is input into the weight analysis model to obtain the number of weights corresponding to the number of occurrences.
[0074] The color saturation, color brightness value, spatial dispersion, number of occurrences of each pixel point, as well as the saturation weight, the brightness value weight, the dispersion weight, and the number weight are combined and calculated to obtain the pixel score corresponding to each pixel point, and the pixel point with the largest pixel score is determined as the reference pixel point.
[0075] S105 , determining background pixels and foreground pixels in each pixel based on the chromaticity difference between each pixel and the reference pixel.
[0076] Specifically, the color of each pixel is traversed, and the color of each pixel and the original color channel value of the reference pixel are converted into the chromaticity space, and then the chromaticity difference between each pixel and the reference pixel is obtained, wherein the chromaticity space is a mathematical method for representing color, and the basic parameters representing color are used to describe and then record the color. The color in the space is specified by three-dimensional coordinates representing three color attribute parameters.
[0077] The similarity between each pixel and the green screen color is determined by calculating the vector length of the chromaticity difference, i.e., the chromaticity distance; based on a preset similarity threshold and the calculated chromaticity distance and the color similarity of the reference pixel, if the color similarity is less than the preset similarity threshold, the pixel is determined as the foreground pixel; if the color similarity is greater than or equal to the preset similarity threshold, the pixel is determined as the background pixel.
[0078] S106, correcting the transparency of the background pixel points to a target transparency, and generating a target insertion image based on the background pixel points and foreground pixel points of the target transparency.
[0079] Specifically, the color similarity between each background pixel and the reference pixel is obtained, and it is determined whether the color similarity of each background pixel falls within a preset color similarity range interval, so as to obtain the saturation overflow value and the grayscale overflow value corresponding to the color similarity range interval, and further determine the preset saturation adjustment parameter corresponding to the saturation overflow value and the grayscale value adjustment parameter corresponding to the grayscale overflow value. A saturation smoothing mask corresponding to each background pixel is generated according to the saturation adjustment parameter and the grayscale value adjustment parameter. The saturation smoothing mask is applied to the transparency channel of each background pixel to correct the transparency of each background pixel, and a target insertion image is generated based on the background pixels and foreground pixels after the transparency correction is completed.
[0080] S107, inserting the target insertion image into a preset insertion position of the target image.
[0081] In the embodiment of the present application, the preset insertion position is determined by the user according to the actual scenario and is not specifically limited here.
[0082] Specifically, a preset insertion position marked by a user on a target image is obtained, the target insertion image is resized according to the size of the preset insertion position, and then the target insertion image is inserted into the preset insertion position of the target image.
[0083] Please also read Figure 3 , Figure 3 Schematic diagram of a scene of an image fusion method provided in an embodiment of the present application. Figure 3 As shown, the target image is a frame image of the real-time conference video. At this time, the background pixels of the initial inserted image are black. After the transparency correction is performed on the initial inserted image, a target inserted image with transparent background pixels is obtained, and the target inserted image is inserted into the target image for display.
[0084] As can be seen from the above, by sampling the pixels of the initial insertion image to obtain the primary color channel values and determine the color parameters and spatial dispersion, it is possible to comprehensively analyze the image features from the two key dimensions of color and spatial distribution. Based on this, the reference pixels are determined and the background pixels and foreground pixels are distinguished, which can accurately identify the key elements and background parts of the image, providing data support for subsequent image processing. The correction of the transparency of the background pixels and the process of generating the target insertion image can make the insertion image and the target image more natural and harmonious when fused, avoiding the appearance of abrupt splicing marks, thereby effectively improving the quality and visual effect of image synthesis. Finally, the target insertion image is inserted into the preset position of the target image, realizing the seamless fusion of the image and expanding the application scenarios, thereby improving the applicability and immediacy of image fusion.
[0085] Because a lot of redundant data will be generated when processing images, which will affect resource consumption. Figure 4 , Figure 4 FIG. 1 is a flow chart of an image fusion method provided in an embodiment of the present application. Figure 4 As shown, the method of the embodiment of the present application may include the following steps S201-S206.
[0086] S201, dividing an initial insertion image into a plurality of sub-images of preset sizes, each of which has at least one pixel.
[0087] In an embodiment of the present application, a preset pixel sampling algorithm including but not limited to a Poisson-Disk Sampling algorithm may be used to divide the initial insertion image according to a preset grid size, wherein the number of divisions and the size of the division granularity may be set according to the actual scenario and are not specifically limited here.
[0088] Specifically, the initial insertion image is divided into a plurality of sub-images according to a preset division number or division size. For example, the initial insertion image is divided into 88 sub-images of a size of 4*4.
[0089] S202: Select a preset number of pixels from each sub-image.
[0090] Specifically, each sub-image is traversed, and a preset number of pixels are selected from each sub-image using a random selection strategy, wherein the preset number is set by the user according to actual needs and is not specifically limited here. For example, the preset number of pixels is 1, and there are 4 sub-images, namely sub-image A, sub-image B, sub-image C, and sub-image D. According to the preset number of pixels, 1 pixel is selected from sub-image A, sub-image B, sub-image C, and sub-image D, respectively, thereby reducing resource overhead.
[0091] Please also read Figure 5 , Figure 5 Schematic diagram of a scene of an image fusion method provided in an embodiment of the present application. Figure 5 As shown, the initial insertion image is divided into a plurality of square regions of a preset size, wherein each square region is a sub-image, and then a pixel point is randomly selected in the region of each sub-image as the target pixel point of the sub-image. Since only one pixel point is selected from each sub-image, the number of pixel points collected in the entire initial insertion image will be greatly reduced to about 1 / 16 of the original number, thereby effectively reducing the number of pixels while maintaining image quality, thereby reducing the occupancy rate of storage space.
[0092] S203, performing color quantization on each pixel based on a preset color quantization algorithm to determine a primary color channel value of each pixel.
[0093] Specifically, please refer to the above step S101 for step S203, which will not be described in detail here.
[0094] S204, obtaining an initial primary color channel value of a first pixel among all the pixels, where the first pixel is any pixel among all the pixels.
[0095] Specifically, the coordinate value of the first pixel in the initial insertion image is located to obtain the primary color channel value corresponding to the first pixel, wherein each pixel is composed of three primary color channels of red, green and blue, which respectively represent the intensity of the pixel in red, green and blue light. Therefore, for the selected first pixel, the values of the red, green and blue channels are read respectively to obtain the initial primary color channel value of the first pixel.
[0096] For example, take an RGB initial insertion image with a resolution of 800×600 pixels as an example, and assume that the pixel (0, 0) located at the upper left corner of the initial insertion image is randomly selected as the first pixel. And the first pixel consists of three primary color channels: red (R), green (G), and blue (B). Use the corresponding image processing software or programming language library, such as the PIL library in Python, to locate the initial insertion image at this coordinate (0, 0). Then, read the values of the initial insertion image in the R channel as 200; the value in the G channel as 100; and the value in the B channel as 50, that is, the initial primary color channel values corresponding to the first pixel (0, 0) are R=200, G=100, and B=50. These values represent that the intensity of the first pixel in red light is 200, the intensity in green light is 100, and the intensity in blue light is 50.
[0097] S205 , converting the initial primary color channel value into binary data, and saving the binary data in layers to obtain a color quantization parameter of the first pixel.
[0098] Specifically, the initial primary color channel value of the first pixel, for example, R=200, G=100, B=50, is converted into binary data, that is, the R channel is 11001000, the G channel is 01100100, and the B channel is 00110010, and these binary data are arranged in order from high to low into a 24-bit binary number. Then the 24-bit binary number is divided into three layers, each with 8 bits, corresponding to the R, G, and B channels respectively. The octree color quantization algorithm is used to construct an octree to represent the color space in the image, and the color value of the first pixel is inserted into the corresponding node in the octree. By recursively inserting the color values of other pixels and performing node splitting and merging, the color quantization parameter of the first pixel is finally generated. In this process, it is necessary to check the number of colors in each node. If the number of colors exceeds a preset threshold, the node is merged into a representative color value. Finally, the node corresponding to the first pixel is found in the octree, and the representative color value of the node is obtained as the color quantization parameter of the first pixel. This method not only effectively reduces the number of colors in the image, but also maintains the overall visual effect of the image.
[0099] S206 , obtaining a quantization parameter set corresponding to the color quantization parameter, and determining the primary color channel value corresponding to the quantization parameter set as the primary color channel value of the first pixel.
[0100] Specifically, the quantization parameter set to which the color quantization parameter of the first pixel belongs is determined, wherein the quantization parameter set includes a plurality of range intervals of the color quantization parameters. By finding the position of the color quantization parameter of the first pixel in these range intervals, the parameter range interval corresponding to the color quantization parameter can be determined, and the primary color channel value corresponding to the parameter range interval is reallocated to the first pixel as the primary color channel value of the first pixel.
[0101] Exemplarily, the primary color channel value of the first pixel is (R=180, G=120, B=60). Use the color quantization algorithm to process this image and obtain the color quantization parameter of the first pixel as (R=4, G=3, B=2). Further determine the quantization parameter set to which the color quantization parameter belongs, for example, the range interval of R is [0,7], the range interval of G is [0,7], and the range interval of B is [0,7]. By searching, determine that the range interval corresponding to R=4 is [3,5], the range interval corresponding to G=3 is [2,4], and the range interval corresponding to B=2 is [1,3]. Finally, the primary color channel values corresponding to these range intervals, for example, the primary color channel value corresponding to the R range interval is 150, the primary color channel value corresponding to the G range interval is 110, and the primary color channel value corresponding to the B range interval is 70.
[0102] As can be seen from the above, by dividing the initial inserted image into multiple sub-images, the image can be processed in blocks, which greatly reduces the amount of data processed at one time and reduces the system's computational burden and memory usage. At the same time, only a preset number of pixels are selected from each sub-image for processing, which further reduces the amount of calculation, so that the entire color quantization process can be completed in a shorter time, especially in the face of high-resolution images or scenes that require real-time image processing, which can significantly improve the processing speed and meet the needs of immediacy. By converting the initial primary color channel values into binary data and saving them in layers, the color information distortion caused by the data format conversion or the accumulation of errors in the calculation process can be avoided. Furthermore, the color information can be hierarchically managed and called according to different needs and accuracy requirements through the layered storage method, so as to reduce the storage space occupied and improve the efficiency of the image during storage and transmission.
[0103] Spatial dispersion is an important indicator to measure the uniformity of pixel distribution in its neighborhood. If the spatial dispersion of pixels is not determined, the characteristics of pixels in the image cannot be accurately analyzed, thus affecting the final presentation effect of image fusion. Figure 6 , Figure 6 FIG. 1 is a flow chart of an image fusion method provided in an embodiment of the present application. Figure 6 As shown, the method of the embodiment of the present application may include the following steps S301-S305.
[0104] S301 , determining a maximum primary color value and a minimum primary color value of a first pixel in primary color channel values of a first pixel.
[0105] S302: Determine the color saturation of the first pixel based on the maximum primary color value and the minimum primary color value.
[0106] Specifically, in S301-S302, the red, green, and blue channel values of the first pixel are extracted from the primary color channel values of the first pixel, and the maximum brightness and the minimum brightness corresponding to the red, green, and blue channel values are found respectively. By calculating the brightness difference between the maximum brightness and the minimum brightness, and further dividing the brightness difference by the maximum brightness, the color saturation of the first pixel can be obtained.
[0107] For example, the primary color channel values of the first pixel are respectively 200 for the red channel, 100 for the green channel, and 50 for the blue channel. It can be seen that the value of the red channel is 200, which is the maximum brightness value among the three channels; and the value of the blue channel is 50, which is the minimum brightness value among the three channels. Then, the brightness difference is calculated, that is, 200 minus 50 to get 150. Finally, the brightness difference 150 is divided by the maximum brightness value 200 to get 0.75, so the color saturation of the first pixel is 0.75.
[0108] S303: Determine a color brightness value of the first pixel based on the primary color channel value of the first pixel and the weight value of each primary color channel.
[0109] Specifically, the maximum brightness value corresponding to the red, green, and blue channels of each pixel is extracted from the primary color channel value of each pixel, and the maximum brightness value is multiplied by the channel weight and then added to obtain the color brightness value of the first pixel.
[0110] Exemplarily, the primary color channel values of the first pixel point include a red channel value of 150, a green channel value of 200, and a blue channel value of 100, the preset red channel weight is 0.299, the green channel weight is 0.587, and the blue channel weight is 0.114. The color brightness value of the first pixel point is = (150*0.299)+(200*0.587)+(100*0.114)=44.85+117.4+11.4=173.65.
[0111] S304, obtaining average position information of the primary color channel value of the first pixel in the initial insertion image.
[0112] S305 : Determine the spatial dispersion of the first pixel based on the average position information and the first position information of the first pixel in the initial insertion image.
[0113] Specifically, in S304-S305, the neighborhood of the first pixel is determined in the initial insertion image, wherein the neighborhood is a rectangular area of a preset size, and each pixel in the neighborhood is traversed, and its coordinates are accumulated and then divided by the total number of pixels in the neighborhood, so as to obtain the average position information of the first pixel. For example, taking a 3x3 neighborhood as an example, assuming that the position of the first pixel is (5,5), the coordinates of the pixels in its neighborhood are (4,4), (4,5), (4,6), (5,4), (5,5), (5,6), (6,4), (6,5) and (6,6), respectively, and the average of these coordinates is calculated to obtain the average position information (5,5), wherein the coordinates are the average distribution coordinates of the red, green and blue channels of each pixel in the domain. The spatial dispersion is measured by calculating the Euclidean distance between two positions. The Euclidean distance formula is: distance = sqrt((x1-x2)^2+(y1-y2)^2), where (x1, y1) is the actual coordinate position of the first pixel, and (x2, y2) represents the average position information. For example, the actual position of the first pixel is (5, 5) and the average position information is (5, 5). Substituting these values into the Euclidean distance formula, the spatial dispersion of the first pixel is 0.
[0114] As can be seen from the above, by analyzing the primary color channel value of the first pixel, the maximum primary color value and the minimum primary color value of the first pixel are determined, and then the color saturation of the first pixel is calculated based on these two values. At the same time, by combining the primary color channel value of the first pixel and the weight value of each primary color channel, the color brightness value of the pixel can be determined, thereby providing an important basis for subsequent color parameter analysis. The spatial dispersion of the pixel is determined by obtaining the average position information of the primary color channel value of the first pixel in the initial insertion image and comparing it with the actual position information of the first pixel in the initial insertion image. This process helps to evaluate the distribution of pixels in the entire image and provides key information for subsequent pixel classification and image processing. The accuracy of image fusion is improved by accurately calculating the color saturation, color brightness value and spatial dispersion of the first pixel.
[0115] The average position information is an important indicator used to describe the central tendency of a group of pixels in an image. Without accurate average position information, it will be impossible to accurately determine the center position of these pixels, thus affecting the accuracy of subsequent spatial analysis and processing tasks. Figure 7 , Figure 7 FIG. 1 is a flow chart of an image fusion method provided in an embodiment of the present application. Figure 7 As shown, the method of the embodiment of the present application may include the following steps S401-S403.
[0116] S401, classifying the primary color channel value of each pixel to obtain a primary color channel value set.
[0117] Specifically, the primary color channel values of each pixel are traversed to detect whether the primary color channel value falls within a preset channel value range, so as to classify the primary color channel values and generate a primary color channel value set.
[0118] S402 , obtaining, in each pixel point, a pixel point set corresponding to a target primary color channel value in a primary color channel value set.
[0119] Specifically, the primary color channel value of the current pixel is obtained as the target primary color channel value, and the target primary color channel value is further numerically matched with the primary color channel value set to obtain a pixel point set corresponding to the channel value range interval of the target primary color channel value.
[0120] S403: Determine average position information of the target primary color channel value based on second position information of each second pixel point in the pixel point set in the initial insertion image.
[0121] Specifically, in S403, the second position information of the second pixel points is accumulated and then divided by the total number of the second pixel points to obtain the average position information of the target primary color channel value. For example, the second position information of the second pixel points is (4,4), (4,5), (4,6), (5,4), (5,5), (5,6), (6,4), (6,5) and (6,6), respectively, so the average position information is (5,5).
[0122] As can be seen from the above, by classifying the primary color channel values of each pixel, a set of different primary color channel values can be obtained, which helps us manage and process image data more effectively. By selecting any target primary color channel value from the primary color channel value set and obtaining the corresponding pixel point set, in-depth analysis can be performed on specific color features. Based on the second position information of each second pixel point in the pixel point set in the initial insertion image, the average position information of the target primary color channel value is calculated. This process helps to reveal the overall distribution of pixels with the same or similar color features in the image.
[0123] The weight analysis model can assign different weights to different features, thereby highlighting those features that are more important to the final score calculation. In image processing, some color channels or texture features may reflect the key information of the image better than other features. By giving these features higher weights, they can play a greater role in the score calculation. See Figure 8 , Figure 8 FIG. 1 is a flow chart of an image fusion method provided in an embodiment of the present application. Figure 8 As shown, the method of the embodiment of the present application may include the following steps S501-S503.
[0124] S501, inputting the color saturation, color brightness value and spatial dispersion of the first pixel into a pre-trained weight analysis model to obtain a saturation weight, a brightness value weight and a dispersion weight.
[0125] In the embodiment of the present application, the first pixel point is any pixel point among the pixel points.
[0126] Specifically, three key color attributes are extracted from the first pixel, namely color saturation, color brightness value and spatial dispersion. Color saturation, color brightness value and spatial dispersion respectively describe the color vividness, brightness and distribution of the pixel in the image space. The color saturation, color brightness value and spatial dispersion are input into a pre-trained weight analysis model, wherein the weight analysis model is constructed based on a machine learning algorithm and is used to calculate the corresponding weights according to the input pixel attributes. After receiving the input attributes, the weight analysis model will process and output three weight values, namely saturation weight, brightness value weight and dispersion weight.
[0127] S502, determining a pixel score of the first pixel based on the color saturation, color brightness value, spatial dispersion, saturation weight, brightness value weight, and dispersion weight of the first pixel.
[0128] For example, the color saturation of the first pixel A is 80, the color brightness value is 150, and the spatial dispersion is 0.2. At the same time, through the pre-trained weight analysis model, the saturation weight is 0.3, the brightness value weight is 0.5, and the dispersion weight is 0.2. Multiply each attribute value by its corresponding weight, and then add and sum to get the pixel score of the first pixel. The specific calculation is: pixel score = 80 × 0.3 + 150 × 0.5 + 0.2 × 0.2 = 24 + 75 + 0.04 = 99.04.
[0129] S503: Determine the third pixel point with the largest pixel score among all the pixel points as a reference pixel point.
[0130] Exemplarily, there are three pixel points, namely pixel A, pixel B, and pixel C = 90.5, where the pixel score of pixel A is 85.3, the pixel score of pixel B is 95.2, and the pixel score of pixel C is 88.7. At this time, since the pixel score of pixel B is the largest, pixel B is determined as the reference pixel.
[0131] As can be seen from the above, by carefully classifying the primary color channel values of each pixel, this method can accurately identify and organize the color information in the image, thereby ensuring the accuracy of color classification. Furthermore, the average position of the target primary color channel value is calculated using the position information of the pixel points, which enhances the accuracy of color distribution analysis. In addition, by applying a pre-trained weight analysis model, this method dynamically evaluates the importance of the color saturation, brightness value, and spatial dispersion of each pixel point, thereby assigning a reasonable weight to each pixel point. This weight-based pixel score calculation method not only improves the accuracy of pixel selection, but also makes the entire image processing process more efficient and intelligent.
[0132] To improve the recognition accuracy of the weight analysis model. Fig. 9 , Fig. 9 FIG. 1 is a flow chart of an image fusion method provided in an embodiment of the present application. Figure 6 As shown, the method of the embodiment of the present application may include the following steps S601-S603.
[0133] It should be noted that in statistics or data analysis, changes in the frequency of an event, such as a color, have different relative importance at different stages. When the event changes from a rare state (such as only appearing once) to a slightly more common state, such as appearing twice, this change is considered significant and may be important because it may mark the beginning of a new trend or pattern. However, when the event has already occurred frequently, such as 100 times, and only increases to a slightly higher frequency, such as 101 times, this small change appears relatively unimportant overall because its share of the total frequency has hardly changed and is unlikely to represent any significant new information or trend. In short, as the frequency of an event increases, the relative importance of the same frequency increment gradually decreases.
[0134] S601, obtaining the number of occurrences of the primary color channel value of the first pixel in the process of pixel traversal.
[0135] Specifically, each time a pixel is traversed, the primary color channel value of the current pixel is compared and analyzed with the primary color channel value of the first pixel. If the primary color channel values are the same, the number of occurrences of the primary color channel value of the first pixel is accumulated.
[0136] S602, obtaining the frequency weight corresponding to the number of occurrences based on the weight analysis model.
[0137] Specifically, the number of occurrences is passed as input to a pre-trained weight analysis model, where the weight analysis model is built based on a machine learning algorithm and is used to calculate the corresponding weights based on the input pixel attributes. After receiving the input attributes, the weight analysis model processes and outputs the number of weights.
[0138] S603, determining the pixel score of the first pixel based on the color saturation, color brightness value, spatial dispersion, number of occurrences, saturation weight, brightness value weight, dispersion weight, and number weight of the first pixel.
[0139] For example, the color saturation of the first pixel A is 80, the color brightness value is 150, the spatial dispersion is 0.2, and the number of occurrences is 2. At the same time, through the pre-trained weight analysis model, the saturation weight is 0.3, the brightness weight is 0.5, the dispersion weight is 0.2, and the number of occurrences weight is 3. Multiply each attribute value by its corresponding weight, and then add and sum to get the pixel score of the first pixel, which is specifically calculated as: pixel score = 80 × 0.3 + 150 × 0.5 + 0.2 × 0.2 + 2 × 6 = 24 + 75 + 0.04 + 6 = 105.04.
[0140] As can be seen from the above, by counting the number of times the primary color channel value of the first pixel appears in the entire pixel traversal process, and using the weight analysis model to obtain the number of times weight corresponding to the number of times, this scheme not only considers the color attributes of the pixel (such as saturation, brightness value and spatial dispersion), but also introduces the information of the frequency of pixel occurrence, thereby providing a more comprehensive evaluation for each pixel. When determining the pixel score of the first pixel, the color saturation, brightness value, spatial dispersion and their weights are combined, and the number of times the pixel appears and its corresponding weight are also considered, thereby improving the accuracy and efficiency of image processing.
[0141] Because background pixels may contain various noise and interference information, this information may have a negative impact on the performance of image processing algorithms. If not distinguished, these interference information may be mistaken for useful data, resulting in inaccurate results. See Fig.10 , Fig.10 FIG. 1 is a flow chart of an image fusion method provided in an embodiment of the present application. Fig.10 As shown, the method of the embodiment of the present application may include the following steps S701-S705.
[0142] S701, determining the color similarity between each pixel in the initial insertion image and the reference pixel.
[0143] Specifically, each pixel in the inserted image and the reference pixel are converted from the RGB color space to the perceptually uniform CIE Lab color space to eliminate the brightness difference between different color channels and more accurately reflect the visual perception of the human eye. Then, the Euclidean distance between each pixel in the inserted image and the reference pixel in the Lab color space is calculated, and the Euclidean distance is used as the color similarity between each pixel and the reference pixel.
[0144] S702: If the color similarity is less than a preset similarity threshold, the pixel is determined as a foreground pixel.
[0145] S703: If the color similarity is greater than or equal to a preset similarity threshold, the pixel is determined as a background pixel.
[0146] Specifically, in S702-S703, the preset similarity threshold is set by the user according to the actual scene, and is not specifically limited here. For example, the preset threshold of color similarity is set to 50. For a certain pixel A in the inserted image, its RGB value is (240, 10, 10). After converting it to the CIE Lab color space, the color similarity is calculated with the reference pixel, and the distance is 40. Since 40 is less than the preset similarity threshold of 50, pixel A is determined as a foreground pixel. For another example, pixel B, the RGB value is (100, 100, 100) and the color similarity distance is 60. Since the color similarity of pixel B is greater than the preset 50, pixel B is determined as a background pixel.
[0147] S704, determining a saturation overflow value and a grayscale overflow value of the background pixel based on the color similarity between the background pixel and the reference pixel.
[0148] Specifically, after obtaining the color similarity of each background pixel according to the above S703, for each background pixel that falls into a specific color similarity interval, obtain the saturation overflow adjustment parameter and the grayscale overflow value adjustment parameter corresponding to the interval, use the saturation adjustment parameter and the grayscale value adjustment parameter to generate a saturation smoothing mask for each background pixel and combine the saturation smoothing mask with the transparency channel of the background pixel to correct the transparency of the background pixel.
[0149] S705, generating a saturation smoothing mask of the background pixel points based on the saturation overflow value and the grayscale overflow value, and correcting the transparency of the background pixel points to a target transparency based on the saturation smoothing mask.
[0150] Exemplarily, the initial transparency of background pixel A is 0.6, and the color similarity of background pixel A is 45, which falls within the color similarity interval of 40 to 50. The saturation overflow adjustment parameter corresponding to this interval is 10, and the grayscale overflow value adjustment parameter is 5. Then, the saturation adjustment parameter 10 is used to increase the saturation of background pixel A, and the grayscale value adjustment parameter 5 is used to appropriately reduce the grayscale value of background pixel A. Based on the saturation overflow adjustment parameter 10 and the grayscale value adjustment parameter 5, a saturation smoothing mask is generated, and its value is 0.7. The saturation smoothing mask 0.7 is combined with the original transparency channel value 0.5 of the background pixel A to adjust the transparency channel value of the background pixel A to 0.6 (i.e., 0.7×0.5+0.5×(1-0.7)).
[0151] From the above, it can be seen that by calculating the color similarity between each pixel in the inserted image and the reference pixel and comparing the color similarity with the preset similarity threshold, the pixels can be effectively distinguished as foreground pixels and background pixels, so as to accurately identify the foreground object and background in the initial image. For the pixels identified as the background, the method further determines the saturation overflow value and the grayscale overflow value based on the color similarity between the pixels and the reference pixels. These overflow values reflect the degree of difference between the background pixels and the reference pixels in color, and can accurately adjust the color attributes of the background pixels. The saturation smoothing mask is generated by the calculated saturation overflow value and grayscale overflow value to correct the transparency of the background pixels to the target transparency, thereby improving the accuracy of image fusion.
[0152] Please also read Fig.11 , Fig.11 Schematic diagram of a scene of an image fusion method provided in an embodiment of the present application. Fig.11 As shown, the background pixels of the initial insertion image are black. After the transparency correction is performed on the background pixels of the initial insertion image, a target insertion image with transparent background pixels is obtained.
[0153] based on Figure 1 The system architecture will be combined with Fig.12 , the image fusion device provided in the embodiment of the present application is introduced in detail. It should be noted that, Fig.12 The image fusion device in the present application is used to execute Figure 2-Figure 6 For the convenience of explanation, only the part related to the embodiment of the present application is shown. For the specific technical details not disclosed, please refer to the present application. Figure 2-Figure 10 In the embodiment shown, the image fusion device 800 may include an image acquisition unit 801, a color acquisition unit 802, a dispersion acquisition unit 803, a pixel point determination unit 804, a chromaticity contrast unit 805, a correction unit 806 and an insertion unit 807, which are specifically as follows:
[0154] The image acquisition unit 801 is used to acquire an initial insertion image and a target image, perform pixel sampling on the initial insertion image, and obtain the primary color channel value of each pixel point in the initial insertion image;
[0155] A color acquisition unit 802 is used to determine the color parameter of each pixel based on the primary color channel value of each pixel;
[0156] The dispersion acquisition unit 803 is used to determine the spatial dispersion of each pixel based on the original color channel value of each pixel and the position information of each pixel in the initial insertion image;
[0157] A pixel determination unit 804, configured to determine a reference pixel among the pixels based on the color parameter and the spatial dispersion;
[0158] A chromaticity contrast unit 805 is used to determine background pixels and foreground pixels in each pixel based on the chromaticity difference between each pixel and the reference pixel;
[0159] A correction unit 806, configured to correct the transparency of the background pixel points to a target transparency, and generate a target insertion image based on the background pixel points and foreground pixel points of the target transparency;
[0160] The inserting unit 807 is configured to insert the target insertion image into a preset insertion position of the target image.
[0161] In some embodiments, the image acquisition unit 801 further includes an image division unit, a selection unit, and a quantization unit.
[0162] An image division unit, used for dividing the inserted image into a plurality of sub-images of preset sizes, wherein the sub-images contain at least one pixel;
[0163] A selection unit, used for selecting a preset number of pixels from each sub-image;
[0164] The quantization unit is used to perform color quantization on each pixel based on a preset color quantization algorithm to determine the primary color channel value of each pixel.
[0165] In some embodiments, the image acquisition unit 801 further includes a channel value acquisition unit, a data conversion unit, and a channel value determination unit.
[0166] A channel value acquisition unit, used to acquire an initial primary color channel value of a first pixel among all the pixels, where the first pixel is any pixel among all the pixels;
[0167] A data conversion unit, used for converting the initial primary color channel value into binary data, and storing the binary data in layers to obtain a color quantization parameter of a first pixel;
[0168] The channel value determination unit is used to obtain a quantization parameter set corresponding to the color quantization parameter, and determine the primary color channel value corresponding to the quantization parameter set as the primary color channel value of the first pixel.
[0169] In some embodiments, the color acquisition unit 802 further includes a primary color value acquisition unit, a saturation acquisition unit, and a brightness value acquisition unit.
[0170] A primary color value acquisition unit, used to determine a maximum primary color value and a minimum primary color value of the first pixel in the primary color channel value of the first pixel;
[0171] a saturation acquisition unit, configured to determine the color saturation of the first pixel based on the maximum primary color value and the minimum primary color value;
[0172] The brightness value acquisition unit is used to determine the color brightness value of the first pixel based on the primary color channel value of the first pixel and the weight value of each primary color channel.
[0173] In some embodiments, the dispersion acquisition unit 803 further includes a position acquisition unit and a dispersion determination unit.
[0174] A position acquisition unit, used to acquire average position information of the primary color channel value of the first pixel point in the initial insertion image;
[0175] The dispersion determination unit is used to determine the spatial dispersion of the first pixel point based on the average position information and the first position information of the first pixel point in the initial insertion image.
[0176] In some embodiments, the dispersion acquisition unit 803 further includes a classification unit, a set acquisition unit, and an average position determination unit.
[0177] A classification unit, used for classifying the primary color channel value of each pixel point to obtain a primary color channel value set;
[0178] A set acquisition unit, used to acquire, in each pixel point, a set of pixel points corresponding to a target primary color channel value in the primary color channel value set, where the target primary color channel value is any primary color channel value in the primary color channel value set;
[0179] The average position determining unit is used to determine the average position information of the target primary color channel value based on the second position information of each second pixel point in the pixel point set in the initial insertion image.
[0180] In some embodiments, the pixel point determination unit 804 further includes an input unit, a pixel score determination unit and a determination unit.
[0181] An input unit, used to input the color saturation, color brightness value and spatial dispersion of the first pixel into a pre-trained weight analysis model to obtain a saturation weight, a brightness value weight and a dispersion weight;
[0182] a pixel score determination unit, configured to determine a pixel score of the first pixel based on the color saturation, color brightness value, spatial dispersion, saturation weight, brightness value weight, and dispersion weight of the first pixel;
[0183] The determination unit is used to determine the third pixel point with the largest pixel score among the pixel points as the reference pixel point.
[0184] In some embodiments, the pixel point determination unit 804 further includes a frequency acquisition unit, a frequency weight acquisition unit and a second pixel score determination unit.
[0185] A frequency acquisition unit, used to acquire the number of occurrences of the primary color channel value of the first pixel point during the pixel point traversal process;
[0186] A frequency weight acquisition unit, used to acquire the frequency weight corresponding to the number of occurrences based on a weight analysis model;
[0187] The second pixel score determination unit is used to determine the pixel score of the first pixel based on the color saturation, color brightness value, spatial dispersion, number of occurrences, saturation weight, brightness value weight, dispersion weight, and number weight of the first pixel.
[0188] In some embodiments, the chromaticity comparison unit 805 further includes a similarity calculation unit, a first determination unit and a second determination unit.
[0189] A similarity calculation unit, used to determine the color similarity between each pixel in the initial insertion image and the reference pixel;
[0190] A first determination unit, configured to determine a pixel point as a foreground pixel point if the color similarity is less than a preset similarity threshold;
[0191] The second determination unit is configured to determine the pixel point as a background pixel point if the color similarity is greater than or equal to a preset similarity threshold.
[0192] In some embodiments, the correction unit 806 further includes an overflow value calculation unit and a saturation correction unit.
[0193] An overflow value calculation unit, used to determine a saturation overflow value and a grayscale overflow value of a background pixel point based on a color similarity between the background pixel point and the reference pixel point;
[0194] The saturation correction unit is used to generate a saturation smoothing mask of the background pixel points based on the saturation overflow value and the grayscale overflow value, and correct the transparency of the background pixel points to a target transparency based on the saturation smoothing mask.
[0195] In an embodiment of the present application, by sampling the pixels of the initial inserted image to obtain the primary color channel values and determine the color parameters and spatial dispersion, it is possible to comprehensively analyze the image features from the two key dimensions of color and spatial distribution. Based on this, by determining the reference pixels and distinguishing between background pixels and foreground pixels, the key elements and background parts in the image can be accurately identified, providing data support for subsequent image processing. The correction of the transparency of the background pixels and the process of generating the target inserted image can make the inserted image and the target image more natural and harmonious when fused, avoiding the appearance of abrupt splicing marks, thereby effectively improving the quality and visual effect of image synthesis. Finally, the target inserted image is inserted into the preset position of the target image, realizing seamless fusion of the image and expanding the application scenarios, thereby improving the applicability and immediacy of image fusion.
[0196] In addition, the image fusion device provided in the above embodiment and an image fusion method embodiment belong to the same concept, and the implementation process thereof is detailed in the method embodiment, which will not be repeated here.
[0197] The serial numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0198] The present application also provides a computer storage medium that can store multiple program instructions, which are suitable for being loaded and executed by a processor as described above. Figure 4-Figure 10 The method steps of the embodiment shown in the figure can be found in the specific implementation process. Figure 4-Figure 10 The specific description of the illustrated embodiment will not be repeated here.
[0199] See also Fig.13 , is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.13As shown, the electronic device 1000 may include: at least one processor 1001, such as a CPU, at least one network interface 1004, an input / output interface 1003, a memory 1005, and at least one communication bus 1002. The communication bus 1002 is used to realize the connection and communication between these components. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 1005 may optionally be at least one storage device located away from the aforementioned processor 1001. As shown in FIG. Fig.13 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, an input and output interface module, and an image fusion application.
[0200] exist Fig.13 In the electronic device 1000 shown, the input and output interface 1003 is mainly used to obtain audio and video signals and output them to the user's terminal device.
[0201] In some embodiments, the processor 1001 can be used to call an image fusion application stored in the memory 1005, and specifically perform the following operations: in response to a control operation on a display device, generate a first state control instruction based on the display state indicated by the control operation; send the first state control instruction to the display device, and obtain first state response data returned by the display device after executing the first state control instruction; generate a first state change message based on the first state response data, and set the display content displayed by the first control device based on the first state change message; send the first state change message to the second control device, so that the second control device sets the display content displayed by the second control device based on the first state change message.
[0202] Optionally, the processor 1001 generates a first state control instruction based on the display state indicated by the control operation when executing a control operation in response to the display device, and specifically executes: calling a first control module to parse the control operation in response to the control operation in the first view layer to obtain the selected display content; the first control module generates a first state control instruction based on the display state.
[0203] Optionally, the processor 1001 sends a first state control instruction to the display device and obtains first state response data returned by the display device after executing the first state control instruction. Specifically, the processor 1001 performs: calling the first control module to send the first state control instruction to the first calling module; the first calling module sends the first state control instruction to the display device based on the access interface of the display device; the first calling module obtains the first state response data returned by the display device after executing the first state control instruction.
[0204] Optionally, the processor 1001 generates a first state change message based on the first state response data, and sets the display content displayed by the first control device based on the first state change message. Specifically, the following steps are performed: calling the first calling module to send the first state response data to the first message synchronization service module; the first message synchronization service module generates a first state change message based on the first state response data; the first message synchronization service module pushes the first state change message to the first state storage module; and the first view layer obtains the first state change message from the first state storage module to set the display content displayed by the first view layer.
[0205] Optionally, the processor 1001 executes sending a first status change message to a second control device so that the second control device sets the display content displayed by the second control device based on the first status change message. Specifically, the processor 1001 executes: calling the first message synchronization service module to send the first status response data to the second message synchronization service module of the second control device so that the second control device sets the display content displayed by the second control device based on the first status change message.
[0206] Optionally, processor 1001 is also used to specifically execute: calling the first message synchronization service module to receive a second state control instruction sent by the second message synchronization service module of the second control device; the first message synchronization service module sends the second state control instruction to the first control module; the first control module sends the second state control instruction to the first calling module; the first calling module sends the second state control instruction to the display device based on the access interface of the display device; the first calling module obtains the second state response data returned by the display device after executing the second state control instruction; the first calling module sends the second state response data to the first message synchronization service module to generate a second state change message; the first message synchronization service module pushes the second state change message to the first state storage module; the first view layer obtains the second state change message from the first state storage module to set the display content displayed by the first view layer; the first message synchronization service module sends the second state change message to the second message synchronization service module of the second control device.
[0207] In the embodiment of the present application, the first state control instruction is generated by the display state indicated by the control operation to ensure the accuracy and pertinence of the instruction, avoid the sending of erroneous operations or invalid instructions, and by sending the first state control instruction to the display device and obtaining the display device response data in real time, it can be confirmed whether the instruction is successfully executed, which provides a basis for subsequent state updates and enhances the reliability and stability of the system. By generating a first state change message based on the first state response data and setting the display content displayed by the first control device based on the first state change message, the real-time update of the display state of the control device is ensured, so that the user can intuitively understand the current display content of the display device, and improve the user experience and the interactivity of the system. By sending the first state change message to the second control device, so that the second control device sets the display content displayed by the second control device based on the first state change message: the state synchronization between multiple control devices is realized, so that users on different control devices can timely understand the latest display content of the display device, thereby enhancing the state coordination and information sharing capabilities between different applications.
[0208] In some embodiments, the processor 1001 can be used to call an image fusion application stored in the memory 1005, and specifically perform the following operations: obtain an initial insertion image and a target image, perform pixel sampling on the initial insertion image, and obtain the primary color channel value of each pixel in the initial insertion image; determine the color parameter of each pixel based on the primary color channel value of each pixel; determine the spatial dispersion of each pixel based on the primary color channel value of each pixel and the position information of each pixel in the initial insertion image; determine a reference pixel in each pixel based on the color parameter and the spatial dispersion; determine the background pixel and the foreground pixel in each pixel based on the chromaticity difference between each pixel and the reference pixel; correct the transparency of the background pixel to the target transparency, and generate a target insertion image based on the background pixel and foreground pixel of the target transparency.
[0209] Optionally, the processor 1001 performs pixel sampling on the initial inserted image to obtain the primary color channel value of each pixel in the initial inserted image, and specifically performs: dividing the inserted image into multiple sub-images of preset sizes, each sub-image having at least one pixel; selecting a preset number of pixels from each sub-image; and performing color quantization on each pixel based on a preset color quantization algorithm to determine the primary color channel value of each pixel.
[0210] Optionally, the processor 1001 performs color quantization on each pixel based on a preset color quantization algorithm to determine the primary color channel value corresponding to each pixel, and specifically performs: obtaining an initial primary color channel value of a first pixel among each pixel, where the first pixel is any pixel among each pixel; converting the initial primary color channel value into binary data, and saving the binary data in layers to obtain a color quantization parameter of the first pixel; obtaining a quantization parameter set corresponding to the color quantization parameter, and determining the primary color channel value corresponding to the quantization parameter set as the primary color channel value of the first pixel.
[0211] Optionally, the processor 1001 determines the color parameters of each pixel based on the primary color channel values of each pixel, and specifically performs: determining the maximum primary color value and the minimum primary color value of the first pixel in the primary color channel value of the first pixel; determining the color saturation of the first pixel based on the maximum primary color value and the minimum primary color value; determining the color brightness value of the first pixel based on the primary color channel value of the first pixel and the weight values of each primary color channel.
[0212] Optionally, the processor 1001 determines the spatial dispersion of each pixel point based on the original color channel value and the position information of each pixel point in the initial insertion image, and specifically performs: obtaining the average position information of the original color channel value of the first pixel point in the initial insertion image; and determining the spatial dispersion of the first pixel point based on the average position information and the first position information of the first pixel point in the initial insertion image.
[0213] Optionally, before determining the spatial dispersion of each pixel point based on the primary color channel value and the position information of each pixel point in the initial insertion image, the processor 1001 specifically performs the following steps: classifying the primary color channel value of each pixel point to obtain a primary color channel value set; obtaining, for each pixel point, a pixel point set corresponding to a target primary color channel value in the primary color channel value set, where the target primary color channel value is any primary color channel value in the primary color channel value set; and determining the average position information of the target primary color channel value based on the second position information of each second pixel point in the pixel point set in the initial insertion image.
[0214] Optionally, the processor 1001 determines a reference pixel point among each pixel point based on color parameters and spatial dispersion, and specifically performs: inputting the color saturation, color brightness value and spatial dispersion of the first pixel point into a pre-trained weight analysis model to obtain a saturation weight, a brightness value weight and a dispersion weight; determining the pixel score of the first pixel point based on the color saturation, color brightness value, spatial dispersion of the first pixel point and the saturation weight, brightness value weight and dispersion weight; and determining the third pixel point with the largest pixel score among each pixel point as the reference pixel point.
[0215] Optionally, the processor 1001 is also used to specifically execute: obtaining the number of occurrences of the primary color channel value of the first pixel point during the pixel traversal process; obtaining the number of occurrences weight corresponding to the number of occurrences based on a weight analysis model; determining the pixel score of the first pixel point based on the color saturation, color brightness value, spatial dispersion, saturation weight, brightness value weight, and dispersion weight of the first pixel point, including: determining the pixel score of the first pixel point based on the color saturation, color brightness value, spatial dispersion, number of occurrences, saturation weight, brightness value weight, dispersion weight, and number of occurrences of the first pixel point.
[0216] Optionally, the processor 1001 determines the background pixel and the foreground pixel in each pixel based on the chromaticity difference between each pixel and the reference pixel, and specifically performs: determining the color similarity between each pixel in the initial inserted image and the reference pixel; if the color similarity is less than a preset similarity threshold, determining the pixel as a foreground pixel; if the color similarity is greater than or equal to the preset similarity threshold, determining the pixel as a background pixel.
[0217] Optionally, the processor 1001 corrects the transparency of the background pixel to the target transparency by: determining the saturation overflow value and the grayscale overflow value of the background pixel based on the color similarity between the background pixel and the reference pixel; generating a saturation smoothing mask of the background pixel based on the saturation overflow value and the grayscale overflow value, and correcting the transparency of the background pixel to the target transparency based on the saturation smoothing mask.
[0218] In an embodiment of the present application, by sampling the pixels of the initial inserted image to obtain the primary color channel values and determine the color parameters and spatial dispersion, it is possible to comprehensively analyze the image features from the two key dimensions of color and spatial distribution. Based on this, by determining the reference pixels and distinguishing between background pixels and foreground pixels, the key elements and background parts in the image can be accurately identified, providing data support for subsequent image processing. The correction of the transparency of the background pixels and the process of generating the target inserted image can make the inserted image and the target image more natural and harmonious when fused, avoiding the appearance of abrupt splicing marks, thereby effectively improving the quality and visual effect of image synthesis. Finally, the target inserted image is inserted into the preset position of the target image, realizing seamless fusion of the image and expanding the application scenarios, thereby improving the applicability and immediacy of image fusion.
[0219] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM).
[0220] The above disclosure is only the preferred embodiment of this specification, which certainly cannot be used to limit the scope of rights of this specification. Therefore, equivalent changes made according to the claims of this specification are still within the scope covered by this specification.
Claims
1. An image fusion method, characterized in that: include: Acquire an initial insertion image and a target image, perform pixel sampling on the initial insertion image, and obtain a primary color channel value of each pixel point in the initial insertion image; Determine the color parameter of each pixel based on the primary color channel value of each pixel; Determining the spatial dispersion of each pixel based on the primary color channel value of each pixel and the position information of each pixel in the initial insertion image; Determining a reference pixel point among the pixel points based on the color parameter and the spatial dispersion; Determine a background pixel and a foreground pixel in each of the pixels based on a chromaticity difference between each of the pixels and the reference pixel, wherein the chromaticity difference includes a color similarity between the pixel and the reference pixel; Correcting the transparency of the background pixels to a target transparency, and generating a target insertion image based on the background pixels and the foreground pixels of the target transparency, wherein the target insertion image is used to display a picture composed of the foreground pixels; The target insertion image is inserted into a preset insertion position of the target image.
2. The method according to claim 1, characterized in that The performing pixel sampling on the initial insertion image to obtain the primary color channel value of each pixel in the initial insertion image includes: Dividing the initial insertion image into a plurality of sub-images of preset sizes, wherein at least one pixel exists in each sub-image; Selecting a preset number of pixels from each of the sub-images; Color quantization is performed on each of the pixels based on a preset color quantization algorithm to determine the primary color channel value of each of the pixels.
3. The method according to claim 2, characterized in that The performing color quantization on each of the pixels based on a preset color quantization algorithm to determine the primary color channel value corresponding to each of the pixels includes: Obtaining an initial primary color channel value of a first pixel point among the pixel points, where the first pixel point is any pixel point among the pixel points; Converting the initial primary color channel value into binary data, and saving the binary data in layers to obtain a color quantization parameter of the first pixel; A quantization parameter set corresponding to the color quantization parameter is obtained, and the primary color channel value corresponding to the quantization parameter set is determined as the primary color channel value of the first pixel.
4. The method according to claim 3, characterized in that The color parameters include color saturation and color brightness value; The determining the color parameter of each pixel based on the primary color channel value of each pixel includes: Determine the maximum and minimum primary color values of the first pixel in the primary color channel values of the first pixel; Determine the color saturation of the first pixel based on the maximum primary color value and the minimum primary color value; Based on the primary color channel value of the first pixel and the weight value of each primary color channel, a color brightness value of the first pixel is determined.
5. The method according to claim 4, characterized in that The determining the spatial dispersion of each pixel point based on the primary color channel value and the position information of each pixel point in the initial insertion image includes: Obtaining average position information of the primary color channel value of the first pixel in the initial insertion image; Based on the average position information and the first position information of the first pixel point in the initial insertion image, a spatial dispersion degree of the first pixel point is determined.
6. The method according to claim 5, characterized in that Before determining the spatial dispersion of each pixel point based on the primary color channel value and the position information of each pixel point in the initial insertion image, the method further includes: Classifying the primary color channel values of each pixel point to obtain a primary color channel value set; In each of the pixel points, a pixel point set corresponding to a target primary color channel value in the primary color channel value set is obtained, where the target primary color channel value is any primary color channel value in the primary color channel value set; Based on the second position information of each second pixel point in the pixel point set in the initial insertion image, the average position information of the target primary color channel value is determined.
7. The method according to claim 5, characterized in that The determining of a reference pixel point among the pixel points based on the color parameter and the spatial dispersion includes: Inputting the color saturation, color brightness value and spatial dispersion of the first pixel into a pre-trained weight analysis model to obtain a saturation weight, a brightness value weight and a dispersion weight; Determine a pixel score of the first pixel based on the color saturation, color brightness value, spatial dispersion, the saturation weight, the brightness value weight, and the dispersion weight of the first pixel; Among the pixel points, a third pixel point with the largest pixel score is determined as a reference pixel point.
8. The method according to claim 7, characterized in that The method further comprises: Obtaining the number of occurrences of the primary color channel value of the first pixel during the pixel traversal process; Obtaining a frequency weight corresponding to the frequency of occurrence based on the weight analysis model; The determining the pixel score of the first pixel based on the color saturation, the color brightness value, the spatial dispersion, the saturation weight, the brightness value weight, and the dispersion weight of the first pixel includes: The pixel score of the first pixel is determined based on the color saturation, color brightness value, spatial dispersion, number of occurrences, and the saturation weight, the brightness value weight, the dispersion weight, and the number weight of the first pixel.
9. The method according to claim 1, characterized in that: The determining of background pixels and foreground pixels in each of the pixels based on the chromaticity difference between each of the pixels and the reference pixels respectively comprises: Determine the color similarity between each pixel in the initial insertion image and the reference pixel; If the color similarity is less than a preset similarity threshold, the pixel is determined as the foreground pixel; If the color similarity is greater than or equal to a preset similarity threshold, the pixel point is determined as the background pixel point.
10. The method according to claim 1, characterized in that The correcting the transparency of the background pixel points to generate the corrected background pixel points includes: Determine a saturation overflow value and a grayscale overflow value of the background pixel based on a color similarity between the background pixel and the reference pixel; A saturation smoothing mask of the background pixel is generated based on the saturation overflow value and the grayscale overflow value, and the transparency of the background pixel is corrected to the target transparency based on the saturation smoothing mask.
11. An image fusion device, characterized in that: The device comprises: An image acquisition unit, used to acquire an initial insertion image and a target image, perform pixel sampling on the initial insertion image, and obtain a primary color channel value of each pixel point in the initial insertion image; A color acquisition unit, used to determine the color parameter of each pixel based on the primary color channel value of each pixel; A dispersion degree acquisition unit, used for determining the spatial dispersion degree of each pixel point based on the primary color channel value of each pixel point and the position information of each pixel point in the initial insertion image; A pixel point determination unit, configured to determine a reference pixel point among the pixel points based on the color parameter and the spatial dispersion; A chromaticity contrast unit, configured to determine background pixels and foreground pixels in each of the pixels based on chromaticity differences between each of the pixels and the reference pixels; A correction unit, configured to correct the transparency of the background pixels to generate corrected background pixels, and generate a target insertion image based on the corrected background pixels and the foreground pixels; An inserting unit is used to insert the target insertion image into a preset insertion position of the target image.
12. An electronic device, characterized in that: The electronic device comprises: A memory for storing executable program codes; A processor is used to call and run the executable program code from the memory, so that the electronic device executes the image fusion method as described in any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed, the image fusion method according to any one of claims 1 to 10 is implemented.
Citation Information
Patent Citations
Image color matting method and system, computer equipment and storage medium
CN113409221A
Image processing method and device, computer device and storage medium
CN113436284A
Vehicle exterior environment visual detection method and device for assisting driving
CN113537003A
Cited By
Real-time online measurement method and device for crystal growth thickness, equipment and medium
CN119915190A