Visual object superposition method and device, computer equipment and readable storage medium
By filtering and compensating the pixel set of visual objects, the problem of visual object defects caused by traditional interpolation algorithms is solved, and a high-quality visual object superposition effect is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HAIGUANG INTEGRATED CIRCUIT DESIGN (BEIJING) CO LTD
- Filing Date
- 2026-01-15
- Publication Date
- 2026-05-12
AI Technical Summary
In traditional techniques, interpolation algorithms add pixels that are not equal to the Colorkey during the visual object superposition process, resulting in visual object defects that are visible to the naked eye and reducing the quality of the target visual object.
By acquiring the visual object to be superimposed and the visual object to be superimposed, an initial blurred pixel set is determined based on an interpolation algorithm. The first target pixel set is then selected using color key colors and preset edge pixel conditions. The second target pixel set is then selected based on the distance between the initial non-target pixel set and the first target pixel set. Finally, the target pixel set is obtained, the superposition boundary is defined and compensation is performed, and seamless superposition is achieved.
It achieves seamless overlay of visual objects, corrects defects in visual objects, and improves the quality of target visual objects.
Smart Images

Figure CN122023558A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of display technology, and in particular to a method, apparatus, computer device, computer-readable storage medium, and computer program product for superimposing visual objects. Background Technology
[0002] In the display field, users often have the need to overlay multiple images, multiple videos, or images and videos. For example, a video might be playing on a desktop, but the video is obscured by the interface of another application. To achieve this, a visual object overlay method is needed to superimpose the visual object to be overlaid onto the target area of the overlaid visual object. The target area is the region where the visual object to be overlaid is displayed.
[0003] In traditional techniques, a Colorkey color is drawn in the target area. An interpolation algorithm is used to magnify the superimposed visual object, and the pixels in the magnified superimposed visual object that are equal to the Colorkey are updated to the pixels of the target visual object. Then, the updated superimposed visual object is shrunk to obtain the target visual object.
[0004] However, in traditional techniques, the interpolation algorithm adds new pixels that are similar to but not equal to Colorkey, causing the Colorkey determination to fail. This results in visual defects that are visible to the naked eye, leading to poor quality of the generated target visual object. Summary of the Invention
[0005] Therefore, it is necessary to provide a method, apparatus, computer device, computer-readable storage medium, and computer program product for overlaying visual objects to address the aforementioned technical problems.
[0006] Firstly, this application provides a method for overlaying visual objects, including:
[0007] Obtain the visual object to be superimposed and the visual object to be superimposed, and determine the initial set of blurred pixels based on the visual object to be superimposed and the interpolation algorithm;
[0008] Based on the color key color and preset edge pixel conditions, a first target pixel set is selected from the initial blurred pixel set, and an initial non-target pixel set is determined;
[0009] Based on the distance between the blurred pixels in the initial non-target pixel set and the first target pixel in the first target pixel set, a second target pixel set is selected from the initial non-target pixel set, and the first target pixel set is compensated according to the second target pixel set to obtain the target pixel set;
[0010] The target visual object is obtained by overlaying the visual object to be overlaid onto the visual object based on the target pixel set.
[0011] In one embodiment, determining the initial blurred pixel set based on the superimposed visual object and the interpolation algorithm includes:
[0012] Obtain the location information of the target area, and draw the target area as a color key color in the superimposed visual object according to the location information;
[0013] An initial set of blurred pixels is determined in the superimposed visual object according to a preset interpolation algorithm.
[0014] In one embodiment, determining the initial set of blurred pixels in the superimposed visual object according to a preset interpolation algorithm includes:
[0015] The superimposed visual object is magnified based on a preset interpolation algorithm to obtain the magnified superimposed visual object;
[0016] Based on the location information of the target area, the magnified target area is determined in the superimposed visual object;
[0017] Based on the magnified target area and the preset blur distance, an initial blur pixel set is determined from the initial pixel set corresponding to the magnified superimposed visual object.
[0018] In one embodiment, the step of filtering a first target pixel set based on color key color and preset edge pixel conditions in the initial blurred pixel set, and determining an initial non-target pixel set, includes:
[0019] Based on the color key color and preset edge pixel conditions, each blurred pixel in the initial blurred pixel set is marked to obtain each overlapping label;
[0020] Based on the overlapping labels, a first target pixel set is selected from the initial blurred pixel set;
[0021] An initial non-target pixel set is constructed based on the blurred pixels in the initial blurred pixel set that are not in the first target pixel set.
[0022] In one embodiment, the overlapping labels include a first overlapping label and a second overlapping label. The step of marking each blurred pixel in the initial blurred pixel set based on color key color and preset edge pixel conditions to obtain overlapping labels includes:
[0023] Based on the relationship between each blurred pixel in the initial blurred pixel set and the color key color, the blurred pixels are marked to obtain the first overlapping label;
[0024] Based on each of the first overlapping labels, a set of blurred pixels is selected from the initial set of blurred pixels;
[0025] According to the preset edge pixel conditions, each of the blurred pixels in the blurred pixel set is marked to obtain the second overlapping label.
[0026] In one embodiment, the step of marking the blurred pixels based on the relationship between each blurred pixel in the initial blurred pixel set and the color key color to obtain the first overlapping label includes:
[0027] For each blurred pixel in the initial blurred pixel set, determine whether the blurred pixel matches the color key color;
[0028] If the blurred pixel matches the color key color, the first overlapping label of the blurred pixel is determined to be the first mark;
[0029] If the blurred pixel does not match the color key color, the first overlapping label of the blurred pixel is determined to be the second label.
[0030] In one embodiment, filtering the set of blurred pixels based on each of the first overlapping labels in the initial set of blurred pixels includes:
[0031] For each blurred pixel in the initial blurred pixel set, determine whether the first overlapping label of the blurred pixel is a first marker;
[0032] If the first overlapping label is not the first marker, the blurred pixel is added to the blurred pixel set.
[0033] In one embodiment, the step of marking each of the blurred pixels in the blurred pixel set according to preset edge pixel conditions to obtain the second overlapping label includes:
[0034] For each blurred pixel in the blurred pixel set, determine whether the blurred pixel meets the preset edge pixel conditions;
[0035] If the blurred pixel meets the edge pixel condition, the second overlapping label of the blurred pixel is determined to be the first label;
[0036] If the blurred pixel does not meet the edge pixel condition, the second overlapping label of the blurred pixel is determined as the second mark.
[0037] In one embodiment, determining whether the blurred pixel meets the preset edge pixel conditions includes:
[0038] Determine the set of neighboring pixels of the blurred pixel, and determine whether the first overlapping label of each neighboring pixel in the set of neighboring pixels is a first label;
[0039] If the first overlapping label of each of the adjacent pixels is the first mark, it is determined that the blurred pixel does not meet the edge pixel condition;
[0040] If the first overlapping label of the adjacent pixels is the second label, it is determined that the blurred pixel satisfies the edge pixel condition.
[0041] In one embodiment, the step of filtering a second target pixel set from the initial non-target pixel set based on the distance between blurred pixels in the initial non-target pixel set and first target pixels in the first target pixel set, and compensating the first target pixel set according to the second target pixel set to obtain a target pixel set, includes:
[0042] For each blurred pixel in the initial non-target pixel set, the first target pixel closest to the blurred pixel is determined as the neighboring target pixel;
[0043] Based on the distance between the neighboring target pixels and the blurred pixels and a preset distance threshold, a second target pixel set is selected from the initial non-target pixel set;
[0044] The second target pixel set is updated to the first target pixel set to obtain the target pixel set.
[0045] In one embodiment, the step of filtering a second set of target pixels from the initial non-target pixel set based on the distance between the neighboring target pixels and the blurred pixels and a preset distance threshold includes:
[0046] Calculate the absolute distance between the neighboring target pixel and the blurred pixel, and determine whether the absolute distance is less than or equal to a preset distance threshold;
[0047] If the absolute distance is less than or equal to the distance threshold, the blurred pixel is determined as the second target pixel and added to the second target pixel set based on the second target pixel.
[0048] In one embodiment, the step of overlaying the visual object to be overlaid onto the visual object to be overlaid based on the target pixel set to obtain the target visual object includes:
[0049] The visual object to be superimposed is magnified, and the superimposed area is determined in the magnified visual object based on the target pixel set;
[0050] The magnified visual object to be superimposed is superimposed onto the superimposition area to obtain the initial target visual object;
[0051] The initial target visual object is reduced in size to obtain the target visual object.
[0052] Secondly, this application also provides a visual object overlay device, comprising:
[0053] The acquisition module is used to acquire the visual object to be superimposed and the visual object to be superimposed, and to determine the initial blur pixel set based on the visual object to be superimposed and the interpolation algorithm.
[0054] The first filtering module is used to filter the first target pixel set in the initial blurred pixel set based on the color key color and preset edge pixel conditions, and to determine the initial non-target pixel set;
[0055] The second filtering module is used to filter a second target pixel set in the initial non-target pixel set based on the distance between the blurred pixels in the initial non-target pixel set and the first target pixel in the first target pixel set, and to compensate the first target pixel set according to the second target pixel set to obtain a target pixel set.
[0056] The overlay module is used to overlay the visual object to be overlaid onto the visual object being overlaid based on the target pixel set, so as to obtain the target visual object.
[0057] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0058] Obtain the visual object to be superimposed and the visual object to be superimposed, and determine the initial set of blurred pixels based on the visual object to be superimposed and the interpolation algorithm;
[0059] Based on the color key color and preset edge pixel conditions, a first target pixel set is selected from the initial blurred pixel set, and an initial non-target pixel set is determined;
[0060] Based on the distance between the blurred pixels in the initial non-target pixel set and the first target pixel in the first target pixel set, a second target pixel set is selected from the initial non-target pixel set, and the first target pixel set is compensated according to the second target pixel set to obtain the target pixel set;
[0061] The target visual object is obtained by overlaying the visual object to be overlaid onto the visual object based on the target pixel set.
[0062] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:
[0063] Obtain the visual object to be superimposed and the visual object to be superimposed, and determine the initial set of blurred pixels based on the visual object to be superimposed and the interpolation algorithm;
[0064] Based on the color key color and preset edge pixel conditions, a first target pixel set is selected from the initial blurred pixel set, and an initial non-target pixel set is determined;
[0065] Based on the distance between the blurred pixels in the initial non-target pixel set and the first target pixel in the first target pixel set, a second target pixel set is selected from the initial non-target pixel set, and the first target pixel set is compensated according to the second target pixel set to obtain the target pixel set;
[0066] The target visual object is obtained by overlaying the visual object to be overlaid onto the visual object based on the target pixel set.
[0067] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:
[0068] Obtain the visual object to be superimposed and the visual object to be superimposed, and determine the initial set of blurred pixels based on the visual object to be superimposed and the interpolation algorithm;
[0069] Based on the color key color and preset edge pixel conditions, a first target pixel set is selected from the initial blurred pixel set, and an initial non-target pixel set is determined;
[0070] Based on the distance between the blurred pixels in the initial non-target pixel set and the first target pixel in the first target pixel set, a second target pixel set is selected from the initial non-target pixel set, and the first target pixel set is compensated according to the second target pixel set to obtain the target pixel set;
[0071] The target visual object is obtained by overlaying the visual object to be overlaid onto the visual object based on the target pixel set.
[0072] The aforementioned visual object overlay method, apparatus, computer device, computer-readable storage medium, and computer program product acquire a visual object to be overlaid and a visual object to be overlaid, and determine an initial blurred pixel set based on the visual object to be overlaid and an interpolation algorithm; filter a first target pixel set in the initial blurred pixel set based on color key colors and preset edge pixel conditions, and determine an initial non-target pixel set; filter a second target pixel set in the initial non-target pixel set based on the distance between blurred pixels in the initial non-target pixel set and first target pixels in the first target pixel set, and compensate the first target pixel set according to the second target pixel set to obtain a target pixel set; and overlay the visual object to be overlaid onto the visual object to be overlaid according to the target pixel set to obtain the target visual object. This method uses color key color and edge pixel conditions to filter the first target pixel, initially obtaining the area to be overlaid. Based on the distance between the blurred pixels in the initial non-target pixel set and the first target pixel, the first target pixel set is supplemented to obtain the target pixel set, clarifying the overlay boundary. Thus, the visual object to be overlaid is overlaid based on the target pixels in the target pixel set, which can clearly overlay the visual object onto the object being overlaid, generating the target visual object, achieving seamless overlay, repairing the flaws of the target visual object, and improving the quality of the target visual object. Attached Figure Description
[0073] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0074] Figure 1 This is a schematic diagram illustrating the overlay of an object to be overlaid onto an unobstructed visual object in one embodiment.
[0075] Figure 2 This is a schematic diagram illustrating the overlay of an object to be overlaid onto an occluded visual object in one embodiment.
[0076] Figure 3 This is a flowchart illustrating a visual object overlay method in one embodiment;
[0077] Figure 4 This is a flowchart illustrating the process of determining a set of blurred pixels in one embodiment;
[0078] Figure 5 This is a flowchart illustrating the process of determining a set of blurred pixels based on an interpolation algorithm in one embodiment.
[0079] Figure 6 This is a flowchart illustrating the process of determining a first target pixel set and an initial non-target pixel set in one embodiment;
[0080] Figure 7 This is a schematic diagram of the process of marking blurred pixels in one embodiment;
[0081] Figure 8 This is a flowchart illustrating the process of determining the first overlapping label in one embodiment;
[0082] Figure 9 This is a schematic diagram of the process for filtering a set of blurred pixels in one embodiment;
[0083] Figure 10 This is a flowchart illustrating the process of determining the second overlapping label in one embodiment;
[0084] Figure 11 This is a flowchart illustrating the process of determining whether a blurred pixel satisfies the edge pixel condition in one embodiment.
[0085] Figure 12 This is a flowchart illustrating the process of determining a target pixel set in one embodiment;
[0086] Figure 13 This is a schematic diagram of the process for filtering the second target pixel set in one embodiment;
[0087] Figure 14 This is a flowchart illustrating the process of determining a target visual object in one embodiment;
[0088] Figure 15 This is a schematic diagram of a visual object overlay method in an exemplary embodiment;
[0089] Figure 16 This is a schematic diagram illustrating the processing of the outer edge in an exemplary embodiment;
[0090] Figure 17 This is a structural block diagram of a visual object overlay device in one embodiment;
[0091] Figure 18 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0092] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0093] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.
[0094] In the display field, users often have the need to overlay multiple images, multiple videos, or images and videos. For example, a video might be playing on a desktop, with a calculator interface displayed on top of the video. To achieve this, a visual object overlay method is needed to superimpose the visual object to be overlaid onto the target area of the overlaid visual object. The target area is the region where the visual object to be overlaid is displayed.
[0095] The visual object can be a video or an image, and this embodiment of the application does not limit it. Figure 1 This is a schematic diagram illustrating the overlay of an object onto an unobstructed visual object in one embodiment. For example... Figure 1 As shown, the visual object to be superimposed is the target image, and the visual object to be superimposed is the video image. The target image contains a target region drawn with Colorkey colors. The computer device uses the Colorkey algorithm to superimpose the video image onto the target image to obtain the composite image.
[0096] Figure 2 This is a schematic diagram illustrating the overlay of an object to be overlaid onto an occluded visual object in one embodiment. For example... Figure 2 As shown, the visual object to be superimposed is the target image, and the visual object to be superimposed is the video image. The target image contains a target region drawn with Colorkey colors. The computer device superimposes the video image onto the target image using the Colorkey algorithm. During superposition, it is necessary to avoid occluding the target region to obtain the composite image. The occluding image is the image that obscures the target region in the image to be superimposed.
[0097] In traditional techniques, a Colorkey color is drawn in the target area. An interpolation algorithm is used to magnify the superimposed visual object, and the pixels in the magnified superimposed visual object that are equal to the Colorkey are updated to the pixels of the target visual object. Then, the updated superimposed visual object is shrunk to obtain the target visual object.
[0098] However, in traditional techniques, interpolation algorithms add new pixels that are similar to but not equal to Colorkey, causing visual defects that are visible to the naked eye, resulting in poor quality of the generated target visual object.
[0099] This application provides a method for overlaying visual objects. By using color key color and edge pixel conditions, a first target pixel is selected to initially obtain the area to be overlaid. Based on the distance between the blurred pixels in the initial non-target pixel set and the first target pixel, the first target pixel set is supplemented to obtain a target pixel set, thus clarifying the overlay boundary. Therefore, the visual object to be overlaid is overlaid based on the target pixels in the target pixel set, which can clearly overlay the visual object onto the object being overlaid, generating the target visual object, achieving seamless overlay, repairing the flaws of the target visual object, and improving the quality of the target visual object.
[0100] In one embodiment, such as Figure 3 As shown, a method for visual object overlay is provided. This application embodiment uses the application of this method to a computer device as an example for illustration. This application embodiment does not limit the execution device based on the visual object overlay method, and includes the following steps 302 to 308:
[0101] Step 302: Obtain the visual object to be superimposed and the visual object to be superimposed, and determine the initial blur pixel set based on the visual object to be superimposed and the interpolation algorithm.
[0102] In implementation, an interpolation algorithm is pre-set in the computer device. The computer device acquires the visual object to be superimposed and the visual object to be superimposed. The visual object can be, but is not limited to, an image or video; this embodiment does not limit the visual object. During display, the visual object to be superimposed is located above the visual object to be superimposed, and the visual object to be superimposed is displayed. Then, the computer device acquires the position information of the target area and determines the initial set of blurred pixels based on the position information of the target area, the interpolation algorithm, and the visual object to be superimposed. The target area is the area where the visual object to be superimposed is displayed. The area of the target area needs to be greater than or equal to the area of the visual object to be superimposed.
[0103] Specifically, the computer device includes an interpolation algorithm and a blur distance. The computer device acquires the visual object to be overlaid and the visual object to be overlaid. Then, the computer device acquires the location information of the target region and, based on this location information, renders the target region as a color key color within the visual object to be overlaid. The computer device uses the interpolation algorithm and a preset blur distance to determine a set of blurred pixels within the visual object to be overlaid.
[0104] In an alternative embodiment, as described above Figure 1As shown, the object to be overlaid is the target image, and the object to be overlaid is the video image. The target image is the desktop. To display the video image of a floating window on a static desktop, the computer device needs to overlay the video image onto the target image. The computer device is equipped with an interpolation algorithm and a blur distance. The computer device acquires the target image and the video image. Then, the computer device acquires the position information of the target area and draws the target area as a color key in the target image based on the position information. The target area is the area where the video data (the object to be overlaid) is displayed. The computer device uses the interpolation algorithm and the preset blur distance to determine the set of blurred pixels in the target image.
[0105] In an alternative embodiment, as described above Figure 2 As shown, the visual object to be overlaid is the target image, and the visual object to be overlaid is the video image. The target image is the desktop. To display the video image of a floating window on a static desktop, the computer device needs to overlay the video image onto the target image. However, due to user requirements, an occluding image needs to be placed in the target area. At this time, the video image is above the target image, and the occluding image is above the video image. For the target image, the video image is the object to be overlaid, and for the video image, the occluding image is the object to be overlaid. The computer device is equipped with an interpolation algorithm and a blur distance. The computer device acquires the target image, the video image, and the occluding image. For the pair of visual objects to be overlaid (video image and target image), the computer device acquires the position information of the target area and draws the target area as a color key color in the target image based on the position information. Here, the target area is the area where the video data (the object to be overlaid) is displayed. The computer device uses an interpolation algorithm and a preset blur distance to determine the initial set of blurred pixels in the target image.
[0106] For the pair of visual objects to be superimposed—video image and occluded image—the computer device acquires the location information of the occluded region corresponding to the occluded image. Using the location information of the occluded region, an interpolation algorithm, and a preset blur distance, it determines a supplementary set of blurred pixels in the target image. Based on the initial set of blurred pixels and the supplementary set of blurred pixels, it then determines the final set of blurred pixels.
[0107] Step 304: Based on the color key color and preset edge pixel conditions, filter the first target pixel set in the initial blurred pixel set, and determine the initial non-target pixel set.
[0108] The color key, also known as the chroma key, refers to the specific color value selected as the alpha channel. In image processing or graphics display, all pixels in the image that match this color are replaced with fully transparent (or semi-transparent) pixels, thus revealing other image content. The color key color is typically green, i.e., #00FF00.
[0109] In implementation, the computer equipment is pre-set with edge pixel conditions. For each blurred pixel in the blurred pixel set, the computer equipment marks the blurred pixels according to the edge pixel conditions and color key colors, and divides the initial blurred pixel set according to the overlapping labels obtained from the marking, thus obtaining the first target pixel set and the initial non-target pixel set.
[0110] Specifically, for each blurred pixel in the blurred pixel set, the computer device marks the blurred pixel according to edge pixel conditions and color key colors, obtaining the overlap label of the blurred pixel. Then, based on the overlap labels of each blurred pixel, the computer device determines whether the blurred pixel is a first target pixel. If the blurred pixel is a first target pixel, the computer device adds the blurred pixel to the first target pixel set. If the blurred pixel set is not a first target pixel set, the computer device adds the blurred pixel set to the initial non-target pixel set.
[0111] Step 306: Based on the distance between the blurred pixels in the initial non-target pixel set and the first target pixel in the first target pixel set, a second target pixel set is selected from the initial non-target pixel set, and the first target pixel set is compensated according to the second target pixel set to obtain the target pixel set.
[0112] In implementation, for each blurred pixel in the initial non-target pixel set, the computer device determines the corresponding first target pixel in the first target pixel set and identifies this first target pixel as a neighboring target pixel. The computer device then determines whether the blurred pixel is a second target pixel based on the distance between the neighboring target pixels and the blurred pixel, as well as a preset distance threshold. If the blurred pixel is a second target pixel, the computer device adds it to the second target pixel set. Finally, the computer device adds the second target pixel set to the first target pixel set to obtain the target pixel set.
[0113] Specifically, for each blurred pixel in the initial non-target pixel set, the computer device determines the nearest first target pixel in the first target pixel set as a neighboring target pixel. The computer device calculates the absolute distance between the neighboring target pixel and the blurred pixel, and determines whether the blurred pixel is a second target pixel based on the relationship between the absolute distance and a preset distance threshold. If the blurred pixel is a second target pixel, the computer device adds the second target pixel to the second target pixel set. Then, the computer device adds the second target pixel set to the first target pixel set, completing the compensation of the first target pixel set, and obtaining the target pixel set.
[0114] Step 308: Based on the target pixel set, overlay the visual object to be overlaid onto the visual object to be overlaid to obtain the target visual object.
[0115] In practice, the computer device magnifies the visual object to be superimposed and overlays the magnified visual object onto the magnified target area to obtain the initial target visual object. Then, the computer device shrinks the initial target visual object to obtain the final target visual object.
[0116] In the above visual object overlay method, the first target pixel is selected by using color key color and edge pixel conditions, and the area to be overlaid is initially obtained. Based on the distance between the blurred pixels in the initial non-target pixel set and the first target pixel, the first target pixel set is supplemented to obtain the target pixel set, which clarifies the overlay boundary. Thus, the visual object to be overlaid is overlaid based on the target pixels in the target pixel set. This method can clearly overlay the visual object to be overlaid onto the object being overlaid, generating the target visual object, achieving seamless overlay, repairing the flaws of the target visual object, and improving the quality of the target visual object.
[0117] In one exemplary embodiment, such as Figure 4 As shown, the specific processing steps for determining the blurred pixel set based on the superimposed visual object and the interpolation algorithm in step 302 include steps 402 to 404. Wherein:
[0118] Step 402: Obtain the location information of the target area, and draw the target area as the color key color in the superimposed visual object according to the location information.
[0119] In practice, the computer device acquires the location information of the target area. Then, based on the location information of the target area, the computer device locks the target area within the overlaid visual objects and renders the target area as a color key color.
[0120] In an optional embodiment, if an occluding image exists on the target area, the computer device acquires the location information of the occluding image and the location information of the target area. Based on the location information of the target area and the occluding image, the computer device locks a drawing area within the overlaid visual object. This drawing area is located within the target area and does not contain the occluding image located within the target area. The computer device draws the drawing area using a color key color. The color key color does not overlap with the occluding image.
[0121] Optionally, the color key color is a fixed value, which can be green. This application embodiment does not limit the color key color.
[0122] Step 404: Determine the set of blurred pixels in the superimposed visual object according to the preset interpolation algorithm.
[0123] In implementation, the computer equipment is pre-set with an interpolation algorithm. The computer equipment magnifies the superimposed visual object using an image processing algorithm, obtaining the magnified superimposed object. Based on the location information of the target region, the computer equipment determines the magnified target region within the magnified superimposed object, and based on the magnified target region and a preset blur distance, determines an initial blurred pixel set within the initial pixel set corresponding to the magnified superimposed visual object.
[0124] Specifically, if there is an occluded image in the target area, the computer device magnifies the superimposed visual object according to an image processing algorithm to obtain the magnified superimposed object. Based on the positional information of the drawing area, the computer device determines the magnified target area in the magnified superimposed object. Then, based on the magnified target area and a preset blur distance, the computer device determines the blurred pixel set in the pixel set corresponding to the magnified superimposed visual object.
[0125] In this embodiment, the initial set of blurred pixels is determined by the location information of the target area, which determines the range that needs to be processed, making it easier to continue to determine the target pixel set to be superimposed based on the blurred pixel set.
[0126] In one exemplary embodiment, such as Figure 5 As shown, the specific processing procedure of step 404 includes steps 502 to 506. Wherein:
[0127] Step 502: Enlarge the superimposed visual object based on a preset interpolation algorithm to obtain the enlarged superimposed visual object.
[0128] In practice, the computer equipment is pre-programmed with an interpolation algorithm. The computer equipment uses the interpolation algorithm to magnify the superimposed visual object, resulting in a magnified superimposed visual object.
[0129] Specifically, if the magnification factor is 4 times, the computer device will magnify the superimposed visual object according to the interpolation algorithm to obtain the superimposed visual object magnified by 4 times.
[0130] Optionally, the interpolation algorithm may be, but is not limited to, Bicubic, Bilinear, or Lanczos resampling algorithms. Other interpolation algorithms are also applicable. This application does not limit the interpolation algorithm.
[0131] Step 504: Based on the location information of the target area, determine the magnified target area in the superimposed visual object.
[0132] In practice, the computer equipment performs logical binarization on the magnified superimposed object based on the location information of the target area to obtain the magnified target area.
[0133] In one exemplary embodiment, the above Figure 1 For example, assume the magnification factor is 4 (n), and the superimposed visual object is the target image. The target region is a region Rectangle(x, y, w, h). The computer device performs logical binarization on the magnified target image (the color-keyed image), that is, within the color-keyed region Rectangle(4x, 4y, 4w, 4h). The computer device determines Rectangle(4x, 4y, 4w, 4h) as the magnified target region. This region corresponds to the new pixel coordinates based on the Nearest Neighbor algorithm.
[0134] In an optional embodiment, if an occluded image exists on the target area, the computer device removes the occluded area from the target area to obtain the drawing area. Based on the position information of the drawing area, the computer device performs logical binarization on the magnified superimposed object to obtain the magnified drawing area. The computer device then determines the magnified drawing area as the magnified target area.
[0135] Optionally, the magnification factor is determined according to the visual object processing requirements, and this application embodiment does not limit it.
[0136] Step 506: Based on the magnified target area and the preset blur distance, determine the blur pixel set in the pixel set corresponding to the magnified superimposed visual object.
[0137] The magnified superimposed visual object consists of multiple pixels.
[0138] In implementation, a blur distance is preset in the computer equipment. The computer equipment uses this preset blur distance to enlarge the magnified target area and identifies the pixels within that enlarged area as blur pixels. Then, the computer equipment constructs a blur pixel set based on these blur pixels.
[0139] In an optional embodiment, the computer device directly identifies pixels within the magnified target area as blurred pixels and constructs a blurred pixel set from these blurred pixels.
[0140] In this embodiment, the visual object overlay method of this application is applicable to both the inner and outer edges of the convex and concave image regions. It only requires determining the set of blurred pixels based on the occlusion area, thus expanding the applicability of the object overlay method.
[0141] In one exemplary embodiment, such as Figure 6 As shown, the specific processing procedure of step 304 includes steps 602 to 606. Wherein:
[0142] Step 602: Based on the color key color and preset edge pixel conditions, mark each blurred pixel in the initial blurred pixel set to obtain each overlapping label.
[0143] The overlapping tags include the first overlapping tag and the second overlapping tag.
[0144] In implementation, for each blurred pixel in the initial blurred pixel set, the computer device determines a first overlap label for that blurred pixel based on the relationship between that blurred pixel and the color key color. Then, the computer device marks the blurred pixels according to edge pixel conditions to obtain a second overlap label.
[0145] Specifically, for each blurred pixel in the initial blurred pixel set, the computer device determines whether the color of the blurred pixel is a color key color, obtaining a first determination result. The computer device then marks the blurred pixels according to the first determination result, obtaining a first overlap label. Next, the computer device filters the blurred pixel set from the initial blurred pixel set based on the first overlap label, and marks each blurred pixel in the blurred pixel set according to edge pixel conditions, obtaining a second overlap label.
[0146] Optionally, the first or second overlapping label is not necessarily 1 bit wide; this application also uses other bit widths for implementation.
[0147] Step 604: Filter the first target pixel set from the initial blurred pixel set based on each overlapping label.
[0148] In implementation, for each blurred pixel in the initial blurred pixel set, the computer device determines whether the first overlap label of the blurred pixel is a first marker, and whether the second overlap label is a second marker. If the first overlap label of the blurred pixel is a first marker and the second overlap label is a second marker, the computer device identifies the blurred pixel as a first target pixel and adds the first target pixel to the first target pixel set.
[0149] Specifically, the computer device pre-sets a first target pixel set, which is empty. For each blurred pixel in the initial blurred pixel set, the computer device checks whether the first overlap label is a first marker and whether the second overlap label is a second marker. If the first overlap label of the blurred pixel is the first marker and the second overlap label is the second marker, the computer device determines the blurred pixel as the first target pixel and adds the first target pixel to the first target pixel set.
[0150] In an exemplary embodiment, if the first overlap label of a blurred pixel is a first marker and the second overlap label is a second marker, it indicates that the blurred pixel is a pixel in the target region, and that the pixel is far from the boundary or from the occluded image. The computer device determines that the blurred pixel can be occluded and identifies the blurred pixel as a first target pixel. Then, the computer device adds the first target pixel to a first target pixel set.
[0151] Step 606: Construct an initial non-target pixel set based on the blurred pixels in the initial blurred pixel set that are not in the first target pixel set.
[0152] In implementation, the computer device pre-sets an initial set of non-target pixels, which is initially empty. For each blurred pixel in the initial set of blurred pixels, the computer device determines whether the blurred pixel is a first target pixel. If the blurred pixel is not a first target pixel, the computer device adds the blurred pixel to the initial set of non-target pixels. This initial set of blurred pixels is only initially determined to be unoccluded.
[0153] In this embodiment, the first target pixel set is filtered from the initial blurred pixel set by using color key color and edge pixel conditions, and the pixels located in the target area but not at the edge are obtained, thus initially obtaining the area to be superimposed.
[0154] In one exemplary embodiment, the overlapping label includes a first overlapping label and a second overlapping label, such as Figure 7 As shown, the specific processing procedure of step 602 includes steps 702 to 706. Wherein:
[0155] Step 702: Based on the relationship between each blurred pixel in the initial blurred pixel set and the color key color, the blurred pixels are marked to obtain the first overlapping label.
[0156] In implementation, the computer device determines whether each blurred pixel in the initial blurred pixel set matches the color key color, obtaining a second determination result. Then, the computer device marks the blurred pixel according to the second determination result, obtaining a first overlap label.
[0157] Specifically, for each blurred pixel in the initial blurred pixel set, the computer device determines whether the blurred pixel matches the color key color, obtaining a second determination result. If the second determination result indicates that the blurred pixel matches the color key color, the computer device determines the first overlap label of the blurred pixel as a first mark. If the second determination result indicates that the blurred pixel does not match the color key color, the computer device determines the first overlap label of the blurred pixel as a second mark.
[0158] Step 704: Filter the fuzzy pixel set in the initial fuzzy pixel set based on each first overlapping label.
[0159] In practice, the computer device selects fuzzy pixels with the first overlapping label as the first marker from the initial fuzzy pixel set to form the fuzzy pixel set.
[0160] Specifically, for each blurred pixel in the initial blurred pixel set, the computer device determines whether the first overlap label of the blurred pixel is the first mark. If the first overlap label of the blurred pixel is the first mark, the computer device adds the blurred pixel to the blurred pixel set.
[0161] Step 706: According to the preset edge pixel conditions, mark each blurred pixel in the blurred pixel set to obtain the second overlapping label.
[0162] In implementation, edge pixel conditions are pre-set in the computer device. For each blurred pixel in the blurred pixel set, the computer device determines whether the blurred pixel meets the edge pixel conditions, obtaining a third judgment result. Then, the computer device marks the blurred pixels according to the third judgment result, obtaining a second overlap label.
[0163] Specifically, the computer device pre-sets edge pixel conditions. These conditions require the existence of a second label for the first overlap label of the neighboring pixels surrounding the blurred pixel. For each blurred pixel in the blurred pixel set, the computer device determines the corresponding set of neighboring pixels. Then, based on the first overlap labels of the neighboring pixels in the set, the computer device determines whether the blurred pixel satisfies the edge pixel conditions, obtaining a third determination result. If the blurred pixel satisfies the edge pixel conditions, the computer device determines that the second overlap label of the blurred pixel is the first label. If the blurred pixel does not satisfy the edge pixel conditions, the computer device determines that the second overlap label of the blurred pixel is the second label.
[0164] In this embodiment, a first overlap label is added to the blurred pixels using color key color, and a second overlap label is added to the blurred pixels using preset edge conditions. This facilitates subsequent determination of whether to superimpose the blurred pixel based on the overlap label. Furthermore, both the first and second overlap labels are 1 bit wide, which significantly reduces the use of SRAM (Static Random Access Memory) during hardware design, thereby improving superposition efficiency.
[0165] In one exemplary embodiment, such as Figure 8 As shown, the specific processing procedure of step 702 includes steps 802 to 806. Wherein:
[0166] Step 802: For each blurred pixel in the initial blurred pixel set, determine whether the blurred pixel matches the color key color.
[0167] In implementation, the computer equipment pre-sets tolerance ranges. These tolerance ranges are divided into uniform tolerance and independent tolerance. Uniform tolerance uses the same tolerance value for the three channels R (red), G (green), and B (blue). Independent tolerance allows different tolerance ranges to be set for R, G, and B respectively. For each blurred pixel in the initial blurred pixel set, the computer equipment determines whether the difference between the blurred pixel's color and the color key color is within the tolerance range. If the difference is within the tolerance range, the computer equipment determines that the blurred pixel matches the color key color and executes step 804. If the difference is not within the tolerance range, the computer equipment determines that the blurred pixel does not match the color key color and executes step 806.
[0168] In an optional embodiment, the tolerance range is set to 0, meaning the color of the blurred pixel is equal to the color key color. The computer device determines whether the color of the blurred pixel is the color key color. If the color of the blurred pixel is the color key color, the computer device determines that the blurred pixel matches the color key color. If the color of the blurred pixel is not the color key color, the computer device determines that the blurred pixel does not match the color key color.
[0169] Step 804: If the blurred pixel matches the color key color, determine the first overlapping label of the blurred pixel as the first mark.
[0170] The first overlapping label is cmask.
[0171] In practice, if a blurred pixel matches the color key color, the computer device determines the first overlapping label of that blurred pixel as the first mark.
[0172] In one exemplary embodiment, since the displayed electronic circuitry can recognize binary, this application sets a first flag to 1 and a second flag to 0. If a blurred pixel does not match the color key color, the computer device determines that the blurred pixel's cmask=1.
[0173] Step 806: If the blurred pixel does not match the color key color, determine the first overlapping label of the blurred pixel as the second label.
[0174] The first overlapping label is cmask.
[0175] In practice, if a blurred pixel does not match the color key color, the computer device determines the first overlapping label of the blurred pixel as the second label.
[0176] In one exemplary embodiment, since the displayed electronic circuitry can recognize binary, this application sets a first flag to 1 and a second flag to 0. If a blurred pixel does not match the color key color, the computer device determines that the blurred pixel's cmask=0.
[0177] In this embodiment, by determining whether the blurred pixel matches the color key color, it is possible to initially determine whether the blurred pixel is located in the area that needs to be superimposed, thus obtaining the first overlap label, which facilitates subsequent filtering of the area that needs to be superimposed based on the first overlap label.
[0178] In one exemplary embodiment, such as Figure 9 As shown, the specific processing procedure of step 304 includes steps 902 to 904. Wherein:
[0179] Step 902: For each blurred pixel in the initial blurred pixel set, determine whether the first overlapping label of the blurred pixel is the first label.
[0180] In implementation, for each blurred pixel in the blurred pixel set, the computer device determines whether the first overlapping label of the blurred pixel is the first marker. That is, the computer device determines whether the cmask of the blurred pixel is 1.
[0181] Step 904: If the first overlapping label is not the first mark, add the blurred pixel to the blurred pixel set.
[0182] In implementation, a set of blurred pixels is pre-configured in the computer device, and this set is initially empty. If the first overlap label is the first marker, the computer device adds the blurred pixels to the set of blurred pixels.
[0183] Specifically, if the cmask of a blurred pixel is 1, the computer device adds the blurred pixel to the blurred pixel set.
[0184] In an optional embodiment, if the cmask of a blurred pixel is 0, the computer device filters out the blurred pixel.
[0185] In this embodiment, by selecting the blurred pixels whose first overlapping label is the first label, a blurred pixel set is obtained, which facilitates the subsequent labeling of the blurred pixels in the blurred pixel set with the second overlapping label. This greatly reduces the number of blurred pixels that need to be labeled, effectively reduces redundant calculations, and improves the efficiency of the visual object overlay method.
[0186] In one exemplary embodiment, such as Figure 10 As shown, the specific processing procedure of step 706 includes steps 1002 to 1006. Wherein:
[0187] Step 1002: For each blurred pixel in the blurred pixel set, determine whether the blurred pixel meets the preset edge pixel conditions.
[0188] In practice, for each blurred pixel in the blurred pixel set, the computer device determines the set of neighboring pixels corresponding to that blurred pixel, and determines whether the blurred pixel meets the preset edge pixel conditions based on the first overlap label of each neighboring pixel in the neighboring pixel set.
[0189] Specifically, for each blurred pixel in the blurred pixel set, the computer device determines the set of neighboring pixels corresponding to that blurred pixel. Then, the computer device determines whether the first overlapping labels of each neighboring pixel in the neighboring pixel set are all first labels. If the first overlapping labels of each neighboring pixel are all first labels, the computer device determines that the blurred pixel does not meet the edge pixel condition. If there is a second label in the first overlapping labels of the neighboring pixels, the computer device determines that the blurred pixel meets the edge pixel condition.
[0190] Step 1004: If the blurred pixel meets the edge pixel condition, determine the second overlapping label of the blurred pixel as the first label.
[0191] The second overlapping label is edge_mask.
[0192] In practice, if a blurred pixel meets the edge pixel condition, the computer device determines the second overlapping label of the blurred pixel as the first label.
[0193] In one exemplary embodiment, since the displayed electronic circuitry can recognize binary, this application sets a first flag to 1 and a second flag to 0. If a blurred pixel meets the edge pixel condition, the computer device determines that the blurred pixel's edge_mask = 1.
[0194] Step 1006: If the blurred pixel does not meet the edge pixel condition, determine the second overlapping label of the blurred pixel as the second label.
[0195] The second overlapping label is edge_mask.
[0196] In practice, if a blurred pixel does not meet the edge pixel condition, the computer device determines the second overlapping label of the blurred pixel as the second mark.
[0197] In one exemplary embodiment, since the displayed electronic circuitry can recognize binary, this application sets the first flag to 1 and the second flag to 0. If a blurred pixel does not meet the edge pixel condition, the computer device determines that the blurred pixel's edge_mask = 0.
[0198] In this embodiment, blurred pixels are marked by edge pixel conditions to obtain a second overlapping label, which clarifies whether the blurred pixel is in the center of the magnified target area, making it easier to filter blurred pixels in the future.
[0199] In one exemplary embodiment, such as Figure 11 As shown, the specific processing procedure of step 1002 includes steps 1102 to 1106. Wherein:
[0200] Step 1102: Determine the set of neighboring pixels of the blurred pixel, and determine whether the first overlapping label of each neighboring pixel in the set of neighboring pixels is the first label.
[0201] In implementation, the computer device uses the blurred pixel as the center and identifies the eight adjacent pixels of that blurred pixel as neighboring pixels, and constructs a neighboring pixel set based on each neighboring pixel. Then, the computer device determines whether the first overlapping label of all neighboring pixels in the neighboring pixel set is the first label.
[0202] In an exemplary embodiment, a 3x3 square is used as an example. The blurred pixel is the pixel at the very center. Then, all pixels in the square are neighboring pixels of the blurred pixel. The computer device constructs a neighboring pixel set based on each neighboring pixel and determines whether the first overlap label of all neighboring pixels in the neighboring pixel set is a first tag.
[0203] Step 1104: If the first overlapping label of each adjacent pixel is the first label, it is determined that the blurred pixel does not meet the edge pixel condition.
[0204] In practice, if the first overlapping label of each adjacent pixel is the first label, the computer device determines that the blurred pixel is not an edge pixel and that the blurred pixel does not meet the edge pixel condition.
[0205] Step 1106: If there is a first overlapping label of adjacent pixels as the second label, determine that the blurred pixel satisfies the edge pixel condition.
[0206] In practice, if there is a first overlapping label of adjacent pixels as the second label, the computer device determines that the blurred pixel is an edge pixel and that the blurred pixel satisfies the edge pixel condition.
[0207] In this embodiment, by using the first overlapping label of the adjacent pixels of the blurred pixel, it is determined whether the blurred pixel meets the edge pixel condition, thus clarifying whether the blurred pixel is in the center of the magnified target area, which facilitates the subsequent screening of blurred pixels.
[0208] In one exemplary embodiment, such as Figure 12As shown, the specific processing procedure of step 306 includes steps 1202 to 1206. Wherein:
[0209] Step 1202: For each blurred pixel in the initial non-target pixel set, determine the first target pixel closest to the blurred pixel as the neighboring target pixel.
[0210] In practice, for each blurred pixel in the initial non-target pixel set, the computer device determines the nearest first target pixel in the first target pixel set as the neighboring target pixel.
[0211] Specifically, for each blurred pixel in the initial non-target pixel set, the computer device, using the blurred pixel as the center, determines neighboring blurred pixels outwards and checks whether each neighboring blurred pixel is a first target pixel. If a neighboring blurred pixel is a first target pixel, the computer device identifies it as a neighboring target pixel. If a neighboring blurred pixel is not a first target pixel, the computer device continues to determine neighboring blurred pixels outwards until a neighboring blurred pixel is identified as a first target pixel, at which point the computer device identifies it as the first target pixel.
[0212] In an optional embodiment, the computer device filters a set of non-target pixels with a first overlay label as the first marker from the initial set of non-target pixels. For each blurred pixel in the set of non-target pixels, the computer device determines the nearest first target pixel in the first set of target pixels as a neighboring target pixel.
[0213] Step 1204: Based on the distance between neighboring target pixels and blurred pixels and a preset distance threshold, filter the second target pixel set from the initial non-target pixel set.
[0214] In implementation, a distance threshold is preset in the computer device. The computer device calculates the absolute distance between neighboring target pixels and blurred pixels, and determines whether a blurred pixel is a second target pixel based on the relationship between the absolute distance and the preset distance threshold. Then, the computer device constructs a second target pixel set based on each second target pixel.
[0215] Specifically, the computer device calculates the absolute distance between neighboring target pixels and blurred pixels, and determines whether the absolute distance is less than or equal to a preset distance threshold. If the absolute distance is less than or equal to the distance threshold, the computer device identifies the blurred pixel as the second target pixel and adds the second target pixel to the second target pixel set.
[0216] Step 1206: Update the second target pixel set to the first target pixel set to obtain the target pixel set.
[0217] In practice, the computer device adds the second target pixel set to the first target pixel set, thus completing the supplementation of the first target pixel set and obtaining the target pixel set.
[0218] In this embodiment, the first target pixel set is supplemented based on the distance between the blurred pixels in the initial non-target pixel set and the first target pixel, thus obtaining the target pixel set and clarifying the superposition boundary. Therefore, the visual object to be superimposed is superimposed based on the target pixels in the target pixel set, which can clearly superimpose the visual object to be superimposed onto the superimposed object, generating the target visual object, achieving seamless superposition, repairing the defects of the target visual object, and improving the quality of the target visual object.
[0219] In one exemplary embodiment, such as Figure 13 As shown, the specific processing procedure of step 1204 includes steps 1302 to 1304. Wherein:
[0220] Step 1302: Calculate the absolute distance between the neighboring target pixel and the blurred pixel, and determine whether the absolute distance is less than or equal to a preset distance threshold.
[0221] In implementation, a distance threshold is preset in the computer device. The computer device calculates the absolute distance between the neighboring target pixel and the blurred pixel based on the coordinates of the neighboring target pixel and the coordinates between the blurred pixels. Then, the computer device determines whether the absolute distance is less than or equal to the preset distance threshold.
[0222] Optionally, the distance threshold can be set to 5, the same as the magnification factor, and determined according to the stacking requirements. This application embodiment does not limit the distance threshold.
[0223] Step 1304: If the absolute distance is less than or equal to the distance threshold, the blurred pixel is determined as the second target pixel, and added to the second target pixel set based on the second target pixel.
[0224] In implementation, a second target pixel set is pre-set in the computer device, and this second target pixel set is pre-emptively empty. If the absolute distance is less than or equal to a distance threshold, the computer device identifies the blurred pixel as the second target pixel and adds it to the second target pixel set based on the second target pixel.
[0225] In this embodiment, a second target pixel set is obtained by re-patching the new Colorkey region. The first target pixel set is then supplemented based on the second target pixel set to obtain the target pixel set. The overlay boundary is defined, and the overlay value of the object to be overlaid is applied to the overlay object based on the overlay boundary. This completely eliminates the influence of newly generated pixels with similar Colorkey, achieves seamless overlay, and improves the quality of the target visual object.
[0226] In one exemplary embodiment, such as Figure 14 As shown, the specific processing procedure of step 308 includes steps 1402 to 1406. Wherein:
[0227] Step 1402: Zoom in on the visual object to be overlaid, and determine the overlay area in the zoomed-in visual object based on the target pixel set.
[0228] In practice, the computer equipment uses an interpolation algorithm to magnify the visual object to be superimposed according to the magnification factor of the object being superimposed, resulting in a magnified visual object. Then, the computer equipment determines the superimposed region within the magnified visual object based on the target pixel set. Since all target pixels in the target pixel set can be superimposed, the computer equipment can determine the superimposed region based on the position of each target pixel in the target pixel set.
[0229] In an optional embodiment, if there is an occluded image in the target area, the overlay area does not include the area of the occluded image.
[0230] Step 1404: The magnified visual object to be superimposed is superimposed onto the superimposed area to obtain the initial target visual object.
[0231] In practice, the computer equipment superimposes the magnified visual object onto the superimposed area according to the ratio of the magnified visual object to be superimposed and the superimposed area, thus obtaining the initial target visual object.
[0232] Step 1406: Shrink the initial target visual object to obtain the target visual object.
[0233] In practice, the computer equipment determines the reduction factor based on the magnification factor. Then, the computer equipment reduces the target visual object based on the magnification notes to obtain the target visual object.
[0234] In this embodiment, the visual object to be superimposed is superimposed based on the target pixels in the target pixel set. This can clearly superimpose the visual object onto the object being superimposed, generating the target visual object, achieving seamless superposition, repairing the defects of the target visual object, and improving the quality of the target visual object.
[0235] In an exemplary embodiment, assuming the magnification factor is 4 (n), the Colorkey region (target region) in the target image (the visual object being overlaid) is a region Rectangle(x, y, w, h). The computer device performs logical binarization on the magnified target image (the image with Colorkey), that is, within the Colorkey region Rectangle(4x, 4y, 4w, 4h), this region is the magnified target region, and also the new pixel coordinates corresponding to the Nearest algorithm. Then, the computer device sets the color mask of all pixels within Rectangle(4x, 4y, 4w, 4h) that conform to the Colorkey to 1 (cmask), and masks the non-Colorkey pixels within the region to 0. That is, the computer device marks the first overlap label of blurred pixels that conform to the Colorkey color as 1, and marks the first overlap label of blurred pixels that do not conform to the Colorkey color as 0. Then, the computer device determines whether the blurred pixel is an edge pixel. If the blurred pixel is an edge pixel, the computer device determines the second overlap label of the blurred pixel to 0. In other words, the computer device will set the edge_mask of a pixel to 1 if it is an edge pixel, and 0 otherwise. An edge pixel is defined as a pixel whose cmask is 0 if any one of its eight adjacent pixels (top, bottom, left, and right) is 1.
[0236] The pixels in the original edge region (edge_mask = 1) will be interpolated and filled with non-Colorkey (cmask) pixels. However, in terms of pure spatial domain, the position information of the enlarged desktop image can be magnified by 4x (same as the Nearest method). In this case, there is no interpolation of position information, only a scaling factor. The actual interpolated pixels exist within their respective territories (Colorkey and non-Colorkey regions), such as... Figure 15 As shown. Figure 15 This is a schematic diagram of a visual object overlay method in an exemplary embodiment. Figure 16 This is a schematic diagram of the processing of the outer edge in an exemplary embodiment.
[0237] According to the spatial information, some interpolated pixels should belong to the Colorkey, or be in an area covering the Colorkey, but 8 rows / columns (8 x 8x magnification in this example) have been interpolated (note). Figure 16The two long black lines in the image (which are the theoretical Colorkey and non-Colorkey dividing lines in the spatial domain) will cause some pixels in the interpolation area that are actually Colorkey to not be recognized as Colorkey. This will cause a stripe similar to Colorkey to appear around the window that was originally overlaid on the Colorkey, affecting the visual experience.
[0238] In this application, pixels whose absolute distance from the edge pixel (cmask == 1 && edge_mask) of the true Colorkey are <= 4 (same magnification factor) are subjected to Colorkey modification processing, that is, they are expanded outward by 4 (same magnification factor) pixels (ignoring the outer boundary), which is patched into a new Colorkey, thus determining the second target pixel and defining the second target pixel as a pixel that can be superimposed.
[0239] exist Figure 16 In the middle, for the physical boundary interpolation problem of the player window of src0. The shorter thin black line is the boundary of the interpolated Colorkey pixels, and the thick black line is the spatial domain theoretical Colorkey (Nearest) boundary. Patch the 4 (same magnification, abs(4)) rows / columns within these two lines so that they are all Colorkey pixels, such as Figure 16 As shown. Figure 16 The lower left corner is near the edge area (that is, the visual object area that is not to be superimposed), therefore... Figure 16 It has two pixel interpolation regions.
[0240] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.
[0241] Based on the same inventive concept, this application also provides a visual object overlay apparatus for implementing the visual object overlay method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more embodiments of the visual object overlay apparatus provided below can be found in the limitations of the visual object overlay method described above, and will not be repeated here.
[0242] In one exemplary embodiment, such as Figure 17 As shown, a visual object overlay device 1700 is provided, including: an acquisition module 1701, a first filtering module 1702, a second filtering module 1703, and an overlay module 1704, wherein:
[0243] The acquisition module 1701 is used to acquire the visual object to be superimposed and the visual object to be superimposed, and to determine the initial blur pixel set based on the visual object to be superimposed and the interpolation algorithm.
[0244] The first filtering module 1702 is used to filter the first target pixel set in the initial fuzzy pixel set based on the color key color and the preset edge pixel conditions, and to determine the initial non-target pixel set.
[0245] The second filtering module 1703 is used to filter the second target pixel set in the initial non-target pixel set based on the distance between the blurred pixels in the initial non-target pixel set and the first target pixel in the first target pixel set, and to compensate the first target pixel set according to the second target pixel set to obtain the target pixel set.
[0246] The overlay module 1704 is used to overlay the visual object to be overlaid onto the visual object being overlaid based on the target pixel set, so as to obtain the target visual object.
[0247] In an exemplary embodiment, the acquisition module 1701 includes a first acquisition submodule and a first determination submodule. The first determination submodule includes:
[0248] The second acquisition submodule is used to acquire the location information of the target area and, based on the location information, draw the target area as the color key color in the overlaid visual object.
[0249] The second determining submodule is used to determine the initial set of blurred pixels in the superimposed visual object according to a preset interpolation algorithm.
[0250] In an exemplary embodiment, the second determining submodule is specifically used to enlarge the superimposed visual object based on a preset interpolation algorithm to obtain the enlarged superimposed visual object; determine the enlarged target region in the superimposed visual object according to the position information of the target region; and determine an initial blurred pixel set in the initial pixel set corresponding to the enlarged superimposed visual object based on the enlarged target region and a preset blur distance.
[0251] In one exemplary embodiment, the first screening module 1702 includes:
[0252] The first marking submodule is used to mark each blurred pixel in the initial blurred pixel set based on the color key color and the preset edge pixel conditions to obtain each overlapping label;
[0253] The first filtering submodule is used to filter the first target pixel set based on each overlapping label in the initial blurred pixel set;
[0254] The first construction submodule is used to construct an initial non-target pixel set based on the blurred pixels in the initial blurred pixel set that are not in the first target pixel set.
[0255] In one exemplary embodiment, the overlapping label includes a first overlapping label and a second overlapping label, and the first filtering submodule includes:
[0256] The second marking submodule is used to mark the blurred pixels based on the relationship between each blurred pixel in the initial blurred pixel set and the color key color, so as to obtain the first overlapping label;
[0257] The second filtering submodule is used to filter the fuzzy pixel set based on each first overlapping label in the initial fuzzy pixel set;
[0258] The third marking submodule is used to mark each fuzzy pixel in the fuzzy pixel set according to the preset edge pixel conditions to obtain the second overlapping label.
[0259] In an exemplary embodiment, the second tagging submodule is specifically configured to: for each blurred pixel in the initial blurred pixel set, determine whether the blurred pixel matches the color key color; if the blurred pixel matches the color key color, determine the first overlapping label of the blurred pixel as the first tag; if the blurred pixel does not match the color key color, determine the first overlapping label of the blurred pixel as the second tag.
[0260] In an exemplary embodiment, the second filtering submodule is specifically configured to: for each blurred pixel in the initial blurred pixel set, determine whether the first overlapping label of the blurred pixel is a first mark; if the first overlapping label is not a first mark, add the blurred pixel to the blurred pixel set.
[0261] In one exemplary embodiment, the third tagging submodule includes:
[0262] The first judgment submodule is used to determine whether each blurred pixel in the blurred pixel set meets the preset edge pixel conditions.
[0263] The third determination submodule is used to determine the second overlapping label of the blurred pixel as the first label if the blurred pixel meets the edge pixel condition;
[0264] The fourth determination submodule is used to determine the second overlapping label of the blurred pixel as the second mark if the blurred pixel does not meet the edge pixel condition.
[0265] In an exemplary embodiment, the first determination submodule is specifically used to determine the set of adjacent pixels of the blurred pixel, and to determine whether the first overlapping label of each adjacent pixel in the set of adjacent pixels is a first mark; if the first overlapping label of each adjacent pixel is a first mark, it is determined that the blurred pixel does not meet the edge pixel condition; if there is an adjacent pixel whose first overlapping label is a second mark, it is determined that the blurred pixel meets the edge pixel condition.
[0266] In one exemplary embodiment, the second screening module 1703 includes:
[0267] The fifth determination submodule is used to determine the first target pixel closest to the fuzzy pixel as the neighboring target pixel for each fuzzy pixel in the initial non-target pixel set;
[0268] The third filtering submodule is used to filter the second target pixel set from the initial non-target pixel set based on the distance between neighboring target pixels and blurred pixels and a preset distance threshold.
[0269] The first update submodule is used to update the second target pixel set to the first target pixel set to obtain the target pixel set.
[0270] In an exemplary embodiment, the third filtering submodule is specifically used to: calculate the absolute distance between neighboring target pixels and blurred pixels, and determine whether the absolute distance is less than or equal to a preset distance threshold; if the absolute distance is less than or equal to the distance threshold, determine the blurred pixels as second target pixels, and add them to the second target pixel set based on the second target pixels.
[0271] In an exemplary embodiment, the overlay module 1704 is specifically used to: enlarge the visual object to be overlaid, and determine the overlay area in the enlarged visual object based on the target pixel set; overlay the enlarged visual object onto the overlay area to obtain an initial target visual object; and shrink the initial target visual object to obtain a target visual object.
[0272] Each module in the aforementioned visual object overlay device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0273] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 18 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When executed by the processor, the computer program implements a visual object overlay method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0274] Those skilled in the art will understand that Figure 18 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0275] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0276] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0277] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0278] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0279] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0280] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0281] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for overlaying visual objects, characterized in that, The method includes: Obtain the visual object to be superimposed and the visual object to be superimposed, and determine the initial set of blurred pixels based on the visual object to be superimposed and the interpolation algorithm; Based on the color key color and preset edge pixel conditions, a first target pixel set is selected from the initial blurred pixel set, and an initial non-target pixel set is determined; Based on the distance between the blurred pixels in the initial non-target pixel set and the first target pixel in the first target pixel set, a second target pixel set is selected from the initial non-target pixel set, and the first target pixel set is compensated according to the second target pixel set to obtain the target pixel set; The target visual object is obtained by overlaying the visual object to be overlaid onto the visual object based on the target pixel set.
2. The method according to claim 1, characterized in that, The step of determining the initial blurred pixel set based on the superimposed visual object and the interpolation algorithm includes: Obtain the location information of the target area, and draw the target area as a color key color in the superimposed visual object according to the location information; An initial set of blurred pixels is determined in the superimposed visual object according to a preset interpolation algorithm.
3. The method according to claim 2, characterized in that, Determining the initial set of blurred pixels in the superimposed visual object according to a preset interpolation algorithm includes: The superimposed visual object is magnified based on a preset interpolation algorithm to obtain the magnified superimposed visual object; Based on the location information of the target area, the magnified target area is determined in the superimposed visual object; Based on the magnified target area and the preset blur distance, an initial blur pixel set is determined from the initial pixel set corresponding to the magnified superimposed visual object.
4. The method according to claim 1, characterized in that, The process of filtering a first target pixel set based on color key color and preset edge pixel conditions in the initial blurred pixel set, and determining an initial non-target pixel set, includes: Based on the color key color and preset edge pixel conditions, each blurred pixel in the initial blurred pixel set is marked to obtain each overlapping label; Based on the overlapping labels, a first target pixel set is selected from the initial blurred pixel set; An initial non-target pixel set is constructed based on the blurred pixels in the initial blurred pixel set that are not in the first target pixel set.
5. The method according to claim 4, characterized in that, The overlapping labels include a first overlapping label and a second overlapping label. The overlapping labels are obtained by marking each blurred pixel in the initial blurred pixel set based on the color key color and preset edge pixel conditions, including: Based on the relationship between each blurred pixel in the initial blurred pixel set and the color key color, the blurred pixels are marked to obtain the first overlapping label; Based on each of the first overlapping labels, a set of blurred pixels is selected from the initial set of blurred pixels; According to the preset edge pixel conditions, each of the blurred pixels in the blurred pixel set is marked to obtain the second overlapping label.
6. The method according to claim 5, characterized in that, The step of marking the blurred pixels based on the relationship between each blurred pixel in the initial blurred pixel set and the color key color to obtain the first overlapping label includes: For each blurred pixel in the initial blurred pixel set, determine whether the blurred pixel matches the color key color; If the blurred pixel matches the color key color, the first overlapping label of the blurred pixel is determined to be the first mark; If the blurred pixel does not match the color key color, the first overlapping label of the blurred pixel is determined to be the second label.
7. The method according to claim 5, characterized in that, The step of filtering the set of blurred pixels in the initial blurred pixel set based on each of the first overlapping labels includes: For each blurred pixel in the initial blurred pixel set, determine whether the first overlapping label of the blurred pixel is a first marker; If the first overlapping label is not the first marker, the blurred pixel is added to the blurred pixel set.
8. The method according to claim 5, characterized in that, The step of marking each blurred pixel in the blurred pixel set according to preset edge pixel conditions to obtain the second overlapping label includes: For each blurred pixel in the blurred pixel set, determine whether the blurred pixel meets the preset edge pixel conditions; If the blurred pixel meets the edge pixel condition, the second overlapping label of the blurred pixel is determined to be the first label; If the blurred pixel does not meet the edge pixel condition, the second overlapping label of the blurred pixel is determined as the second mark.
9. The method according to claim 8, characterized in that, The step of determining whether the blurred pixel meets the preset edge pixel conditions includes: Determine the set of neighboring pixels of the blurred pixel, and determine whether the first overlapping label of each neighboring pixel in the set of neighboring pixels is a first label; If the first overlapping label of each of the adjacent pixels is the first mark, it is determined that the blurred pixel does not meet the edge pixel condition; If the first overlapping label of the adjacent pixels is the second label, it is determined that the blurred pixel satisfies the edge pixel condition.
10. The method according to claim 1, characterized in that, The step of filtering a second target pixel set from the initial non-target pixel set based on the distance between blurred pixels in the initial non-target pixel set and the first target pixel set in the first target pixel set, and compensating the first target pixel set according to the second target pixel set to obtain the target pixel set, includes: For each blurred pixel in the initial non-target pixel set, the first target pixel closest to the blurred pixel is determined as the neighboring target pixel; Based on the distance between the neighboring target pixels and the blurred pixels and a preset distance threshold, a second target pixel set is selected from the initial non-target pixel set; The second target pixel set is updated to the first target pixel set to obtain the target pixel set.
11. The method according to claim 10, characterized in that, The step of filtering a second set of target pixels from the initial non-target pixel set based on the distance between the neighboring target pixels and the blurred pixels and a preset distance threshold includes: Calculate the absolute distance between the neighboring target pixel and the blurred pixel, and determine whether the absolute distance is less than or equal to a preset distance threshold; If the absolute distance is less than or equal to the distance threshold, the blurred pixel is determined as the second target pixel and added to the second target pixel set based on the second target pixel.
12. The method according to claim 1, characterized in that, The step of overlaying the visual object to be overlaid onto the visual object being overlaid based on the target pixel set to obtain the target visual object includes: The visual object to be superimposed is magnified, and the superimposed area is determined in the magnified visual object based on the target pixel set; The magnified visual object to be superimposed is superimposed onto the superimposition area to obtain the initial target visual object; The initial target visual object is reduced in size to obtain the target visual object.
13. A visual object overlay device, characterized in that, The device includes: The acquisition module is used to acquire the visual object to be superimposed and the visual object to be superimposed, and to determine the initial blur pixel set based on the visual object to be superimposed and the interpolation algorithm. The first filtering module is used to filter the first target pixel set in the initial blurred pixel set based on the color key color and preset edge pixel conditions, and to determine the initial non-target pixel set; The second filtering module is used to filter a second target pixel set in the initial non-target pixel set based on the distance between the blurred pixels in the initial non-target pixel set and the first target pixel in the first target pixel set, and to compensate the first target pixel set according to the second target pixel set to obtain a target pixel set. The overlay module is used to overlay the visual object to be overlaid onto the visual object being overlaid based on the target pixel set, so as to obtain the target visual object.
14. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 12.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 12.
16. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 12.